blob: 772fbf358fc6f9e3c972166342117ecf18d7901a [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;
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);
46 public boolean onPrepareOptionsMenu(Menu menu);
47 public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
48 public void onHomeIntent();
49 public boolean handleBackPressed();
Robert Kozikowski67c30862015-03-30 23:46:46 +010050 public void onTrimMemory(int level);
Adam Cohen9211d422014-10-07 18:14:53 -070051
52 /*
53 * Extension points for providing custom behavior on certain user interactions.
54 */
55 public void onLauncherProviderChange();
56 public void finishBindingItems(final boolean upgradePath);
57 public void onClickAllAppsButton(View v);
58 public void bindAllApplications(ArrayList<AppInfo> apps);
59 public void onClickFolderIcon(View v);
60 public void onClickAppShortcut(View v);
Winson Chung8f1eff72015-05-28 17:33:40 -070061 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070062 public void onClickPagedViewIcon(View v);
63 public void onClickWallpaperPicker(View v);
64 public void onClickSettingsButton(View v);
65 public void onClickAddWidgetButton(View v);
66 public void onPageSwitch(View newPage, int newPageIndex);
67 public void onWorkspaceLockedChanged();
68 public void onDragStarted(View view);
69 public void onInteractionBegin();
70 public void onInteractionEnd();
71
72 /*
73 * Extension points for replacing the search experience
74 */
Winson Chungb1777442015-06-16 13:35:04 -070075 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070076 public boolean forceDisableVoiceButtonProxy();
77 public boolean providesSearch();
78 public boolean startSearch(String initialQuery, boolean selectInitialQuery,
79 Bundle appSearchData, Rect sourceBounds);
Sunny Goyalc42ac0a2016-02-18 15:31:55 -080080 @Deprecated
Winson Chungbedf9232015-07-10 12:38:30 -070081 public boolean startSearchFromAllApps(String query);
Winson Chungb1777442015-06-16 13:35:04 -070082 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070083 public void startVoice();
84 public boolean hasCustomContentToLeft();
85 public void populateCustomContentContainer();
86 public View getQsbBar();
Tony Wickham775455c2015-10-16 09:49:32 -070087 public Bundle getAdditionalSearchWidgetOptions();
Adam Cohen9211d422014-10-07 18:14:53 -070088
89 /*
90 * Extensions points for adding / replacing some other aspects of the Launcher experience.
91 */
92 public Intent getFirstRunActivity();
93 public boolean hasFirstRunActivity();
94 public boolean hasDismissableIntroScreen();
95 public View getIntroScreen();
96 public boolean shouldMoveToDefaultScreenOnHomeIntent();
97 public boolean hasSettings();
Winson Chungef7f8742015-06-04 17:18:17 -070098 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070099 public ComponentName getWallpaperPickerComponent();
100 public boolean overrideWallpaperDimensions();
101 public boolean isLauncherPreinstalled();
Winson Chungef7f8742015-06-04 17:18:17 -0700102 public AllAppsSearchBarController getAllAppsSearchBarController();
Winson Chung6b1c73f2015-06-18 11:38:42 -0700103 public List<ComponentKey> getPredictedApps();
Tony Wickham55616cd2015-09-23 14:55:17 -0700104 public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1;
105 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
106 public int getSearchBarHeight();
Adam Cohen9211d422014-10-07 18:14:53 -0700107
Adam Cohenc2d6e892014-10-16 09:49:24 -0700108 /**
109 * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup,
110 * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}.
111 *
112 * @return true if this launcher extension will provide an overlay
113 */
114 public boolean hasLauncherOverlay();
115
116 /**
117 * Handshake to establish an overlay relationship
118 *
Adam Cohena6d04922014-10-23 17:28:30 -0700119 * @param container Full screen overlay ViewGroup into which custom views can be placed.
Adam Cohenc2d6e892014-10-16 09:49:24 -0700120 * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
121 * @return an interface used to make requests and notify the Launcher in relation to the overlay
122 */
Adam Cohena6d04922014-10-23 17:28:30 -0700123 public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
Adam Cohenc2d6e892014-10-16 09:49:24 -0700124 Launcher.LauncherOverlayCallbacks callbacks);
125
Winson Chung0f785722015-04-08 10:27:49 -0700126 /**
Jun Mukai8af0cd82015-05-12 12:32:12 -0700127 * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
128 *
129 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
130 * but for implementation purposes is passed around as an object.
131 */
132 public void setLauncherSearchCallback(Object callbacks);
Adam Cohen9211d422014-10-07 18:14:53 -0700133}