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

Commit dd51f86f authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Implement PiP custom close action on phone

To use this new custom close action on Phone
- We expect app providing actions via
  PictureInPictureParams.Builder#setActions as they normally do
- We also expect app providing a custom close action via
  PictureInPictureParams.Builder#setCloseAction
- The custom close action is used on Phone only if it matches one of the
  actions listed in setActions (by comparing the PendingIntent)

SysUI will render the custom close action with a highlighted background
and ensures the PiP dismisses after certain timeout if the app fails to
respond in time.

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/fR0hxeorlYrxXyzfZ02btK
Bug: 223896879
Test: see video
Change-Id: I65c585ae3224061311e476753bc4c72f00c4fa33
parent 6da0c2fc
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid
        android:color="@color/pip_custom_close_bg" />
    <size
        android:width="@dimen/pip_custom_close_bg_size"
        android:height="@dimen/pip_custom_close_bg_size" />
</shape>
+8 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,14 @@
    android:background="?android:selectableItemBackgroundBorderless"
    android:background="?android:selectableItemBackgroundBorderless"
    android:forceHasOverlappingRendering="false">
    android:forceHasOverlappingRendering="false">


    <ImageView
        android:id="@+id/custom_close_bg"
        android:layout_width="@dimen/pip_custom_close_bg_size"
        android:layout_height="@dimen/pip_custom_close_bg_size"
        android:layout_gravity="center"
        android:src="@drawable/pip_custom_close_bg"
        android:visibility="gone"/>

    <ImageView
    <ImageView
        android:id="@+id/image"
        android:id="@+id/image"
        android:layout_width="@dimen/pip_action_inner_size"
        android:layout_width="@dimen/pip_action_inner_size"
+4 −1
Original line number Original line Diff line number Diff line
@@ -30,6 +30,9 @@
    <color name="bubbles_dark">@color/GM2_grey_800</color>
    <color name="bubbles_dark">@color/GM2_grey_800</color>
    <color name="bubbles_icon_tint">@color/GM2_grey_700</color>
    <color name="bubbles_icon_tint">@color/GM2_grey_700</color>


    <!-- PiP -->
    <color name="pip_custom_close_bg">#D93025</color>

    <!-- Compat controls UI -->
    <!-- Compat controls UI -->
    <color name="compat_controls_background">@android:color/system_neutral1_800</color>
    <color name="compat_controls_background">@android:color/system_neutral1_800</color>
    <color name="compat_controls_text">@android:color/system_neutral1_50</color>
    <color name="compat_controls_text">@android:color/system_neutral1_50</color>
+4 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,10 @@
    <!-- Show PiP enter split icon, which allows apps to directly enter splitscreen from PiP. -->
    <!-- Show PiP enter split icon, which allows apps to directly enter splitscreen from PiP. -->
    <bool name="config_pipEnableEnterSplitButton">false</bool>
    <bool name="config_pipEnableEnterSplitButton">false</bool>


    <!-- Time (duration in milliseconds) that the shell waits for an app to close the PiP by itself
         if a custom action is present before closing it. -->
    <integer name="config_pipForceCloseDelay">1000</integer>

    <!-- Animation duration when using long press on recents to dock -->
    <!-- Animation duration when using long press on recents to dock -->
    <integer name="long_press_dock_anim_duration">250</integer>
    <integer name="long_press_dock_anim_duration">250</integer>


+3 −0
Original line number Original line Diff line number Diff line
@@ -78,6 +78,9 @@
         WindowConfiguration#PINNED_WINDOWING_MODE_ELEVATION_IN_DIP -->
         WindowConfiguration#PINNED_WINDOWING_MODE_ELEVATION_IN_DIP -->
    <dimen name="pip_shadow_radius">5dp</dimen>
    <dimen name="pip_shadow_radius">5dp</dimen>


    <!-- The width and height of the background for custom action in PiP menu. -->
    <dimen name="pip_custom_close_bg_size">32dp</dimen>

    <dimen name="dismiss_target_x_size">24dp</dimen>
    <dimen name="dismiss_target_x_size">24dp</dimen>
    <dimen name="floating_dismiss_bottom_margin">50dp</dimen>
    <dimen name="floating_dismiss_bottom_margin">50dp</dimen>


Loading