Refine AutoCompleteNetworkPreferenceDialogFragment
This commit is contained in:
@@ -43,22 +43,19 @@ class AutoCompleteNetworkPreferenceDialogFragment : EditTextPreferenceDialogFrag
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateDialogView(context: Context) = super.onCreateDialogView(context)!!.apply {
|
override fun onCreateDialogView(context: Context) = super.onCreateDialogView(context)!!.apply {
|
||||||
editText = AlwaysAutoCompleteEditText(context).apply {
|
|
||||||
id = android.R.id.edit
|
|
||||||
minHeight = resources.getDimensionPixelSize(R.dimen.touch_target_min)
|
|
||||||
}
|
|
||||||
val oldEditText = findViewById<View>(android.R.id.edit)!!
|
val oldEditText = findViewById<View>(android.R.id.edit)!!
|
||||||
val container = oldEditText.parent as ViewGroup
|
val container = oldEditText.parent as ViewGroup
|
||||||
container.removeView(oldEditText)
|
container.removeView(oldEditText)
|
||||||
container.addView(editText, oldEditText.layoutParams)
|
container.addView(layoutInflater.inflate(R.layout.preference_widget_edittext_autocomplete, container, false),
|
||||||
|
oldEditText.layoutParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindDialogView(view: View) {
|
override fun onBindDialogView(view: View) {
|
||||||
super.onBindDialogView(view)
|
super.onBindDialogView(view)
|
||||||
|
editText = view.findViewById(android.R.id.edit)
|
||||||
editText.hint = (preference.summaryProvider as SummaryFallbackProvider).fallback
|
editText.hint = (preference.summaryProvider as SummaryFallbackProvider).fallback
|
||||||
adapter = ArrayAdapter(view.context, android.R.layout.select_dialog_item)
|
adapter = ArrayAdapter(view.context, android.R.layout.select_dialog_item)
|
||||||
editText.setAdapter(adapter)
|
editText.setAdapter(adapter)
|
||||||
editText.clearFocus() // having focus is buggy currently
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
|
||||||
|
<be.mygod.vpnhotspot.widget.AlwaysAutoCompleteEditText
|
||||||
|
android:id="@android:id/edit"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/touch_target_min"/>
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
Reference in New Issue
Block a user