summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2015-04-22 02:15:28 +0300
committeralk3pInjection <webmaster@raspii.tech>2022-02-17 10:03:45 +0800
commit23ff012691ed97d316d39387779f823c31a33adf (patch)
tree0967f949a359f6803d05c4c4ace9de1a7c0d5081
parent6bfa9d5a1cb0c8a19c93a83f5935821bf6670c25 (diff)
SystemUI: Add Heads Up tile
Change-Id: I0e3cff73752c59d804dcec43b86524c2e8df4f57
-rw-r--r--packages/SystemUI/res/drawable/ic_qs_heads_up.xml36
-rw-r--r--packages/SystemUI/res/values/config.xml2
-rw-r--r--packages/SystemUI/res/values/ice_strings.xml7
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/HeadsUpTile.java141
5 files changed, 192 insertions, 2 deletions
diff --git a/packages/SystemUI/res/drawable/ic_qs_heads_up.xml b/packages/SystemUI/res/drawable/ic_qs_heads_up.xml
new file mode 100644
index 000000000000..b107602787c1
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_qs_heads_up.xml
@@ -0,0 +1,36 @@
+<!--
+Copyright (C) 2014 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="64dp"
+ android:height="64dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+
+ <path
+ android:pathData="M0,0h24v24H0V0z" />
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M18,16v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-0.83-0.68-1.5-1.51-1.5S10.5,3.17,10.5,4v0.68C7.63,5.36,6,7.92,6,11v5 l-1.3,1.29C4.07,17.92,4.51,19,5.4,19h13.17c0.89,0,1.34-1.08,0.71-1.71L18,16z" />
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M11.99,22c1.1,0,2-0.9,2-2h-4C9.99,21.1,10.88,22,11.99,22z" />
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M6.77,4.73C7.19,4.35,7.2,3.7,6.8,3.3l0,0c-0.38-0.38-1-0.39-1.39-0.02C3.7,4.84,2.52,6.96,2.14,9.34 C2.05,9.95,2.52,10.5,3.14,10.5h0c0.48,0,0.9-0.35,0.98-0.83C4.42,7.73,5.38,6,6.77,4.73z" />
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M18.6,3.28c-0.4-0.37-1.02-0.36-1.4,0.02l0,0c-0.4,0.4-0.38,1.04,0.03,1.42c1.38,1.27,2.35,3,2.65,4.94 c0.07,0.48,0.49,0.83,0.98,0.83c0.61,0,1.09-0.55,0.99-1.16C21.47,6.96,20.3,4.85,18.6,3.28z" />
+</vector>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 9d5fd53118c4..934b2d4c9d91 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -107,7 +107,7 @@
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
<string name="quick_settings_tiles_stock" translatable="false">
- internet,wifi,cell,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,caffeine
+ internet,wifi,cell,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,caffeine,heads_up
</string>
<!-- The tiles to display in QuickSettings -->
diff --git a/packages/SystemUI/res/values/ice_strings.xml b/packages/SystemUI/res/values/ice_strings.xml
index e933983103cd..ac82cf770d27 100644
--- a/packages/SystemUI/res/values/ice_strings.xml
+++ b/packages/SystemUI/res/values/ice_strings.xml
@@ -20,4 +20,11 @@
<string name="quick_settings_caffeine_label">Caffeine</string>
<string name="accessibility_quick_settings_caffeine_off">Caffeine off.</string>
<string name="accessibility_quick_settings_caffeine_on">Caffeine on.</string>
+
+ <!-- Heads up QS tile -->
+ <string name="quick_settings_heads_up_label">Heads up</string>
+ <string name="accessibility_quick_settings_heads_up_off">Heads up off.</string>
+ <string name="accessibility_quick_settings_heads_up_on">Heads up on.</string>
+ <string name="accessibility_quick_settings_heads_up_changed_off">Heads up turned off.</string>
+ <string name="accessibility_quick_settings_heads_up_changed_on">Heads up turned on.</string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
index 89d71ac6a28d..e3bb23c7a94b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
@@ -38,6 +38,7 @@ import com.android.systemui.qs.tiles.DataSaverTile;
import com.android.systemui.qs.tiles.DeviceControlsTile;
import com.android.systemui.qs.tiles.DndTile;
import com.android.systemui.qs.tiles.FlashlightTile;
+import com.android.systemui.qs.tiles.HeadsUpTile;
import com.android.systemui.qs.tiles.HotspotTile;
import com.android.systemui.qs.tiles.InternetTile;
import com.android.systemui.qs.tiles.LocationTile;
@@ -92,6 +93,7 @@ public class QSFactoryImpl implements QSFactory {
private final Provider<AlarmTile> mAlarmTileProvider;
private final Provider<QuickAccessWalletTile> mQuickAccessWalletTileProvider;
private final Provider<CaffeineTile> mCaffeineTileProvider;
+ private final Provider<HeadsUpTile> mHeadsUpTileProvider;
private final Lazy<QSHost> mQsHostLazy;
private final Provider<CustomTile.Builder> mCustomTileBuilderProvider;
@@ -127,7 +129,8 @@ public class QSFactoryImpl implements QSFactory {
Provider<DeviceControlsTile> deviceControlsTileProvider,
Provider<AlarmTile> alarmTileProvider,
Provider<QuickAccessWalletTile> quickAccessWalletTileProvider,
- Provider<CaffeineTile> caffeineTileProvider) {
+ Provider<CaffeineTile> caffeineTileProvider,
+ Provider<HeadsUpTile> headsUpTileProvider) {
mQsHostLazy = qsHostLazy;
mCustomTileBuilderProvider = customTileBuilderProvider;
@@ -159,6 +162,7 @@ public class QSFactoryImpl implements QSFactory {
mAlarmTileProvider = alarmTileProvider;
mQuickAccessWalletTileProvider = quickAccessWalletTileProvider;
mCaffeineTileProvider = caffeineTileProvider;
+ mHeadsUpTileProvider = headsUpTileProvider;
}
public QSTile createTile(String tileSpec) {
@@ -228,6 +232,8 @@ public class QSFactoryImpl implements QSFactory {
// Additional tiles.
case "caffeine":
return mCaffeineTileProvider.get();
+ case "heads_up":
+ return mHeadsUpTileProvider.get();
}
// Custom tiles
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HeadsUpTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HeadsUpTile.java
new file mode 100644
index 000000000000..0a9a46af075e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HeadsUpTile.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ * Copyright (C) 2017 The LineageOS 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.content.Intent;
+import android.os.Handler;
+import android.os.Looper;
+import android.provider.Settings;
+import android.provider.Settings.Global;
+import android.service.quicksettings.Tile;
+import android.view.View;
+
+import androidx.annotation.Nullable;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.R;
+import com.android.systemui.dagger.qualifiers.Background;
+import com.android.systemui.dagger.qualifiers.Main;
+import com.android.systemui.plugins.ActivityStarter;
+import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.plugins.qs.QSTile.BooleanState;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.qs.GlobalSetting;
+import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.logging.QSLogger;
+import com.android.systemui.qs.tileimpl.QSTileImpl;
+
+import javax.inject.Inject;
+
+/** Quick settings tile: Heads up **/
+public class HeadsUpTile extends QSTileImpl<BooleanState> {
+
+ private final Icon mIcon = ResourceIcon.get(R.drawable.ic_qs_heads_up);
+
+ private static final Intent NOTIFICATION_SETTINGS =
+ new Intent("android.settings.NOTIFICATION_SETTINGS");
+
+ private final GlobalSetting mSetting;
+
+ @Inject
+ public HeadsUpTile(
+ QSHost host,
+ @Background Looper backgroundLooper,
+ @Main Handler mainHandler,
+ FalsingManager falsingManager,
+ MetricsLogger metricsLogger,
+ StatusBarStateController statusBarStateController,
+ ActivityStarter activityStarter,
+ QSLogger qsLogger
+ ) {
+ super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
+ statusBarStateController, activityStarter, qsLogger);
+
+ mSetting = new GlobalSetting(mContext, mHandler, Global.HEADS_UP_NOTIFICATIONS_ENABLED) {
+ @Override
+ protected void handleValueChanged(int value) {
+ handleRefreshState(value);
+ }
+ };
+ }
+
+ @Override
+ public BooleanState newTileState() {
+ return new BooleanState();
+ }
+
+ @Override
+ protected void handleClick(@Nullable View view) {
+ setEnabled(!mState.value);
+ refreshState();
+ }
+
+ @Override
+ public Intent getLongClickIntent() {
+ return NOTIFICATION_SETTINGS;
+ }
+
+ private void setEnabled(boolean enabled) {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
+ enabled ? 1 : 0);
+ }
+
+ @Override
+ protected void handleUpdateState(BooleanState state, Object arg) {
+ final int value = arg instanceof Integer ? (Integer) arg : mSetting.getValue();
+ final boolean headsUp = value != 0;
+ state.value = headsUp;
+ state.label = mContext.getString(R.string.quick_settings_heads_up_label);
+ state.icon = mIcon;
+ if (headsUp) {
+ state.contentDescription = mContext.getString(
+ R.string.accessibility_quick_settings_heads_up_on);
+ state.state = Tile.STATE_ACTIVE;
+ } else {
+ state.contentDescription = mContext.getString(
+ R.string.accessibility_quick_settings_heads_up_off);
+ state.state = Tile.STATE_INACTIVE;
+ }
+ }
+
+ @Override
+ public CharSequence getTileLabel() {
+ return mContext.getString(R.string.quick_settings_heads_up_label);
+ }
+
+ @Override
+ protected String composeChangeAnnouncement() {
+ if (mState.value) {
+ return mContext.getString(R.string.accessibility_quick_settings_heads_up_changed_on);
+ } else {
+ return mContext.getString(R.string.accessibility_quick_settings_heads_up_changed_off);
+ }
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.ICE;
+ }
+
+ @Override
+ public void handleSetListening(boolean listening) {
+ // Do nothing
+ }
+}