diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index d70f4e3127474..d72643ecca7d8 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -911,4 +911,12 @@
No thanks
+
+ Hide %1$s?
+
+
+ It will reappear the next time you turn it on in settings.
+
+
+ Hide
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 1ddd3520c8366..91b15697f94dc 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -296,7 +296,14 @@ public class QSPanel extends ViewGroup {
r.tile.secondaryClick();
}
};
- r.tileView.init(click, clickSecondary);
+ final View.OnLongClickListener longClick = new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ r.tile.longClick();
+ return true;
+ }
+ };
+ r.tileView.init(click, clickSecondary, longClick);
r.tile.setListening(mListening);
callback.onStateChanged(r.tile.getState());
r.tile.refreshState();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 2a66484fb556f..1790a4ec73753 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -112,6 +112,10 @@ public abstract class QSTile implements Listenable {
mHandler.sendEmptyMessage(H.SECONDARY_CLICK);
}
+ public void longClick() {
+ mHandler.sendEmptyMessage(H.LONG_CLICK);
+ }
+
public void showDetail(boolean show) {
mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0).sendToTarget();
}
@@ -155,6 +159,10 @@ public abstract class QSTile implements Listenable {
// optional
}
+ protected void handleLongClick() {
+ // optional
+ }
+
protected void handleRefreshState(Object arg) {
handleUpdateState(mTmpState, arg);
final boolean changed = mTmpState.copyTo(mState);
@@ -216,12 +224,13 @@ public abstract class QSTile implements Listenable {
private static final int SET_CALLBACK = 1;
private static final int CLICK = 2;
private static final int SECONDARY_CLICK = 3;
- private static final int REFRESH_STATE = 4;
- private static final int SHOW_DETAIL = 5;
- private static final int USER_SWITCH = 6;
- private static final int TOGGLE_STATE_CHANGED = 7;
- private static final int SCAN_STATE_CHANGED = 8;
- private static final int DESTROY = 9;
+ private static final int LONG_CLICK = 4;
+ private static final int REFRESH_STATE = 5;
+ private static final int SHOW_DETAIL = 6;
+ private static final int USER_SWITCH = 7;
+ private static final int TOGGLE_STATE_CHANGED = 8;
+ private static final int SCAN_STATE_CHANGED = 9;
+ private static final int DESTROY = 10;
private H(Looper looper) {
super(looper);
@@ -241,6 +250,9 @@ public abstract class QSTile implements Listenable {
} else if (msg.what == SECONDARY_CLICK) {
name = "handleSecondaryClick";
handleSecondaryClick();
+ } else if (msg.what == LONG_CLICK) {
+ name = "handleLongClick";
+ handleLongClick();
} else if (msg.what == REFRESH_STATE) {
name = "handleRefreshState";
handleRefreshState(msg.obj);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index 3d0f47cda6388..bb353d5f91e9a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -63,6 +63,7 @@ public class QSTileView extends ViewGroup {
private boolean mDual;
private OnClickListener mClickPrimary;
private OnClickListener mClickSecondary;
+ private OnLongClickListener mLongClick;
private Drawable mTileBackground;
private RippleDrawable mRipple;
@@ -190,6 +191,7 @@ public class QSTileView extends ViewGroup {
mTopBackgroundView.setOnClickListener(null);
mTopBackgroundView.setClickable(false);
setOnClickListener(mClickPrimary);
+ setOnLongClickListener(mLongClick);
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
setBackground(mTileBackground);
}
@@ -206,9 +208,11 @@ public class QSTileView extends ViewGroup {
}
}
- public void init(OnClickListener clickPrimary, OnClickListener clickSecondary) {
+ public void init(OnClickListener clickPrimary, OnClickListener clickSecondary,
+ OnLongClickListener longClick) {
mClickPrimary = clickPrimary;
mClickSecondary = clickSecondary;
+ mLongClick = longClick;
}
protected View createIcon() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java b/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
index a1092a363413f..e60aa530dee40 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
@@ -18,10 +18,13 @@ package com.android.systemui.qs;
import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.Listenable;
public class UsageTracker implements Listenable {
@@ -65,6 +68,25 @@ public class UsageTracker implements Listenable {
getSharedPrefs().edit().remove(mPrefKey).commit();
}
+ public void showResetConfirmation(String title, final Runnable onConfirmed) {
+ final SystemUIDialog d = new SystemUIDialog(mContext);
+ d.setTitle(title);
+ d.setMessage(mContext.getString(R.string.quick_settings_reset_confirmation_message));
+ d.setNegativeButton(android.R.string.cancel, null);
+ d.setPositiveButton(R.string.quick_settings_reset_confirmation_button,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ reset();
+ if (onConfirmed != null) {
+ onConfirmed.run();
+ }
+ }
+ });
+ d.setCanceledOnTouchOutside(true);
+ d.show();
+ }
+
private SharedPreferences getSharedPrefs() {
return mContext.getSharedPreferences(mContext.getPackageName(), 0);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
index a19c29ff0f325..b565afa6845e9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java
@@ -87,6 +87,19 @@ public class ColorInversionTile extends QSTile {
mDisable.setAllowAnimation(true);
}
+ @Override
+ protected void handleLongClick() {
+ if (mState.value) return; // don't allow usage reset if inversion is active
+ final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
+ mState.label);
+ mUsageTracker.showResetConfirmation(title, new Runnable() {
+ @Override
+ public void run() {
+ refreshState();
+ }
+ });
+ }
+
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
final int value = arg instanceof Integer ? (Integer) arg : mSetting.getValue();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
index 64dab858031d0..374ceab347901 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -64,6 +64,19 @@ public class HotspotTile extends QSTile {
mController.setHotspotEnabled(!isEnabled);
}
+ @Override
+ protected void handleLongClick() {
+ if (mState.value) return; // don't allow usage reset if hotspot is active
+ final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
+ mState.label);
+ mUsageTracker.showResetConfirmation(title, new Runnable() {
+ @Override
+ public void run() {
+ refreshState();
+ }
+ });
+ }
+
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed()
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
index 6fb9cd8972770..27365302daeab 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
@@ -39,6 +39,8 @@ public class IntentTile extends QSTile {
private PendingIntent mOnClick;
private String mOnClickUri;
+ private PendingIntent mOnLongClick;
+ private String mOnLongClickUri;
private int mCurrentUserId;
private IntentTile(Host host, String action) {
@@ -80,15 +82,24 @@ public class IntentTile extends QSTile {
@Override
protected void handleClick() {
+ sendIntent("click", mOnClick, mOnClickUri);
+ }
+
+ @Override
+ protected void handleLongClick() {
+ sendIntent("long-click", mOnLongClick, mOnLongClickUri);
+ }
+
+ private void sendIntent(String type, PendingIntent pi, String uri) {
try {
- if (mOnClick != null) {
- mOnClick.send();
- } else if (mOnClickUri != null) {
- final Intent intent = Intent.parseUri(mOnClickUri, Intent.URI_INTENT_SCHEME);
+ if (pi != null) {
+ pi.send();
+ } else if (uri != null) {
+ final Intent intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
mContext.sendBroadcastAsUser(intent, new UserHandle(mCurrentUserId));
}
} catch (Throwable t) {
- Log.w(TAG, "Error sending click intent", t);
+ Log.w(TAG, "Error sending " + type + " intent", t);
}
}
@@ -120,6 +131,8 @@ public class IntentTile extends QSTile {
}
mOnClick = intent.getParcelableExtra("onClick");
mOnClickUri = intent.getStringExtra("onClickUri");
+ mOnLongClick = intent.getParcelableExtra("onLongClick");
+ mOnLongClickUri = intent.getStringExtra("onLongClickUri");
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {