blob: f33cf83e849b70893eff933088965a029b6454bc [file] [log] [blame]
Adam Cohen9211d422014-10-07 18:14:53 -07001package com.android.launcher3;
2
Adam Cohen9211d422014-10-07 18:14:53 -07003import android.content.Intent;
4import android.graphics.Rect;
5import android.os.Bundle;
6import android.view.Menu;
7import android.view.View;
Hyunyoung Songddec1c72016-04-12 18:32:04 -07008
Winson Chungef7f8742015-06-04 17:18:17 -07009import com.android.launcher3.allapps.AllAppsSearchBarController;
Hyunyoung Song8fd5e932016-03-08 16:55:47 -080010import com.android.launcher3.logging.UserEventLogger;
Winson Chung6b1c73f2015-06-18 11:38:42 -070011import com.android.launcher3.util.ComponentKey;
Adam Cohen9211d422014-10-07 18:14:53 -070012
13import java.io.FileDescriptor;
14import java.io.PrintWriter;
15import java.util.ArrayList;
Winson Chung4ac30062015-05-08 17:34:17 -070016import java.util.List;
Adam Cohen9211d422014-10-07 18:14:53 -070017
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);
Dave Hawkey3a43ed62015-06-26 10:27:47 -060043 public void onRequestPermissionsResult(int requestCode, String[] permissions,
44 int[] grantResults);
Adam Cohen9211d422014-10-07 18:14:53 -070045 public void onWindowFocusChanged(boolean hasFocus);
Sunny Goyalc86df472016-02-25 09:19:38 -080046 public void onAttachedToWindow();
47 public void onDetachedFromWindow();
Adam Cohen9211d422014-10-07 18:14:53 -070048 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();
Robert Kozikowski67c30862015-03-30 23:46:46 +010052 public void onTrimMemory(int level);
Adam Cohen9211d422014-10-07 18:14:53 -070053
54 /*
55 * Extension points for providing custom behavior on certain user interactions.
56 */
57 public void onLauncherProviderChange();
58 public void finishBindingItems(final boolean upgradePath);
Adam Cohen9211d422014-10-07 18:14:53 -070059 public void bindAllApplications(ArrayList<AppInfo> apps);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080060 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
Adam Cohen9211d422014-10-07 18:14:53 -070069 public void onClickFolderIcon(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080070 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070071 public void onClickAppShortcut(View v);
Winson Chung8f1eff72015-05-28 17:33:40 -070072 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070073 public void onClickPagedViewIcon(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080074 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070075 public void onClickWallpaperPicker(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080076 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070077 public void onClickSettingsButton(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080078 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070079 public void onClickAddWidgetButton(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080080 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070081 public void onPageSwitch(View newPage, int newPageIndex);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080082 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070083 public void onWorkspaceLockedChanged();
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080084 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070085 public void onDragStarted(View view);
Adam Cohen9211d422014-10-07 18:14:53 -070086
Adam Cohen9211d422014-10-07 18:14:53 -070087 public boolean providesSearch();
88 public boolean startSearch(String initialQuery, boolean selectInitialQuery,
89 Bundle appSearchData, Rect sourceBounds);
Sunny Goyalc42ac0a2016-02-18 15:31:55 -080090 @Deprecated
Winson Chungbedf9232015-07-10 12:38:30 -070091 public boolean startSearchFromAllApps(String query);
Adam Cohen9211d422014-10-07 18:14:53 -070092 public boolean hasCustomContentToLeft();
93 public void populateCustomContentContainer();
94 public View getQsbBar();
Tony Wickham775455c2015-10-16 09:49:32 -070095 public Bundle getAdditionalSearchWidgetOptions();
Adam Cohen9211d422014-10-07 18:14:53 -070096
97 /*
98 * Extensions points for adding / replacing some other aspects of the Launcher experience.
99 */
Hyunyoung Song8fd5e932016-03-08 16:55:47 -0800100 public UserEventLogger getLogger();
Adam Cohen9211d422014-10-07 18:14:53 -0700101 public Intent getFirstRunActivity();
102 public boolean hasFirstRunActivity();
103 public boolean hasDismissableIntroScreen();
104 public View getIntroScreen();
105 public boolean shouldMoveToDefaultScreenOnHomeIntent();
106 public boolean hasSettings();
Sunny Goyal6f866092016-03-17 17:04:15 -0700107 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -0700108 public boolean overrideWallpaperDimensions();
109 public boolean isLauncherPreinstalled();
Winson Chungef7f8742015-06-04 17:18:17 -0700110 public AllAppsSearchBarController getAllAppsSearchBarController();
Winson Chung6b1c73f2015-06-18 11:38:42 -0700111 public List<ComponentKey> getPredictedApps();
Tony Wickham55616cd2015-09-23 14:55:17 -0700112 public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1;
113 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
114 public int getSearchBarHeight();
Adam Cohen9211d422014-10-07 18:14:53 -0700115
Adam Cohenc2d6e892014-10-16 09:49:24 -0700116 /**
Jun Mukai8af0cd82015-05-12 12:32:12 -0700117 * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
118 *
119 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
120 * but for implementation purposes is passed around as an object.
121 */
122 public void setLauncherSearchCallback(Object callbacks);
Adam Cohen9211d422014-10-07 18:14:53 -0700123}