summaryrefslogtreecommitdiff
path: root/quickstep/src
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-03-24 01:04:31 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-24 01:04:31 -0700
commit69461b2d75293f34b4bb86361bf92c356b4cb6c6 (patch)
treee23dd47dda8f0dfe02ae08d22a2871dbbbdfb064 /quickstep/src
parent7e4fa0f8335e47c002f79aecedaab91691da2217 (diff)
parent116eafb95c2d4538fb8b59c95a828823a2fe4148 (diff)
Merge "Add "change aspect ratio" to Recents/Overview" into main
Diffstat (limited to 'quickstep/src')
-rw-r--r--quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt100
-rw-r--r--quickstep/src/com/android/quickstep/TaskOverlayFactory.java1
2 files changed, 101 insertions, 0 deletions
diff --git a/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt b/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt
new file mode 100644
index 0000000000..68860ac91b
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2025 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.
+ */
+
+package com.android.quickstep
+
+import android.content.Intent
+import android.provider.Settings
+import android.view.View
+import androidx.core.net.toUri
+import com.android.launcher3.AbstractFloatingViewHelper
+import com.android.launcher3.R
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent
+import com.android.launcher3.popup.SystemShortcut
+import com.android.quickstep.views.RecentsViewContainer
+import com.android.quickstep.views.TaskContainer
+import com.android.window.flags.Flags.universalResizableByDefault
+
+/**
+ * System shortcut to change the application's aspect ratio compatibility mode.
+ *
+ * This shows up only on screens that are not compact, ie. shortest-width greater than {@link
+ * com.android.launcher3.util.window.WindowManagerProxy#MIN_TABLET_WIDTH}.
+ */
+class AspectRatioSystemShortcut(
+ viewContainer: RecentsViewContainer,
+ taskContainer: TaskContainer,
+ abstractFloatingViewHelper: AbstractFloatingViewHelper,
+) :
+ SystemShortcut<RecentsViewContainer>(
+ R.drawable.ic_aspect_ratio,
+ R.string.recent_task_option_aspect_ratio,
+ viewContainer,
+ taskContainer.itemInfo,
+ taskContainer.taskView,
+ abstractFloatingViewHelper,
+ ) {
+ override fun onClick(view: View) {
+ dismissTaskMenuView()
+
+ val intent =
+ Intent(Settings.ACTION_MANAGE_USER_ASPECT_RATIO_SETTINGS)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ if (mItemInfo.targetPackage != null) {
+ intent.setData(("package:" + mItemInfo.targetPackage).toUri())
+ }
+
+ mTarget.startActivitySafely(view, intent, mItemInfo)
+ mTarget
+ .statsLogManager
+ .logger()
+ .withItemInfo(mItemInfo)
+ .log(LauncherEvent.LAUNCHER_ASPECT_RATIO_SETTINGS_SYSTEM_SHORTCUT_TAP)
+ }
+
+ companion object {
+ /** Optionally create a factory for the aspect ratio system shortcut. */
+ @JvmOverloads
+ fun createFactory(
+ abstractFloatingViewHelper: AbstractFloatingViewHelper = AbstractFloatingViewHelper()
+ ): TaskShortcutFactory {
+ return object : TaskShortcutFactory {
+ override fun getShortcuts(
+ viewContainer: RecentsViewContainer,
+ taskContainer: TaskContainer,
+ ): List<AspectRatioSystemShortcut>? {
+ return when {
+ // Only available when the feature flag is on.
+ !universalResizableByDefault() -> null
+
+ // The option is only shown on sw600dp+ screens (checked by isTablet)
+ !viewContainer.deviceProfile.isTablet -> null
+
+ else -> {
+ listOf(
+ AspectRatioSystemShortcut(
+ viewContainer,
+ taskContainer,
+ abstractFloatingViewHelper,
+ )
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index ae6bfbc517..5bf4451fad 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -118,6 +118,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
TaskShortcutFactory.FREE_FORM,
DesktopSystemShortcut.Companion.createFactory(),
ExternalDisplaySystemShortcut.Companion.createFactory(),
+ AspectRatioSystemShortcut.Companion.createFactory(),
TaskShortcutFactory.WELLBEING,
TaskShortcutFactory.SAVE_APP_PAIR,
TaskShortcutFactory.SCREENSHOT,