Selaa lähdekoodia

0.0.48.beta20
- 修复了在对话框显示时且输入法弹起时,启动其他Activity返回后出现对话框位置异常的问题;
- 修复了特定机型下FullScreenDialog背景闪烁的问题;

Kongzue 2 vuotta sitten
vanhempi
commit
b3d31c606f

+ 1 - 3
DialogX/src/main/java/com/kongzue/dialogx/dialogs/FullScreenDialog.java

@@ -245,9 +245,7 @@ public class FullScreenDialog extends BaseDialog {
                     float zoomScale = 1 - (boxRoot.getHeight() - realY) * 0.00002f;
                     if (zoomScale > 1) zoomScale = 1;
                     if (!hideZoomBackground) {
-                        imgZoomActivity.setScaleX(zoomScale);
-                        imgZoomActivity.setScaleY(zoomScale);
-
+                        imgZoomActivity.setScale(zoomScale);
                         imgZoomActivity.setRadius(dip2px(15) * ((boxRoot.getHeight() - realY) / boxRoot.getHeight()));
                     }
                 }

+ 1 - 0
DialogX/src/main/java/com/kongzue/dialogx/impl/ActivityLifecycleImpl.java

@@ -6,6 +6,7 @@ import android.content.Context;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.ArrayMap;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;

+ 3 - 2
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -834,9 +834,10 @@ public abstract class BaseDialog implements LifecycleOwner {
     }
 
     public static void publicWindowInsets(WindowInsets windowInsets) {
-        if (windowInsets != null) {
-            BaseDialog.windowInsets = windowInsets;
+        if (windowInsets == null) {
+            return;
         }
+        BaseDialog.windowInsets = windowInsets;
         if (runningDialogList != null) {
             CopyOnWriteArrayList<BaseDialog> copyOnWriteList = new CopyOnWriteArrayList<>(runningDialogList);
             for (int i = copyOnWriteList.size() - 1; i >= 0; i--) {

+ 11 - 0
DialogX/src/main/java/com/kongzue/dialogx/util/views/ActivityScreenShotImageView.java

@@ -67,8 +67,13 @@ public class ActivityScreenShotImageView extends ImageView {
         height = getHeight();
     }
 
+    boolean readyDraw = false;
+
     @Override
     protected void onDraw(Canvas canvas) {
+        if (!readyDraw) {
+            super.onDraw(canvas);
+        }
         if (width >= mRadius && height > mRadius) {
             if (isScreenshotSuccess) {
                 canvas.drawColor(Color.BLACK);
@@ -178,6 +183,12 @@ public class ActivityScreenShotImageView extends ImageView {
         }
     }
 
+    public void setScale(float scale) {
+        setScaleX(scale);
+        setScaleY(scale);
+        readyDraw = true;
+    }
+
     BaseDialog dialog;
 
     public void bindDialog(BaseDialog dialog) {

+ 15 - 2
DialogX/src/main/java/com/kongzue/dialogx/util/views/DialogXBaseRelativeLayout.java

@@ -3,12 +3,14 @@ package com.kongzue.dialogx.util.views;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
+import android.graphics.Insets;
 import android.graphics.Rect;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
@@ -35,6 +37,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
@@ -117,6 +120,13 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         return super.dispatchApplyWindowInsets(insets);
     }
 
+    @RequiresApi(api = Build.VERSION_CODES.Q)
+    public void paddingView(Insets insets) {
+        if (insets!=null){
+            paddingView(insets.left, insets.top, insets.right, insets.bottom);
+        }
+    }
+
     public void paddingView(WindowInsets insets) {
         if (!isAttachedToWindow()) {
             getDynamicWindowInsetsAnimationListener(parentKey).remove(dynamicWindowInsetsAnimationListener);
@@ -249,13 +259,13 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
     }
 
     private void getWindowInsetsByDisplayMetrics() {
-        if (parentDialog.getOwnActivity() == null) return;
+        if (parentDialog == null || parentDialog.getOwnActivity() == null) return;
         DisplayMetrics displayMetrics = new DisplayMetrics();
         parentDialog.getOwnActivity().getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
         Rect rect = new Rect();
         View decorView = (View) getParent();
         decorView.getWindowVisibleDisplayFrame(rect);
-        if (rect.left==0 && rect.top==0 && rect.right==0 && rect.bottom==0) return;
+        if (rect.left == 0 && rect.top == 0 && rect.right == 0 && rect.bottom == 0) return;
         paddingView(rect.left, rect.top, displayMetrics.widthPixels - rect.right, displayMetrics.heightPixels - rect.bottom);
     }
 
@@ -303,6 +313,9 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
     @Override
     public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && getRootWindowInsets()!=null && getRootWindowInsets().getStableInsets()!=null) {
+               paddingView(getRootWindowInsets().getStableInsets());
+            }
             initDynamicSafeAreaListener();
         }
         if (direction == View.FOCUS_DOWN && requestFocusView != null && requestFocusView.get() != null) {

+ 1 - 1
gradle.properties

@@ -19,6 +19,6 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.48.beta19
+BUILD_VERSION=0.0.48.beta20
 BUILD_VERSION_INT=47
 DIALOGX_STYLE_VERSION=5