LauncherCallbacks.java revision 8f1eff7b6cc8621888ee46605c32e601f80a890b
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; 10 11import java.io.FileDescriptor; 12import java.io.PrintWriter; 13import java.util.ArrayList; 14import java.util.List; 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 */ 23public 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(); 46 public void onTrimMemory(int level); 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); 54 public void onAllAppsShown(); 55 public void onAllAppsHidden(); 56 public void bindAllApplications(ArrayList<AppInfo> apps); 57 public void onClickFolderIcon(View v); 58 public void onClickAppShortcut(View v); 59 60 @Deprecated 61 public void onClickPagedViewIcon(View v); 62 public void onClickWallpaperPicker(View v); 63 public void onClickSettingsButton(View v); 64 public void onClickAddWidgetButton(View v); 65 public void onPageSwitch(View newPage, int newPageIndex); 66 public void onWorkspaceLockedChanged(); 67 public void onDragStarted(View view); 68 public void onInteractionBegin(); 69 public void onInteractionEnd(); 70 71 /* 72 * Extension points for replacing the search experience 73 */ 74 public boolean forceDisableVoiceButtonProxy(); 75 public boolean providesSearch(); 76 public boolean startSearch(String initialQuery, boolean selectInitialQuery, 77 Bundle appSearchData, Rect sourceBounds); 78 public void startVoice(); 79 public boolean hasCustomContentToLeft(); 80 public void populateCustomContentContainer(); 81 public View getQsbBar(); 82 83 /* 84 * Extensions points for adding / replacing some other aspects of the Launcher experience. 85 */ 86 public Intent getFirstRunActivity(); 87 public boolean hasFirstRunActivity(); 88 public boolean hasDismissableIntroScreen(); 89 public View getIntroScreen(); 90 public boolean shouldMoveToDefaultScreenOnHomeIntent(); 91 public boolean hasSettings(); 92 public ComponentName getWallpaperPickerComponent(); 93 public boolean overrideWallpaperDimensions(); 94 public boolean isLauncherPreinstalled(); 95 public boolean overrideAllAppsSearch(); 96 public List<ComponentName> getPredictedApps(); 97 98 /** 99 * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup, 100 * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}. 101 * 102 * @return true if this launcher extension will provide an overlay 103 */ 104 public boolean hasLauncherOverlay(); 105 106 /** 107 * Handshake to establish an overlay relationship 108 * 109 * @param container Full screen overlay ViewGroup into which custom views can be placed. 110 * @param callbacks A set of callbacks provided by Launcher in relation to the overlay 111 * @return an interface used to make requests and notify the Launcher in relation to the overlay 112 */ 113 public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container, 114 Launcher.LauncherOverlayCallbacks callbacks); 115 116 /** 117 * Sets the callbacks to allow any extensions to callback to the launcher. 118 * 119 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherAppsCallback, but 120 * for implementation purposes is passed around as an object. 121 */ 122 public void setLauncherAppsCallback(Object callbacks); 123 124 /** 125 * Sets the callbacks to allow reacting the actions of search overlays of the launcher. 126 * 127 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback, 128 * but for implementation purposes is passed around as an object. 129 */ 130 public void setLauncherSearchCallback(Object callbacks); 131} 132