diff options
4 files changed, 44 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index afee8468aa07..528fb3da437e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -959,7 +959,7 @@ public abstract class BaseStatusBar extends SystemUI implements }, false /* afterKeyguardGone */); } - private void bindGuts(ExpandableNotificationRow row) { + private void bindGuts(final ExpandableNotificationRow row) { row.inflateGuts(); final StatusBarNotification sbn = row.getStatusBarNotification(); PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier()); @@ -1003,7 +1003,17 @@ public abstract class BaseStatusBar extends SystemUI implements @Override public void onClick(View v) { guts.saveImportance(sbn); - dismissPopups(); + + int[] rowLocation = new int[2]; + int[] doneLocation = new int[2]; + row.getLocationOnScreen(rowLocation); + v.getLocationOnScreen(doneLocation); + + final int centerX = v.getWidth() / 2; + final int centerY = v.getHeight() / 2; + final int x = doneLocation[0] - rowLocation[0] + centerX; + final int y = doneLocation[1] - rowLocation[1] + centerY; + dismissPopups(x, y); } }); @@ -1049,7 +1059,7 @@ public abstract class BaseStatusBar extends SystemUI implements // Post to ensure the the guts are properly layed out. guts.post(new Runnable() { public void run() { - dismissPopups(); + dismissPopups(-1 /* x */, -1 /* y */, false /* resetGear */); guts.setVisibility(View.VISIBLE); final double horz = Math.max(guts.getWidth() - x, x); final double vert = Math.max(guts.getHeight() - y, y); @@ -1083,10 +1093,14 @@ public abstract class BaseStatusBar extends SystemUI implements } public void dismissPopups() { - dismissPopups(-1, -1); + dismissPopups(-1 /* x */, -1 /* y */, true /* resetGear */); } private void dismissPopups(int x, int y) { + dismissPopups(x, y, true /* resetGear */); + } + + public void dismissPopups(int x, int y, boolean resetGear) { if (mNotificationGutsExposed != null) { final NotificationGuts v = mNotificationGutsExposed; mNotificationGutsExposed = null; @@ -1114,8 +1128,7 @@ public abstract class BaseStatusBar extends SystemUI implements v.setExposed(false); mStackScroller.onHeightChanged(null, true /* needsAnimation */); } - - if (mNotificationGearDisplayed != null) { + if (resetGear && mNotificationGearDisplayed != null) { mNotificationGearDisplayed.resetTranslation(); mNotificationGearDisplayed = null; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index da125d8f77a6..e109b0901532 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -656,7 +656,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { mGuts = (NotificationGuts) inflated; mGuts.setClipTopAmount(getClipTopAmount()); mGuts.setActualHeight(getActualHeight()); - mTranslateableViews.add(mGuts); mGutsStub = null; } }); @@ -1175,6 +1174,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { @Override public void setActualHeight(int height, boolean notifyListeners) { super.setActualHeight(height, notifyListeners); + if (mGuts != null && mGuts.areGutsExposed()) { + mGuts.setActualHeight(height); + return; + } int contentHeight = Math.max(getMinHeight(), height); mPrivateLayout.setContentHeight(contentHeight); mPublicLayout.setContentHeight(contentHeight); @@ -1184,7 +1187,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { if (mGuts != null) { mGuts.setActualHeight(height); } - invalidate(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java index 4491ebde742b..476e146d1859 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java @@ -33,7 +33,7 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC /** * Called when the gear behind a notification is touched. */ - public void onGearTouched(ExpandableNotificationRow row); + public void onGearTouched(ExpandableNotificationRow row, int x, int y); } private ExpandableNotificationRow mParent; @@ -45,6 +45,8 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC private boolean mSettingsFadedIn = false; private boolean mAnimating = false; private boolean mOnLeft = true; + private int[] mGearLocation = new int[2]; + private int[] mParentLocation = new int[2]; public NotificationSettingsIconRow(Context context) { this(context, null); @@ -74,6 +76,12 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC resetState(); } + public void resetState() { + setGearAlpha(0f); + mAnimating = false; + setIconLocation(true /* on left */); + } + public void setGearListener(SettingsIconRowListener listener) { mListener = listener; } @@ -86,12 +94,6 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC return mParent; } - public void resetState() { - setGearAlpha(0f); - mAnimating = false; - setIconLocation(true /* on left */); - } - private void setGearAlpha(float alpha) { if (alpha == 0) { mSettingsFadedIn = false; // Can fade in again once it's gone. @@ -200,7 +202,16 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC public void onClick(View v) { if (v.getId() == R.id.gear_icon) { if (mListener != null) { - mListener.onGearTouched(mParent); + mGearIcon.getLocationOnScreen(mGearLocation); + mParent.getLocationOnScreen(mParentLocation); + + final int centerX = (int) (mHorizSpaceForGear / 2); + // Top / bottom padding are not equal, need to subtract them to get center of gear. + final int centerY = (int) (mGearIcon.getHeight() - mGearIcon.getPaddingTop() + - mGearIcon.getPaddingBottom()) / 2 + mGearIcon.getPaddingTop(); + final int x = mGearLocation[0] - mParentLocation[0] + centerX; + final int y = mGearLocation[1] - mParentLocation[1] + centerY; + mListener.onGearTouched(mParent, x, y); } } else { // Do nothing when the background is touched. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index e1f9f3c6fc7e..79f5c7c1b750 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -361,9 +361,9 @@ public class NotificationStackScrollLayout extends ViewGroup } @Override - public void onGearTouched(ExpandableNotificationRow row) { + public void onGearTouched(ExpandableNotificationRow row, int x, int y) { if (mLongPressListener != null) { - mLongPressListener.onLongPress(row, 0, 0); + mLongPressListener.onLongPress(row, x, y); } } |