add link to Contact Scopes for apps that have it enabled
Link is added to launcher and to Recents screen app icon menus.
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 1c66f2a..21aeb5c 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -131,6 +131,7 @@
TaskShortcutFactory.FREE_FORM,
TaskShortcutFactory.WELLBEING,
TaskShortcutFactory.STORAGE_SCOPES,
+ TaskShortcutFactory.CONTACT_SCOPES,
};
/**
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index 923e049..f038818 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -125,6 +125,26 @@
}
};
+ TaskShortcutFactory CONTACT_SCOPES = new TaskShortcutFactory() {
+
+ @Override
+ public boolean showForSplitscreen() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) {
+ TaskView taskView = taskContainer.getTaskView();
+
+ var s = SystemShortcut.ContactScopes.maybeGet(activity, taskContainer.getItemInfo(), taskView);
+ if (s == null) {
+ return null;
+ }
+ return Collections.singletonList(s);
+ }
+ };
+
class SplitSelectSystemShortcut extends SystemShortcut {
private final TaskView mTaskView;
private final SplitPositionOption mSplitPositionOption;
diff --git a/res/drawable/ic_cscopes.xml b/res/drawable/ic_cscopes.xml
new file mode 100644
index 0000000..21c3706
--- /dev/null
+++ b/res/drawable/ic_cscopes.xml
@@ -0,0 +1,11 @@
+<!--"person_add" from Material Symbols-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M720,560L720,440L600,440L600,360L720,360L720,240L800,240L800,360L920,360L920,440L800,440L800,560L720,560ZM360,480Q294,480 247,433Q200,386 200,320Q200,254 247,207Q294,160 360,160Q426,160 473,207Q520,254 520,320Q520,386 473,433Q426,480 360,480ZM40,800L40,688Q40,654 57.5,625.5Q75,597 104,582Q166,551 230,535.5Q294,520 360,520Q426,520 490,535.5Q554,551 616,582Q645,597 662.5,625.5Q680,654 680,688L680,800L40,800ZM120,720L600,720L600,688Q600,677 594.5,668Q589,659 580,654Q526,627 471,613.5Q416,600 360,600Q304,600 249,613.5Q194,627 140,654Q131,659 125.5,668Q120,677 120,688L120,720ZM360,400Q393,400 416.5,376.5Q440,353 440,320Q440,287 416.5,263.5Q393,240 360,240Q327,240 303.5,263.5Q280,287 280,320Q280,353 303.5,376.5Q327,400 360,400ZM360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320ZM360,720L360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720L360,720L360,720Z"/>
+</vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f33f0cd..d09d107 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -165,6 +165,8 @@
<string name="app_info_drop_target_label">App info</string>
<!-- Label for Storage Scopes drop target. [CHAR_LIMIT=20] -->
<string name="storage_scopes_drop_target_label">Storage Scopes</string>
+ <!-- Label for Storage Scopes drop target. [CHAR_LIMIT=20] -->
+ <string name="contact_scopes_label">Contact Scopes</string>
<!-- Label for install drop target. [CHAR_LIMIT=20] -->
<string name="install_drop_target_label">Install</string>
<!-- Label for install dismiss prediction. -->
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 35b1262..f574e83 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -59,6 +59,7 @@
import static com.android.launcher3.model.ItemInstallQueue.FLAG_ACTIVITY_PAUSED;
import static com.android.launcher3.model.ItemInstallQueue.FLAG_DRAG_AND_DROP;
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
+import static com.android.launcher3.popup.SystemShortcut.CONTACT_SCOPES;
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
import static com.android.launcher3.popup.SystemShortcut.STORAGE_SCOPES;
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
@@ -3253,7 +3254,7 @@
}
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
- return Stream.of(APP_INFO, WIDGETS, INSTALL, STORAGE_SCOPES);
+ return Stream.of(APP_INFO, WIDGETS, INSTALL, STORAGE_SCOPES, CONTACT_SCOPES);
}
protected LauncherAccessibilityDelegate createAccessibilityDelegate() {
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 17fca39..f4de913 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -8,6 +8,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.GosPackageState;
+import android.ext.cscopes.ContactScopesApi;
import android.graphics.Rect;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -213,11 +214,44 @@
}
}
+ abstract static class ScopesShortcut<T extends Context & ActivityContext> extends SystemShortcut<T> {
+
+ protected String targetPackage;
+
+ private ScopesShortcut(int icon, int label, T target, ItemInfo itemInfo, View originalView) {
+ super(icon, label, target, itemInfo, originalView);
+ targetPackage = itemInfo.getTargetPackage();
+ }
+
+ protected static boolean hasGosPackageStateFlag(ItemInfo itemInfo, int flag) {
+ String pkg = itemInfo.getTargetPackage();
+ if (pkg == null) {
+ return false;
+ }
+
+ GosPackageState ps = GosPackageState.get(pkg, itemInfo.user.getIdentifier());
+
+ return ps != null && ps.hasFlag(flag);
+ }
+
+ @Override
+ public void onClick(View v) {
+ dismissTaskMenuView(mTarget);
+
+ Intent intent = getIntent(targetPackage);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ var opts = ActivityOptions.makeBasic()
+ .setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR)
+ .toBundle();
+ mTarget.startActivityAsUser(intent, opts, mItemInfo.user);
+ }
+
+ protected abstract Intent getIntent(String targetPkg);
+ }
+
public static final Factory<BaseDraggingActivity> STORAGE_SCOPES = StorageScopes::maybeGet;
- public static class StorageScopes<T extends Context & ActivityContext> extends SystemShortcut<T> {
-
- private String targetPackage;
+ public static class StorageScopes<T extends Context & ActivityContext> extends ScopesShortcut<T> {
private StorageScopes(T target, ItemInfo itemInfo, View originalView) {
super(R.drawable.ic_sscopes_add_file, R.string.storage_scopes_drop_target_label, target,
@@ -226,32 +260,40 @@
@Nullable
public static <T extends Context & ActivityContext> StorageScopes<T> maybeGet(T target, ItemInfo itemInfo, View originalView) {
- String pkg = itemInfo.getTargetPackage();
- if (pkg == null) {
- return null;
- }
-
- GosPackageState ps = GosPackageState.get(pkg, itemInfo.user.getIdentifier());
-
- if (ps != null && ps.hasFlag(GosPackageState.FLAG_STORAGE_SCOPES_ENABLED)) {
- var res = new StorageScopes<T>(target, itemInfo, originalView);
- res.targetPackage = pkg;
- return res;
+ if (hasGosPackageStateFlag(itemInfo, GosPackageState.FLAG_STORAGE_SCOPES_ENABLED)) {
+ return new StorageScopes<>(target, itemInfo, originalView);
}
return null;
}
@Override
- public void onClick(View v) {
- dismissTaskMenuView(mTarget);
+ protected Intent getIntent(String targetPkg) {
+ return StorageScope.createConfigActivityIntent(targetPkg);
+ }
+ }
- var intent = StorageScope.createConfigActivityIntent(targetPackage);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- var opts = ActivityOptions.makeBasic()
- .setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR)
- .toBundle();
- mTarget.startActivityAsUser(intent, opts, mItemInfo.user);
+ public static final Factory<BaseDraggingActivity> CONTACT_SCOPES = ContactScopes::maybeGet;
+
+ public static class ContactScopes<T extends Context & ActivityContext> extends ScopesShortcut<T> {
+
+ private ContactScopes(T target, ItemInfo itemInfo, View originalView) {
+ super(R.drawable.ic_cscopes, R.string.contact_scopes_label, target,
+ itemInfo, originalView);
+ }
+
+ @Nullable
+ public static <T extends Context & ActivityContext> ContactScopes<T> maybeGet(T target, ItemInfo itemInfo, View originalView) {
+ if (hasGosPackageStateFlag(itemInfo, GosPackageState.FLAG_CONTACT_SCOPES_ENABLED)) {
+ return new ContactScopes<>(target, itemInfo, originalView);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected Intent getIntent(String targetPkg) {
+ return ContactScopesApi.createConfigActivityIntent(targetPackage);
}
}