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; |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 10 | |
| 11 | import java.io.FileDescriptor; |
| 12 | import java.io.PrintWriter; |
| 13 | import java.util.ArrayList; |
Winson Chung | 4ac3006 | 2015-05-08 17:34:17 -0700 | [diff] [blame^] | 14 | import java.util.List; |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks |
| 18 | * in order to add additional functionality. Some of these are very general, and give extending |
| 19 | * classes the ability to react to Activity life-cycle or specific user interactions. Others |
| 20 | * are more specific and relate to replacing parts of the application, for example, the search |
| 21 | * interface or the wallpaper picker. |
| 22 | */ |
| 23 | public interface LauncherCallbacks { |
| 24 | |
| 25 | /* |
| 26 | * Activity life-cycle methods. These methods are triggered after |
| 27 | * the code in the corresponding Launcher method is executed. |
| 28 | */ |
| 29 | public void preOnCreate(); |
| 30 | public void onCreate(Bundle savedInstanceState); |
| 31 | public void preOnResume(); |
| 32 | public void onResume(); |
| 33 | public void onStart(); |
| 34 | public void onStop(); |
| 35 | public void onPause(); |
| 36 | public void onDestroy(); |
| 37 | public void onSaveInstanceState(Bundle outState); |
| 38 | public void onPostCreate(Bundle savedInstanceState); |
| 39 | public void onNewIntent(Intent intent); |
| 40 | public void onActivityResult(int requestCode, int resultCode, Intent data); |
| 41 | public void onWindowFocusChanged(boolean hasFocus); |
| 42 | public boolean onPrepareOptionsMenu(Menu menu); |
| 43 | public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args); |
| 44 | public void onHomeIntent(); |
| 45 | public boolean handleBackPressed(); |
Robert Kozikowski | 67c3086 | 2015-03-30 23:46:46 +0100 | [diff] [blame] | 46 | public void onTrimMemory(int level); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * Extension points for providing custom behavior on certain user interactions. |
| 50 | */ |
| 51 | public void onLauncherProviderChange(); |
| 52 | public void finishBindingItems(final boolean upgradePath); |
| 53 | public void onClickAllAppsButton(View v); |
Winson Chung | 0f78572 | 2015-04-08 10:27:49 -0700 | [diff] [blame] | 54 | public void onAllAppsShown(); |
Winson Chung | cd99cd3 | 2015-04-29 11:03:24 -0700 | [diff] [blame] | 55 | public void onAllAppsHidden(); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 56 | public void bindAllApplications(ArrayList<AppInfo> apps); |
| 57 | public void onClickFolderIcon(View v); |
| 58 | public void onClickAppShortcut(View v); |
| 59 | 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(); |
| 90 | public ComponentName getWallpaperPickerComponent(); |
| 91 | public boolean overrideWallpaperDimensions(); |
| 92 | public boolean isLauncherPreinstalled(); |
Winson Chung | 0f78572 | 2015-04-08 10:27:49 -0700 | [diff] [blame] | 93 | public boolean overrideAllAppsSearch(); |
Winson Chung | 4ac3006 | 2015-05-08 17:34:17 -0700 | [diff] [blame^] | 94 | public List<ComponentName> getPredictedApps(); |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 95 | |
Adam Cohen | c2d6e89 | 2014-10-16 09:49:24 -0700 | [diff] [blame] | 96 | /** |
| 97 | * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup, |
| 98 | * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}. |
| 99 | * |
| 100 | * @return true if this launcher extension will provide an overlay |
| 101 | */ |
| 102 | public boolean hasLauncherOverlay(); |
| 103 | |
| 104 | /** |
| 105 | * Handshake to establish an overlay relationship |
| 106 | * |
Adam Cohen | a6d0492 | 2014-10-23 17:28:30 -0700 | [diff] [blame] | 107 | * @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] | 108 | * @param callbacks A set of callbacks provided by Launcher in relation to the overlay |
| 109 | * @return an interface used to make requests and notify the Launcher in relation to the overlay |
| 110 | */ |
Adam Cohen | a6d0492 | 2014-10-23 17:28:30 -0700 | [diff] [blame] | 111 | public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container, |
Adam Cohen | c2d6e89 | 2014-10-16 09:49:24 -0700 | [diff] [blame] | 112 | Launcher.LauncherOverlayCallbacks callbacks); |
| 113 | |
Winson Chung | 0f78572 | 2015-04-08 10:27:49 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Sets the callbacks to allow any extensions to callback to the launcher. |
| 116 | * |
| 117 | * @param callbacks A set of callbacks to the Launcher, is actually a LauncherAppsCallback, but |
| 118 | * for implementation purposes is passed around as an object. |
| 119 | */ |
| 120 | public void setLauncherAppsCallback(Object callbacks); |
| 121 | |
Adam Cohen | 9211d42 | 2014-10-07 18:14:53 -0700 | [diff] [blame] | 122 | } |