Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c06b9ae authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removed vibrations when icons go into / out of the shelf"

parents 242c28f3 4f6c85f6
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -82,9 +82,6 @@ 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;
    private float mFirstElementRoundness;

    public NotificationShelf(Context context, AttributeSet attrs) {
@@ -102,9 +99,6 @@ 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();
@@ -112,15 +106,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
        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;
+0 −5
Original line number Diff line number Diff line
@@ -61,11 +61,6 @@ public class NotificationUtils {
        return sLocationOffset[1] - sLocationBase[1];
    }

    public static boolean isHapticFeedbackDisabled(Context context) {
        return Settings.System.getIntForUser(context.getContentResolver(),
                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0;
    }

    /**
     * @param dimenId the dimen to look up
     * @return the font scaled dimen as if it were in sp but doesn't shrink sizes below dp
+0 −34
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.statusbar.phone;

import static com.android.systemui.statusbar.notification.NotificationUtils.isHapticFeedbackDisabled;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
@@ -120,8 +118,6 @@ 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,7 +125,6 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        super(context, attrs);
        initDimens();
        setWillNotDraw(!DEBUG);
        mVibrator = mContext.getSystemService(Vibrator.class);
    }

    private void initDimens() {
@@ -497,10 +492,6 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        return width - (getWidth() - getActualPaddingStart() - getActualPaddingEnd()) > 0;
    }

    public void setVibrateOnAnimation(boolean vibrateOnAnimation) {
        mVibrateOnAnimation = vibrateOnAnimation;
    }

    public int getIconSize() {
        return mIconSize;
    }
@@ -608,39 +599,14 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
                } else {
                    super.applyToView(view);
                }
                boolean wasInShelf = icon.isInShelf();
                boolean inShelf = iconAppearAmount == 1.0f;
                icon.setIsInShelf(inShelf);
                if (shouldVibrateChange(wasInShelf != inShelf)) {
                    AsyncTask.execute(
                            () -> mVibrator.vibrate(VibrationEffect.get(
                                    VibrationEffect.EFFECT_TICK)));
                }
            }
            justAdded = false;
            justReplaced = false;
            needsCannedAnimation = false;
        }

        private boolean shouldVibrateChange(boolean inShelfChanged) {
            if (!mVibrateOnAnimation) {
                return false;
            }
            if (justAdded) {
                return false;
            }
            if (!mAnimationsEnabled) {
                return false;
            }
            if (!inShelfChanged) {
                return false;
            }
            if (isHapticFeedbackDisabled(mContext)) {
                return false;
            }
            return true;
        }

        public boolean hasCustomTransformHeight() {
            return isLastExpandIcon && customTransformHeight != NO_VALUE;
        }
+21 −3
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.statusbar.phone;

import static com.android.systemui.statusbar.notification.NotificationUtils.isHapticFeedbackDisabled;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
@@ -25,10 +23,14 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.view.InputDevice;
@@ -63,6 +65,7 @@ public abstract class PanelView extends FrameLayout {
    private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger();
    private boolean mPanelUpdateWhenAnimatorEnds;
    private boolean mVibrateOnOpening;
    private boolean mVibrationEnabled;

    private final void logf(String fmt, Object... args) {
        Log.v(TAG, (mViewName != null ? (mViewName + ": ") : "") + String.format(fmt, args));
@@ -105,6 +108,12 @@ public abstract class PanelView extends FrameLayout {
    private FlingAnimationUtils mFlingAnimationUtilsDismissing;
    private FalsingManager mFalsingManager;
    private final Vibrator mVibrator;
    final private ContentObserver mVibrationObserver = new ContentObserver(Handler.getMain()) {
        @Override
        public void onChange(boolean selfChange) {
            updateHapticFeedBackEnabled();
        }
    };

    /**
     * Whether an instant expand request is currently pending and we are just waiting for layout.
@@ -209,6 +218,15 @@ public abstract class PanelView extends FrameLayout {
        mVibrator = mContext.getSystemService(Vibrator.class);
        mVibrateOnOpening = mContext.getResources().getBoolean(
                R.bool.config_vibrateOnIconAnimation);
        mContext.getContentResolver().registerContentObserver(
                Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED), true,
                mVibrationObserver);
        mVibrationObserver.onChange(false /* selfChange */);
    }

    public void updateHapticFeedBackEnabled() {
        mVibrationEnabled = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) != 0;
    }

    protected void loadDimens() {
@@ -400,7 +418,7 @@ public abstract class PanelView extends FrameLayout {
        runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(),
                false /* collapseWhenFinished */);
        notifyBarPanelExpansionChanged();
        if (mVibrateOnOpening && !isHapticFeedbackDisabled(mContext)) {
        if (mVibrateOnOpening && mVibrationEnabled) {
            AsyncTask.execute(() ->
                    mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_TICK, false)));
        }
+0 −1
Original line number Diff line number Diff line
@@ -248,7 +248,6 @@ public class StatusBarWindowView extends FrameLayout {

    public void setTouchActive(boolean touchActive) {
        mTouchActive = touchActive;
        mStackScrollLayout.setTouchActive(touchActive);
    }

    @Override
Loading