Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 1 | package com.android.launcher3; |
| 2 | |
| 3 | import android.content.ComponentName; |
| 4 | import android.content.Intent; |
| 5 | import android.graphics.Rect; |
| 6 | import android.os.Bundle; |
| 7 | import android.view.Menu; |
| 8 | import android.view.View; |
Adam Cohen | c2d6e89 | 2014-10-16 09:49:24 -0700 | [diff] [blame] | 9 | import android.view.ViewGroup; |
Winson Chung | ef7f874 | 2015-06-04 17:18:17 -0700 | [diff] [blame] | 10 | import com.android.launcher3.allapps.AllAppsSearchBarController; |
Winson Chung | 6b1c73f | 2015-06-18 11:38:42 -0700 | [diff] [blame] | 11 | import com.android.launcher3.util.ComponentKey; |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 12 | |
| 13 | import java.io.FileDescriptor; |
| 14 | import java.io.PrintWriter; |
| 15 | import java.util.ArrayList; |
Winson Chung | 4ac3006 | 2015-05-08 17:34:17 -0700 | [diff] [blame] | 16 | import java.util.List; |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 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 | */ |
| 25 | public 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 Hawkey | 3a43ed6 | 2015-06-26 10:27:47 -0600 | [diff] [blame] | 43 | public void onRequestPermissionsResult(int requestCode, String[] permissions, |
| 44 | int[] grantResults); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 45 | 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 Kozikowski | 67c3086 | 2015-03-30 23:46:46 +0100 | [diff] [blame] | 50 | public void onTrimMemory(int level); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Extension points for providing custom behavior on certain user interactions. |
| 54 | */ |
| 55 | public void onLauncherProviderChange(); |
| 56 | public void finishBindingItems(final boolean upgradePath); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 57 | public void bindAllApplications(ArrayList<AppInfo> apps); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 58 | public void onInteractionBegin(); |
| 59 | public void onInteractionEnd(); |
| 60 | |
| 61 | /** |
| 62 | * Extension points for Gel Logging. |
| 63 | */ |
| 64 | @Deprecated |
| 65 | public void onClickAllAppsButton(View v); |
| 66 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 67 | public void onClickFolderIcon(View v); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 68 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 69 | public void onClickAppShortcut(View v); |
Winson Chung | 8f1eff7 | 2015-05-28 17:33:40 -0700 | [diff] [blame] | 70 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 71 | public void onClickPagedViewIcon(View v); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 72 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 73 | public void onClickWallpaperPicker(View v); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 74 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 75 | public void onClickSettingsButton(View v); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 76 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 77 | public void onClickAddWidgetButton(View v); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 78 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 79 | public void onPageSwitch(View newPage, int newPageIndex); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 80 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 81 | public void onWorkspaceLockedChanged(); |
Hyunyoung Song | fbf19cc | 2016-02-19 12:14:47 -0800 | [diff] [blame^] | 82 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 83 | public void onDragStarted(View view); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * Extension points for replacing the search experience |
| 87 | */ |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 88 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 89 | public boolean forceDisableVoiceButtonProxy(); |
| 90 | public boolean providesSearch(); |
| 91 | public boolean startSearch(String initialQuery, boolean selectInitialQuery, |
| 92 | Bundle appSearchData, Rect sourceBounds); |
Sunny Goyal | c42ac0a | 2016-02-18 15:31:55 -0800 | [diff] [blame] | 93 | @Deprecated |
Winson Chung | bedf923 | 2015-07-10 12:38:30 -0700 | [diff] [blame] | 94 | public boolean startSearchFromAllApps(String query); |
Winson Chung | b177744 | 2015-06-16 13:35:04 -0700 | [diff] [blame] | 95 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 96 | public void startVoice(); |
| 97 | public boolean hasCustomContentToLeft(); |
| 98 | public void populateCustomContentContainer(); |
| 99 | public View getQsbBar(); |
Tony Wickham | 775455c | 2015-10-16 09:49:32 -0700 | [diff] [blame] | 100 | public Bundle getAdditionalSearchWidgetOptions(); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 101 | |
| 102 | /* |
| 103 | * Extensions points for adding / replacing some other aspects of the Launcher experience. |
| 104 | */ |
| 105 | public Intent getFirstRunActivity(); |
| 106 | public boolean hasFirstRunActivity(); |
| 107 | public boolean hasDismissableIntroScreen(); |
| 108 | public View getIntroScreen(); |
| 109 | public boolean shouldMoveToDefaultScreenOnHomeIntent(); |
| 110 | public boolean hasSettings(); |
Winson Chung | ef7f874 | 2015-06-04 17:18:17 -0700 | [diff] [blame] | 111 | @Deprecated |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 112 | public ComponentName getWallpaperPickerComponent(); |
| 113 | public boolean overrideWallpaperDimensions(); |
| 114 | public boolean isLauncherPreinstalled(); |
Winson Chung | ef7f874 | 2015-06-04 17:18:17 -0700 | [diff] [blame] | 115 | public AllAppsSearchBarController getAllAppsSearchBarController(); |
Winson Chung | 6b1c73f | 2015-06-18 11:38:42 -0700 | [diff] [blame] | 116 | public List<ComponentKey> getPredictedApps(); |
Tony Wickham | 55616cd | 2015-09-23 14:55:17 -0700 | [diff] [blame] | 117 | public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1; |
| 118 | /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */ |
| 119 | public int getSearchBarHeight(); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 120 | |
Adam Cohen | c2d6e89 | 2014-10-16 09:49:24 -0700 | [diff] [blame] | 121 | /** |
| 122 | * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup, |
| 123 | * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}. |
| 124 | * |
| 125 | * @return true if this launcher extension will provide an overlay |
| 126 | */ |
| 127 | public boolean hasLauncherOverlay(); |
| 128 | |
| 129 | /** |
| 130 | * Handshake to establish an overlay relationship |
| 131 | * |
Adam Cohen | a6d0492 | 2014-10-23 17:28:30 -0700 | [diff] [blame] | 132 | * @param container Full screen overlay ViewGroup into which custom views can be placed. |
Adam Cohen | c2d6e89 | 2014-10-16 09:49:24 -0700 | [diff] [blame] | 133 | * @param callbacks A set of callbacks provided by Launcher in relation to the overlay |
| 134 | * @return an interface used to make requests and notify the Launcher in relation to the overlay |
| 135 | */ |
Adam Cohen | a6d0492 | 2014-10-23 17:28:30 -0700 | [diff] [blame] | 136 | public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container, |
Adam Cohen | c2d6e89 | 2014-10-16 09:49:24 -0700 | [diff] [blame] | 137 | Launcher.LauncherOverlayCallbacks callbacks); |
| 138 | |
Winson Chung | 0f78572 | 2015-04-08 10:27:49 -0700 | [diff] [blame] | 139 | /** |
Jun Mukai | 8af0cd8 | 2015-05-12 12:32:12 -0700 | [diff] [blame] | 140 | * Sets the callbacks to allow reacting the actions of search overlays of the launcher. |
| 141 | * |
| 142 | * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback, |
| 143 | * but for implementation purposes is passed around as an object. |
| 144 | */ |
| 145 | public void setLauncherSearchCallback(Object callbacks); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 146 | } |