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 Original line 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 mTouchAboveFalsingThreshold;
    private boolean mDisableHwLayers;
    private boolean mDisableHwLayers;
    private final boolean mFadeDependingOnAmountSwiped;
    private final boolean mFadeDependingOnAmountSwiped;
@@ -149,8 +149,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
        // Extra long-press!
        // Extra long-press!
        mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f);
        mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f);


        mDensityScale =  resources.getDisplayMetrics().density;
        updateResourceProperties(resources);
        mFalsingThreshold = resources.getDimensionPixelSize(R.dimen.swipe_helper_falsing_threshold);
        mFadeDependingOnAmountSwiped = resources.getBoolean(
        mFadeDependingOnAmountSwiped = resources.getBoolean(
                R.bool.config_fadeDependingOnAmountSwiped);
                R.bool.config_fadeDependingOnAmountSwiped);
        mFalsingManager = falsingManager;
        mFalsingManager = falsingManager;
@@ -165,6 +164,14 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                getMaxEscapeAnimDuration() / 1000f);
                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) {
    public void setDensityScale(float densityScale) {
        mDensityScale = densityScale;
        mDensityScale = densityScale;
    }
    }
@@ -1001,5 +1008,8 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
         * @return If true, the given view is draggable.
         * @return If true, the given view is draggable.
         */
         */
        default boolean canChildBeDragged(@NonNull View animView) { return true; }
        default boolean canChildBeDragged(@NonNull View animView) { return true; }

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


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


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

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


        void onDensityScaleChange(float density);

        boolean handleSwipeableViewTranslation(SwipeableView view, float translate);
        boolean handleSwipeableViewTranslation(SwipeableView view, float translate);


        // Reset any ongoing magnetic interactions
        // Reset any ongoing magnetic interactions