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

Commit 6fbdc9cf authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Use separate SemanticKey for keys with null values

* Using the same key for all the segments resulted in
always returning null whenever we did motionValue.get(key)
* My guess is that the identitiy section we set after each
section using the same key was overwriting the segment section
* Either way, now we get valid snap targets when we query the
motion spec

Bug: 383631946
Flag: com.android.wm.shell.enable_magnetic_split_divider
Test: Manual
Change-Id: Iec9a6c269df87b3a913076ac60184398560089fd
parent f1944fbb
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -59,6 +59,13 @@ class MagneticDividerUtils {
         */
        @JvmStatic val SNAP_POSITION_KEY = SemanticKey<Int?>()

        /**
         * Key used for identity regions which don't have drop zones associated with them.
         * Need to keep this key separate for the SemanticKeys we create with null values as it
         * seems like this overwrites the semantics created with real snapTarget values
         */
        @JvmStatic private val SNAP_POSITION_KEY_IDENTITY = SemanticKey<Int?>()

        /**
         * Create a MotionSpec that has "snap zones" for each of the SnapTargets provided.
         */
@@ -84,7 +91,7 @@ class MagneticDividerUtils {
                    // opposed to "effects" movement).
                    spatialDirectionalMotionSpec(
                        initialMapping = Mapping.Fixed(topLeftDismissPosition),
                        semantics = listOf(SNAP_POSITION_KEY with null),
                        semantics = listOf(SNAP_POSITION_KEY_IDENTITY with null),
                        defaultSpring = MagneticSpring
                    ) {
                        // NOTE: This block is a trailing lambda passed in as the "init" parameter.
@@ -140,7 +147,7 @@ class MagneticDividerUtils {
                            // Create another identity zone.
                            identity(
                                breakpoint = targetPosition + snapThreshold,
                                semantics = listOf(SNAP_POSITION_KEY with null)
                                semantics = listOf(SNAP_POSITION_KEY_IDENTITY with null)
                            )
                        }

@@ -151,7 +158,7 @@ class MagneticDividerUtils {
                        fixedValue(
                            breakpoint = bottomRightDismissPosition,
                            value = bottomRightDismissPosition,
                            semantics = listOf(SNAP_POSITION_KEY with null)
                            semantics = listOf(SNAP_POSITION_KEY_IDENTITY with null)
                        )
                    }
                }