Kaynağa Gözat

update 0.0.29 ver.

kongzue 4 yıl önce
ebeveyn
işleme
9e25984c97

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

@@ -5,6 +5,8 @@ import android.content.Context;
 import android.graphics.Rect;
 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;
@@ -21,6 +23,8 @@ import com.kongzue.dialogx.interfaces.BaseDialog;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
 import com.kongzue.dialogx.interfaces.OnSafeInsetsChangeListener;
 
+import static com.kongzue.dialogx.DialogX.log;
+
 /**
  * @author: Kongzue
  * @github: https://github.com/kongzue/
@@ -112,7 +116,8 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         ViewCompat.setFitsSystemWindows(this, ViewCompat.getFitsSystemWindows((View) parent));
         ViewCompat.requestApplyInsets(this);
         
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !isInEditMode()) {
+        if (BaseDialog.getContext() == null) return;
+        if (!isInEditMode()) {
             ((Activity) BaseDialog.getContext()).getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(decorViewLayoutListener);
         }
         
@@ -126,13 +131,20 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         public void onGlobalLayout() {
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                 paddingView(getRootWindowInsets());
+            } else {
+                if (BaseDialog.getContext() == null) return;
+                DisplayMetrics displayMetrics = new DisplayMetrics();
+                ((Activity) BaseDialog.getContext()).getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
+                Rect rect = new Rect();
+                ((Activity) BaseDialog.getContext()).getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
+                paddingView( rect.left,  rect.top, displayMetrics.widthPixels - rect.right, displayMetrics.heightPixels - rect.bottom);
             }
         }
     };
     
     @Override
     protected void onDetachedFromWindow() {
-        if (decorViewLayoutListener != null && ((Activity) BaseDialog.getContext())!=null) {
+        if (decorViewLayoutListener != null && ((Activity) BaseDialog.getContext()) != null) {
             ((Activity) BaseDialog.getContext()).getWindow().getDecorView().getViewTreeObserver().removeOnGlobalLayoutListener(decorViewLayoutListener);
         }
         if (onLifecycleCallBack != null) {
@@ -165,6 +177,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
     protected Rect unsafePlace;
     
     private void paddingView(int left, int top, int right, int bottom) {
+        Log.e(">>>", "paddingView: left:" + left + " top:" + top + " right:" + right + " bottom:" + bottom);
         unsafePlace = new Rect(left, top, right, bottom);
         if (onSafeInsetsChangeListener != null) onSafeInsetsChangeListener.onChange(unsafePlace);
         MaxRelativeLayout bkgView = findViewById(R.id.bkg);

+ 1 - 0
DialogXKongzueStyle/src/main/res/layout/layout_dialogx_kongzue.xml

@@ -77,6 +77,7 @@
                             android:layout_marginHorizontal="20dp"
                             android:visibility="gone"
                             android:layout_marginBottom="15dp"
+                            android:textColorHint="@color/black30"
                             android:paddingTop="10dp"
                             android:maxLines="1"
                             android:paddingHorizontal="10dp"

+ 1 - 0
DialogXKongzueStyle/src/main/res/layout/layout_dialogx_kongzue_dark.xml

@@ -83,6 +83,7 @@
                             android:paddingTop="10dp"
                             android:paddingBottom="10dp"
                             android:scrollbars="vertical"
+                            android:textColorHint="@color/white30"
                             android:text=""
                             android:textColor="@color/white90"
                             android:textSize="14dp"

+ 2 - 2
README.md

@@ -106,7 +106,7 @@ DialogX 采用了主题分离结构,主框架仅包含 Material 设计风格
 想要在您的项目引入 DialogX,您需要在 app 的 build.gradle 文件中找到 `dependencies{}` 代码块,并在其中加入以下语句:
 
 ```
-implementation 'com.kongzue.dialogx:DialogX:0.0.28'
+implementation 'com.kongzue.dialogx:DialogX:0.0.29'
 ```
 
 若有需要,也可以手动配置 Maven:
@@ -115,7 +115,7 @@ implementation 'com.kongzue.dialogx:DialogX:0.0.28'
 <dependency>
   <groupId>com.kongzue.dialogx</groupId>
   <artifactId>DialogX</artifactId>
-  <version>0.0.28</version>
+  <version>0.0.29</version>
   <type>pom</type>
 </dependency>
 ```

+ 2 - 2
gradle.properties

@@ -18,5 +18,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.28
-BUILD_VERSION_INT=28
+BUILD_VERSION=0.0.29
+BUILD_VERSION_INT=29