[QS] Add header tooltip for long press
Added some hooks in animator to pass along expanded/animating/collapsed
state in a more clear manner. Added tooltip view with the teaser text to
animate in at the top of the view (and fade out either when we start
animating or automatically after 5 seconds).
Added prefs for tracking how often tooltip is shown/hiding it based on
that number.
Updated dimensions for correct spacing (based on redlines).
Test: Visually
Bug: 72528203
Change-Id: I70e4654ed95057fac6d8dbb890d575c2a5d9f215
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index cdcc5e6..476cb40 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -18,6 +18,7 @@
import static com.android.systemui.qs.tileimpl.QSTileImpl.getColorForState;
+import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
@@ -57,6 +58,7 @@
public class QSPanel extends LinearLayout implements Tunable, Callback, BrightnessMirrorListener {
public static final String QS_SHOW_BRIGHTNESS = "qs_show_brightness";
+ public static final String QS_SHOW_LONG_PRESS_TOOLTIP = "qs_show_long_press";
protected final Context mContext;
protected final ArrayList<TileRecord> mRecords = new ArrayList<TileRecord>();
@@ -72,6 +74,7 @@
private BrightnessController mBrightnessController;
protected QSTileHost mHost;
+ protected QSTooltipView mTooltipView;
protected QSSecurityFooter mFooter;
private boolean mGridContentVisible = true;
@@ -93,6 +96,11 @@
setOrientation(VERTICAL);
+ mTooltipView = (QSTooltipView) LayoutInflater.from(mContext)
+ .inflate(R.layout.quick_settings_header, this, false);
+
+ addView(mTooltipView);
+
mBrightnessView = LayoutInflater.from(mContext).inflate(
R.layout.quick_settings_brightness_dialog, this, false);
addView(mBrightnessView);
@@ -142,7 +150,10 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- Dependency.get(TunerService.class).addTunable(this, QS_SHOW_BRIGHTNESS);
+ final TunerService tunerService = Dependency.get(TunerService.class);
+ tunerService.addTunable(this, QS_SHOW_BRIGHTNESS);
+ tunerService.addTunable(this, QS_SHOW_LONG_PRESS_TOOLTIP);
+
if (mHost != null) {
setTiles(mHost.getTiles());
}
@@ -174,11 +185,16 @@
@Override
public void onTuningChanged(String key, String newValue) {
if (QS_SHOW_BRIGHTNESS.equals(key)) {
- mBrightnessView.setVisibility(newValue == null || Integer.parseInt(newValue) != 0
- ? VISIBLE : GONE);
+ updateViewVisibilityForTuningValue(mBrightnessView, newValue);
+ } else if (QS_SHOW_LONG_PRESS_TOOLTIP.equals(key)) {
+ updateViewVisibilityForTuningValue(mTooltipView, newValue);
}
}
+ private void updateViewVisibilityForTuningValue(View view, @Nullable String newValue) {
+ view.setVisibility(newValue == null || Integer.parseInt(newValue) != 0 ? VISIBLE : GONE);
+ }
+
public void openDetails(String subPanel) {
QSTile tile = getTile(subPanel);
showDetailAdapter(true, tile.getDetailAdapter(), new int[]{getWidth() / 2, 0});
@@ -213,6 +229,10 @@
return mBrightnessView;
}
+ View getHeaderView() {
+ return mTooltipView;
+ }
+
public void setCallback(QSDetail.Callback callback) {
mCallback = callback;
}
@@ -269,6 +289,21 @@
if (mCustomizePanel != null && mCustomizePanel.isShown()) {
mCustomizePanel.hide(mCustomizePanel.getWidth() / 2, mCustomizePanel.getHeight() / 2);
}
+
+ // Instantly hide the header here since we don't want it to still be animating.
+ mTooltipView.setVisibility(View.INVISIBLE);
+ }
+
+ /**
+ * Called when the panel is fully animated out/expanded. This is different from the state
+ * tracked by {@link #mExpanded}, which only checks if the panel is even partially pulled out.
+ */
+ public void onExpanded() {
+ mTooltipView.fadeIn();
+ }
+
+ public void onAnimating() {
+ mTooltipView.fadeOut();
}
public void setExpanded(boolean expanded) {