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