diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-23 23:16:57 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-28 13:52:59 +0000 |
| commit | a10fa073d93a143174fb7020aa1fd8692b727b4f (patch) | |
| tree | fadd00c3f37b604d6b7bbada327e067739ff4675 /android | |
| parent | 0ad325047380968ac22012010c1ea81f204db2dc (diff) | |
| download | mullvadvpn-a10fa073d93a143174fb7020aa1fd8692b727b4f.tar.xz mullvadvpn-a10fa073d93a143174fb7020aa1fd8692b727b4f.zip | |
Remove obsoleted `CellInput` controller class
Diffstat (limited to 'android')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellInput.kt | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellInput.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellInput.kt deleted file mode 100644 index dd40712e24..0000000000 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/CellInput.kt +++ /dev/null @@ -1,60 +0,0 @@ -package net.mullvad.mullvadvpn.ui - -import android.text.Editable -import android.text.TextWatcher -import android.widget.EditText -import net.mullvad.mullvadvpn.R - -class CellInput(val input: EditText, val minValue: Int, val maxValue: Int) { - private val context = input.context - - private val validInputColor = context.getColor(R.color.white) - private val invalidInputColor = context.getColor(R.color.red) - - var value - get() = input.text.toString().trim().toIntOrNull() - set(value) { - input.setText(value?.toString() ?: "") - } - - var onSubmit: ((Int?) -> Unit)? = null - - var hasFocus = false - private set(value) { - if (field != value) { - field = value - - if (value == false) { - val inputValue = this@CellInput.value - - if (inputValue == null || (inputValue >= minValue && inputValue <= maxValue)) { - onSubmit?.invoke(inputValue) - } - } - } - } - - init { - input.apply { - addTextChangedListener(InputWatcher()) - - setOnFocusChangeListener { _, newHasFocus -> hasFocus = newHasFocus } - } - } - - inner class InputWatcher : TextWatcher { - override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) {} - - override fun onTextChanged(text: CharSequence, start: Int, count: Int, after: Int) {} - - override fun afterTextChanged(text: Editable) { - val value = text.toString().trim().toIntOrNull() - - if (value != null && value >= minValue && value <= maxValue) { - input.setTextColor(validInputColor) - } else { - input.setTextColor(invalidInputColor) - } - } - } -} |
