summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doze/res/color/switch_bar_bg.xml20
-rw-r--r--doze/res/color/switchbar_switch_thumb_tint.xml20
-rw-r--r--doze/res/color/switchbar_switch_track_tint.xml21
-rw-r--r--doze/res/drawable/switchbar_background.xml10
-rw-r--r--doze/res/layout/switch_bar.xml7
-rw-r--r--doze/res/values/styles.xml5
-rw-r--r--doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java12
7 files changed, 84 insertions, 11 deletions
diff --git a/doze/res/color/switch_bar_bg.xml b/doze/res/color/switch_bar_bg.xml
new file mode 100644
index 0000000..ba2dae1
--- /dev/null
+++ b/doze/res/color/switch_bar_bg.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#ff80868B" android:state_activated="false" />
+ <item android:color="?android:attr/colorAccent" android:state_activated="true" />
+</selector>
diff --git a/doze/res/color/switchbar_switch_thumb_tint.xml b/doze/res/color/switchbar_switch_thumb_tint.xml
new file mode 100644
index 0000000..d4bf9b3
--- /dev/null
+++ b/doze/res/color/switchbar_switch_thumb_tint.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#FFFFFF" />
+</selector>
diff --git a/doze/res/color/switchbar_switch_track_tint.xml b/doze/res/color/switchbar_switch_track_tint.xml
new file mode 100644
index 0000000..ae45c7a
--- /dev/null
+++ b/doze/res/color/switchbar_switch_track_tint.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<selector
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#BFFFFFFF" />
+</selector>
diff --git a/doze/res/drawable/switchbar_background.xml b/doze/res/drawable/switchbar_background.xml
index 314ed12..f210707 100644
--- a/doze/res/drawable/switchbar_background.xml
+++ b/doze/res/drawable/switchbar_background.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
+<!-- Copyright (C) 2019 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?android:attr/colorControlHighlight">
- <item android:drawable="?android:attr/colorSecondary" />
-</ripple>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/switch_bar_bg" />
+</shape>
diff --git a/doze/res/layout/switch_bar.xml b/doze/res/layout/switch_bar.xml
index 7199174..9e11a0a 100644
--- a/doze/res/layout/switch_bar.xml
+++ b/doze/res/layout/switch_bar.xml
@@ -29,11 +29,12 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
- android:paddingStart="48dp"
+ android:paddingStart="56dp"
android:maxLines="2"
android:ellipsize="end"
android:textAppearance="@android:style/TextAppearance.Material.Title"
- android:textColor="?android:attr/textColorPrimary"
+ android:textColor="@android:color/white"
+ android:textSize="18sp"
android:textAlignment="viewStart" />
<Switch
@@ -42,6 +43,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
- android:theme="@style/Theme.Main.SwitchBar" />
+ android:theme="@style/Theme.Main.SwitchBar.Switch" />
</LinearLayout>
diff --git a/doze/res/values/styles.xml b/doze/res/values/styles.xml
index 082e53c..3443c0b 100644
--- a/doze/res/values/styles.xml
+++ b/doze/res/values/styles.xml
@@ -54,4 +54,9 @@
<style name="Theme.Main.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar">
</style>
+
+ <style name="Theme.Main.SwitchBar.Switch">
+ <item name="android:trackTint">@color/switchbar_switch_track_tint</item>
+ <item name="android:thumbTint">@color/switchbar_switch_thumb_tint</item>
+ </style>
</resources>
diff --git a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java
index 3770b5e..fd1756e 100644
--- a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java
+++ b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java
@@ -43,6 +43,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
CompoundButton.OnCheckedChangeListener {
private TextView mTextView;
+ private View mSwitchBar;
private SwitchPreference mPickUpPreference;
private SwitchPreference mHandwavePreference;
@@ -101,11 +102,15 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
mTextView.setText(getString(dozeEnabled ?
R.string.switch_bar_on : R.string.switch_bar_off));
- View switchBar = view.findViewById(R.id.switch_bar);
- Switch switchWidget = switchBar.findViewById(android.R.id.switch_widget);
+ mSwitchBar = view.findViewById(R.id.switch_bar);
+ Switch switchWidget = mSwitchBar.findViewById(android.R.id.switch_widget);
switchWidget.setChecked(dozeEnabled);
switchWidget.setOnCheckedChangeListener(this);
- switchBar.setOnClickListener(v -> switchWidget.setChecked(!switchWidget.isChecked()));
+ mSwitchBar.setActivated(dozeEnabled);
+ mSwitchBar.setOnClickListener(v -> {
+ switchWidget.setChecked(!switchWidget.isChecked());
+ mSwitchBar.setActivated(switchWidget.isChecked());
+ });
}
@Override
@@ -121,6 +126,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
Utils.checkDozeService(getActivity());
mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off));
+ mSwitchBar.setActivated(isChecked);
mPickUpPreference.setEnabled(isChecked);
mHandwavePreference.setEnabled(isChecked);