Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8816dff9 authored by Jason Monk's avatar Jason Monk
Browse files

SysUI Tuner: UI cleanup and grouping

Clean up strings and locations of various features.

Change-Id: Ie427a2d8c51afa6f2a68b4cde1d6b15cda897e1a
parent 5dbd4aad
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -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>
+27 −57
Original line number Diff line number Diff line
@@ -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"
+2 −4
Original line number Diff line number Diff line
@@ -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);
        }
    }

+96 −0
Original line number Diff line number Diff line
/*
 * 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;
    }
}
+90 −0
Original line number Diff line number Diff line
/*
 * 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;
    }
}
Loading