1 /*
2  * Copyright (C) 2016 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;
18 
19 import android.content.Intent;
20 import android.graphics.Rect;
21 import android.os.Bundle;
22 import android.view.Menu;
23 import android.view.View;
24 
25 import com.android.launcher3.allapps.AllAppsSearchBarController;
26 import com.android.launcher3.logging.UserEventDispatcher;
27 import com.android.launcher3.util.ComponentKey;
28 
29 import java.io.FileDescriptor;
30 import java.io.PrintWriter;
31 import java.util.ArrayList;
32 import java.util.List;
33 
34 /**
35  * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
36  * in order to add additional functionality. Some of these are very general, and give extending
37  * classes the ability to react to Activity life-cycle or specific user interactions. Others
38  * are more specific and relate to replacing parts of the application, for example, the search
39  * interface or the wallpaper picker.
40  */
41 public interface LauncherCallbacks {
42 
43     /*
44      * Activity life-cycle methods. These methods are triggered after
45      * the code in the corresponding Launcher method is executed.
46      */
preOnCreate()47     public void preOnCreate();
onCreate(Bundle savedInstanceState)48     public void onCreate(Bundle savedInstanceState);
preOnResume()49     public void preOnResume();
onResume()50     public void onResume();
onStart()51     public void onStart();
onStop()52     public void onStop();
onPause()53     public void onPause();
onDestroy()54     public void onDestroy();
onSaveInstanceState(Bundle outState)55     public void onSaveInstanceState(Bundle outState);
onPostCreate(Bundle savedInstanceState)56     public void onPostCreate(Bundle savedInstanceState);
onNewIntent(Intent intent)57     public void onNewIntent(Intent intent);
onActivityResult(int requestCode, int resultCode, Intent data)58     public void onActivityResult(int requestCode, int resultCode, Intent data);
onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)59     public void onRequestPermissionsResult(int requestCode, String[] permissions,
60             int[] grantResults);
onWindowFocusChanged(boolean hasFocus)61     public void onWindowFocusChanged(boolean hasFocus);
onAttachedToWindow()62     public void onAttachedToWindow();
onDetachedFromWindow()63     public void onDetachedFromWindow();
onPrepareOptionsMenu(Menu menu)64     public boolean onPrepareOptionsMenu(Menu menu);
dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args)65     public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
onHomeIntent()66     public void onHomeIntent();
handleBackPressed()67     public boolean handleBackPressed();
onTrimMemory(int level)68     public void onTrimMemory(int level);
69 
70     /*
71      * Extension points for providing custom behavior on certain user interactions.
72      */
onLauncherProviderChange()73     public void onLauncherProviderChange();
finishBindingItems(final boolean upgradePath)74     public void finishBindingItems(final boolean upgradePath);
bindAllApplications(ArrayList<AppInfo> apps)75     public void bindAllApplications(ArrayList<AppInfo> apps);
onInteractionBegin()76     public void onInteractionBegin();
onInteractionEnd()77     public void onInteractionEnd();
78 
79     @Deprecated
onWorkspaceLockedChanged()80     public void onWorkspaceLockedChanged();
81 
82     /**
83      * Starts a search with {@param initialQuery}. Return false if search was not started.
84      */
startSearch( String initialQuery, boolean selectInitialQuery, Bundle appSearchData)85     public boolean startSearch(
86             String initialQuery, boolean selectInitialQuery, Bundle appSearchData);
hasCustomContentToLeft()87     public boolean hasCustomContentToLeft();
populateCustomContentContainer()88     public void populateCustomContentContainer();
getQsbBar()89     public View getQsbBar();
getAdditionalSearchWidgetOptions()90     public Bundle getAdditionalSearchWidgetOptions();
91 
92     /*
93      * Extensions points for adding / replacing some other aspects of the Launcher experience.
94      */
shouldMoveToDefaultScreenOnHomeIntent()95     public boolean shouldMoveToDefaultScreenOnHomeIntent();
hasSettings()96     public boolean hasSettings();
getAllAppsSearchBarController()97     public AllAppsSearchBarController getAllAppsSearchBarController();
getPredictedApps()98     public List<ComponentKey> getPredictedApps();
99     public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1;
100     /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
getSearchBarHeight()101     public int getSearchBarHeight();
102 
103     /**
104      * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
105      *
106      * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
107      *                  but for implementation purposes is passed around as an object.
108      */
setLauncherSearchCallback(Object callbacks)109     public void setLauncherSearchCallback(Object callbacks);
110 
shouldShowDiscoveryBounce()111     public boolean shouldShowDiscoveryBounce();
112 }
113