blob: e73275400a8d8900d1878aba13c8ebbd75d28a65 [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;
Adam Cohen9211d422014-10-07 18:14:53 -070011
12import java.io.FileDescriptor;
13import java.io.PrintWriter;
14import java.util.ArrayList;
Winson Chung4ac30062015-05-08 17:34:17 -070015import java.util.List;
Adam Cohen9211d422014-10-07 18:14:53 -070016
17/**
18 * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
19 * in order to add additional functionality. Some of these are very general, and give extending
20 * classes the ability to react to Activity life-cycle or specific user interactions. Others
21 * are more specific and relate to replacing parts of the application, for example, the search
22 * interface or the wallpaper picker.
23 */
24public interface LauncherCallbacks {
25
26 /*
27 * Activity life-cycle methods. These methods are triggered after
28 * the code in the corresponding Launcher method is executed.
29 */
30 public void preOnCreate();
31 public void onCreate(Bundle savedInstanceState);
32 public void preOnResume();
33 public void onResume();
34 public void onStart();
35 public void onStop();
36 public void onPause();
37 public void onDestroy();
38 public void onSaveInstanceState(Bundle outState);
39 public void onPostCreate(Bundle savedInstanceState);
40 public void onNewIntent(Intent intent);
41 public void onActivityResult(int requestCode, int resultCode, Intent data);
42 public void onWindowFocusChanged(boolean hasFocus);
43 public boolean onPrepareOptionsMenu(Menu menu);
44 public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
45 public void onHomeIntent();
46 public boolean handleBackPressed();
Robert Kozikowski67c30862015-03-30 23:46:46 +010047 public void onTrimMemory(int level);
Adam Cohen9211d422014-10-07 18:14:53 -070048
49 /*
50 * Extension points for providing custom behavior on certain user interactions.
51 */
52 public void onLauncherProviderChange();
53 public void finishBindingItems(final boolean upgradePath);
54 public void onClickAllAppsButton(View v);
55 public void bindAllApplications(ArrayList<AppInfo> apps);
56 public void onClickFolderIcon(View v);
57 public void onClickAppShortcut(View v);
Winson Chung8f1eff72015-05-28 17:33:40 -070058 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070059 public void onClickPagedViewIcon(View v);
60 public void onClickWallpaperPicker(View v);
61 public void onClickSettingsButton(View v);
62 public void onClickAddWidgetButton(View v);
63 public void onPageSwitch(View newPage, int newPageIndex);
64 public void onWorkspaceLockedChanged();
65 public void onDragStarted(View view);
66 public void onInteractionBegin();
67 public void onInteractionEnd();
68
69 /*
70 * Extension points for replacing the search experience
71 */
72 public boolean forceDisableVoiceButtonProxy();
73 public boolean providesSearch();
74 public boolean startSearch(String initialQuery, boolean selectInitialQuery,
75 Bundle appSearchData, Rect sourceBounds);
76 public void startVoice();
77 public boolean hasCustomContentToLeft();
78 public void populateCustomContentContainer();
79 public View getQsbBar();
80
81 /*
82 * Extensions points for adding / replacing some other aspects of the Launcher experience.
83 */
84 public Intent getFirstRunActivity();
85 public boolean hasFirstRunActivity();
86 public boolean hasDismissableIntroScreen();
87 public View getIntroScreen();
88 public boolean shouldMoveToDefaultScreenOnHomeIntent();
89 public boolean hasSettings();
Winson Chungef7f8742015-06-04 17:18:17 -070090 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070091 public ComponentName getWallpaperPickerComponent();
92 public boolean overrideWallpaperDimensions();
93 public boolean isLauncherPreinstalled();
Winson Chungef7f8742015-06-04 17:18:17 -070094 public AllAppsSearchBarController getAllAppsSearchBarController();
Winson Chung4ac30062015-05-08 17:34:17 -070095 public List<ComponentName> getPredictedApps();
Adam Cohen9211d422014-10-07 18:14:53 -070096
Adam Cohenc2d6e892014-10-16 09:49:24 -070097 /**
98 * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup,
99 * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}.
100 *
101 * @return true if this launcher extension will provide an overlay
102 */
103 public boolean hasLauncherOverlay();
104
105 /**
106 * Handshake to establish an overlay relationship
107 *
Adam Cohena6d04922014-10-23 17:28:30 -0700108 * @param container Full screen overlay ViewGroup into which custom views can be placed.
Adam Cohenc2d6e892014-10-16 09:49:24 -0700109 * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
110 * @return an interface used to make requests and notify the Launcher in relation to the overlay
111 */
Adam Cohena6d04922014-10-23 17:28:30 -0700112 public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
Adam Cohenc2d6e892014-10-16 09:49:24 -0700113 Launcher.LauncherOverlayCallbacks callbacks);
114
Winson Chung0f785722015-04-08 10:27:49 -0700115 /**
Jun Mukai8af0cd82015-05-12 12:32:12 -0700116 * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
117 *
118 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
119 * but for implementation purposes is passed around as an object.
120 */
121 public void setLauncherSearchCallback(Object callbacks);
Adam Cohen9211d422014-10-07 18:14:53 -0700122}