Dark Theme QS tile
Creates Dark Theme tile and adds it to the default config, under the fold. Test: manually toggle tile Fixes: 130253100 Change-Id: I2859d2eb20db1c6d9dd8e8e24979294316b905bb
This commit is contained in:
25
core/res/res/drawable/ic_qs_ui_mode_night.xml
Normal file
25
core/res/res/drawable/ic_qs_ui_mode_night.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2019 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
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,22C17.52,22 22,17.52 22,12 22,6.48 17.52,2 12,2 6.48,2 2,6.48 2,12 2,17.52 6.48,22 12,22ZM12,3.915c3.889,0 8,4.005 8,8.085 0,4.08 -3.927,7.992 -7.928,7.992z"/>
|
||||
</vector>
|
||||
@@ -1484,6 +1484,7 @@
|
||||
<java-symbol type="drawable" name="ic_settings_print" />
|
||||
<java-symbol type="drawable" name="ic_signal_location" />
|
||||
<java-symbol type="drawable" name="ic_info_outline_24" />
|
||||
<java-symbol type="drawable" name="ic_qs_ui_mode_night" />
|
||||
|
||||
<java-symbol type="drawable" name="stat_notify_mmcc_indication_icn" />
|
||||
<java-symbol type="drawable" name="autofilled_highlight"/>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<permission name="android.permission.MANAGE_USERS"/>
|
||||
<permission name="android.permission.MASTER_CLEAR"/>
|
||||
<permission name="android.permission.MEDIA_CONTENT_CONTROL"/>
|
||||
<permission name="android.permission.MODIFY_DAY_NIGHT_MODE"/>
|
||||
<permission name="android.permission.MODIFY_PHONE_STATE"/>
|
||||
<permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
||||
<permission name="android.permission.OVERRIDE_WIFI_CONFIG"/>
|
||||
|
||||
@@ -175,6 +175,9 @@
|
||||
<!-- Adding Quick Settings tiles -->
|
||||
<uses-permission android:name="android.permission.BIND_QUICK_SETTINGS_TILE" />
|
||||
|
||||
<!-- Quick Settings tile: Night Mode / Dark Theme -->
|
||||
<uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE" />
|
||||
|
||||
<!-- Block notifications inline notifications -->
|
||||
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
|
||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||
<string name="quick_settings_tiles_stock" translatable="false">
|
||||
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,work,cast,night
|
||||
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,dark,saver,work,cast,night
|
||||
</string>
|
||||
|
||||
<!-- The tiles to display in QuickSettings -->
|
||||
|
||||
@@ -865,6 +865,8 @@
|
||||
<string name="quick_settings_night_secondary_label_on_at">On at <xliff:g id="time" example="10 pm">%s</xliff:g></string>
|
||||
<!-- QuickSettings: Secondary text for when the Night Light or some other tile will be on until some user-selected time. [CHAR LIMIT=20] -->
|
||||
<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: NFC tile [CHAR LIMIT=NONE] -->
|
||||
<string name="quick_settings_nfc_label">NFC</string>
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.systemui.qs.tiles.LocationTile;
|
||||
import com.android.systemui.qs.tiles.NfcTile;
|
||||
import com.android.systemui.qs.tiles.NightDisplayTile;
|
||||
import com.android.systemui.qs.tiles.RotationLockTile;
|
||||
import com.android.systemui.qs.tiles.UiModeNightTile;
|
||||
import com.android.systemui.qs.tiles.UserTile;
|
||||
import com.android.systemui.qs.tiles.WifiTile;
|
||||
import com.android.systemui.qs.tiles.WorkModeTile;
|
||||
@@ -73,6 +74,7 @@ public class QSFactoryImpl implements QSFactory {
|
||||
private final Provider<NightDisplayTile> mNightDisplayTileProvider;
|
||||
private final Provider<NfcTile> mNfcTileProvider;
|
||||
private final Provider<GarbageMonitor.MemoryTile> mMemoryTileProvider;
|
||||
private final Provider<UiModeNightTile> mUiModeNightTileProvider;
|
||||
|
||||
private QSTileHost mHost;
|
||||
|
||||
@@ -94,7 +96,8 @@ public class QSFactoryImpl implements QSFactory {
|
||||
Provider<DataSaverTile> dataSaverTileProvider,
|
||||
Provider<NightDisplayTile> nightDisplayTileProvider,
|
||||
Provider<NfcTile> nfcTileProvider,
|
||||
Provider<GarbageMonitor.MemoryTile> memoryTileProvider) {
|
||||
Provider<GarbageMonitor.MemoryTile> memoryTileProvider,
|
||||
Provider<UiModeNightTile> uiModeNightTileProvider) {
|
||||
mWifiTileProvider = wifiTileProvider;
|
||||
mBluetoothTileProvider = bluetoothTileProvider;
|
||||
mCellularTileProvider = cellularTileProvider;
|
||||
@@ -113,6 +116,7 @@ public class QSFactoryImpl implements QSFactory {
|
||||
mNightDisplayTileProvider = nightDisplayTileProvider;
|
||||
mNfcTileProvider = nfcTileProvider;
|
||||
mMemoryTileProvider = memoryTileProvider;
|
||||
mUiModeNightTileProvider = uiModeNightTileProvider;
|
||||
}
|
||||
|
||||
public void setHost(QSTileHost host) {
|
||||
@@ -164,6 +168,8 @@ public class QSFactoryImpl implements QSFactory {
|
||||
return mNightDisplayTileProvider.get();
|
||||
case "nfc":
|
||||
return mNfcTileProvider.get();
|
||||
case "dark":
|
||||
return mUiModeNightTileProvider.get();
|
||||
}
|
||||
|
||||
// Intent tiles.
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.qs.tiles;
|
||||
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.provider.Settings;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
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.ConfigurationController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Quick Settings tile for: Night Mode / Dark Theme / Dark Mode.
|
||||
*
|
||||
* The string id of this tile is "dark" because "night" was already
|
||||
* taken by {@link NightDisplayTile}.
|
||||
*/
|
||||
public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements
|
||||
ConfigurationController.ConfigurationListener {
|
||||
|
||||
private final Icon mIcon = ResourceIcon.get(
|
||||
com.android.internal.R.drawable.ic_qs_ui_mode_night);
|
||||
private UiModeManager mUiModeManager;
|
||||
|
||||
@Inject
|
||||
public UiModeNightTile(QSHost host, ConfigurationController configurationController) {
|
||||
super(host);
|
||||
mUiModeManager = mContext.getSystemService(UiModeManager.class);
|
||||
configurationController.observe(getLifecycle(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiModeChanged() {
|
||||
refreshState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanState newTileState() {
|
||||
return new BooleanState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
boolean newState = !mState.value;
|
||||
mUiModeManager.setNightMode(newState ? UiModeManager.MODE_NIGHT_YES
|
||||
: UiModeManager.MODE_NIGHT_NO);
|
||||
refreshState(newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
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.contentDescription = state.label;
|
||||
state.icon = mIcon;
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.QS_UI_MODE_NIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_DISPLAY_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleSetListening(boolean listening) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTileLabel() {
|
||||
return getState().label;
|
||||
}
|
||||
}
|
||||
@@ -7175,6 +7175,13 @@ message MetricsEvent {
|
||||
// Salt generation for the above hashed direct share target
|
||||
FIELD_HASHED_TARGET_SALT_GEN = 1705;
|
||||
|
||||
// OPEN: QS dark theme tile shown
|
||||
// ACTION: QS dark theme tile tapped
|
||||
// SUBTYPE: 0 is off, 1 is on
|
||||
// CATEGORY: QUICK_SETTINGS
|
||||
// OS: Q
|
||||
QS_UI_MODE_NIGHT = 1706;
|
||||
|
||||
// ---- End Q Constants, all Q constants go above this line ----
|
||||
// Add new aosp constants above this line.
|
||||
// END OF AOSP CONSTANTS
|
||||
|
||||
Reference in New Issue
Block a user