summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/qs
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-04-21 13:13:06 -0700
committerRoman Birg <roman@cyngn.com>2016-01-18 10:30:03 -0800
commit6fb2c183a3a769382f63109fa5a15937692253d1 (patch)
treee6280b504057eb86cd9554ccdfd52c3257a3ee17 /packages/SystemUI/src/com/android/systemui/qs
parentf15ce7a7a91008b18556f37e311b44c5a0da0448 (diff)
downloadframeworks_base-6fb2c183a3a769382f63109fa5a15937692253d1.zip
frameworks_base-6fb2c183a3a769382f63109fa5a15937692253d1.tar.gz
frameworks_base-6fb2c183a3a769382f63109fa5a15937692253d1.tar.bz2
SystemUI: add a disabled state for Quick Tiles
Some tiles may want to be visible, but not allow any user interaction due to security reasons. Add a visual disabled state for tiles which are not enabled. With this patch, the Profiles tile and the Lockscreen toggle tile disable themselves on a secure lock screen. Ref: CYNGNOS-1597 Change-Id: I65ec7837661483d238d8dc3fa18419f76c8029dd Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/qs')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSPanel.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTile.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTileView.java21
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/EditTile.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/ProfilesTile.java20
7 files changed, 78 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java
index df45120..c7b1f1d 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java
@@ -353,6 +353,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
}
final int visibility = state.visible ? VISIBLE : GONE;
setTileVisibility(r.tileView, visibility);
+ setTileEnabled(r.tileView, state.enabled);
r.tileView.onStateChanged(state);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 1e6867d..7f3d452 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -281,6 +281,15 @@ public class QSPanel extends ViewGroup {
v.setVisibility(visibility);
}
+ protected void setTileEnabled(View v, boolean enabled) {
+ mHandler.obtainMessage(H.SET_TILE_ENABLED, enabled ? 1 : 0, 0, v).sendToTarget();
+ }
+
+ private void handleSetTileEnabled(View v, boolean enabled) {
+ if (enabled == v.isEnabled()) return;
+ v.setEnabled(enabled);
+ }
+
public void setTiles(Collection<QSTile<?>> tiles) {
for (TileRecord record : mRecords) {
removeView(record.tileView);
@@ -606,12 +615,15 @@ public class QSPanel extends ViewGroup {
private class H extends Handler {
private static final int SHOW_DETAIL = 1;
private static final int SET_TILE_VISIBILITY = 2;
+ private static final int SET_TILE_ENABLED = 3;
@Override
public void handleMessage(Message msg) {
if (msg.what == SHOW_DETAIL) {
handleShowDetail((Record)msg.obj, msg.arg1 != 0);
} else if (msg.what == SET_TILE_VISIBILITY) {
handleSetTileVisibility((View)msg.obj, msg.arg1);
+ } else if (msg.what == SET_TILE_ENABLED) {
+ handleSetTileEnabled((View)msg.obj, msg.arg1 == 1);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 7d7e516..6d0c857 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -497,6 +497,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
public static class State {
public boolean visible;
+ public boolean enabled = true;
public Icon icon;
public String label;
public String contentDescription;
@@ -507,6 +508,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
if (other == null) throw new IllegalArgumentException();
if (!other.getClass().equals(getClass())) throw new IllegalArgumentException();
final boolean changed = other.visible != visible
+ || !Objects.equals(other.enabled, enabled)
|| !Objects.equals(other.icon, icon)
|| !Objects.equals(other.label, label)
|| !Objects.equals(other.contentDescription, contentDescription)
@@ -514,6 +516,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
|| !Objects.equals(other.dualLabelContentDescription,
dualLabelContentDescription);
other.visible = visible;
+ other.enabled = enabled;
other.icon = icon;
other.label = label;
other.contentDescription = contentDescription;
@@ -530,6 +533,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
protected StringBuilder toStringBuilder() {
final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('[');
sb.append("visible=").append(visible);
+ sb.append(",enabled=").append(enabled);
sb.append(",icon=").append(icon);
sb.append(",label=").append(label);
sb.append(",contentDescription=").append(contentDescription);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index d1a1ad5..a95fac3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -22,6 +22,8 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
@@ -328,9 +330,20 @@ public class QSTileView extends ViewGroup {
mDualLabel.setText(state.label);
mDualLabel.setContentDescription(state.dualLabelContentDescription);
mTopBackgroundView.setContentDescription(state.contentDescription);
+ if (!Objects.equals(state.enabled, mDualLabel.isEnabled())) {
+ mTopBackgroundView.setEnabled(state.enabled);
+ mDualLabel.setEnabled(state.enabled);
+ mDualLabel.setTextColor(mContext.getResources().getColor(state.enabled ?
+ R.color.qs_tile_text : R.color.qs_tile_text_disabled));
+ }
} else {
mLabel.setText(state.label);
setContentDescription(state.contentDescription);
+ if (!Objects.equals(state.enabled, mLabel.isEnabled())) {
+ mLabel.setEnabled(state.enabled);
+ mLabel.setTextColor(mContext.getResources().getColor(state.enabled ?
+ R.color.qs_tile_text : R.color.qs_tile_text_disabled));
+ }
}
}
@@ -349,6 +362,14 @@ public class QSTileView extends ViewGroup {
}
}
}
+ if (!Objects.equals(state.enabled, iv.isEnabled())) {
+ iv.setEnabled(state.enabled);
+ if (state.enabled) {
+ iv.setColorFilter(null);
+ } else {
+ iv.setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
+ }
+ }
}
public void onStateChanged(QSTile.State state) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/EditTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/EditTile.java
index cbc906f..7c9b762 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/EditTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/EditTile.java
@@ -18,9 +18,10 @@ package com.android.systemui.qs.tiles;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
+import com.android.systemui.statusbar.policy.KeyguardMonitor;
import org.cyanogenmod.internal.logging.CMMetricsLogger;
-public class EditTile extends QSTile<QSTile.BooleanState> {
+public class EditTile extends QSTile<QSTile.BooleanState> implements KeyguardMonitor.Callback {
private boolean mListening;
@@ -53,7 +54,10 @@ public class EditTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
- state.visible = !getHost().getKeyguardMonitor().isShowing();
+ final boolean showing = getHost().getKeyguardMonitor().isShowing();
+ final boolean secure = getHost().getKeyguardMonitor().isSecure();
+ state.visible = !showing || !secure;
+ state.enabled = true;
state.label = mContext.getString(R.string.quick_settings_edit_label);
if (arg instanceof Boolean) {
@@ -79,6 +83,16 @@ public class EditTile extends QSTile<QSTile.BooleanState> {
public void setListening(boolean listening) {
if (mListening == listening) return;
mListening = listening;
+ if (mListening) {
+ mHost.getKeyguardMonitor().addCallback(this);
+ } else {
+ mHost.getKeyguardMonitor().removeCallback(this);
+ }
+ refreshState();
+ }
+
+ @Override
+ public void onKeyguardChanged() {
refreshState();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java
index 6f1a921..37cfa6e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LockscreenToggleTile.java
@@ -75,6 +75,7 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
if (listening) {
mSettingsObserver.observe();
mKeyguard.addCallback(this);
+ refreshState();
} else {
mSettingsObserver.unobserve();
mKeyguard.removeCallback(this);
@@ -89,6 +90,7 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
@Override
protected void handleClick() {
setPersistedState(!mPersistedState);
+ refreshState();
}
@Override
@@ -104,7 +106,8 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
|| mKeyguardViewMediator.getKeyguardEnabledInternal();
state.value = lockscreenEnabled;
- state.visible = !mKeyguard.isShowing() || !mKeyguard.isSecure();
+ state.visible = mKeyguardViewMediator.isKeyguardBound();
+ state.enabled = !mKeyguard.isShowing() || !mKeyguard.isSecure();
state.label = mContext.getString(lockscreenEnforced
? R.string.quick_settings_lockscreen_label_enforced
: R.string.quick_settings_lockscreen_label);
@@ -146,4 +149,4 @@ public class LockscreenToggleTile extends QSTile<QSTile.BooleanState>
enabled ? 1 : 0, UserHandle.USER_CURRENT);
mPersistedState = enabled;
}
-} \ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ProfilesTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ProfilesTile.java
index 9053643..6f65f6c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ProfilesTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ProfilesTile.java
@@ -47,7 +47,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-public class ProfilesTile extends QSTile<QSTile.State> {
+public class ProfilesTile extends QSTile<QSTile.State> implements KeyguardMonitor.Callback {
private static final Intent PROFILES_SETTINGS =
new Intent("android.settings.PROFILES_SETTINGS");
@@ -57,11 +57,19 @@ public class ProfilesTile extends QSTile<QSTile.State> {
private ProfileManager mProfileManager;
private QSDetailItemsList mDetails;
private ProfileAdapter mAdapter;
+ private KeyguardMonitor mKeyguardMonitor;
public ProfilesTile(Host host) {
super(host);
mProfileManager = ProfileManager.getInstance(mContext);
mObserver = new ProfilesObserver(mHandler);
+ mKeyguardMonitor = host.getKeyguardMonitor();
+ mKeyguardMonitor.addCallback(this);
+ }
+
+ @Override
+ protected void handleDestroy() {
+ mKeyguardMonitor.removeCallback(this);
}
@Override
@@ -82,6 +90,10 @@ public class ProfilesTile extends QSTile<QSTile.State> {
@Override
protected void handleUpdateState(State state, Object arg) {
state.visible = true;
+
+
+
+ state.enabled = !mKeyguardMonitor.isShowing() || !mKeyguardMonitor.isSecure();
if (profilesEnabled()) {
state.icon = ResourceIcon.get(R.drawable.ic_qs_profiles_on);
state.label = mProfileManager.getActiveProfile().getName();
@@ -125,6 +137,7 @@ public class ProfilesTile extends QSTile<QSTile.State> {
filter.addAction(ProfileManager.INTENT_ACTION_PROFILE_SELECTED);
filter.addAction(ProfileManager.INTENT_ACTION_PROFILE_UPDATED);
mContext.registerReceiver(mReceiver, filter);
+ refreshState();
} else {
mObserver.endObserving();
mContext.unregisterReceiver(mReceiver);
@@ -136,6 +149,11 @@ public class ProfilesTile extends QSTile<QSTile.State> {
return new ProfileDetailAdapter();
}
+ @Override
+ public void onKeyguardChanged() {
+ refreshState();
+ }
+
private class ProfileAdapter extends ArrayAdapter<Profile> {
public ProfileAdapter(Context context, List<Profile> profiles) {
super(context, android.R.layout.simple_list_item_single_choice, profiles);