From 2c23b130114c92c9bc52c3b4ba085ebaa85da832 Mon Sep 17 00:00:00 2001 From: Rohan Shah Date: Fri, 9 Mar 2018 13:41:11 -0800 Subject: [PATCH] [QS] Update hotspot tile secondary text (data saver) Updating the secondary text to show a different message when data saver is enabled (to explain to the user why they can't toggle the tile). Also collapsed double ternary to make it a bit easier to read. Test: Visually Bug: 33003328 Change-Id: I8a98f95c60ec9dcbe5899e87e29759e8d377b106 --- packages/SystemUI/res/values/strings.xml | 3 +++ .../systemui/qs/tiles/HotspotTile.java | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 89e6da38ffa7f..4eb122c554566 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -780,6 +780,9 @@ Hotspot Turning on… + + Data Saver is on %d device diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java index 81e3d5ad17de9..00d6bd0d307f8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -137,7 +137,6 @@ public class HotspotTile extends QSTileImpl { 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 { 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,