Skip to content

Commit

Permalink
preference_switch: Apply appropriate colors from system
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Gupta <[email protected]>
  • Loading branch information
theimpulson committed Jul 26, 2024
1 parent 3f7022e commit ca4474e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/src/main/res/color/material_switch_decoration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:alpha="?android:attr/disabledAlpha"
android:color="@android:color/system_neutral1_300"
android:state_enabled="false" />
<item android:color="@android:color/system_accent1_500" android:state_checked="true" />
<item android:color="@android:color/system_neutral1_300" />
</selector>
13 changes: 13 additions & 0 deletions app/src/main/res/color/material_switch_thumb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:alpha="?android:attr/disabledAlpha"
android:color="@android:color/darker_gray"
android:state_enabled="false" />
<item android:color="@android:color/white" android:state_checked="true" />
<item android:color="@android:color/darker_gray" />
</selector>
13 changes: 13 additions & 0 deletions app/src/main/res/color/material_switch_track.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:alpha="?android:attr/disabledAlpha"
android:color="@android:color/system_neutral1_50"
android:state_enabled="false" />
<item android:color="@android:color/system_accent1_500" android:state_checked="true" />
<item android:color="@android:color/system_neutral1_50" />
</selector>
6 changes: 5 additions & 1 deletion app/src/main/res/layout/preference_switch.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.materialswitch.MaterialSwitch xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false" />
android:focusable="false"
app:thumbTint="@color/material_switch_thumb"
app:trackDecorationTint="@color/material_switch_decoration"
app:trackTint="@color/material_switch_track" />

0 comments on commit ca4474e

Please sign in to comment.