diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEEditTextPreference.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEEditTextPreference.kt index 9665e8586..d1b31a9a8 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEEditTextPreference.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEEditTextPreference.kt @@ -20,10 +20,8 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.applyTint -class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextPreference( - context, - attrs -), +class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : + EditTextPreference(context, attrs), DialogInterface.OnClickListener, DialogInterface.OnDismissListener { private var builder: AlertDialog.Builder? = null @@ -36,8 +34,7 @@ class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextP private var mWhichButtonClicked: Int = 0 override fun onClick() { - if (dialog != null && dialog!!.isShowing) return - + if (dialog?.isShowing == true) return showDialog(null) } @@ -96,14 +93,14 @@ class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextP view.findViewById(android.R.id.message).visibility = View.GONE - val editText = this.editText!! - - ATH.setTint(editText, ThemeStore.accentColor(context)) + editText?.let { + ATH.setTint(it, ThemeStore.accentColor(context)) - editText.requestFocus() - editText.setText(text) - // Place cursor at the end - editText.setSelection(editText.length()) + it.requestFocus() + it.setText(text) + // Place cursor at the end + it.setSelection(it.length()) + } } override fun onClick(dialog: DialogInterface?, which: Int) { @@ -163,7 +160,7 @@ class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextP dest.writeBundle(dialogBundle) } - constructor(superState: Parcelable) : super(superState) {} + constructor(superState: Parcelable) : super(superState) companion object { diff --git a/app/src/main/res/xml/pref_config_web_dav.xml b/app/src/main/res/xml/pref_config_web_dav.xml index d9312c992..531698b1c 100644 --- a/app/src/main/res/xml/pref_config_web_dav.xml +++ b/app/src/main/res/xml/pref_config_web_dav.xml @@ -21,13 +21,17 @@ android:title="WebDav 密码" android:summary="输入你的WebDav授权密码" android:singleLine="true" - android:password="true" + android:inputType="textPassword" + app:iconSpaceReserved="false" /> + + \ No newline at end of file