LauncherCallbacks.java revision 775455c4a8266655bf43b943e969d42ac32609ec
1package 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; 9import android.view.ViewGroup; 10import com.android.launcher3.allapps.AllAppsSearchBarController; 11import com.android.launcher3.util.ComponentKey; 12 13import java.io.FileDescriptor; 14import java.io.PrintWriter; 15import java.util.ArrayList; 16import java.util.List; 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 */ 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); 43 public void onRequestPermissionsResult(int requestCode, String[] permissions, 44 int[] grantResults); 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(); 50 public void onTrimMemory(int level); 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); 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); 61 @Deprecated 62 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 */ 75 @Deprecated 76 public boolean forceDisableVoiceButtonProxy(); 77 public boolean providesSearch(); 78 public boolean startSearch(String initialQuery, boolean selectInitialQuery, 79 Bundle appSearchData, Rect sourceBounds); 80 public boolean startSearchFromAllApps(String query); 81 @Deprecated 82 public void startVoice(); 83 public boolean hasCustomContentToLeft(); 84 public void populateCustomContentContainer(); 85 public View getQsbBar(); 86 public Bundle getAdditionalSearchWidgetOptions(); 87 88 /* 89 * Extensions points for adding / replacing some other aspects of the Launcher experience. 90 */ 91 public Intent getFirstRunActivity(); 92 public boolean hasFirstRunActivity(); 93 public boolean hasDismissableIntroScreen(); 94 public View getIntroScreen(); 95 public boolean shouldMoveToDefaultScreenOnHomeIntent(); 96 public boolean hasSettings(); 97 @Deprecated 98 public ComponentName getWallpaperPickerComponent(); 99 public boolean overrideWallpaperDimensions(); 100 public boolean isLauncherPreinstalled(); 101 public AllAppsSearchBarController getAllAppsSearchBarController(); 102 public List<ComponentKey> getPredictedApps(); 103 public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1; 104 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */ 105 public int getSearchBarHeight(); 106 107 /** 108 * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup, 109 * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}. 110 * 111 * @return true if this launcher extension will provide an overlay 112 */ 113 public boolean hasLauncherOverlay(); 114 115 /** 116 * Handshake to establish an overlay relationship 117 * 118 * @param container Full screen overlay ViewGroup into which custom views can be placed. 119 * @param callbacks A set of callbacks provided by Launcher in relation to the overlay 120 * @return an interface used to make requests and notify the Launcher in relation to the overlay 121 */ 122 public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container, 123 Launcher.LauncherOverlayCallbacks callbacks); 124 125 /** 126 * Sets the callbacks to allow reacting the actions of search overlays of the launcher. 127 * 128 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback, 129 * but for implementation purposes is passed around as an object. 130 */ 131 public void setLauncherSearchCallback(Object callbacks); 132} 133