pull/34/head
kunfei 5 years ago
parent 8f6e3eca6f
commit ea803610c3
  1. 23
      app/src/main/java/io/legado/app/lib/theme/prefs/ATEEditTextPreference.kt
  2. 8
      app/src/main/res/xml/pref_config_web_dav.xml

@ -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<TextView>(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)
it.requestFocus()
it.setText(text)
// Place cursor at the end
editText.setSelection(editText.length())
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 {

@ -21,13 +21,17 @@
android:title="WebDav 密码"
android:summary="输入你的WebDav授权密码"
android:singleLine="true"
android:password="true"
android:inputType="textPassword"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="web_dav_restore"
android:title="备份"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="web_dav_restore"
android:title="恢复"
android:summary="从WebDav恢复"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceScreen>
Loading…
Cancel
Save