• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.quickstep;
18 
19 import android.graphics.Matrix;
20 import android.view.View;
21 
22 import com.android.launcher3.BaseActivity;
23 import com.android.launcher3.BaseDraggingActivity;
24 import com.android.launcher3.R;
25 import com.android.launcher3.util.MainThreadInitializedObject;
26 import com.android.launcher3.util.ResourceBasedOverride;
27 import com.android.quickstep.views.TaskThumbnailView;
28 import com.android.quickstep.views.TaskView;
29 import com.android.systemui.shared.recents.model.Task;
30 import com.android.systemui.shared.recents.model.ThumbnailData;
31 
32 import java.util.ArrayList;
33 import java.util.List;
34 
35 /**
36  * Factory class to create and add an overlays on the TaskView
37  */
38 public class TaskOverlayFactory implements ResourceBasedOverride {
39 
40     /** Note that these will be shown in order from top to bottom, if available for the task. */
41     private static final TaskSystemShortcut[] MENU_OPTIONS = new TaskSystemShortcut[]{
42             new TaskSystemShortcut.AppInfo(),
43             new TaskSystemShortcut.SplitScreen(),
44             new TaskSystemShortcut.Pin(),
45             new TaskSystemShortcut.Install(),
46             new TaskSystemShortcut.Freeform()
47     };
48 
49     public static final MainThreadInitializedObject<TaskOverlayFactory> INSTANCE =
50             new MainThreadInitializedObject<>(c -> Overrides.getObject(TaskOverlayFactory.class,
51                     c, R.string.task_overlay_factory_class));
52 
getEnabledShortcuts(TaskView taskView)53     public List<TaskSystemShortcut> getEnabledShortcuts(TaskView taskView) {
54         final ArrayList<TaskSystemShortcut> shortcuts = new ArrayList<>();
55         final BaseDraggingActivity activity = BaseActivity.fromContext(taskView.getContext());
56         for (TaskSystemShortcut menuOption : MENU_OPTIONS) {
57             View.OnClickListener onClickListener =
58                     menuOption.getOnClickListener(activity, taskView);
59             if (onClickListener != null) {
60                 shortcuts.add(menuOption);
61             }
62         }
63         return shortcuts;
64     }
65 
createOverlay(TaskThumbnailView thumbnailView)66     public TaskOverlay createOverlay(TaskThumbnailView thumbnailView) {
67         return new TaskOverlay();
68     }
69 
70     public static class TaskOverlay {
71 
72         /**
73          * Called when the current task is interactive for the user
74          */
initOverlay(Task task, ThumbnailData thumbnail, Matrix matrix)75         public void initOverlay(Task task, ThumbnailData thumbnail, Matrix matrix) { }
76 
77         /**
78          * Called when the overlay is no longer used.
79          */
reset()80         public void reset() { }
81     }
82 }
83