diff options
7 files changed, 60 insertions, 2 deletions
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index b0ee03989298..ed200ad60c14 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -396,4 +396,8 @@ one bar higher than they actually are --> <bool name="config_inflateSignalStrength">false</bool> + <!-- Should we vibrate on an icon animation of the shelf. This should only be active if the + vibrator is capable of subtle vibrations --> + <bool name="config_vibrateOnIconAnimation">false</bool> + </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 1889806bf985..41db927a67bd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -78,6 +78,9 @@ public class NotificationShelf extends ActivatableNotificationView implements private boolean mNoAnimationsInThisFrame; private boolean mAnimationsEnabled = true; private boolean mShowNotificationShelf; + private boolean mVibrationOnAnimation; + private boolean mUserTouchingScreen; + private boolean mTouchActive; public NotificationShelf(Context context, AttributeSet attrs) { super(context, attrs); @@ -94,12 +97,24 @@ public class NotificationShelf extends ActivatableNotificationView implements setClipChildren(false); setClipToPadding(false); mShelfIcons.setShowAllIcons(false); + mVibrationOnAnimation = mContext.getResources().getBoolean( + R.bool.config_vibrateOnIconAnimation); + updateVibrationOnAnimation(); mViewInvertHelper = new ViewInvertHelper(mShelfIcons, NotificationPanelView.DOZE_ANIMATION_DURATION); mShelfState = new ShelfState(); initDimens(); } + private void updateVibrationOnAnimation() { + mShelfIcons.setVibrateOnAnimation(mVibrationOnAnimation && mTouchActive); + } + + public void setTouchActive(boolean touchActive) { + mTouchActive = touchActive; + updateVibrationOnAnimation(); + } + public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout) { mAmbientState = ambientState; mHostLayout = hostLayout; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index 05d47ec9af63..e729f605e948 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -131,6 +131,7 @@ public class StatusBarIconView extends AnimatedImageView { private final NotificationIconDozeHelper mDozer; private int mContrastedDrawableColor; private int mCachedContrastBackgroundColor = NO_COLOR; + private boolean mIsInShelf; public StatusBarIconView(Context context, String slot, StatusBarNotification sbn) { this(context, slot, sbn, false); @@ -766,6 +767,14 @@ public class StatusBarIconView extends AnimatedImageView { } } + public void setIsInShelf(boolean isInShelf) { + mIsInShelf = isInShelf; + } + + public boolean isInShelf() { + return mIsInShelf; + } + public interface OnVisibilityChangedListener { void onVisibilityChanged(int newVisibility); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java index 38c8d31e0970..e0d9748c48bf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -22,6 +22,8 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Icon; +import android.os.VibrationEffect; +import android.os.Vibrator; import android.support.v4.util.ArrayMap; import android.support.v4.util.ArraySet; import android.util.AttributeSet; @@ -122,6 +124,8 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { private float mVisualOverflowAdaption; private boolean mDisallowNextAnimation; private boolean mAnimationsEnabled = true; + private boolean mVibrateOnAnimation; + private Vibrator mVibrator; private ArrayMap<String, ArrayList<StatusBarIcon>> mReplacingIcons; private int mDarkOffsetX; @@ -129,6 +133,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { super(context, attrs); initDimens(); setWillNotDraw(!DEBUG); + mVibrator = mContext.getSystemService(Vibrator.class); } private void initDimens() { @@ -499,6 +504,10 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { return width - (getWidth() - getActualPaddingStart() - getActualPaddingEnd()) > 0; } + public void setVibrateOnAnimation(boolean vibrateOnAnimation) { + mVibrateOnAnimation = vibrateOnAnimation; + } + public int getIconSize() { return mIconSize; } @@ -611,6 +620,13 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { } else { super.applyToView(view); } + boolean wasInShelf = icon.isInShelf(); + boolean inShelf = iconAppearAmount == 1.0f; + icon.setIsInShelf(inShelf); + if (mVibrateOnAnimation && !justAdded && mAnimationsEnabled + && wasInShelf != inShelf) { + mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_TICK)); + } } justAdded = false; justReplaced = false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index 16d85bec4829..d3ee55098474 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -24,6 +24,8 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.os.SystemClock; +import android.os.VibrationEffect; +import android.os.Vibrator; import android.util.AttributeSet; import android.util.Log; import android.view.InputDevice; @@ -98,6 +100,7 @@ public abstract class PanelView extends FrameLayout { private FlingAnimationUtils mFlingAnimationUtilsClosing; private FlingAnimationUtils mFlingAnimationUtilsDismissing; private FalsingManager mFalsingManager; + private final Vibrator mVibrator; /** * Whether an instant expand request is currently pending and we are just waiting for layout. @@ -199,6 +202,7 @@ public abstract class PanelView extends FrameLayout { mFalsingManager = FalsingManager.getInstance(context); mNotificationsDragEnabled = getResources().getBoolean(R.bool.config_enableNotificationShadeDrag); + mVibrator = mContext.getSystemService(Vibrator.class); } protected void loadDimens() { @@ -390,6 +394,7 @@ public abstract class PanelView extends FrameLayout { runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(), false /* collapseWhenFinished */); notifyBarPanelExpansionChanged(); + mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK)); } protected abstract float getOpeningHeight(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index adc33a144689..0dcf6d277145 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -246,6 +246,11 @@ public class StatusBarWindowView extends FrameLayout { return false; } + public void setTouchActive(boolean touchActive) { + mTouchActive = touchActive; + mStackScrollLayout.setTouchActive(touchActive); + } + @Override public boolean dispatchTouchEvent(MotionEvent ev) { boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN; @@ -253,11 +258,11 @@ public class StatusBarWindowView extends FrameLayout { mNotificationPanel.startExpandLatencyTracking(); } if (isDown) { - mTouchActive = true; + setTouchActive(true); mTouchCancelled = false; } else if (ev.getActionMasked() == MotionEvent.ACTION_UP || ev.getActionMasked() == MotionEvent.ACTION_CANCEL) { - mTouchActive = false; + setTouchActive(false); } if (mTouchCancelled) { return false; 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 4bbe895da7ca..472e30c7f6da 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -4311,6 +4311,10 @@ public class NotificationStackScrollLayout extends ViewGroup mAmbientState.getScrollY())); } + public void setTouchActive(boolean touchActive) { + mShelf.setTouchActive(touchActive); + } + /** * A listener that is notified when some child locations might have changed. */ |