blob: fc7ff709f0334664848b141a648d0678470d0b25 [file] [log] [blame]
Adam Cohen9211d422014-10-07 18:14:53 -07001package 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;
Adam Cohenc2d6e892014-10-16 09:49:24 -07009import android.view.ViewGroup;
Winson Chungef7f8742015-06-04 17:18:17 -070010import com.android.launcher3.allapps.AllAppsSearchBarController;
Hyunyoung Song8fd5e932016-03-08 16:55:47 -080011import com.android.launcher3.logging.UserEventLogger;
Winson Chung6b1c73f2015-06-18 11:38:42 -070012import com.android.launcher3.util.ComponentKey;
Adam Cohen9211d422014-10-07 18:14:53 -070013
14import java.io.FileDescriptor;
15import java.io.PrintWriter;
16import java.util.ArrayList;
Winson Chung4ac30062015-05-08 17:34:17 -070017import java.util.List;
Adam Cohen9211d422014-10-07 18:14:53 -070018
19/**
20 * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
21 * in order to add additional functionality. Some of these are very general, and give extending
22 * classes the ability to react to Activity life-cycle or specific user interactions. Others
23 * are more specific and relate to replacing parts of the application, for example, the search
24 * interface or the wallpaper picker.
25 */
26public interface LauncherCallbacks {
27
28 /*
29 * Activity life-cycle methods. These methods are triggered after
30 * the code in the corresponding Launcher method is executed.
31 */
32 public void preOnCreate();
33 public void onCreate(Bundle savedInstanceState);
34 public void preOnResume();
35 public void onResume();
36 public void onStart();
37 public void onStop();
38 public void onPause();
39 public void onDestroy();
40 public void onSaveInstanceState(Bundle outState);
41 public void onPostCreate(Bundle savedInstanceState);
42 public void onNewIntent(Intent intent);
43 public void onActivityResult(int requestCode, int resultCode, Intent data);
Dave Hawkey3a43ed62015-06-26 10:27:47 -060044 public void onRequestPermissionsResult(int requestCode, String[] permissions,
45 int[] grantResults);
Adam Cohen9211d422014-10-07 18:14:53 -070046 public void onWindowFocusChanged(boolean hasFocus);
Sunny Goyalc86df472016-02-25 09:19:38 -080047 public void onAttachedToWindow();
48 public void onDetachedFromWindow();
Adam Cohen9211d422014-10-07 18:14:53 -070049 public boolean onPrepareOptionsMenu(Menu menu);
50 public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
51 public void onHomeIntent();
52 public boolean handleBackPressed();
Robert Kozikowski67c30862015-03-30 23:46:46 +010053 public void onTrimMemory(int level);
Adam Cohen9211d422014-10-07 18:14:53 -070054
55 /*
56 * Extension points for providing custom behavior on certain user interactions.
57 */
58 public void onLauncherProviderChange();
59 public void finishBindingItems(final boolean upgradePath);
Adam Cohen9211d422014-10-07 18:14:53 -070060 public void bindAllApplications(ArrayList<AppInfo> apps);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080061 public void onInteractionBegin();
62 public void onInteractionEnd();
63
64 /**
65 * Extension points for Gel Logging.
66 */
67 @Deprecated
68 public void onClickAllAppsButton(View v);
69 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070070 public void onClickFolderIcon(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080071 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070072 public void onClickAppShortcut(View v);
Winson Chung8f1eff72015-05-28 17:33:40 -070073 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070074 public void onClickPagedViewIcon(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080075 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070076 public void onClickWallpaperPicker(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080077 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070078 public void onClickSettingsButton(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080079 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070080 public void onClickAddWidgetButton(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080081 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070082 public void onPageSwitch(View newPage, int newPageIndex);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080083 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070084 public void onWorkspaceLockedChanged();
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080085 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070086 public void onDragStarted(View view);
Adam Cohen9211d422014-10-07 18:14:53 -070087
Adam Cohen9211d422014-10-07 18:14:53 -070088 public boolean providesSearch();
89 public boolean startSearch(String initialQuery, boolean selectInitialQuery,
90 Bundle appSearchData, Rect sourceBounds);
Sunny Goyalc42ac0a2016-02-18 15:31:55 -080091 @Deprecated
Winson Chungbedf9232015-07-10 12:38:30 -070092 public boolean startSearchFromAllApps(String query);
Adam Cohen9211d422014-10-07 18:14:53 -070093 public boolean hasCustomContentToLeft();
94 public void populateCustomContentContainer();
95 public View getQsbBar();
Tony Wickham775455c2015-10-16 09:49:32 -070096 public Bundle getAdditionalSearchWidgetOptions();
Adam Cohen9211d422014-10-07 18:14:53 -070097
98 /*
99 * Extensions points for adding / replacing some other aspects of the Launcher experience.
100 */
Hyunyoung Song8fd5e932016-03-08 16:55:47 -0800101 public UserEventLogger getLogger();
Adam Cohen9211d422014-10-07 18:14:53 -0700102 public Intent getFirstRunActivity();
103 public boolean hasFirstRunActivity();
104 public boolean hasDismissableIntroScreen();
105 public View getIntroScreen();
106 public boolean shouldMoveToDefaultScreenOnHomeIntent();
107 public boolean hasSettings();
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}