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

Commit e6f94296 authored by Rohan Shah's avatar Rohan Shah Committed by android-build-merger
Browse files

Merge "[QS] Update hotspot tile secondary text (data saver)" into pi-dev am: 0cee663b

am: f30ff8ae

Change-Id: I414bcf8d8f36045ca8c4584178e28d5238355b7f
parents 504791bd f30ff8ae
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -780,6 +780,9 @@
    <string name="quick_settings_hotspot_label">Hotspot</string>
    <!-- QuickSettings: Hotspot. Secondary label shown when the hotspot is being enabled [CHAR LIMIT=NONE] -->
    <string name="quick_settings_hotspot_secondary_label_transient">Turning on&#8230;</string>
    <!-- QuickSettings: Hotspot. Secondary label shown when Data Saver mode is enabled to explain to
         the user why they can't toggle the hotspot tile. [CHAR LIMIT=20] -->
    <string name="quick_settings_hotspot_secondary_label_data_saver_enabled">Data Saver is on</string>
    <!-- QuickSettings: Hotspot: Secondary label for how many devices are connected to the hotspot [CHAR LIMIT=NONE] -->
    <plurals name="quick_settings_hotspot_secondary_label_num_devices">
        <item quantity="one">%d device</item>
+15 −9
Original line number Diff line number Diff line
@@ -137,7 +137,6 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> {

        state.icon = mEnabledStatic;
        state.label = mContext.getString(R.string.quick_settings_hotspot_label);
        state.secondaryLabel = getSecondaryLabel(state.value, isTransient, numConnectedDevices);
        state.isAirplaneMode = mAirplaneMode.getValue() != 0;
        state.isTransient = isTransient;
        state.slash.isSlashed = !state.value && !state.isTransient;
@@ -149,19 +148,26 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> {

        final boolean isTileUnavailable = (state.isAirplaneMode || isDataSaverEnabled);
        final boolean isTileActive = (state.value || state.isTransient);
        state.state = isTileUnavailable
                ? Tile.STATE_UNAVAILABLE
                : isTileActive
                        ? Tile.STATE_ACTIVE
                        : Tile.STATE_INACTIVE;

        if (isTileUnavailable) {
            state.state = Tile.STATE_UNAVAILABLE;
        } else {
            state.state = isTileActive ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
        }

        state.secondaryLabel = getSecondaryLabel(
                isTileActive, isTransient, isDataSaverEnabled, numConnectedDevices);
    }

    @Nullable
    private String getSecondaryLabel(
            boolean enabled, boolean isTransient, int numConnectedDevices) {
    private String getSecondaryLabel(boolean isActive, boolean isTransient,
            boolean isDataSaverEnabled, int numConnectedDevices) {
        if (isTransient) {
            return mContext.getString(R.string.quick_settings_hotspot_secondary_label_transient);
        } else if (numConnectedDevices > 0 && enabled) {
        } else if (isDataSaverEnabled) {
            return mContext.getString(
                    R.string.quick_settings_hotspot_secondary_label_data_saver_enabled);
        } else if (numConnectedDevices > 0 && isActive) {
            return mContext.getResources().getQuantityString(
                    R.plurals.quick_settings_hotspot_secondary_label_num_devices,
                    numConnectedDevices,