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

Commit 8b864518 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Making sure cached properties are updated set on configuration changes.

This guarantees that we update the magnetic swipe threshold in the
magnetic row manager at least once.

Test: presubmit
Flag: com.android.systemui.magnetic_notification_swipes
Bug: 395875362
Change-Id: I008970889c77038692a84b7d5ba8781bf8831e88
parent 90db7a62
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
        }
    };

    private final int mFalsingThreshold;
    private int mFalsingThreshold;
    private boolean mTouchAboveFalsingThreshold;
    private boolean mDisableHwLayers;
    private final boolean mFadeDependingOnAmountSwiped;
@@ -149,8 +149,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
        // Extra long-press!
        mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f);

        mDensityScale =  resources.getDisplayMetrics().density;
        mFalsingThreshold = resources.getDimensionPixelSize(R.dimen.swipe_helper_falsing_threshold);
        updateResourceProperties(resources);
        mFadeDependingOnAmountSwiped = resources.getBoolean(
                R.bool.config_fadeDependingOnAmountSwiped);
        mFalsingManager = falsingManager;
@@ -165,6 +164,14 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                getMaxEscapeAnimDuration() / 1000f);
    }

    /** Update ane properties that depend on Resources */
    public void updateResourceProperties(Resources resources) {
        float density = resources.getDisplayMetrics().density;
        setDensityScale(density);
        mCallback.onDensityScaleChange(density);
        mFalsingThreshold = resources.getDimensionPixelSize(R.dimen.swipe_helper_falsing_threshold);
    }

    public void setDensityScale(float densityScale) {
        mDensityScale = densityScale;
    }
@@ -1001,5 +1008,8 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
         * @return If true, the given view is draggable.
         */
        default boolean canChildBeDragged(@NonNull View animView) { return true; }

        /** The density scale has changed */
        void onDensityScaleChange(float density);
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -896,6 +896,7 @@ public class NotificationStackScrollLayout
        mOverflingDistance = configuration.getScaledOverflingDistance();

        Resources res = context.getResources();
        mSwipeHelper.updateResourceProperties(res);
        final boolean isSmallScreenLandscape = res.getBoolean(R.bool.is_small_screen_landscape);
        boolean useSmallLandscapeLockscreenResources = mIsSmallLandscapeLockscreenEnabled
                && isSmallScreenLandscape;
@@ -2073,8 +2074,6 @@ public class NotificationStackScrollLayout
        Resources res = getResources();
        updateSplitNotificationShade();
        mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
        float densityScale = res.getDisplayMetrics().density;
        mSwipeHelper.setDensityScale(densityScale);
        float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
        mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
        reinitView();
+0 −8
Original line number Diff line number Diff line
@@ -533,12 +533,6 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc
        mPulsing = pulsing;
    }

    @Override
    public void setDensityScale(float densityScale) {
        super.setDensityScale(densityScale);
        mCallback.onDensityScaleChange(densityScale);
    }

    @Override
    public void resetTouchState() {
        super.resetTouchState();
@@ -565,8 +559,6 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc
         */
        float getTotalTranslationLength(View animView);

        void onDensityScaleChange(float density);

        boolean handleSwipeableViewTranslation(SwipeableView view, float translate);

        // Reset any ongoing magnetic interactions