ui: switch from SwitchMaterial to MaterialSwitch
This required some weird changes to prevent clipping on the top, because apparently the new switch is a bit fatter. I think this actually looks a bit uglier than before, but it seems like that's what Material design wants. Maybe we can improve it? Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
497a60cc90
commit
f13624c58f
@ -8,9 +8,9 @@ package com.wireguard.android.widget
|
||||
import android.content.Context
|
||||
import android.os.Parcelable
|
||||
import android.util.AttributeSet
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
|
||||
class ToggleSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : SwitchMaterial(context, attrs) {
|
||||
class ToggleSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : MaterialSwitch(context, attrs) {
|
||||
private var isRestoringState = false
|
||||
private var listener: OnBeforeCheckedChangeListener? = null
|
||||
override fun onRestoreInstanceState(state: Parcelable) {
|
||||
|
@ -65,7 +65,7 @@
|
||||
android:nextFocusDown="@id/interface_name_text"
|
||||
android:nextFocusForward="@id/interface_name_text"
|
||||
app:checked="@{tunnel.state == State.UP}"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/interface_title"
|
||||
app:layout_constraintBaseline_toBottomOf="@+id/interface_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:onBeforeCheckedChanged="@{fragment::setTunnelState}" />
|
||||
|
||||
|
@ -34,7 +34,8 @@
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusable="true"
|
||||
android:nextFocusRight="@+id/tunnel_switch"
|
||||
android:padding="16dp">
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tunnel_name"
|
||||
@ -42,7 +43,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@{key}"
|
||||
@ -52,7 +53,7 @@
|
||||
android:id="@+id/tunnel_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/tunnel_name"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:nextFocusLeft="@+id/tunnel_list_item"
|
||||
app:checked="@{item.state == State.UP}"
|
||||
|
Loading…
Reference in New Issue
Block a user