Only show clear field button when field has focus + don't empty field but set default value
This commit is contained in:
parent
5f1984fe4b
commit
a703299aae
3 changed files with 13 additions and 3 deletions
|
@ -103,11 +103,12 @@ class ControlsViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAudioDeviceChanged(core: Core, audioDevice: AudioDevice) {
|
override fun onAudioDeviceChanged(core: Core, audioDevice: AudioDevice) {
|
||||||
updateAudioRelated()
|
updateSpeakerState()
|
||||||
|
updateBluetoothHeadsetState()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAudioDevicesListUpdated(core: Core) {
|
override fun onAudioDevicesListUpdated(core: Core) {
|
||||||
updateAudioRelated()
|
updateAudioRoutesState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,13 @@ fun editTextSetting(view: EditText, lambda: () -> Unit) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("onFocusChangeVisibilityOf")
|
||||||
|
fun setEditTextOnFocusChangeVisibilityOf(editText: EditText, view: View) {
|
||||||
|
editText.setOnFocusChangeListener { _, hasFocus ->
|
||||||
|
view.visibility = if (hasFocus) View.VISIBLE else View.INVISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@BindingAdapter("selectedIndex", "settingListener")
|
@BindingAdapter("selectedIndex", "settingListener")
|
||||||
fun spinnerSetting(spinner: Spinner, selectedIndex: Int, listener: SettingListener) {
|
fun spinnerSetting(spinner: Spinner, selectedIndex: Int, listener: SettingListener) {
|
||||||
spinner.setSelection(selectedIndex, true)
|
spinner.setSelection(selectedIndex, true)
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/settings_clear_input"
|
android:id="@+id/settings_clear_input"
|
||||||
android:onClick="@{() -> settingsInput.setText(``)}"
|
android:onClick="@{() -> settingsInput.setText(defaultValue)}"
|
||||||
|
android:visibility="invisible"
|
||||||
android:contentDescription="@string/content_description_clear_field"
|
android:contentDescription="@string/content_description_clear_field"
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
|
@ -57,6 +58,7 @@
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/settings_input"
|
android:id="@+id/settings_input"
|
||||||
onValueChanged="@{() -> listener.onTextValueChanged(settingsInput.getText().toString())}"
|
onValueChanged="@{() -> listener.onTextValueChanged(settingsInput.getText().toString())}"
|
||||||
|
onFocusChangeVisibilityOf="@{settingsClearInput}"
|
||||||
android:text="@{defaultValue}"
|
android:text="@{defaultValue}"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:inputType="@{inputType ?? InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS}"
|
android:inputType="@{inputType ?? InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS}"
|
||||||
|
|
Loading…
Reference in a new issue