Skip to content

Commit f13624c

Browse files
committed
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 <[email protected]>
1 parent 497a60c commit f13624c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

ui/src/main/java/com/wireguard/android/widget/ToggleSwitch.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ package com.wireguard.android.widget
88
import android.content.Context
99
import android.os.Parcelable
1010
import android.util.AttributeSet
11-
import com.google.android.material.switchmaterial.SwitchMaterial
11+
import com.google.android.material.materialswitch.MaterialSwitch
1212

13-
class ToggleSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : SwitchMaterial(context, attrs) {
13+
class ToggleSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : MaterialSwitch(context, attrs) {
1414
private var isRestoringState = false
1515
private var listener: OnBeforeCheckedChangeListener? = null
1616
override fun onRestoreInstanceState(state: Parcelable) {

ui/src/main/res/layout/tunnel_detail_fragment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
android:nextFocusDown="@id/interface_name_text"
6666
android:nextFocusForward="@id/interface_name_text"
6767
app:checked="@{tunnel.state == State.UP}"
68-
app:layout_constraintBaseline_toBaselineOf="@+id/interface_title"
68+
app:layout_constraintBaseline_toBottomOf="@+id/interface_title"
6969
app:layout_constraintEnd_toEndOf="parent"
7070
app:onBeforeCheckedChanged="@{fragment::setTunnelState}" />
7171

ui/src/main/res/layout/tunnel_list_item.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@
3434
android:descendantFocusability="beforeDescendants"
3535
android:focusable="true"
3636
android:nextFocusRight="@+id/tunnel_switch"
37-
android:padding="16dp">
37+
android:paddingHorizontal="16dp"
38+
android:paddingVertical="8dp">
3839

3940
<TextView
4041
android:id="@+id/tunnel_name"
4142
style="?android:attr/textAppearanceMedium"
4243
android:layout_width="wrap_content"
4344
android:layout_height="wrap_content"
4445
android:layout_alignParentStart="true"
45-
android:layout_alignParentTop="true"
46+
android:layout_centerVertical="true"
4647
android:ellipsize="end"
4748
android:maxLines="1"
4849
android:text="@{key}"
@@ -52,7 +53,7 @@
5253
android:id="@+id/tunnel_switch"
5354
android:layout_width="wrap_content"
5455
android:layout_height="wrap_content"
55-
android:layout_alignBaseline="@+id/tunnel_name"
56+
android:layout_centerVertical="true"
5657
android:layout_alignParentEnd="true"
5758
android:nextFocusLeft="@+id/tunnel_list_item"
5859
app:checked="@{item.state == State.UP}"

0 commit comments

Comments
 (0)