From f13624c58f0b8b46d3fd9958fe83f1631736cd45 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 25 Mar 2023 23:58:06 +0100 Subject: [PATCH] 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 --- .../main/java/com/wireguard/android/widget/ToggleSwitch.kt | 4 ++-- ui/src/main/res/layout/tunnel_detail_fragment.xml | 2 +- ui/src/main/res/layout/tunnel_list_item.xml | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.kt b/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.kt index b0eae4d0..0bde810d 100644 --- a/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.kt +++ b/ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.kt @@ -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) { diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index 164fabf0..96829e3c 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -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}" /> diff --git a/ui/src/main/res/layout/tunnel_list_item.xml b/ui/src/main/res/layout/tunnel_list_item.xml index 9c9517a7..57690e5e 100644 --- a/ui/src/main/res/layout/tunnel_list_item.xml +++ b/ui/src/main/res/layout/tunnel_list_item.xml @@ -34,7 +34,8 @@ android:descendantFocusability="beforeDescendants" android:focusable="true" android:nextFocusRight="@+id/tunnel_switch" - android:padding="16dp"> + android:paddingHorizontal="16dp" + android:paddingVertical="8dp">