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; 9 import android.view.ViewGroup; 10 import com.android.launcher3.allapps.AllAppsSearchBarController; 11 import com.android.launcher3.util.ComponentKey; 12 13 import java.io.FileDescriptor; 14 import java.io.PrintWriter; 15 import java.util.ArrayList; 16 import 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 */ 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 */ preOnCreate()31 public void preOnCreate(); onCreate(Bundle savedInstanceState)32 public void onCreate(Bundle savedInstanceState); preOnResume()33 public void preOnResume(); onResume()34 public void onResume(); onStart()35 public void onStart(); onStop()36 public void onStop(); onPause()37 public void onPause(); onDestroy()38 public void onDestroy(); onSaveInstanceState(Bundle outState)39 public void onSaveInstanceState(Bundle outState); onPostCreate(Bundle savedInstanceState)40 public void onPostCreate(Bundle savedInstanceState); onNewIntent(Intent intent)41 public void onNewIntent(Intent intent); onActivityResult(int requestCode, int resultCode, Intent data)42 public void onActivityResult(int requestCode, int resultCode, Intent data); onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)43 public void onRequestPermissionsResult(int requestCode, String[] permissions, 44 int[] grantResults); onWindowFocusChanged(boolean hasFocus)45 public void onWindowFocusChanged(boolean hasFocus); onAttachedToWindow()46 public void onAttachedToWindow(); onDetachedFromWindow()47 public void onDetachedFromWindow(); onPrepareOptionsMenu(Menu menu)48 public boolean onPrepareOptionsMenu(Menu menu); dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args)49 public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args); onHomeIntent()50 public void onHomeIntent(); handleBackPressed()51 public boolean handleBackPressed(); onTrimMemory(int level)52 public void onTrimMemory(int level); 53 54 /* 55 * Extension points for providing custom behavior on certain user interactions. 56 */ onLauncherProviderChange()57 public void onLauncherProviderChange(); finishBindingItems(final boolean upgradePath)58 public void finishBindingItems(final boolean upgradePath); onClickAllAppsButton(View v)59 public void onClickAllAppsButton(View v); bindAllApplications(ArrayList<AppInfo> apps)60 public void bindAllApplications(ArrayList<AppInfo> apps); onClickFolderIcon(View v)61 public void onClickFolderIcon(View v); onClickAppShortcut(View v)62 public void onClickAppShortcut(View v); 63 @Deprecated onClickPagedViewIcon(View v)64 public void onClickPagedViewIcon(View v); onClickWallpaperPicker(View v)65 public void onClickWallpaperPicker(View v); onClickSettingsButton(View v)66 public void onClickSettingsButton(View v); onClickAddWidgetButton(View v)67 public void onClickAddWidgetButton(View v); onPageSwitch(View newPage, int newPageIndex)68 public void onPageSwitch(View newPage, int newPageIndex); onWorkspaceLockedChanged()69 public void onWorkspaceLockedChanged(); onDragStarted(View view)70 public void onDragStarted(View view); onInteractionBegin()71 public void onInteractionBegin(); onInteractionEnd()72 public void onInteractionEnd(); 73 providesSearch()74 public boolean providesSearch(); startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds)75 public boolean startSearch(String initialQuery, boolean selectInitialQuery, 76 Bundle appSearchData, Rect sourceBounds); 77 @Deprecated startSearchFromAllApps(String query)78 public boolean startSearchFromAllApps(String query); hasCustomContentToLeft()79 public boolean hasCustomContentToLeft(); populateCustomContentContainer()80 public void populateCustomContentContainer(); getQsbBar()81 public View getQsbBar(); getAdditionalSearchWidgetOptions()82 public Bundle getAdditionalSearchWidgetOptions(); 83 84 /* 85 * Extensions points for adding / replacing some other aspects of the Launcher experience. 86 */ getFirstRunActivity()87 public Intent getFirstRunActivity(); hasFirstRunActivity()88 public boolean hasFirstRunActivity(); hasDismissableIntroScreen()89 public boolean hasDismissableIntroScreen(); getIntroScreen()90 public View getIntroScreen(); shouldMoveToDefaultScreenOnHomeIntent()91 public boolean shouldMoveToDefaultScreenOnHomeIntent(); hasSettings()92 public boolean hasSettings(); overrideWallpaperDimensions()93 public boolean overrideWallpaperDimensions(); isLauncherPreinstalled()94 public boolean isLauncherPreinstalled(); getAllAppsSearchBarController()95 public AllAppsSearchBarController getAllAppsSearchBarController(); getPredictedApps()96 public List<ComponentKey> getPredictedApps(); 97 public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1; 98 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */ getSearchBarHeight()99 public int getSearchBarHeight(); 100 101 /** 102 * Sets the callbacks to allow reacting the actions of search overlays of the launcher. 103 * 104 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback, 105 * but for implementation purposes is passed around as an object. 106 */ setLauncherSearchCallback(Object callbacks)107 public void setLauncherSearchCallback(Object callbacks); 108 } 109