diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-09-16 21:43:58 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-09-24 14:53:20 +0000 |
| commit | a8b0859c15167eba1d9e87cb6e6e8582245da982 (patch) | |
| tree | 3a1a1a1c1ed1610a1ae5e0b2c27fd6caec35b24b /android/src | |
| parent | e25ba60a5886c0d1488471b157d9c8d609011a84 (diff) | |
| download | mullvadvpn-a8b0859c15167eba1d9e87cb6e6e8582245da982.tar.xz mullvadvpn-a8b0859c15167eba1d9e87cb6e6e8582245da982.zip | |
Format account history entries
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryAdapter.kt | 9 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryHolder.kt | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryAdapter.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryAdapter.kt index 53082c8ea2..155d1d73fc 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryAdapter.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryAdapter.kt @@ -5,8 +5,15 @@ import android.view.LayoutInflater import android.view.ViewGroup import kotlin.properties.Delegates.observable import net.mullvad.mullvadvpn.R +import net.mullvad.mullvadvpn.util.SegmentedTextFormatter class AccountHistoryAdapter : Adapter<AccountHistoryHolder>() { + private val formatter = SegmentedTextFormatter(' ').apply { + isValidInputCharacter = { character -> + '0' <= character && character <= '9' + } + } + var accountHistory by observable(ArrayList<String>()) { _, _, _ -> notifyDataSetChanged() } @@ -17,7 +24,7 @@ class AccountHistoryAdapter : Adapter<AccountHistoryHolder>() { val inflater = LayoutInflater.from(parentView.context) val view = inflater.inflate(R.layout.account_history_entry, parentView, false) - return AccountHistoryHolder(view).apply { + return AccountHistoryHolder(view, formatter).apply { onSelect = { account -> onSelectEntry?.invoke(account) } } } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryHolder.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryHolder.kt index 5a7a0b34da..f19da6a5be 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryHolder.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountHistoryHolder.kt @@ -5,12 +5,16 @@ import android.view.View import android.widget.TextView import kotlin.properties.Delegates.observable import net.mullvad.mullvadvpn.R +import net.mullvad.mullvadvpn.util.SegmentedTextFormatter -class AccountHistoryHolder(view: View) : ViewHolder(view) { +class AccountHistoryHolder( + view: View, + private val formatter: SegmentedTextFormatter +) : ViewHolder(view) { private val label: TextView = view.findViewById(R.id.label) var accountToken by observable("") { _, _, account -> - label.text = account + label.text = formatter.format(account) } var onSelect: ((String) -> Unit)? = null |
