Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -871,6 +871,8 @@ <string name="quick_settings_secondary_label_until">Until <xliff:g id="time" example="7 am">%s</xliff:g></string> <!-- QuickSettings: Label for the toggle to activate Dark theme (A.K.A Dark Mode). [CHAR LIMIT=20] --> <string name="quick_settings_ui_mode_night_label">Dark Theme</string> <!-- QuickSettings: Label for the Dark theme tile when enabled by battery saver. [CHAR LIMIT=40] --> <string name="quick_settings_ui_mode_night_label_battery_saver">Dark Theme\nBattery saver</string> <!-- QuickSettings: NFC tile [CHAR LIMIT=NONE] --> <string name="quick_settings_nfc_label">NFC</string> Loading packages/SystemUI/src/com/android/systemui/qs/tiles/UiModeNightTile.java +26 −5 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.systemui.R; import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.qs.QSHost; import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; import javax.inject.Inject; Loading @@ -39,17 +40,22 @@ import javax.inject.Inject; * taken by {@link NightDisplayTile}. */ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements ConfigurationController.ConfigurationListener { ConfigurationController.ConfigurationListener, BatteryController.BatteryStateChangeCallback { private final Icon mIcon = ResourceIcon.get( com.android.internal.R.drawable.ic_qs_ui_mode_night); private UiModeManager mUiModeManager; private final UiModeManager mUiModeManager; private final BatteryController mBatteryController; @Inject public UiModeNightTile(QSHost host, ConfigurationController configurationController) { public UiModeNightTile(QSHost host, ConfigurationController configurationController, BatteryController batteryController) { super(host); mBatteryController = batteryController; mUiModeManager = mContext.getSystemService(UiModeManager.class); configurationController.observe(getLifecycle(), this); batteryController.observe(getLifecycle(), this); } @Override Loading @@ -57,6 +63,11 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements refreshState(); } @Override public void onPowerSaveChanged(boolean isPowerSave) { refreshState(); } @Override public BooleanState newTileState() { return new BooleanState(); Loading @@ -64,6 +75,9 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements @Override protected void handleClick() { if (getState().state == Tile.STATE_UNAVAILABLE) { return; } boolean newState = !mState.value; mUiModeManager.setNightMode(newState ? UiModeManager.MODE_NIGHT_YES : UiModeManager.MODE_NIGHT_NO); Loading @@ -72,15 +86,22 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements @Override protected void handleUpdateState(BooleanState state, Object arg) { boolean powerSave = mBatteryController.isPowerSave(); boolean nightMode = (mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; state.value = nightMode; state.label = mContext.getString(R.string.quick_settings_ui_mode_night_label); state.label = mContext.getString(powerSave ? R.string.quick_settings_ui_mode_night_label_battery_saver : R.string.quick_settings_ui_mode_night_label); state.contentDescription = state.label; state.icon = mIcon; state.expandedAccessibilityClassName = Switch.class.getName(); if (powerSave) { state.state = Tile.STATE_UNAVAILABLE; } else { state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; } state.showRippleEffect = false; } Loading Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -871,6 +871,8 @@ <string name="quick_settings_secondary_label_until">Until <xliff:g id="time" example="7 am">%s</xliff:g></string> <!-- QuickSettings: Label for the toggle to activate Dark theme (A.K.A Dark Mode). [CHAR LIMIT=20] --> <string name="quick_settings_ui_mode_night_label">Dark Theme</string> <!-- QuickSettings: Label for the Dark theme tile when enabled by battery saver. [CHAR LIMIT=40] --> <string name="quick_settings_ui_mode_night_label_battery_saver">Dark Theme\nBattery saver</string> <!-- QuickSettings: NFC tile [CHAR LIMIT=NONE] --> <string name="quick_settings_nfc_label">NFC</string> Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/UiModeNightTile.java +26 −5 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.systemui.R; import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.qs.QSHost; import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; import javax.inject.Inject; Loading @@ -39,17 +40,22 @@ import javax.inject.Inject; * taken by {@link NightDisplayTile}. */ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements ConfigurationController.ConfigurationListener { ConfigurationController.ConfigurationListener, BatteryController.BatteryStateChangeCallback { private final Icon mIcon = ResourceIcon.get( com.android.internal.R.drawable.ic_qs_ui_mode_night); private UiModeManager mUiModeManager; private final UiModeManager mUiModeManager; private final BatteryController mBatteryController; @Inject public UiModeNightTile(QSHost host, ConfigurationController configurationController) { public UiModeNightTile(QSHost host, ConfigurationController configurationController, BatteryController batteryController) { super(host); mBatteryController = batteryController; mUiModeManager = mContext.getSystemService(UiModeManager.class); configurationController.observe(getLifecycle(), this); batteryController.observe(getLifecycle(), this); } @Override Loading @@ -57,6 +63,11 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements refreshState(); } @Override public void onPowerSaveChanged(boolean isPowerSave) { refreshState(); } @Override public BooleanState newTileState() { return new BooleanState(); Loading @@ -64,6 +75,9 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements @Override protected void handleClick() { if (getState().state == Tile.STATE_UNAVAILABLE) { return; } boolean newState = !mState.value; mUiModeManager.setNightMode(newState ? UiModeManager.MODE_NIGHT_YES : UiModeManager.MODE_NIGHT_NO); Loading @@ -72,15 +86,22 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements @Override protected void handleUpdateState(BooleanState state, Object arg) { boolean powerSave = mBatteryController.isPowerSave(); boolean nightMode = (mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; state.value = nightMode; state.label = mContext.getString(R.string.quick_settings_ui_mode_night_label); state.label = mContext.getString(powerSave ? R.string.quick_settings_ui_mode_night_label_battery_saver : R.string.quick_settings_ui_mode_night_label); state.contentDescription = state.label; state.icon = mIcon; state.expandedAccessibilityClassName = Switch.class.getName(); if (powerSave) { state.state = Tile.STATE_UNAVAILABLE; } else { state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; } state.showRippleEffect = false; } Loading