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

Commit 024b39a4 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge changes from topic "expanded-view-drop-target-launcher" into main

* changes:
  Send expanded view drop target size to launcher
  Update bubble bar expanded view drop target size
parents d0ab87f1 6cde120f
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.internal.protolog.common.ProtoLog
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.DeviceConfig
import com.android.wm.shell.bubbles.bar.BubbleExpandedViewPinController.Companion.DROP_TARGET_SCALE
import com.android.wm.shell.common.bubbles.BaseBubblePinController
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_IN_DURATION
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_OUT_DURATION
@@ -248,15 +247,8 @@ class BubbleExpandedViewPinControllerTest {
    private val dropTargetView: View?
        get() = container.findViewById(R.id.bubble_bar_drop_target)

    private fun getExpectedDropTargetBounds(onLeft: Boolean): Rect {
        val rect = Rect()
        positioner.getBubbleBarExpandedViewBounds(onLeft, false /* isOveflowExpanded */, rect)
        // Scale the rect to expected size, but keep the center point the same
        val centerX = rect.centerX()
        val centerY = rect.centerY()
        rect.scale(DROP_TARGET_SCALE)
        rect.offset(centerX - rect.centerX(), centerY - rect.centerY())
        return rect
    private fun getExpectedDropTargetBounds(onLeft: Boolean): Rect = Rect().also {
        positioner.getBubbleBarExpandedViewBounds(onLeft, false /* isOveflowExpanded */, it)
    }

    private fun runOnMainSync(runnable: Runnable) {
+10 −8
Original line number Diff line number Diff line
@@ -13,12 +13,14 @@
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:shape="rectangle">
    <corners android:radius="@dimen/bubble_bar_expanded_view_corner_radius" />
    android:inset="@dimen/bubble_bar_expanded_view_drop_target_padding">
    <shape android:shape="rectangle">
        <corners android:radius="@dimen/bubble_bar_expanded_view_drop_target_corner" />
        <solid android:color="@color/bubble_drop_target_background_color" />
        <stroke
            android:width="1dp"
            android:color="?androidprv:attr/materialColorPrimaryContainer" />
    </shape>
</inset>
+3 −0
Original line number Diff line number Diff line
@@ -274,6 +274,9 @@
    <dimen name="bubble_bar_expanded_view_corner_radius">16dp</dimen>
    <!-- Corner radius for expanded view while it is being dragged -->
    <dimen name="bubble_bar_expanded_view_corner_radius_dragged">28dp</dimen>
    <!-- Corner radius for expanded view drop target -->
    <dimen name="bubble_bar_expanded_view_drop_target_corner">28dp</dimen>
    <dimen name="bubble_bar_expanded_view_drop_target_padding">24dp</dimen>
    <!-- Width of the box around bottom center of the screen where drag only leads to dismiss -->
    <dimen name="bubble_bar_dismiss_zone_width">192dp</dimen>
    <!-- Height of the box around bottom center of the screen where drag only leads to dismiss -->
+9 −0
Original line number Diff line number Diff line
@@ -1171,6 +1171,15 @@ public class BubbleController implements ConfigurationChangeListener,
     */
    public void startBubbleDrag(String bubbleKey) {
        onBubbleDrag(bubbleKey, true /* isBeingDragged */);
        if (mBubbleStateListener != null) {
            boolean overflow = BubbleOverflow.KEY.equals(bubbleKey);
            Rect rect = new Rect();
            mBubblePositioner.getBubbleBarExpandedViewBounds(mBubblePositioner.isBubbleBarOnLeft(),
                    overflow, rect);
            BubbleBarUpdate update = new BubbleBarUpdate();
            update.expandedViewDropTargetSize = new Point(rect.width(), rect.height());
            mBubbleStateListener.onBubbleStateChange(update);
        }
    }

    /**
+5 −15
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.graphics.Rect
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.annotation.VisibleForTesting
import androidx.core.view.updateLayoutParams
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.BubblePositioner
@@ -79,7 +78,11 @@ class BubbleExpandedViewPinController(

    override fun updateLocation(location: BubbleBarLocation) {
        val view = dropTargetView ?: return
        getBounds(location.isOnLeft(view.isLayoutRtl), tempRect)
        positioner.getBubbleBarExpandedViewBounds(
            location.isOnLeft(view.isLayoutRtl),
            false /* isOverflowExpanded */,
            tempRect
        )
        view.updateLayoutParams<FrameLayout.LayoutParams> {
            width = tempRect.width()
            height = tempRect.height()
@@ -87,17 +90,4 @@ class BubbleExpandedViewPinController(
        view.x = tempRect.left.toFloat()
        view.y = tempRect.top.toFloat()
    }

    private fun getBounds(onLeft: Boolean, out: Rect) {
        positioner.getBubbleBarExpandedViewBounds(onLeft, false /* isOverflowExpanded */, out)
        val centerX = out.centerX()
        val centerY = out.centerY()
        out.scale(DROP_TARGET_SCALE)
        // Move rect center back to the same position as before scale
        out.offset(centerX - out.centerX(), centerY - out.centerY())
    }

    companion object {
        @VisibleForTesting const val DROP_TARGET_SCALE = 0.9f
    }
}
Loading