pull/34/head
kunfei 5 years ago
parent 8f6e3eca6f
commit ea803610c3
  1. 25
      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.lib.theme.ThemeStore
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextPreference( class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) :
context, EditTextPreference(context, attrs),
attrs
),
DialogInterface.OnClickListener, DialogInterface.OnDismissListener { DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private var builder: AlertDialog.Builder? = null private var builder: AlertDialog.Builder? = null
@ -36,8 +34,7 @@ class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextP
private var mWhichButtonClicked: Int = 0 private var mWhichButtonClicked: Int = 0
override fun onClick() { override fun onClick() {
if (dialog != null && dialog!!.isShowing) return if (dialog?.isShowing == true) return
showDialog(null) showDialog(null)
} }
@ -96,14 +93,14 @@ class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextP
view.findViewById<TextView>(android.R.id.message).visibility = View.GONE view.findViewById<TextView>(android.R.id.message).visibility = View.GONE
val editText = this.editText!! editText?.let {
ATH.setTint(it, ThemeStore.accentColor(context))
ATH.setTint(editText, ThemeStore.accentColor(context))
editText.requestFocus() it.requestFocus()
editText.setText(text) it.setText(text)
// Place cursor at the end // Place cursor at the end
editText.setSelection(editText.length()) it.setSelection(it.length())
}
} }
override fun onClick(dialog: DialogInterface?, which: Int) { override fun onClick(dialog: DialogInterface?, which: Int) {
@ -163,7 +160,7 @@ class ATEEditTextPreference(context: Context?, attrs: AttributeSet?) : EditTextP
dest.writeBundle(dialogBundle) dest.writeBundle(dialogBundle)
} }
constructor(superState: Parcelable) : super(superState) {} constructor(superState: Parcelable) : super(superState)
companion object { companion object {

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