Added new style for switch

This commit is contained in:
h4h13 2019-04-20 15:35:31 +05:30
parent 39b0b4c931
commit b0605ff183
10 changed files with 108 additions and 63 deletions

View file

@ -30,7 +30,6 @@ class ATESwitchPreference : CheckBoxPreference {
}
private fun init() {
layoutResource = R.layout.ate_preference_custom_support
widgetLayoutResource = R.layout.ate_preference_switch_support
}
}

View file

@ -1,11 +1,11 @@
package code.name.monkey.appthemehelper.common.views
import android.content.Context
import androidx.appcompat.widget.SwitchCompat
import android.util.AttributeSet
import android.view.View
import androidx.appcompat.widget.SwitchCompat
import code.name.monkey.appthemehelper.ATH
import code.name.monkey.appthemehelper.R
import code.name.monkey.appthemehelper.ThemeStore
@ -27,6 +27,9 @@ class ATESwitch : SwitchCompat {
}
private fun init(context: Context, attrs: AttributeSet?) {
setThumbResource(R.drawable.toggle_switch)
setTrackResource(R.drawable.ate_track)
background = null
ATH.setTint(this, ThemeStore.accentColor(context))
}

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape android:dither="true" android:shape="rectangle" android:useLevel="false" android:visible="true">
<solid android:color="@color/md_deep_purple_A700" />
<corners android:radius="25dp" />
<size android:width="2dp" />
</shape>
</item>
<item android:state_checked="false">
<shape android:dither="true" android:shape="rectangle" android:useLevel="false" android:visible="true">
<solid android:color="@color/md_white_1000" />
<corners android:radius="25dp" />
<size android:width="2dp" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false">
<shape android:dither="true" android:shape="rectangle" android:useLevel="false" android:visible="true">
<solid android:color="@color/md_white_1000" />
<corners android:radius="10dp" />
<size android:width="20dp" android:height="20dp" />
<stroke android:width="6dp" android:color="#0000ffff" />
</shape>
</item>
</selector>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<code.name.monkey.appthemehelper.common.views.ATESwitch xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:button="@drawable/ate_switch"
android:clickable="false"
android:focusable="false"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />

View file

@ -3,7 +3,5 @@
android:id="@android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />
android:focusable="false" />

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/custom_list_view_row_table_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@ -27,12 +26,11 @@
<TextView
android:id="@+id/custom_list_view_row_text_view"
style="@style/TextAppearance.MaterialComponents.Subtitle1"
android:layout_width="fill_parent"
android:layout_height="22dip"
android:gravity="center_vertical"
android:textColor="#000000"
style="@style/TextAppearance.MaterialComponents.Subtitle1"
/>
android:textColor="#000000" />
<TextView
android:id="@+id/custom_list_view_row_subtext_view"