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>
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);
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;
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);
}
}
+ public void setIsInShelf(boolean isInShelf) {
+ mIsInShelf = isInShelf;
+ }
+
+ public boolean isInShelf() {
+ return mIsInShelf;
+ }
+
public interface OnVisibilityChangedListener {
void onVisibilityChanged(int newVisibility);
}
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;
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;
super(context, attrs);
initDimens();
setWillNotDraw(!DEBUG);
+ mVibrator = mContext.getSystemService(Vibrator.class);
}
private void initDimens() {
return width - (getWidth() - getActualPaddingStart() - getActualPaddingEnd()) > 0;
}
+ public void setVibrateOnAnimation(boolean vibrateOnAnimation) {
+ mVibrateOnAnimation = vibrateOnAnimation;
+ }
+
public int getIconSize() {
return mIconSize;
}
} 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;
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;
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.
mFalsingManager = FalsingManager.getInstance(context);
mNotificationsDragEnabled =
getResources().getBoolean(R.bool.config_enableNotificationShadeDrag);
+ mVibrator = mContext.getSystemService(Vibrator.class);
}
protected void loadDimens() {
runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(),
false /* collapseWhenFinished */);
notifyBarPanelExpansionChanged();
+ mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_CLICK));
}
protected abstract float getOpeningHeight();
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;
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;
mAmbientState.getScrollY()));
}
+ public void setTouchActive(boolean touchActive) {
+ mShelf.setTouchActive(touchActive);
+ }
+
/**
* A listener that is notified when some child locations might have changed.
*/