cmparts: Status bar settings
* Add all statusbar settings (battery, clock, etc)
Change-Id: I6efc1eaa44b08f0eab53d919b815b2b1cc4f836b
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4c4acbc..2d7ede6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -103,7 +103,7 @@
android:name=".profiles.ProfilesSettings"
android:label="@string/profiles_settings_title"
android:targetActivity="PartsActivity">
- <intent-filter>
+ <intent-filter android:priority="-2">
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
<action android:name="org.cyanogenmod.cmparts.PROFILES_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -116,5 +116,23 @@
android:resource="@drawable/ic_settings_profiles" />
</activity-alias>
+ <!-- Status bar settings (dashboard) -->
+ <activity-alias
+ android:name=".statusbar.StatusBarSettings"
+ android:label="@string/status_bar_title"
+ android:targetActivity="PartsActivity">
+ <intent-filter android:priority="1">
+ <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
+ <action android:name="org.cyanogenmod.cmparts.STATUS_BAR_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data
+ android:name="com.android.settings.category"
+ android:value="com.android.settings.category.personal" />
+ <meta-data
+ android:name="com.android.settings.icon"
+ android:resource="@drawable/ic_settings_statusbar" />
+ </activity-alias>
+
</application>
</manifest>
diff --git a/res/drawable/ic_settings_statusbar.xml b/res/drawable/ic_settings_statusbar.xml
new file mode 100644
index 0000000..cfd04a4
--- /dev/null
+++ b/res/drawable/ic_settings_statusbar.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012-2015 The CyanogenMod 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M18,20H6V8h12V20Z
+M18,2H6C4.9,2,4,2.9,4,4v16c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2L18,2z" />
+</vector>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 40570c7..f4063d6 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -171,4 +171,79 @@
<item>2</item>
</string-array>
+ <!-- Status bar -->
+ <string-array name="status_bar_clock_style_entries" translatable="false">
+ <item>@string/status_bar_clock_style_right</item>
+ <item>@string/status_bar_clock_style_center</item>
+ <item>@string/status_bar_clock_style_left</item>
+ <item>@string/status_bar_clock_style_hidden</item>
+ </string-array>
+
+ <string-array name="status_bar_clock_style_entries_rtl" translatable="false">
+ <item>@string/status_bar_clock_style_left</item>
+ <item>@string/status_bar_clock_style_center</item>
+ <item>@string/status_bar_clock_style_right</item>
+ <item>@string/status_bar_clock_style_hidden</item>
+ </string-array>
+
+ <string-array name="status_bar_clock_style_values" translatable="false">
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>0</item>
+ </string-array>
+
+ <string-array name="status_bar_am_pm_entries" translatable="false">
+ <item>@string/status_bar_am_pm_normal</item>
+ <item>@string/status_bar_am_pm_small</item>
+ <item>@string/status_bar_am_pm_hidden</item>
+ </string-array>
+
+ <string-array name="status_bar_am_pm_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
+ <string-array name="status_bar_battery_style_entries" translatable="false">
+ <item>@string/status_bar_battery_style_icon_portrait</item>
+ <item>@string/status_bar_battery_style_icon_landscape</item>
+ <item>@string/status_bar_battery_style_circle</item>
+ <item>@string/status_bar_battery_style_text</item>
+ <item>@string/status_bar_battery_style_hidden</item>
+ </string-array>
+
+ <string-array name="status_bar_battery_style_values" translatable="false">
+ <item>0</item>
+ <item>5</item>
+ <item>2</item>
+ <item>6</item>
+ <item>4</item>
+ </string-array>
+
+ <string-array name="status_bar_battery_percentage_entries" translatable="false">
+ <item>@string/status_bar_battery_percentage_default</item>
+ <item>@string/status_bar_battery_percentage_text_inside</item>
+ <item>@string/status_bar_battery_percentage_text_next</item>
+ </string-array>
+
+ <string-array name="status_bar_battery_percentage_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
+ <!-- Quick pulldown -->
+ <string-array name="status_bar_quick_qs_pulldown_entries" translatable="false">
+ <item>@string/status_bar_quick_qs_pulldown_off</item>
+ <item>@string/status_bar_quick_qs_pulldown_right</item>
+ <item>@string/status_bar_quick_qs_pulldown_left</item>
+ </string-array>
+
+ <string-array name="status_bar_quick_qs_pulldown_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8694e01..6e90b5f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -412,4 +412,49 @@
<string name="alarm_volume_title">Alarm</string>
<string name="doze_title">Ambient display</string>
+ <!-- Status bar -->
+ <string name="status_bar_title">Status bar</string>
+ <string name="status_bar_toggle_brightness">Brightness control</string>
+ <string name="status_bar_toggle_brightness_summary">Adjust brightness by sliding across the status bar</string>
+ <string name="status_bar_notif_count_title">Show notification count</string>
+ <string name="status_bar_notif_count_summary">Display the number of pending notifications</string>
+ <string name="status_bar_quick_qs_pulldown_title">Quick pulldown</string>
+ <string name="status_bar_quick_qs_pulldown_summary">%1$s edge of the status bar pulls down Quick Settings</string>
+ <string name="status_bar_quick_qs_pulldown_summary_left">Left</string>
+ <string name="status_bar_quick_qs_pulldown_summary_right">Right</string>
+ <string name="status_bar_quick_qs_pulldown_off">Off</string>
+ <string name="status_bar_quick_qs_pulldown_left">Left</string>
+ <string name="status_bar_quick_qs_pulldown_right">Right</string>
+
+ <!-- Status bar - Clock -->
+ <string name="status_bar_clock_style_title">Clock style</string>
+ <string name="status_bar_clock_style_right">Right</string>
+ <string name="status_bar_clock_style_left">Left</string>
+ <string name="status_bar_clock_style_center">Center</string>
+ <string name="status_bar_clock_style_hidden">Hidden</string>
+
+ <string name="status_bar_am_pm_title">AM/PM style</string>
+ <string name="status_bar_am_pm_info">24-hour clock is enabled</string>
+ <string name="status_bar_am_pm_normal">Normal</string>
+ <string name="status_bar_am_pm_small">Small</string>
+ <string name="status_bar_am_pm_hidden">Hidden</string>
+
+ <!-- Status bar - Battery -->
+ <string name="status_bar_battery_style_title">Battery status style</string>
+ <string name="status_bar_battery_style_icon_portrait">Icon portrait</string>
+ <string name="status_bar_battery_style_icon_landscape">Icon landscape</string>
+ <string name="status_bar_battery_style_circle">Circle</string>
+ <string name="status_bar_battery_style_text">Text</string>
+ <string name="status_bar_battery_style_hidden">Hidden</string>
+
+ <!-- Status bar - Battery percentage -->
+ <string name="status_bar_battery_percentage_title">Battery percentage</string>
+ <string name="status_bar_battery_percentage_default">Hidden</string>
+ <string name="status_bar_battery_percentage_text_inside">Inside the icon</string>
+ <string name="status_bar_battery_percentage_text_next">Next to the icon</string>
+
+ <!-- Status bar - icon blacklist -->
+ <string name="status_bar_icons_title">Status bar icons</string>
+ <string name="status_bar_icons_summary">Control which status bar icons are shown</string>
+
</resources>
diff --git a/res/xml/parts_catalog.xml b/res/xml/parts_catalog.xml
index 7ec6a17..bfb3d7f 100644
--- a/res/xml/parts_catalog.xml
+++ b/res/xml/parts_catalog.xml
@@ -38,4 +38,8 @@
android:title="@string/profiles_settings_title"
android:fragment="org.cyanogenmod.cmparts.profiles.ProfilesSettings" />
+ <part android:key="status_bar_settings"
+ android:title="@string/status_bar_title"
+ android:fragment="org.cyanogenmod.cmparts.statusbar.StatusBarSettings" />
+
</parts-catalog>
diff --git a/res/xml/status_bar_settings.xml b/res/xml/status_bar_settings.xml
new file mode 100644
index 0000000..2c2b27c
--- /dev/null
+++ b/res/xml/status_bar_settings.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2014-2016 The CyanogenMod 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.
+-->
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/status_bar_title">
+
+ <PreferenceScreen
+ android:key="status_bar_icons"
+ android:title="@string/status_bar_icons_title"
+ android:summary="@string/status_bar_icons_summary">
+ <intent
+ android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.systemui"
+ android:targetClass="com.android.systemui.tuner.TunerActivity$StatusBarIconActivity" />
+ </PreferenceScreen>
+
+ <cyanogenmod.preference.CMSystemSettingListPreference
+ android:key="status_bar_clock"
+ android:title="@string/status_bar_clock_style_title"
+ android:dialogTitle="@string/status_bar_clock_style_title"
+ android:entries="@array/status_bar_clock_style_entries"
+ android:entryValues="@array/status_bar_clock_style_values" />
+
+ <cyanogenmod.preference.CMSystemSettingListPreference
+ android:key="status_bar_am_pm"
+ android:title="@string/status_bar_am_pm_title"
+ android:dialogTitle="@string/status_bar_am_pm_title"
+ android:entries="@array/status_bar_am_pm_entries"
+ android:entryValues="@array/status_bar_am_pm_values" />
+
+ <cyanogenmod.preference.CMSystemSettingListPreference
+ android:key="status_bar_battery_style"
+ android:title="@string/status_bar_battery_style_title"
+ android:dialogTitle="@string/status_bar_battery_style_title"
+ android:entries="@array/status_bar_battery_style_entries"
+ android:entryValues="@array/status_bar_battery_style_values" />
+
+ <cyanogenmod.preference.CMSystemSettingListPreference
+ android:key="status_bar_show_battery_percent"
+ android:title="@string/status_bar_battery_percentage_title"
+ android:dialogTitle="@string/status_bar_battery_percentage_title"
+ android:entries="@array/status_bar_battery_percentage_entries"
+ android:entryValues="@array/status_bar_battery_percentage_values" />
+
+ <cyanogenmod.preference.CMSystemSettingSwitchPreference
+ android:key="status_bar_brightness_control"
+ android:title="@string/status_bar_toggle_brightness"
+ android:summary="@string/status_bar_toggle_brightness_summary"
+ android:defaultValue="false" />
+
+ <cyanogenmod.preference.CMSystemSettingSwitchPreference
+ android:key="status_bar_notif_count"
+ android:title="@string/status_bar_notif_count_title"
+ android:summary="@string/status_bar_notif_count_summary"
+ android:defaultValue="false" />
+
+ <cyanogenmod.preference.CMSystemSettingListPreference
+ android:key="qs_quick_pulldown"
+ android:title="@string/status_bar_quick_qs_pulldown_title"
+ android:entries="@array/status_bar_quick_qs_pulldown_entries"
+ android:entryValues="@array/status_bar_quick_qs_pulldown_values" />
+
+</PreferenceScreen>
diff --git a/src/org/cyanogenmod/cmparts/statusbar/StatusBarSettings.java b/src/org/cyanogenmod/cmparts/statusbar/StatusBarSettings.java
new file mode 100644
index 0000000..80b7a1e
--- /dev/null
+++ b/src/org/cyanogenmod/cmparts/statusbar/StatusBarSettings.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014-2015 The CyanogenMod 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.
+ */
+package org.cyanogenmod.cmparts.statusbar;
+
+import android.content.ContentResolver;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.text.format.DateFormat;
+import android.view.View;
+
+import org.cyanogenmod.cmparts.R;
+import org.cyanogenmod.cmparts.SettingsPreferenceFragment;
+
+import cyanogenmod.preference.CMSystemSettingListPreference;
+
+public class StatusBarSettings extends SettingsPreferenceFragment {
+
+ private static final String TAG = "StatusBar";
+
+ private static final String STATUS_BAR_CLOCK_STYLE = "status_bar_clock";
+ private static final String STATUS_BAR_AM_PM = "status_bar_am_pm";
+ private static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";
+ private static final String STATUS_BAR_SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
+ private static final String STATUS_BAR_QUICK_QS_PULLDOWN = "qs_quick_pulldown";
+
+ private static final int STATUS_BAR_BATTERY_STYLE_HIDDEN = 4;
+ private static final int STATUS_BAR_BATTERY_STYLE_TEXT = 6;
+
+ private CMSystemSettingListPreference mStatusBarClock;
+ private CMSystemSettingListPreference mStatusBarAmPm;
+ private CMSystemSettingListPreference mStatusBarBattery;
+ private CMSystemSettingListPreference mStatusBarBatteryShowPercent;
+ private CMSystemSettingListPreference mQuickPulldown;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ addPreferencesFromResource(R.xml.status_bar_settings);
+
+ ContentResolver resolver = getActivity().getContentResolver();
+
+ mStatusBarClock = (CMSystemSettingListPreference) findPreference(STATUS_BAR_CLOCK_STYLE);
+ mStatusBarAmPm = (CMSystemSettingListPreference) findPreference(STATUS_BAR_AM_PM);
+ mStatusBarBattery = (CMSystemSettingListPreference) findPreference(STATUS_BAR_BATTERY_STYLE);
+ mStatusBarBatteryShowPercent =
+ (CMSystemSettingListPreference) findPreference(STATUS_BAR_SHOW_BATTERY_PERCENT);
+ mQuickPulldown = (CMSystemSettingListPreference) findPreference(STATUS_BAR_QUICK_QS_PULLDOWN);
+
+ if (DateFormat.is24HourFormat(getActivity())) {
+ mStatusBarAmPm.setEnabled(false);
+ mStatusBarAmPm.setSummary(R.string.status_bar_am_pm_info);
+ }
+
+ enableStatusBarBatteryDependents(mStatusBarBattery.getIntValue(2));
+ updatePulldownSummary(mQuickPulldown.getIntValue(0));
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // Adjust clock position for RTL if necessary
+ Configuration config = getResources().getConfiguration();
+ if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
+ mStatusBarClock.setEntries(getActivity().getResources().getStringArray(
+ R.array.status_bar_clock_style_entries_rtl));
+ mStatusBarClock.setSummary(mStatusBarClock.getEntry());
+ }
+ }
+
+ private void enableStatusBarBatteryDependents(int batteryIconStyle) {
+ if (batteryIconStyle == STATUS_BAR_BATTERY_STYLE_HIDDEN ||
+ batteryIconStyle == STATUS_BAR_BATTERY_STYLE_TEXT) {
+ mStatusBarBatteryShowPercent.setEnabled(false);
+ } else {
+ mStatusBarBatteryShowPercent.setEnabled(true);
+ }
+ }
+
+ private void updatePulldownSummary(int value) {
+ Resources res = getResources();
+
+ if (value == 0) {
+ // quick pulldown deactivated
+ mQuickPulldown.setSummary(res.getString(R.string.status_bar_quick_qs_pulldown_off));
+ } else {
+ String direction = res.getString(value == 2
+ ? R.string.status_bar_quick_qs_pulldown_summary_left
+ : R.string.status_bar_quick_qs_pulldown_summary_right);
+ mQuickPulldown.setSummary(res.getString(R.string.status_bar_quick_qs_pulldown_summary, direction));
+ }
+ }
+}