Files
Lawnchair/quickstep/src/com/android/launcher3/taskbar/NewWindowTaskbarShortcut.kt
T
Saumya Prakash 8e0ed4b01b Add "New Window" option to Taskbar menu.
This change adds a new menu option to Taskbar that is invoked when long
pressing an icon. It createds a new instance for an app if the app
supports multi instance in Desktop Mode.

Bug: 315344726
Test: Manual
Flag: com.android.launcher3.enable_multi_instance_menu_taskbar
Change-Id: Ibc42fbb1ad485496cd938af730b86e051cea559a
2024-09-19 21:30:43 +00:00

48 lines
1.7 KiB
Kotlin

/*
* 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.
*/
package com.android.launcher3.taskbar
import android.content.Context
import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK
import android.view.View
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.R
import com.android.launcher3.model.data.ItemInfo
import com.android.launcher3.popup.SystemShortcut
import com.android.launcher3.views.ActivityContext
/**
* A single menu item shortcut to execute creating a new instance of an app. Default interaction for
* [onClick] is to launch the app in full screen or as a floating window in Desktop Mode.
*/
class NewWindowTaskbarShortcut<T>(target: T, itemInfo: ItemInfo?, originalView: View?) :
SystemShortcut<T>(
R.drawable.desktop_mode_ic_taskbar_menu_new_window,
R.string.new_window_option_taskbar,
target,
itemInfo,
originalView
) where T : Context?, T : ActivityContext? {
override fun onClick(v: View?) {
val intent = mItemInfo.intent ?: return
intent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK)
mTarget?.startActivitySafely(v, intent, mItemInfo)
AbstractFloatingView.closeAllOpenViews(mTarget)
}
}