• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.launcher3.taskbar
18 
19 import android.content.Context
20 import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK
21 import android.view.View
22 import com.android.launcher3.AbstractFloatingView
23 import com.android.launcher3.R
24 import com.android.launcher3.model.data.ItemInfo
25 import com.android.launcher3.popup.SystemShortcut
26 import com.android.launcher3.views.ActivityContext
27 
28 /**
29  * A single menu item shortcut to execute creating a new instance of an app. Default interaction for
30  * [onClick] is to launch the app in full screen or as a floating window in Desktop Mode.
31  */
32 class NewWindowTaskbarShortcut<T>(target: T, itemInfo: ItemInfo?, originalView: View?) :
33     SystemShortcut<T>(
34         R.drawable.desktop_mode_ic_taskbar_menu_new_window,
35         R.string.new_window_option_taskbar,
36         target,
37         itemInfo,
38         originalView
39     ) where T : Context?, T : ActivityContext? {
40 
onClicknull41     override fun onClick(v: View?) {
42         val intent = mItemInfo.intent ?: return
43         intent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK)
44         mTarget?.startActivitySafely(v, intent, mItemInfo)
45         AbstractFloatingView.closeAllOpenViews(mTarget)
46     }
47 }
48