ui: add suffix to persistent keepalive in editor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
77b5937fbb
commit
4bbb1a0fcd
@ -24,7 +24,7 @@ buildscript {
|
|||||||
jsr305Version = '3.0.2'
|
jsr305Version = '3.0.2'
|
||||||
junitVersion = '4.13'
|
junitVersion = '4.13'
|
||||||
kotlinVersion = '1.3.71'
|
kotlinVersion = '1.3.71'
|
||||||
materialComponentsVersion = '1.1.0'
|
materialComponentsVersion = '1.2.0-alpha05'
|
||||||
mavenPluginVersion = '2.1'
|
mavenPluginVersion = '2.1'
|
||||||
preferenceVersion = '1.1.0'
|
preferenceVersion = '1.1.0'
|
||||||
streamsupportVersion = '1.7.2'
|
streamsupportVersion = '1.7.2'
|
||||||
|
@ -151,4 +151,15 @@ object BindingAdapters {
|
|||||||
fun setInetAddressSetText(view: TextView, addresses: Iterable<InetAddress?>?) {
|
fun setInetAddressSetText(view: TextView, addresses: Iterable<InetAddress?>?) {
|
||||||
view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else ""
|
view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun tryParseInt(s: String?): Int {
|
||||||
|
if (s == null)
|
||||||
|
return 0
|
||||||
|
return try {
|
||||||
|
Integer.parseInt(s)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
<import type="com.wireguard.android.widget.KeyInputFilter" />
|
<import type="com.wireguard.android.widget.KeyInputFilter" />
|
||||||
|
|
||||||
|
<import type="com.wireguard.android.databinding.BindingAdapters" />
|
||||||
|
|
||||||
<variable
|
<variable
|
||||||
name="collection"
|
name="collection"
|
||||||
type="androidx.databinding.ObservableList<com.wireguard.android.viewmodel.PeerProxy>" />
|
type="androidx.databinding.ObservableList<com.wireguard.android.viewmodel.PeerProxy>" />
|
||||||
@ -104,6 +106,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/persistent_keepalive"
|
android:hint="@string/persistent_keepalive"
|
||||||
|
app:suffixText="@{@plurals/persistent_keepalive_seconds_suffix(BindingAdapters.tryParseInt(item.persistentKeepalive))}"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/pre_shared_key_label_layout">
|
app:layout_constraintTop_toBottomOf="@id/pre_shared_key_label_layout">
|
||||||
@ -114,7 +117,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/hint_optional_discouraged"
|
android:hint="@string/hint_optional_discouraged"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:text="@={item.persistentKeepalive}" />
|
android:text="@={item.persistentKeepalive}"/>
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
@ -43,6 +43,10 @@
|
|||||||
<item quantity="one">every second</item>
|
<item quantity="one">every second</item>
|
||||||
<item quantity="other">every %d seconds</item>
|
<item quantity="other">every %d seconds</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
<plurals name="persistent_keepalive_seconds_suffix">
|
||||||
|
<item quantity="one">second</item>
|
||||||
|
<item quantity="other">seconds</item>
|
||||||
|
</plurals>
|
||||||
<string name="use_all_applications">Use all apps</string>
|
<string name="use_all_applications">Use all apps</string>
|
||||||
<string name="add_peer">Add peer</string>
|
<string name="add_peer">Add peer</string>
|
||||||
<string name="addresses">Addresses</string>
|
<string name="addresses">Addresses</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user