diff options
| author | 2016-02-09 21:50:36 -0500 | |
|---|---|---|
| committer | 2016-02-18 14:19:49 -0500 | |
| commit | 8816dff9f2bacee226a7f4faec05ec0eb9fa62f0 (patch) | |
| tree | 638fe1ea25c97c142a4a09429e81bc7d20b37800 | |
| parent | 5dbd4aad809e6fec51df62280bcc1bfe05cc7df5 (diff) | |
SysUI Tuner: UI cleanup and grouping
Clean up strings and locations of various features.
Change-Id: Ie427a2d8c51afa6f2a68b4cde1d6b15cda897e1a
7 files changed, 242 insertions, 113 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index fe3391c53fa5..03ccb3baf1bc 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1315,15 +1315,14 @@ <string name="keyboard_shortcut_group_system_back">Back</string> <!-- SysUI Tuner: Option to show full do not disturb panel in volume [CHAR LIMIT=60] --> - <string name="tuner_full_zen_title">Show do not disturb in volume</string> - <!-- SysUI Tuner: Summary of option to show full do not disturb panel in volume [CHAR LIMIT=NONE] --> - <string name="tuner_full_zen_summary">Allow full control of do not disturb in the volume dialog.</string> + <string name="tuner_full_zen_title">Show with volume controls</string> - <!-- SysUI Tuner: Label for screen about volume and do not disturb settings [CHAR LIMIT=60] --> - <string name="volume_and_do_not_disturb">Volume and Do not disturb</string> + <!-- SysUI Tuner: Label for screen about do not disturb settings [CHAR LIMIT=60] --> + <string name="volume_and_do_not_disturb">Do not disturb</string> - <!-- SysUI Tuner: Switch to control volume down behavior [CHAR LIMIT=60] --> - <string name="volume_down_silent">Enter do not disturb on volume down</string> + <!-- SysUI Tuner: Switch to control whether volume buttons enter/exit do + not disturb [CHAR LIMIT=60] --> + <string name="volume_dnd_silent">Volume buttons shortcut</string> <!-- SysUI Tuner: Switch to control volume up behavior [CHAR LIMIT=60] --> <string name="volume_up_silent">Exit do not disturb on volume up</string> @@ -1343,9 +1342,6 @@ <!-- Accessibility description of headset icon [CHAR LIMIT=NONE] --> <string name="accessibility_status_bar_headset">Headset connected</string> - <!-- Explanation of the status bar section of the tuner [CHAR LIMIT=NONE] --> - <string name="tuner_status_bar_explanation">Enable or disable icons from being shown in the status bar.</string> - <!-- Label for quick settings tile for data saver [CHAR LIMIT=30] --> <string name="data_saver">Data Saver</string> @@ -1421,4 +1417,21 @@ <!-- Button to edit the tile ordering of quick settings [CHAR LIMIT=60] --> <string name="qs_edit">Edit</string> + <!-- SysUI Tuner: Options for how clock is displayed [CHAR LIMIT=NONE] --> + <string name="tuner_time">Time</string> + + <!-- SysUI Tuner: Options for how clock is displayed [CHAR LIMIT=NONE] --> + <string-array name="clock_options"> + <item>Show hours, minutes, and seconds</item> + <item>Show hours and minutes (default)</item> + <item>Don\'t show this icon</item> + </string-array> + + <!-- SysUI Tuner: Options for how battery is displayed [CHAR LIMIT=NONE] --> + <string-array name="battery_options"> + <item>Always show percentage</item> + <item>Show percentage when charging (default)</item> + <item>Don\'t show this icon</item> + </string-array> + </resources> diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml index 800762ebf7ff..023a3f047755 100644 --- a/packages/SystemUI/res/xml/tuner_prefs.xml +++ b/packages/SystemUI/res/xml/tuner_prefs.xml @@ -18,19 +18,10 @@ xmlns:sysui="http://schemas.android.com/apk/res-auto" android:title="@string/system_ui_tuner"> - <com.android.systemui.tuner.TunerSwitch - android:key="qs_show_brightness" - android:title="@string/show_brightness" - sysui:defValue="true" /> - <PreferenceScreen android:key="status_bar" android:title="@string/status_bar" > - <Preference - android:selectable="false" - android:summary="@string/tuner_status_bar_explanation" /> - <com.android.systemui.tuner.StatusBarSwitch android:key="rotate" android:title="@string/status_bar_settings_auto_rotation" /> @@ -91,9 +82,10 @@ <!-- other weird signal stuff --> - <com.android.systemui.tuner.StatusBarSwitch - android:key="battery" - android:title="@string/battery" /> + <com.android.systemui.tuner.BatteryPreference + android:title="@string/battery" + android:summary="%s" + android:entries="@array/battery_options" /> <com.android.systemui.tuner.StatusBarSwitch android:key="alarm_clock" @@ -101,45 +93,13 @@ <!-- secure --> - <com.android.systemui.tuner.StatusBarSwitch - android:key="clock" - android:title="@string/clock" /> - - </PreferenceScreen> - - - <PreferenceScreen - android:key="overview" - android:title="@string/overview" > - - <com.android.systemui.tuner.TunerSwitch - android:key="overview_disable_fast_toggle_via_button" - android:title="@string/overview_disable_fast_toggle_via_button" - android:summary="@string/overview_disable_fast_toggle_via_button_desc" /> - - <com.android.systemui.tuner.TunerSwitch - android:key="overview_nav_bar_gesture" - android:title="@string/overview_nav_bar_gesture" - android:summary="@string/overview_nav_bar_gesture_desc" /> + <com.android.systemui.tuner.ClockPreference + android:title="@string/tuner_time" + android:summary="%s" + android:entries="@array/clock_options" /> </PreferenceScreen> - <SwitchPreference - android:key="battery_pct" - android:title="@string/show_battery_percentage" - android:summary="@string/show_battery_percentage_summary" - android:persistent="false" /> - - <com.android.systemui.tuner.TunerSwitch - android:key="clock_seconds" - android:title="@string/clock_seconds" - android:summary="@string/clock_seconds_desc" /> - - <Preference - android:key="demo_mode" - android:title="@string/demo_mode" - android:fragment="com.android.systemui.tuner.DemoModeFragment" /> - <Preference android:key="color_transform" android:title="@string/color_and_appearance" @@ -151,17 +111,11 @@ <com.android.systemui.tuner.TunerSwitch android:key="sysui_show_full_zen" - android:title="@string/tuner_full_zen_title" - android:summary="@string/tuner_full_zen_summary" /> - - <com.android.systemui.tuner.TunerSwitch - android:key="sysui_volume_down_silent" - android:title="@string/volume_down_silent" - sysui:defValue="true" /> + android:title="@string/tuner_full_zen_title" /> <com.android.systemui.tuner.TunerSwitch - android:key="sysui_volume_up_silent" - android:title="@string/volume_up_silent" + android:key="sysui_volume_down_silent,sysui_volume_up_silent" + android:title="@string/volume_dnd_silent" sysui:defValue="true" /> </PreferenceScreen> @@ -171,6 +125,22 @@ android:title="@string/nav_bar" android:fragment="com.android.systemui.tuner.NavBarTuner" /> + <PreferenceScreen + android:key="overview" + android:title="@string/overview" > + + <com.android.systemui.tuner.TunerSwitch + android:key="overview_disable_fast_toggle_via_button" + android:title="@string/overview_disable_fast_toggle_via_button" + android:summary="@string/overview_disable_fast_toggle_via_button_desc" /> + + <com.android.systemui.tuner.TunerSwitch + android:key="overview_nav_bar_gesture" + android:title="@string/overview_nav_bar_gesture" + android:summary="@string/overview_nav_bar_gesture_desc" /> + + </PreferenceScreen> + <!-- Warning, this goes last. --> <Preference android:summary="@string/tuner_persistent_warning" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index df5a62229633..6550c8736164 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -456,11 +456,9 @@ public class PhoneStatusBarPolicy implements Callback, RotationLockController.Ro mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_landscape, mContext.getString(R.string.accessibility_rotation_lock_on_landscape)); } + mIconController.setIconVisibility(mSlotRotate, true); } else { - mIconController.setIcon(mSlotRotate, portrait - ? R.drawable.stat_sys_auto_rotate_portrait - : R.drawable.stat_sys_auto_rotate_landscape, - mContext.getString(R.string.accessibility_rotation_lock_off)); + mIconController.setIconVisibility(mSlotRotate, false); } } diff --git a/packages/SystemUI/src/com/android/systemui/tuner/BatteryPreference.java b/packages/SystemUI/src/com/android/systemui/tuner/BatteryPreference.java new file mode 100644 index 000000000000..8881c7939337 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/tuner/BatteryPreference.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2016 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. + */ + +package com.android.systemui.tuner; + +import android.content.Context; +import android.provider.Settings; +import android.support.v7.preference.DropDownPreference; +import android.text.TextUtils; +import android.util.ArraySet; +import android.util.AttributeSet; +import com.android.internal.logging.MetricsLogger; +import com.android.internal.logging.MetricsProto.MetricsEvent; +import com.android.systemui.statusbar.phone.StatusBarIconController; + +import static com.android.systemui.BatteryMeterDrawable.SHOW_PERCENT_SETTING; + +public class BatteryPreference extends DropDownPreference implements TunerService.Tunable { + + private static final String PERCENT = "percent"; + private static final String DEFAULT = "default"; + private static final String DISABLED = "disabled"; + + private final String mBattery; + private boolean mBatteryEnabled; + private boolean mHasPercentage; + private ArraySet<String> mBlacklist; + private boolean mHasSetValue; + + public BatteryPreference(Context context, AttributeSet attrs) { + super(context, attrs); + mBattery = context.getString(com.android.internal.R.string.status_bar_battery); + setEntryValues(new CharSequence[] {PERCENT, DEFAULT, DISABLED }); + } + + @Override + public void onAttached() { + super.onAttached(); + TunerService.get(getContext()).addTunable(this, StatusBarIconController.ICON_BLACKLIST); + mHasPercentage = Settings.System.getInt(getContext().getContentResolver(), + SHOW_PERCENT_SETTING, 0) != 0; + } + + @Override + public void onDetached() { + TunerService.get(getContext()).removeTunable(this); + super.onDetached(); + } + + @Override + public void onTuningChanged(String key, String newValue) { + if (StatusBarIconController.ICON_BLACKLIST.equals(key)) { + mBlacklist = StatusBarIconController.getIconBlacklist(newValue); + mBatteryEnabled = !mBlacklist.contains(mBattery); + } + if (!mHasSetValue) { + // Because of the complicated tri-state it can end up looping and setting state back to + // what the user didn't choose. To avoid this, just set the state once and rely on the + // preference to handle updates. + mHasSetValue = true; + if (mBatteryEnabled && mHasPercentage) { + setValue(PERCENT); + } else if (mBatteryEnabled) { + setValue(DEFAULT); + } else { + setValue(DISABLED); + } + } + } + + @Override + protected boolean persistString(String value) { + final boolean v = PERCENT.equals(value); + MetricsLogger.action(getContext(), MetricsEvent.TUNER_BATTERY_PERCENTAGE, v); + Settings.System.putInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, v ? 1 : 0); + if (DISABLED.equals(value)) { + mBlacklist.add(mBattery); + } else { + mBlacklist.remove(mBattery); + } + TunerService.get(getContext()).setValue(StatusBarIconController.ICON_BLACKLIST, + TextUtils.join(",", mBlacklist)); + return true; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java b/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java new file mode 100644 index 000000000000..ea92443b7265 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/tuner/ClockPreference.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2016 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. + */ +package com.android.systemui.tuner; + +import android.content.Context; +import android.support.v7.preference.DropDownPreference; +import android.text.TextUtils; +import android.util.ArraySet; +import android.util.AttributeSet; +import com.android.systemui.statusbar.phone.StatusBarIconController; +import com.android.systemui.statusbar.policy.Clock; + +public class ClockPreference extends DropDownPreference implements TunerService.Tunable { + + private static final String SECONDS = "seconds"; + private static final String DEFAULT = "default"; + private static final String DISABLED = "disabled"; + + private final String mClock; + private boolean mClockEnabled; + private boolean mHasSeconds; + private ArraySet<String> mBlacklist; + private boolean mHasSetValue; + + public ClockPreference(Context context, AttributeSet attrs) { + super(context, attrs); + mClock = context.getString(com.android.internal.R.string.status_bar_clock); + setEntryValues(new CharSequence[] { SECONDS, DEFAULT, DISABLED }); + } + + @Override + public void onAttached() { + super.onAttached(); + TunerService.get(getContext()).addTunable(this, StatusBarIconController.ICON_BLACKLIST, + Clock.CLOCK_SECONDS); + } + + @Override + public void onDetached() { + TunerService.get(getContext()).removeTunable(this); + super.onDetached(); + } + + @Override + public void onTuningChanged(String key, String newValue) { + if (StatusBarIconController.ICON_BLACKLIST.equals(key)) { + mBlacklist = StatusBarIconController.getIconBlacklist(newValue); + mClockEnabled = !mBlacklist.contains(mClock); + } else if (Clock.CLOCK_SECONDS.equals(key)) { + mHasSeconds = newValue != null && Integer.parseInt(newValue) != 0; + } + if (!mHasSetValue) { + // Because of the complicated tri-state it can end up looping and setting state back to + // what the user didn't choose. To avoid this, just set the state once and rely on the + // preference to handle updates. + mHasSetValue = true; + if (mClockEnabled && mHasSeconds) { + setValue(SECONDS); + } else if (mClockEnabled) { + setValue(DEFAULT); + } else { + setValue(DISABLED); + } + } + } + + @Override + protected boolean persistString(String value) { + TunerService.get(getContext()).setValue(Clock.CLOCK_SECONDS, SECONDS.equals(value) ? 1 : 0); + if (DISABLED.equals(value)) { + mBlacklist.add(mClock); + } else { + mBlacklist.remove(mClock); + } + TunerService.get(getContext()).setValue(StatusBarIconController.ICON_BLACKLIST, + TextUtils.join(",", mBlacklist)); + return true; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java index 9df53682c5ad..70f2fdcfa8d3 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerFragment.java @@ -37,8 +37,6 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.systemui.R; -import static com.android.systemui.BatteryMeterDrawable.SHOW_PERCENT_SETTING; - public class TunerFragment extends PreferenceFragment { private static final String TAG = "TunerFragment"; @@ -51,10 +49,6 @@ public class TunerFragment extends PreferenceFragment { private static final int MENU_REMOVE = Menu.FIRST + 1; - private final SettingObserver mSettingObserver = new SettingObserver(); - - private SwitchPreference mBatteryPct; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -72,7 +66,6 @@ public class TunerFragment extends PreferenceFragment { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.tuner_prefs); - mBatteryPct = (SwitchPreference) findPreference(KEY_BATTERY_PCT); if (Settings.Secure.getInt(getContext().getContentResolver(), SETTING_SEEN_TUNER_WARNING, 0) == 0) { if (getFragmentManager().findFragmentByTag(WARNING_TAG) == null) { @@ -85,9 +78,6 @@ public class TunerFragment extends PreferenceFragment { public void onResume() { super.onResume(); getActivity().setTitle(R.string.system_ui_tuner); - updateBatteryPct(); - getContext().getContentResolver().registerContentObserver( - System.getUriFor(SHOW_PERCENT_SETTING), false, mSettingObserver); MetricsLogger.visibility(getContext(), MetricsEvent.TUNER, true); } @@ -95,7 +85,6 @@ public class TunerFragment extends PreferenceFragment { @Override public void onPause() { super.onPause(); - getContext().getContentResolver().unregisterContentObserver(mSettingObserver); MetricsLogger.visibility(getContext(), MetricsEvent.TUNER, false); } @@ -123,35 +112,6 @@ public class TunerFragment extends PreferenceFragment { return super.onOptionsItemSelected(item); } - private void updateBatteryPct() { - mBatteryPct.setOnPreferenceChangeListener(null); - mBatteryPct.setChecked(System.getInt(getContext().getContentResolver(), - SHOW_PERCENT_SETTING, 0) != 0); - mBatteryPct.setOnPreferenceChangeListener(mBatteryPctChange); - } - - private final class SettingObserver extends ContentObserver { - public SettingObserver() { - super(new Handler()); - } - - @Override - public void onChange(boolean selfChange, Uri uri, int userId) { - super.onChange(selfChange, uri, userId); - updateBatteryPct(); - } - } - - private final OnPreferenceChangeListener mBatteryPctChange = new OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - final boolean v = (Boolean) newValue; - MetricsLogger.action(getContext(), MetricsEvent.TUNER_BATTERY_PERCENTAGE, v); - System.putInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, v ? 1 : 0); - return true; - } - }; - public static class TunerWarningFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunerSwitch.java b/packages/SystemUI/src/com/android/systemui/tuner/TunerSwitch.java index 7ad752ec74ce..b73813647c0d 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/TunerSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/TunerSwitch.java @@ -23,7 +23,7 @@ public class TunerSwitch extends SwitchPreference implements Tunable { @Override public void onAttached() { super.onAttached(); - TunerService.get(getContext()).addTunable(this, getKey()); + TunerService.get(getContext()).addTunable(this, getKey().split(",")); } @Override @@ -39,7 +39,9 @@ public class TunerSwitch extends SwitchPreference implements Tunable { @Override protected boolean persistBoolean(boolean value) { - Settings.Secure.putString(getContext().getContentResolver(), getKey(), value ? "1" : "0"); + for (String key : getKey().split(",")) { + Settings.Secure.putString(getContext().getContentResolver(), key, value ? "1" : "0"); + } return true; } |