Fixed animation on QSCustomizer ripple
Included offset given by container. Refactored setting animation center
location for hiding properly when configuration changes.
Fixes: 113346905
Test: Visual (high speed video)
Change-Id: I6c1ade2c1c52945c40322591f81b4b88b950582a
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
index 7cb22a3..03febda 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
@@ -101,12 +101,7 @@
if (savedInstanceState != null) {
setExpanded(savedInstanceState.getBoolean(EXTRA_EXPANDED));
setListening(savedInstanceState.getBoolean(EXTRA_LISTENING));
- int[] loc = new int[2];
- View edit = view.findViewById(android.R.id.edit);
- edit.getLocationInWindow(loc);
- int x = loc[0] + edit.getWidth() / 2;
- int y = loc[1] + edit.getHeight() / 2;
- mQSCustomizer.setEditLocation(x, y);
+ setEditLocation(view);
mQSCustomizer.restoreInstanceState(savedInstanceState);
}
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
@@ -161,15 +156,24 @@
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ setEditLocation(getView());
if (newConfig.getLayoutDirection() != mLayoutDirection) {
mLayoutDirection = newConfig.getLayoutDirection();
-
if (mQSAnimator != null) {
mQSAnimator.onRtlChanged();
}
}
}
+ private void setEditLocation(View view) {
+ Log.w(TAG, "I'm changing the location of the button!!!");
+ View edit = view.findViewById(android.R.id.edit);
+ int[] loc = edit.getLocationOnScreen();
+ int x = loc[0] + edit.getWidth() / 2;
+ int y = loc[1] + edit.getHeight() / 2;
+ mQSCustomizer.setEditLocation(x, y);
+ }
+
@Override
public void setContainer(ViewGroup container) {
if (container instanceof NotificationsQuickSettingsContainer) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 3fc258b..8697015 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -29,6 +29,7 @@
import android.os.Message;
import android.service.quicksettings.Tile;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
@@ -60,6 +61,8 @@
public static final String QS_SHOW_BRIGHTNESS = "qs_show_brightness";
public static final String QS_SHOW_HEADER = "qs_show_header";
+ private static final String TAG = "QSPanel";
+
protected final Context mContext;
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
protected final View mBrightnessView;
@@ -313,7 +316,7 @@
public void onCollapse() {
if (mCustomizePanel != null && mCustomizePanel.isShown()) {
- mCustomizePanel.hide(mCustomizePanel.getWidth() / 2, mCustomizePanel.getHeight() / 2);
+ mCustomizePanel.hide();
}
}
@@ -480,8 +483,7 @@
public void run() {
if (mCustomizePanel != null) {
if (!mCustomizePanel.isCustomizing()) {
- int[] loc = new int[2];
- v.getLocationInWindow(loc);
+ int[] loc = v.getLocationOnScreen();
int x = loc[0] + v.getWidth() / 2;
int y = loc[1] + v.getHeight() / 2;
mCustomizePanel.show(x, y);
@@ -495,7 +497,7 @@
public void closeDetail() {
if (mCustomizePanel != null && mCustomizePanel.isShown()) {
// Treat this as a detail panel for now, to make things easy.
- mCustomizePanel.hide(mCustomizePanel.getWidth() / 2, mCustomizePanel.getHeight() / 2);
+ mCustomizePanel.hide();
return;
}
showDetail(false, mDetailRecord);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
index 2ea15bd..3f7eeb8 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
@@ -26,6 +26,7 @@
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
@@ -63,6 +64,7 @@
private static final int MENU_RESET = Menu.FIRST;
private static final String EXTRA_QS_CUSTOMIZING = "qs_customizing";
+ private static final String TAG = "QSCustomizer";
private final QSDetailClipper mClipper;
private final LightBarController mLightBarController;
@@ -94,7 +96,7 @@
mToolbar.setNavigationOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- hide((int) v.getX() + v.getWidth() / 2, (int) v.getY() + v.getHeight() / 2);
+ hide();
}
});
mToolbar.setOnMenuItemClickListener(this);
@@ -154,16 +156,20 @@
mQs = qs;
}
+ /** Animate and show QSCustomizer panel.
+ * @param x,y Location on screen of {@code edit} button to determine center of animation.
+ */
public void show(int x, int y) {
if (!isShown) {
- mX = x;
- mY = y;
+ int containerLocation[] = findViewById(R.id.customize_container).getLocationOnScreen();
+ mX = x - containerLocation[0];
+ mY = y - containerLocation[1];
MetricsLogger.visible(getContext(), MetricsProto.MetricsEvent.QS_EDIT);
isShown = true;
mOpening = true;
setTileSpecs();
setVisibility(View.VISIBLE);
- mClipper.animateCircularClip(x, y, true, mExpandAnimationListener);
+ mClipper.animateCircularClip(mX, mY, true, mExpandAnimationListener);
queryTiles();
mNotifQsContainer.setCustomizerAnimating(true);
mNotifQsContainer.setCustomizerShowing(true);
@@ -192,7 +198,7 @@
mTileQueryHelper.queryTiles(mHost);
}
- public void hide(int x, int y) {
+ public void hide() {
if (isShown) {
MetricsLogger.hidden(getContext(), MetricsProto.MetricsEvent.QS_EDIT);
isShown = false;
@@ -278,16 +284,18 @@
});
}
}
-
+ /** @param x,y Location on screen of animation center.
+ */
public void setEditLocation(int x, int y) {
- mX = x;
- mY = y;
+ int containerLocation[] = findViewById(R.id.customize_container).getLocationOnScreen();
+ mX = x - containerLocation[0];
+ mY = y - containerLocation[1];
}
private final Callback mKeyguardCallback = () -> {
if (!isAttachedToWindow()) return;
if (Dependency.get(KeyguardMonitor.class).isShowing() && !mOpening) {
- hide(0, 0);
+ hide();
}
};