Loading packages/SystemUI/res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -764,6 +764,11 @@ <string name="quick_settings_tethering_label">Tethering</string> <!-- QuickSettings: Hotspot. [CHAR LIMIT=NONE] --> <string name="quick_settings_hotspot_label">Hotspot</string> <!-- QuickSettings: Hotspot: Secondary label for how many devices are connected to the hotspot [CHAR LIMIT=NONE] --> <plurals name="quick_settings_hotspot_num_devices"> <item quantity="one">%d device</item> <item quantity="other">%d devices</item> </plurals> <!-- QuickSettings: Notifications [CHAR LIMIT=NONE] --> <string name="quick_settings_notifications_label">Notifications</string> <!-- QuickSettings: Flashlight [CHAR LIMIT=NONE] --> Loading packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +48 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.qs.tiles; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; Loading Loading @@ -115,11 +116,19 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> { state.label = mContext.getString(R.string.quick_settings_hotspot_label); checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_CONFIG_TETHERING); if (arg instanceof Boolean) { state.value = (boolean) arg; final int numConnectedDevices; if (arg instanceof CallbackInfo) { CallbackInfo info = (CallbackInfo) arg; state.value = info.enabled; numConnectedDevices = info.numConnectedDevices; } else { state.value = mController.isHotspotEnabled(); numConnectedDevices = mController.getNumConnectedDevices(); } state.secondaryLabel = getSecondaryLabel(state.value, numConnectedDevices); state.icon = mEnabledStatic; state.isAirplaneMode = mAirplaneMode.getValue() != 0; state.isTransient = mController.isHotspotTransient(); Loading @@ -133,6 +142,18 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> { : state.value || state.isTransient ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; } @Nullable private String getSecondaryLabel(boolean enabled, int numConnectedDevices) { if (numConnectedDevices > 0 && enabled) { return mContext.getResources().getQuantityString( R.plurals.quick_settings_hotspot_num_devices, numConnectedDevices, numConnectedDevices); } return null; } @Override public int getMetricsCategory() { return MetricsEvent.QS_HOTSPOT; Loading @@ -148,9 +169,30 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> { } private final class Callback implements HotspotController.Callback { final CallbackInfo mCallbackInfo = new CallbackInfo(); @Override public void onHotspotChanged(boolean enabled) { refreshState(enabled); public void onHotspotChanged(boolean enabled, int numConnectedDevices) { mCallbackInfo.enabled = enabled; mCallbackInfo.numConnectedDevices = numConnectedDevices; refreshState(mCallbackInfo); } } /** * Holder for any hotspot state info that needs to passed from the callback to * {@link #handleUpdateState(State, Object)}. */ protected static final class CallbackInfo { boolean enabled; int numConnectedDevices; @Override public String toString() { return new StringBuilder("CallbackInfo[") .append("enabled=").append(enabled) .append(",numConnectedDevices=").append(numConnectedDevices) .append(']').toString(); } } }; } packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,7 @@ public class AutoTileManager { private final HotspotController.Callback mHotspotCallback = new Callback() { @Override public void onHotspotChanged(boolean enabled) { public void onHotspotChanged(boolean enabled, int numDevices) { if (mAutoTracker.isAdded(HOTSPOT)) return; if (enabled) { mHost.addTile(HOTSPOT); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +1 −1 Original line number Diff line number Diff line Loading @@ -665,7 +665,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { @Override public void onHotspotChanged(boolean enabled) { public void onHotspotChanged(boolean enabled, int numDevices) { mIconController.setIconVisibility(mSlotHotspot, enabled); } }; Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java +4 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ public interface HotspotController extends CallbackController<Callback>, Dumpabl void setHotspotEnabled(boolean enabled); boolean isHotspotSupported(); public interface Callback { void onHotspotChanged(boolean enabled); int getNumConnectedDevices(); interface Callback { void onHotspotChanged(boolean enabled, int numDevices); } } Loading
packages/SystemUI/res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -764,6 +764,11 @@ <string name="quick_settings_tethering_label">Tethering</string> <!-- QuickSettings: Hotspot. [CHAR LIMIT=NONE] --> <string name="quick_settings_hotspot_label">Hotspot</string> <!-- QuickSettings: Hotspot: Secondary label for how many devices are connected to the hotspot [CHAR LIMIT=NONE] --> <plurals name="quick_settings_hotspot_num_devices"> <item quantity="one">%d device</item> <item quantity="other">%d devices</item> </plurals> <!-- QuickSettings: Notifications [CHAR LIMIT=NONE] --> <string name="quick_settings_notifications_label">Notifications</string> <!-- QuickSettings: Flashlight [CHAR LIMIT=NONE] --> Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +48 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.qs.tiles; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; Loading Loading @@ -115,11 +116,19 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> { state.label = mContext.getString(R.string.quick_settings_hotspot_label); checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_CONFIG_TETHERING); if (arg instanceof Boolean) { state.value = (boolean) arg; final int numConnectedDevices; if (arg instanceof CallbackInfo) { CallbackInfo info = (CallbackInfo) arg; state.value = info.enabled; numConnectedDevices = info.numConnectedDevices; } else { state.value = mController.isHotspotEnabled(); numConnectedDevices = mController.getNumConnectedDevices(); } state.secondaryLabel = getSecondaryLabel(state.value, numConnectedDevices); state.icon = mEnabledStatic; state.isAirplaneMode = mAirplaneMode.getValue() != 0; state.isTransient = mController.isHotspotTransient(); Loading @@ -133,6 +142,18 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> { : state.value || state.isTransient ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; } @Nullable private String getSecondaryLabel(boolean enabled, int numConnectedDevices) { if (numConnectedDevices > 0 && enabled) { return mContext.getResources().getQuantityString( R.plurals.quick_settings_hotspot_num_devices, numConnectedDevices, numConnectedDevices); } return null; } @Override public int getMetricsCategory() { return MetricsEvent.QS_HOTSPOT; Loading @@ -148,9 +169,30 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> { } private final class Callback implements HotspotController.Callback { final CallbackInfo mCallbackInfo = new CallbackInfo(); @Override public void onHotspotChanged(boolean enabled) { refreshState(enabled); public void onHotspotChanged(boolean enabled, int numConnectedDevices) { mCallbackInfo.enabled = enabled; mCallbackInfo.numConnectedDevices = numConnectedDevices; refreshState(mCallbackInfo); } } /** * Holder for any hotspot state info that needs to passed from the callback to * {@link #handleUpdateState(State, Object)}. */ protected static final class CallbackInfo { boolean enabled; int numConnectedDevices; @Override public String toString() { return new StringBuilder("CallbackInfo[") .append("enabled=").append(enabled) .append(",numConnectedDevices=").append(numConnectedDevices) .append(']').toString(); } } }; }
packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,7 @@ public class AutoTileManager { private final HotspotController.Callback mHotspotCallback = new Callback() { @Override public void onHotspotChanged(boolean enabled) { public void onHotspotChanged(boolean enabled, int numDevices) { if (mAutoTracker.isAdded(HOTSPOT)) return; if (enabled) { mHost.addTile(HOTSPOT); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +1 −1 Original line number Diff line number Diff line Loading @@ -665,7 +665,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { @Override public void onHotspotChanged(boolean enabled) { public void onHotspotChanged(boolean enabled, int numDevices) { mIconController.setIconVisibility(mSlotHotspot, enabled); } }; Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java +4 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ public interface HotspotController extends CallbackController<Callback>, Dumpabl void setHotspotEnabled(boolean enabled); boolean isHotspotSupported(); public interface Callback { void onHotspotChanged(boolean enabled); int getNumConnectedDevices(); interface Callback { void onHotspotChanged(boolean enabled, int numDevices); } }