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

Commit 15380dcf authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Capture links in window decoration

This CL does the following:
1. Adds a capturedLink and capturedLinkTimestamp field into TaskInfo.
2. On TaskInfo#fillTaskInfo, iterates activities top to bottom and finds
   the first activity (if any exist) which was opened using a link.
3. If TaskInfo#capturedLink is not null and has not been previously
   saved, saves the link and posts a runnable to clear the link after a
   set amount of time.
4. Creates an "Open in browser" button in the handle menu if the
   capturedLink field in TaskInfo is not null.
4. When the window decoration is created, finds and saves the component
   name of the default browser.
5. When a click event is received, opens the saved link in the default
   browser.

Bug: 349695493
Test: Open slides from gmail app and use button to switch to browser
Flag: com.android.window.flags.enable_desktop_windowing_app_to_web

Change-Id: I8e638cde8c1fff4c5f2b75da2d9b31541dbe2489
parent 9edff93d
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.os.Parcel;
@@ -302,6 +303,19 @@ public class TaskInfo {
     */
    public boolean isTopActivityStyleFloating;

    /**
     * The URI of the intent that generated the top-most activity opened using a URL.
     * @hide
     */
    @Nullable
    public Uri capturedLink;

    /**
     * The time of the last launch of the activity opened using the {@link #capturedLink}.
     * @hide
     */
    public long capturedLinkTimestamp;

    /**
     * Encapsulate specific App Compat information.
     * @hide
@@ -436,6 +450,8 @@ public class TaskInfo {
                && Objects.equals(topActivity, that.topActivity)
                && isTopActivityTransparent == that.isTopActivityTransparent
                && isTopActivityStyleFloating == that.isTopActivityStyleFloating
                && Objects.equals(capturedLink, that.capturedLink)
                && capturedLinkTimestamp == that.capturedLinkTimestamp
                && appCompatTaskInfo.equalsForTaskOrganizer(that.appCompatTaskInfo);
    }

@@ -506,6 +522,8 @@ public class TaskInfo {
        displayAreaFeatureId = source.readInt();
        isTopActivityTransparent = source.readBoolean();
        isTopActivityStyleFloating = source.readBoolean();
        capturedLink = source.readTypedObject(Uri.CREATOR);
        capturedLinkTimestamp = source.readLong();
        appCompatTaskInfo = source.readTypedObject(AppCompatTaskInfo.CREATOR);
    }

@@ -554,6 +572,8 @@ public class TaskInfo {
        dest.writeInt(displayAreaFeatureId);
        dest.writeBoolean(isTopActivityTransparent);
        dest.writeBoolean(isTopActivityStyleFloating);
        dest.writeTypedObject(capturedLink, flags);
        dest.writeLong(capturedLinkTimestamp);
        dest.writeTypedObject(appCompatTaskInfo, flags);
    }

@@ -592,6 +612,8 @@ public class TaskInfo {
                + " displayAreaFeatureId=" + displayAreaFeatureId
                + " isTopActivityTransparent=" + isTopActivityTransparent
                + " isTopActivityStyleFloating=" + isTopActivityStyleFloating
                + " capturedLink=" + capturedLink
                + " capturedLinkTimestamp=" + capturedLinkTimestamp
                + " appCompatTaskInfo=" + appCompatTaskInfo
                + "}";
    }
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" android:tint="?attr/colorControlNormal">
    <path android:fillColor="@android:color/black" android:pathData="M160,880Q127,880 103.5,856.5Q80,833 80,800L80,440Q80,407 103.5,383.5Q127,360 160,360L240,360L240,160Q240,127 263.5,103.5Q287,80 320,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,520Q880,553 856.5,576.5Q833,600 800,600L720,600L720,800Q720,833 696.5,856.5Q673,880 640,880L160,880ZM160,800L640,800Q640,800 640,800Q640,800 640,800L640,520L160,520L160,800Q160,800 160,800Q160,800 160,800ZM720,520L800,520Q800,520 800,520Q800,520 800,520L800,240L320,240L320,360L640,360Q673,360 696.5,383.5Q720,407 720,440L720,520Z"/>
</vector>
+19 −0
Original line number Diff line number Diff line
@@ -135,5 +135,24 @@
            android:drawableTint="?androidprv:attr/materialColorOnSurface"
            style="@style/DesktopModeHandleMenuActionButton"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/open_in_browser_pill"
        android:layout_width="match_parent"
        android:layout_height="@dimen/desktop_mode_handle_menu_open_in_browser_pill_height"
        android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin"
        android:layout_marginStart="1dp"
        android:orientation="vertical"
        android:elevation="1dp"
        android:background="@drawable/desktop_mode_decor_handle_menu_background">

        <Button
            android:id="@+id/open_in_browser_button"
            android:contentDescription="@string/open_in_browser_text"
            android:text="@string/open_in_browser_text"
            android:drawableStart="@drawable/desktop_mode_ic_handle_menu_open_in_browser"
            android:drawableTint="?androidprv:attr/materialColorOnSurface"
            style="@style/DesktopModeHandleMenuActionButton"/>
    </LinearLayout>
</LinearLayout>
+4 −1
Original line number Diff line number Diff line
@@ -507,8 +507,11 @@
    <!-- The height of the handle menu's "More Actions" pill in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_more_actions_pill_height">52dp</dimen>

    <!-- The height of the handle menu's "Open in browser" pill in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_open_in_browser_pill_height">52dp</dimen>

    <!-- The height of the handle menu in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_height">328dp</dimen>
    <dimen name="desktop_mode_handle_menu_height">380dp</dimen>

    <!-- The top margin of the handle menu in desktop mode. -->
    <dimen name="desktop_mode_handle_menu_margin_top">4dp</dimen>
+2 −0
Original line number Diff line number Diff line
@@ -280,6 +280,8 @@
    <string name="select_text">Select</string>
    <!-- Accessibility text for the handle menu screenshot button [CHAR LIMIT=NONE] -->
    <string name="screenshot_text">Screenshot</string>
    <!-- Accessibility text for the handle menu open in browser button [CHAR LIMIT=NONE] -->
    <string name="open_in_browser_text">Open in browser</string>
    <!-- Accessibility text for the handle menu close button [CHAR LIMIT=NONE] -->
    <string name="close_text">Close</string>
    <!-- Accessibility text for the handle menu close menu button [CHAR LIMIT=NONE] -->
Loading