• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.allapps
18 
19 import android.content.Context
20 import android.view.View
21 import com.android.launcher3.R
22 import com.android.launcher3.allapps.AllAppsTransitionListener
23 import com.android.launcher3.anim.PendingAnimation
24 import com.android.launcher3.dragndrop.DragOptions.PreDragCondition
25 import com.android.launcher3.model.data.ItemInfo
26 import com.android.launcher3.util.ResourceBasedOverride
27 import com.android.launcher3.util.ResourceBasedOverride.Overrides
28 
29 /** Stub for managing the Taskbar search session. */
30 open class TaskbarSearchSessionController : ResourceBasedOverride, AllAppsTransitionListener {
31 
32     /** Start the search session lifecycle. */
startLifecyclenull33     open fun startLifecycle() = Unit
34 
35     /** Destroy the search session. */
36     open fun onDestroy() = Unit
37 
38     /** Updates the predicted items shown in the zero-state. */
39     open fun setZeroStatePredictedItems(items: List<ItemInfo>) = Unit
40 
41     /** Updates the search suggestions shown in the zero-state. */
42     open fun setZeroStateSearchSuggestions(items: List<ItemInfo>) = Unit
43 
44     override fun onAllAppsTransitionStart(toAllApps: Boolean) = Unit
45 
46     override fun onAllAppsTransitionEnd(toAllApps: Boolean) = Unit
47 
48     /** Creates a [PreDragCondition] for [view], if it is a search result that requires one. */
49     open fun createPreDragConditionForSearch(view: View): PreDragCondition? = null
50 
51     open fun canHandleBackInvoked(): Boolean = false
52 
53     open fun handleBackInvoked(): Boolean = false
54 
55     open fun onAllAppsAnimationPending(
56         animation: PendingAnimation,
57         toAllApps: Boolean,
58         showKeyboard: Boolean,
59     ) = Unit
60 
61     companion object {
62         @JvmStatic
63         fun newInstance(context: Context): TaskbarSearchSessionController =
64             Overrides.getObject(
65                 TaskbarSearchSessionController::class.java,
66                 context,
67                 R.string.taskbar_search_session_controller_class,
68             )
69     }
70 }
71