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

Commit 8a9cb1d3 authored by Daegyun Shin's avatar Daegyun Shin Committed by Vishnu Nair
Browse files

[wm]: Support free snap mode

In aosp, split divider can be snapped to the specific targets
(first, middle, or last)

new concept is freely snapping between non-dismiss targets.

Test: manual test
1. change config_dockedStackDividerFreeSnapMode true in config.xml
2. build
3. make split state
4. drag divider any position

Bug: 123693029
Change-Id: I9fc42fb698659608de6509acc9ad44874e793fd5
parent 7873b387
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ public class DividerSnapAlgorithm {
    private final ArrayList<SnapTarget> mTargets = new ArrayList<>();
    private final Rect mInsets = new Rect();
    private final int mSnapMode;
    private final boolean mFreeSnapMode;
    private final int mMinimalSizeResizableTask;
    private final int mTaskHeightInMinimizedMode;
    private final float mFixedRatio;
@@ -125,6 +126,8 @@ public class DividerSnapAlgorithm {
        mInsets.set(insets);
        mSnapMode = isMinimizedMode ? SNAP_MODE_MINIMIZED :
                res.getInteger(com.android.internal.R.integer.config_dockedStackDividerSnapMode);
        mFreeSnapMode = res.getBoolean(
                com.android.internal.R.bool.config_dockedStackDividerFreeSnapMode);
        mFixedRatio = res.getFraction(
                com.android.internal.R.fraction.docked_stack_divider_fixed_ratio, 1, 1);
        mMinimalSizeResizableTask = res.getDimensionPixelSize(
@@ -247,7 +250,20 @@ public class DividerSnapAlgorithm {
        }
    }

    private boolean shouldApplyFreeSnapMode(int position) {
        if (!mFreeSnapMode) {
            return false;
        }
        if (!isFirstSplitTargetAvailable() || !isLastSplitTargetAvailable()) {
            return false;
        }
        return mFirstSplitTarget.position < position && position < mLastSplitTarget.position;
    }

    private SnapTarget snap(int position, boolean hardDismiss) {
        if (shouldApplyFreeSnapMode(position)) {
            return new SnapTarget(position, position, SnapTarget.FLAG_NONE);
        }
        int minIndex = -1;
        float minDistance = Float.MAX_VALUE;
        int size = mTargets.size();
+4 −0
Original line number Diff line number Diff line
@@ -3343,6 +3343,10 @@
         This should only be set when the device has gestural navigation enabled by default. -->
    <bool name="config_showGesturalNavigationHints">false</bool>

    <!-- Controls the free snap mode for the docked stack divider. In this mode, the divider can be
         snapped to any position between the first target and the last target. -->
    <bool name="config_dockedStackDividerFreeSnapMode">false</bool>

    <!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
         These values are in DPs and will be converted to pixel sizes internally. -->
    <string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">16x16</string>
+1 −0
Original line number Diff line number Diff line
@@ -1667,6 +1667,7 @@
  <java-symbol type="bool" name="config_perDisplayFocusEnabled" />
  <java-symbol type="bool" name="config_showNavigationBar" />
  <java-symbol type="bool" name="config_supportAutoRotation" />
  <java-symbol type="bool" name="config_dockedStackDividerFreeSnapMode" />
  <java-symbol type="dimen" name="docked_stack_divider_thickness" />
  <java-symbol type="dimen" name="docked_stack_divider_insets" />
  <java-symbol type="dimen" name="docked_stack_minimize_thickness" />