Эх сурвалжийг харах

refactor(更新) :
- 增加隐藏软键盘工具类,并在登录弹窗消失时隐藏软键盘
- 修改登录页面的软键盘显示策略为自动隐藏
- 修改登录弹窗中的账号和密码输入框的焦点获取方式
- 调整菜单项布局中的间距

周文健 3 сар өмнө
parent
commit
2b4ec58d9b

+ 2 - 1
app/src/main/AndroidManifest.xml

@@ -58,7 +58,8 @@
         <activity
             android:name=".view.activity.LoginActivity"
             android:exported="true"
-            android:launchMode="singleTask">
+            android:launchMode="singleTask"
+            android:windowSoftInputMode="stateHidden|adjustPan">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 

+ 18 - 0
app/src/main/java/com/grkj/iscs_mars/util/KeyboardUtils.kt

@@ -0,0 +1,18 @@
+package com.grkj.iscs_mars.util
+
+import android.content.Context
+import android.view.View
+import android.view.inputmethod.InputMethodManager
+
+/**
+ * 软键盘工具
+ */
+object KeyboardUtils {
+    /**
+     * 隐藏软键盘
+     */
+    fun hideSoftKeyboard(view: View) {
+        val imm = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+        imm.hideSoftInputFromWindow(view.windowToken, 0)
+    }
+}

+ 6 - 0
app/src/main/java/com/grkj/iscs_mars/view/dialog/LoginDialog.kt

@@ -12,6 +12,7 @@ import com.grkj.iscs_mars.extentions.toHexStrings
 import com.grkj.iscs_mars.model.vo.user.UserInfoRespVO
 import com.grkj.iscs_mars.util.ArcSoftUtil
 import com.grkj.iscs_mars.util.FingerprintUtil
+import com.grkj.iscs_mars.util.KeyboardUtils
 import com.grkj.iscs_mars.util.ToastUtils
 import com.grkj.iscs_mars.util.log.LogUtil
 import com.grkj.iscs_mars.view.base.BaseActivity
@@ -51,6 +52,11 @@ class LoginDialog(
             }
         }
         mBinding?.tvCancel?.setOnClickListener { dismiss() }
+        setOnDismissListener {
+            mBinding?.root?.let {
+                KeyboardUtils.hideSoftKeyboard(it)
+            }
+        }
     }
 
     /**

+ 4 - 0
app/src/main/res/layout/dialog_login.xml

@@ -53,6 +53,8 @@
             style="@style/CommonEdit"
             android:layout_width="match_parent"
             android:layout_marginBottom="10dp"
+            android:focusable="false"
+            android:focusableInTouchMode="true"
             android:hint="@string/please_input_account" />
 
         <EditText
@@ -61,6 +63,8 @@
             android:layout_width="match_parent"
             android:layout_marginBottom="10dp"
             android:inputType="textPassword"
+            android:focusable="false"
+            android:focusableInTouchMode="true"
             android:hint="@string/please_input_password" />
 
         <TextView

+ 1 - 1
app/src/main/res/layout/item_rv_menu.xml

@@ -14,5 +14,5 @@
     <TextView
         android:id="@+id/tv_name"
         style="@style/CommonTextView"
-        android:layout_marginTop="8dp" />
+        android:layout_marginTop="4dp" />
 </LinearLayout>