add link to Storage Scopes for apps that have it enabled
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 6e47ff4..1c66f2a 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -129,7 +129,8 @@
TaskShortcutFactory.PIN,
TaskShortcutFactory.INSTALL,
TaskShortcutFactory.FREE_FORM,
- TaskShortcutFactory.WELLBEING
+ TaskShortcutFactory.WELLBEING,
+ TaskShortcutFactory.STORAGE_SCOPES,
};
/**
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index 255b910..923e049 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -105,6 +105,26 @@
}
};
+ TaskShortcutFactory STORAGE_SCOPES = new TaskShortcutFactory() {
+ @Nullable
+ @Override
+ public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
+ TaskIdAttributeContainer taskContainer) {
+ TaskView taskView = taskContainer.getTaskView();
+
+ var s = SystemShortcut.StorageScopes.maybeGet(activity, taskContainer.getItemInfo(), taskView);
+ if (s == null) {
+ return null;
+ }
+ return Collections.singletonList(s);
+ }
+
+ @Override
+ public boolean showForSplitscreen() {
+ return true;
+ }
+ };
+
class SplitSelectSystemShortcut extends SystemShortcut {
private final TaskView mTaskView;
private final SplitPositionOption mSplitPositionOption;
diff --git a/res/drawable/ic_sscopes_add_file.xml b/res/drawable/ic_sscopes_add_file.xml
new file mode 100644
index 0000000..0c78c3f
--- /dev/null
+++ b/res/drawable/ic_sscopes_add_file.xml
@@ -0,0 +1,13 @@
+<!-- note_add from Material Symbols -->
+<vector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48"
+ android:tint="?android:attr/colorControlNormal">
+
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22.5,36.3H25.5V29.85H32V26.85H25.5V20.35H22.5V26.85H16V29.85H22.5ZM11,44Q9.8,44 8.9,43.1Q8,42.2 8,41V7Q8,5.8 8.9,4.9Q9.8,4 11,4H29.05L40,14.95V41Q40,42.2 39.1,43.1Q38.2,44 37,44ZM27.55,16.3V7H11Q11,7 11,7Q11,7 11,7V41Q11,41 11,41Q11,41 11,41H37Q37,41 37,41Q37,41 37,41V16.3ZM11,7V16.3V7V16.3V41Q11,41 11,41Q11,41 11,41Q11,41 11,41Q11,41 11,41V7Q11,7 11,7Q11,7 11,7Z"/>
+</vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 190a3a5..f33f0cd 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -163,6 +163,8 @@
<string name="uninstall_drop_target_label">Uninstall</string>
<!-- Label for app info drop target. [CHAR_LIMIT=20] -->
<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 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 7da16c0..35b1262 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -60,6 +60,7 @@
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.INSTALL;
+import static com.android.launcher3.popup.SystemShortcut.STORAGE_SCOPES;
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
@@ -3252,7 +3253,7 @@
}
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
- return Stream.of(APP_INFO, WIDGETS, INSTALL);
+ return Stream.of(APP_INFO, WIDGETS, INSTALL, STORAGE_SCOPES);
}
protected LauncherAccessibilityDelegate createAccessibilityDelegate() {
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 69bba69..17fca39 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -4,13 +4,16 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP;
import android.app.ActivityOptions;
+import android.app.StorageScope;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.GosPackageState;
import android.graphics.Rect;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
import android.widget.TextView;
+import android.window.SplashScreen;
import androidx.annotation.Nullable;
@@ -210,6 +213,48 @@
}
}
+ public static final Factory<BaseDraggingActivity> STORAGE_SCOPES = StorageScopes::maybeGet;
+
+ public static class StorageScopes<T extends Context & ActivityContext> extends SystemShortcut<T> {
+
+ private String targetPackage;
+
+ private StorageScopes(T target, ItemInfo itemInfo, View originalView) {
+ super(R.drawable.ic_sscopes_add_file, R.string.storage_scopes_drop_target_label, target,
+ itemInfo, originalView);
+ }
+
+ @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;
+ }
+
+ return null;
+ }
+
+ @Override
+ public void onClick(View v) {
+ dismissTaskMenuView(mTarget);
+
+ 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> INSTALL =
(activity, itemInfo, originalView) -> {
boolean supportsWebUI = (itemInfo instanceof WorkspaceItemInfo)