Browse Source

0.0.49.beta12 ready
- 尝试修正 padding属性设置错误的bug(via @Matcha-xiaobin #356);

0.0.49.beta11
- 修复部分已知问题;

0.0.49.beta10
- 完善 OnBindView 内部逻辑,当dialog和view相同时不重复执行onBind事件;
- WaitDialog新增onShow(DialogXRunnable)和onDismiss(DialogXRunnable);
- 尝试修复可能存在的问题;

0.0.49.beta9
- 菜单布局结构优化;

0.0.49.beta8
- 对话框内的 dialogView 引用进行了处理,以及 PopTip 的 baseView,减少在低版本安卓系统上出现内存泄漏的可能性
- FullScreenDialog 新增了方法 hideActivityContentView(boolean) 用于设置是否在显示 FullScreenDialog 时不对 activity 的界面内容进行渲染,这将提升一定的性能,此方法只可以在使用 build 方法构建且在执行show方法之前使用,但这将引发一些问题,例如输入法弹出时 FullScreenDialog 无法上浮等;
- 其他问题修复;

0.0.49.beta6
- 对 BottomMenu 的 setOkButton、setCancelButton、setOtherButton 提供了单独的 OnBottomMenuButtonClickListener 参数接口,可直接提供 BottomMenu 参数的 onClick 回调事件;
- BottomDialog/BottomMenu 新增 set/get OkTextInfo 和 OtherTextInfo 方法;
- 修复 DialogXBaseRelativeLayout 可能存在的嵌套循环调用 requestFocus() 方法的问题;
- 修复关于 WaitDialog 设置背景颜色不生效的问题;

0.0.49.beta5 ready
- ActivityScreenShotImageView 增加静态方法 useHardwareRenderingMode,开启可使用硬件加速渲染模式;
- 修复部分系统下 ActivityScreenShotImageView 在执行回收时触发的“Software rendering doesn't support hardware bitmaps.”异常;
- 其他问题修复;

0.0.49.beta4 ready
- 修复部分系统下 BlurRelativeLayout 或 BlurRelativeLayout 在执行回收时触发的“Calling RS with no Context active.”异常;
- ActivityScreenShotImageView 截图方案更新;

0.0.49.beta4 ready
- 修复在部分设备上由 DialogXBaseRelativeLayout 引发的 StackOverflowError,此问题猜测跟特定版本系统固件存在问题有关;

0.0.49.beta3
- 修复 ActivityScreenShotImageView 可能引发的“Software rendering doesn’t support hardware bitmaps” 异常;
- 修复 BottomDialog/FullScreenDialog 的滑动事件在内部存在 ScrollController 时,若触摸位置处于 ScrollController 布局外无法滑动对话框的问题;

0.0.49.beta2
- InputInfo新增方法:`getInputFilters()`、`setInputFilters(InputFilter[] inputFilters)`、`addInputFilter(InputFilter inputFilter)` 和 `removeInputFilter(InputFilter inputFilter)`(issues:332);
- 尝试性修复 DialogFragment 模式实现下的 WaitDialog 内存泄漏问题(issues:334);
- 修复关于DialogFragmentImpl引发的空指针问题此问题(issues:335);

0.0.49.beta1
- 修复 BlurRelativeLayout 和 BlurLinearLayout 在 iOS 主题下使用 DialogFragment 模式时存在的渲染宽度和高度 <=0 导致的异常(issues:324);
- 修复 IOS 主题下可能存在的 `RSInvalidStateException: Calling RS with no Context active` 异常问题(issues:327);
- 修复可能存在的高频启关对话框过程中,因UI未完成构建被关闭引发的空指针异常(issues:331);

Kongzue 1 year ago
parent
commit
42455d38fa

+ 0 - 29
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -175,10 +175,6 @@ public abstract class BaseDialog implements LifecycleOwner {
             }
             dialog.dialogView = new WeakReference<>(view);
 
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-                publicWindowInsets(dialog.getRootFrameLayout().getRootWindowInsets());
-            }
-
             log(dialog.dialogKey() + ".show on " + dialog.getOwnActivity());
 
             addDialogToRunningList(dialog);
@@ -294,10 +290,6 @@ public abstract class BaseDialog implements LifecycleOwner {
             }
             baseDialog.dialogView = new WeakReference<>(view);
 
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-                publicWindowInsets(baseDialog.getRootFrameLayout().getRootWindowInsets());
-            }
-
             log(baseDialog + ".show on " + activity);
             addDialogToRunningList(baseDialog);
 
@@ -886,27 +878,6 @@ public abstract class BaseDialog implements LifecycleOwner {
         return windowInsets;
     }
 
-    public static void publicWindowInsets(WindowInsets windowInsets) {}
-
-    public static void publicWindowInsetsOld(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--) {
-                BaseDialog baseDialog = copyOnWriteList.get(i);
-                if (baseDialog.isShow && baseDialog.getDialogView() != null) {
-                    View boxRoot = baseDialog.getDialogView().findViewById(R.id.box_root);
-                    if (boxRoot instanceof DialogXBaseRelativeLayout) {
-                        ((DialogXBaseRelativeLayout) boxRoot).paddingView(windowInsets);
-                    }
-                }
-            }
-        }
-    }
-
     protected void bindFloatingActivity(DialogXFloatingWindowActivity activity) {
         floatingWindowActivity = new WeakReference<>(activity);
     }

+ 1 - 192
DialogX/src/main/java/com/kongzue/dialogx/util/views/DialogXBaseRelativeLayout.java

@@ -14,6 +14,7 @@ import android.util.Log;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewParent;
 import android.view.ViewTreeObserver;
 import android.view.WindowInsets;
 import android.view.inputmethod.InputMethodManager;
@@ -161,62 +162,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         });
     }
 
-//    @Override
-//    protected boolean fitSystemWindows(Rect insets) {
-//        if (!useWindowInsetsAnimation && (DialogX.useActivityLayoutTranslationNavigationBar || (getParentDialog() != null && getParentDialog().getDialogImplMode() != DialogX.IMPL_MODE.VIEW))) {
-//            log("#fitSystemWindows paddingView: b=" + insets.bottom);
-//            paddingView(insets.left, insets.top, insets.right, insets.bottom);
-//        }
-//        return super.fitSystemWindows(insets);
-//    }
-
-//    @Override
-//    public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
-//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-//            if (!useWindowInsetsAnimation && (DialogX.useActivityLayoutTranslationNavigationBar || (getParentDialog() != null && getParentDialog().getDialogImplMode() != DialogX.IMPL_MODE.VIEW))) {
-//                paddingView(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
-//                log("#dispatchApplyWindowInsets paddingView: b=" + insets.getSystemWindowInsetBottom());
-//            }
-//        }
-//        return super.dispatchApplyWindowInsets(insets);
-//    }
-
-    public void paddingView(Insets insets) {
-    }
-
-    @RequiresApi(api = Build.VERSION_CODES.Q)
-    public void paddingViewOld(Insets insets) {
-        if (insets != null) {
-            paddingView(insets.left, insets.top, insets.right, insets.bottom);
-            log("#paddingView(insets) paddingView: b=" + insets.bottom);
-        }
-    }
-
-    public void paddingView(WindowInsets insets) {
-    }
-
-    public void paddingViewOld(WindowInsets insets) {
-        if (!isAttachedToWindow()) {
-            getDynamicWindowInsetsAnimationListener(parentKey).remove(dynamicWindowInsetsAnimationListener);
-            return;
-        }
-        if (insets == null) {
-            if (BaseDialog.publicWindowInsets() != null) {
-                insets = BaseDialog.publicWindowInsets();
-            } else {
-                return;
-            }
-        }
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            if (insets.getSystemWindowInsetLeft() == 0 && insets.getSystemWindowInsetTop() == 0 && insets.getSystemWindowInsetRight() == 0 && insets.getSystemWindowInsetBottom() == 0) {
-                getWindowInsetsByDisplayMetrics();
-                return;
-            }
-            paddingView(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
-            log("#paddingView(WindowInsets) paddingView: b=" + insets.getSystemWindowInsetBottom());
-        }
-    }
-
     @Override
     public boolean dispatchKeyEvent(KeyEvent event) {
         log("#dispatchKeyEvent: KeyCode=" + event.getKeyCode());
@@ -238,43 +183,11 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         return super.onTouchEvent(event);
     }
 
-    private ViewTreeObserver.OnGlobalLayoutListener decorViewLayoutListener;
-
     @Override
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
         if (!isInEditMode()) {
-//            final ViewParent parent = getParent();
-//            if (parent instanceof View) {
-//                ViewCompat.setFitsSystemWindows(this, ViewCompat.getFitsSystemWindows((View) parent));
-//            }
-//            ViewCompat.requestApplyInsets(this);
-
             if (getParentDialog() == null || getParentDialog().getOwnActivity() == null) return;
-
-//            View decorView = (View) getParent();
-//            if (decorView != null) {
-//                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
-//                    parentKey = Integer.toHexString(decorView.hashCode());
-//                    getDynamicWindowInsetsAnimationListener(parentKey).add(dynamicWindowInsetsAnimationListener = new DynamicWindowInsetsAnimationListener() {
-//                        @Override
-//                        public void onChange(WindowInsets windowInsets) {
-//                            paddingView(windowInsets);
-//                        }
-//                    });
-//                    paddingWindowInsetsByDefault();
-//                    initDynamicSafeAreaListener();
-//                } else {
-//                    decorView.getViewTreeObserver().addOnGlobalLayoutListener(decorViewLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
-//                        @Override
-//                        public void onGlobalLayout() {
-//                            paddingWindowInsetsByDefault();
-//                        }
-//                    });
-//                    decorViewLayoutListener.onGlobalLayout();
-//                }
-//            }
-
             if (onLifecycleCallBack != null) {
                 onLifecycleCallBack.onShow();
             }
@@ -298,70 +211,8 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         return list;
     }
 
-    boolean useWindowInsetsAnimation = false;
-
-
-    private void initDynamicSafeAreaListener() {
-    }
-
-    @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
-    private void initDynamicSafeAreaListenerOld() {
-        View decorView = (View) getParent();
-        if (decorView != null) {
-            try {
-                ViewCompat.setWindowInsetsAnimationCallback(decorView, new WindowInsetsAnimationCompat.Callback(WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE) {
-
-                    @NonNull
-                    @Override
-                    public WindowInsetsCompat onProgress(@NonNull WindowInsetsCompat insets, @NonNull List<WindowInsetsAnimationCompat> runningAnimations) {
-                        View decorView = (View) getParent();
-                        if (decorView != null) {
-                            String key = Integer.toHexString(decorView.hashCode());
-                            List<DynamicWindowInsetsAnimationListener> dynamicWindowInsetsAnimationListenerList = getDynamicWindowInsetsAnimationListener(key);
-                            if (dynamicWindowInsetsAnimationListenerList != null) {
-                                for (DynamicWindowInsetsAnimationListener listener : dynamicWindowInsetsAnimationListenerList) {
-                                    listener.onChange(insets.toWindowInsets());
-                                }
-                            }
-                        }
-                        return insets;
-                    }
-                });
-                useWindowInsetsAnimation = true;
-            } catch (Exception e) {
-            }
-        }
-    }
-
-    private void paddingWindowInsetsByDefault() {
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-//            paddingView(getRootWindowInsets());
-        } else {
-//            getWindowInsetsByDisplayMetrics();
-        }
-    }
-
-    private void getWindowInsetsByDisplayMetrics() {
-    }
-
-    private void getWindowInsetsByDisplayMetricsOld() {
-        if (getParentDialog() == null || getParentDialog().getOwnActivity() == null) return;
-        DisplayMetrics displayMetrics = new DisplayMetrics();
-        getParentDialog().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;
-        paddingView(rect.left, rect.top, displayMetrics.widthPixels - rect.right, displayMetrics.heightPixels - rect.bottom);
-        log("#getWindowInsetsByDisplayMetrics paddingView: b=" + (displayMetrics.heightPixels - rect.bottom));
-    }
-
     @Override
     protected void onDetachedFromWindow() {
-        View decorView = (View) getParent();
-        if (decorViewLayoutListener != null && decorView != null) {
-            decorView.getViewTreeObserver().removeOnGlobalLayoutListener(decorViewLayoutListener);
-        }
         if (onLifecycleCallBack != null) {
             onLifecycleCallBack.onDismiss();
         }
@@ -405,9 +256,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         if (getParentDialog() != null && getParentDialog() instanceof NoTouchInterface) {
             return false;
         }
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
-            initDynamicSafeAreaListener();
-        }
         if (direction == View.FOCUS_DOWN && requestFocusView != null && requestFocusView.get() != null && requestFocusView.get() != this) {
             return requestFocusView.get().requestFocus();
         }
@@ -420,13 +268,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
     }
 
     public void requestFocusOnResume() {
-        log("#requestFocusOnResume");
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && getRootWindowInsets() != null && getRootWindowInsets().getStableInsets() != null) {
-//            paddingView(getRootWindowInsets().getStableInsets());
-        }
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
-//            initDynamicSafeAreaListener();
-        }
         View findFocusView = findFocus();
         if (findFocusView != null && findFocusView != this) {
             findFocusView.requestFocus();
@@ -444,32 +285,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
 
     protected Rect unsafePlace = new Rect();
 
-    private void paddingView(int left, int top, int right, int bottom) {
-    }
-
-    private void paddingViewOld(int left, int top, int right, int bottom) {
-        unsafePlace = new Rect(left, top, right, bottom);
-        if (onSafeInsetsChangeListener != null) onSafeInsetsChangeListener.onChange(unsafePlace);
-        MaxRelativeLayout bkgView = findViewById(R.id.bkg);
-        if (bkgView != null && bkgView.getLayoutParams() instanceof LayoutParams) {
-            LayoutParams bkgLp = (LayoutParams) bkgView.getLayoutParams();
-            if (bkgLp.getRules()[ALIGN_PARENT_BOTTOM] == RelativeLayout.TRUE && isAutoUnsafePlacePadding()) {
-                bkgView.setNavBarHeight(bottom);
-                setPadding(extraPadding[0] + left, extraPadding[1] + top, extraPadding[2] + right, extraPadding[3]);
-                if (getParentDialog() instanceof DialogXBaseBottomDialog) {
-                    if (((DialogXBaseBottomDialog) getParentDialog()).isBottomNonSafetyAreaBySelf()) {
-                        bkgView.setPadding(0, 0, 0, 0);
-                        return;
-                    }
-                }
-                bkgView.setPadding(0, 0, 0, bottom);
-                return;
-            }
-        }
-        if (isAutoUnsafePlacePadding())
-            setPadding(extraPadding[0] + left, extraPadding[1] + top, extraPadding[2] + right, extraPadding[3] + bottom);
-    }
-
     public DialogXBaseRelativeLayout setOnBackPressedListener(PrivateBackPressedListener onBackPressedListener) {
         this.onBackPressedListener = onBackPressedListener;
         return this;
@@ -494,9 +309,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
 
     public DialogXBaseRelativeLayout setAutoUnsafePlacePadding(boolean autoUnsafePlacePadding) {
         this.autoUnsafePlacePadding = autoUnsafePlacePadding;
-        if (!autoUnsafePlacePadding) {
-//            setPadding(extraPadding[0], extraPadding[1], extraPadding[2], extraPadding[3]);
-        }
         return this;
     }
 
@@ -508,9 +320,6 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         this.parentDialog = parentDialog;
         if (parentDialog != null && parentDialog.getDialogImplMode() != DialogX.IMPL_MODE.VIEW) {
             setFitsSystemWindows(true);
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-                paddingView(getRootWindowInsets());
-            }
         }
         return this;
     }

+ 1 - 1
gradle.properties

@@ -19,7 +19,7 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.49.beta11
+BUILD_VERSION=0.0.49.beta12
 BUILD_VERSION_INT=48
 DIALOGX_STYLE_VERSION=5
 android.nonTransitiveRClass=true