summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2016-04-12 19:00:17 -0700
committer Mady Mellor <madym@google.com> 2016-04-14 15:46:22 -0700
commitcdd5718eacd96ed1a755c877798952a5201b7600 (patch)
treec14b58285433e050c1ebd2583a7ade5726903da0
parent65136ac6a4f6fb2423a0768b451782dcd0e960d5 (diff)
Fix the gear so that it is always centered based on the min noti height
This alters how the gear is positioned so that it is centered based on what the minimum height of the notification or the height of a collapsed group. Bug: 27316874 Change-Id: I726f51ab8b18b485d1b2ea22ca7bb4dd71ee3d85
-rw-r--r--packages/SystemUI/res/layout/notification_settings_icon_row.xml9
-rw-r--r--packages/SystemUI/res/values/dimens.xml8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java41
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java3
5 files changed, 39 insertions, 25 deletions
diff --git a/packages/SystemUI/res/layout/notification_settings_icon_row.xml b/packages/SystemUI/res/layout/notification_settings_icon_row.xml
index f47083af4902..da3461b906fa 100644
--- a/packages/SystemUI/res/layout/notification_settings_icon_row.xml
+++ b/packages/SystemUI/res/layout/notification_settings_icon_row.xml
@@ -24,12 +24,9 @@
<com.android.systemui.statusbar.AlphaOptimizedImageView
android:id="@+id/gear_icon"
- android:layout_width="@dimen/notification_gear_width"
- android:layout_height="@dimen/notification_gear_height"
- android:paddingTop="@dimen/notification_gear_top_padding"
- android:paddingStart="@dimen/notification_gear_padding"
- android:paddingEnd="@dimen/notification_gear_padding"
- android:paddingBottom="@dimen/notification_gear_padding"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/notification_gear_padding"
android:src="@drawable/ic_settings"
android:tint="@color/notification_gear_color"
android:alpha="0"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index cf2e3384de08..b567d393d661 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -81,13 +81,7 @@
<!-- Width of the space containing the gear icon behind a notification -->
<dimen name="notification_gear_width">64dp</dimen>
- <!-- Height of the space containing the gear icon behind a notification -->
- <dimen name="notification_gear_height">74dp</dimen>
-
- <!-- The space above the gear icon displayed behind a notification -->
- <dimen name="notification_gear_top_padding">30dp</dimen>
-
- <!-- The space on either side and below the gear icon displayed behind a notification -->
+ <!-- The space around the gear icon displayed behind a notification -->
<dimen name="notification_gear_padding">20dp</dimen>
<!-- size at which Notification icons will be drawn in the status bar -->
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index e25f9decd256..338fe41183ef 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -260,6 +260,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
int headsUpheight = headsUpCustom && beforeN ? mMaxHeadsUpHeightLegacy
: mMaxHeadsUpHeight;
layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight);
+ if (mSettingsIconRow != null) {
+ mSettingsIconRow.updateVerticalLocation();
+ }
}
public StatusBarNotification getStatusBarNotification() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
index 9ed50224ed2d..060d8f473943 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
@@ -55,8 +55,11 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
private boolean mOnLeft = true;
private boolean mDismissing = false;
private boolean mSnapping = false;
+ private boolean mIconPlaced = false;
+
private int[] mGearLocation = new int[2];
private int[] mParentLocation = new int[2];
+ private int mVertSpaceForGear;
public NotificationSettingsIconRow(Context context) {
this(context, null);
@@ -83,16 +86,18 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
setOnClickListener(this);
mHorizSpaceForGear =
getResources().getDimensionPixelOffset(R.dimen.notification_gear_width);
+ mVertSpaceForGear = getResources().getDimensionPixelOffset(R.dimen.notification_min_height);
resetState();
}
public void resetState() {
setGearAlpha(0f);
+ mIconPlaced = false;
mSettingsFadedIn = false;
mAnimating = false;
mSnapping = false;
mDismissing = false;
- setIconLocation(true /* on left */, true /* force */);
+ setIconLocation(true /* on left */);
if (mListener != null) {
mListener.onSettingsIconRowReset(mParent);
}
@@ -104,7 +109,7 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
public void setNotificationRowParent(ExpandableNotificationRow parent) {
mParent = parent;
- setIconLocation(mOnLeft, true /* force */);
+ setIconLocation(mOnLeft);
}
public void setAppName(String appName) {
@@ -184,7 +189,7 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
if (isIconLocationChange(transX)) {
setGearAlpha(0f);
}
- setIconLocation(transX > 0 /* fromLeft */, false /* force */);
+ setIconLocation(transX > 0 /* fromLeft */);
mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
@@ -221,22 +226,39 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
mFadeAnimator.start();
}
+ public void updateVerticalLocation() {
+ if (mParent == null) {
+ return;
+ }
+ int parentHeight = mParent.getCollapsedHeight();
+ if (parentHeight < mVertSpaceForGear) {
+ mGearIcon.setTranslationY((parentHeight / 2) - (mGearIcon.getHeight() / 2));
+ } else {
+ mGearIcon.setTranslationY((mVertSpaceForGear - mGearIcon.getHeight()) / 2);
+ }
+ }
+
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
- setIconLocation(mOnLeft, true /* force */);
+ setIconLocation(mOnLeft);
}
- public void setIconLocation(boolean onLeft, boolean force) {
- if ((!force && onLeft == mOnLeft) || mSnapping || mParent == null) {
+ public void setIconLocation(boolean onLeft) {
+ updateVerticalLocation();
+ if ((mIconPlaced && onLeft == mOnLeft) || mSnapping || mParent == null
+ || mGearIcon.getWidth() == 0) {
// Do nothing
return;
}
final boolean isRtl = mParent.isLayoutRtl();
+
// TODO No need to cast to float here once b/28050538 is fixed.
final float left = (float) (isRtl ? -(mParent.getWidth() - mHorizSpaceForGear) : 0);
final float right = (float) (isRtl ? 0 : (mParent.getWidth() - mHorizSpaceForGear));
- setTranslationX(onLeft ? left : right);
+ final float centerX = ((mHorizSpaceForGear - mGearIcon.getWidth()) / 2);
+ setTranslationX(onLeft ? left + centerX : right + centerX);
mOnLeft = onLeft;
+ mIconPlaced = true;
}
public boolean isIconLocationChange(float translation) {
@@ -264,9 +286,8 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
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 centerY =
+ (int) (mGearIcon.getTranslationY() * 2 + mGearIcon.getHeight())/ 2;
final int x = mGearLocation[0] - mParentLocation[0] + centerX;
final int y = mGearLocation[1] - mParentLocation[1] + centerY;
mListener.onGearTouched(mParent, x, y);
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 8b52bf65a673..de623858e319 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -3519,8 +3519,7 @@ public class NotificationStackScrollLayout extends ViewGroup
} else {
// Check scheduled, reset alpha and update location; check will fade it in
mCurrIconRow.setGearAlpha(0f);
- mCurrIconRow.setIconLocation(translation > 0 /* onLeft */,
- false /* force */);
+ mCurrIconRow.setIconLocation(translation > 0 /* onLeft */);
}
}
}