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 
11 import java.io.FileDescriptor;
12 import java.io.PrintWriter;
13 import java.util.ArrayList;
14 
15 /**
16  * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
17  * in order to add additional functionality. Some of these are very general, and give extending
18  * classes the ability to react to Activity life-cycle or specific user interactions. Others
19  * are more specific and relate to replacing parts of the application, for example, the search
20  * interface or the wallpaper picker.
21  */
22 public interface LauncherCallbacks {
23 
24     /*
25      * Activity life-cycle methods. These methods are triggered after
26      * the code in the corresponding Launcher method is executed.
27      */
preOnCreate()28     public void preOnCreate();
onCreate(Bundle savedInstanceState)29     public void onCreate(Bundle savedInstanceState);
preOnResume()30     public void preOnResume();
onResume()31     public void onResume();
onStart()32     public void onStart();
onStop()33     public void onStop();
onPause()34     public void onPause();
onDestroy()35     public void onDestroy();
onSaveInstanceState(Bundle outState)36     public void onSaveInstanceState(Bundle outState);
onPostCreate(Bundle savedInstanceState)37     public void onPostCreate(Bundle savedInstanceState);
onNewIntent(Intent intent)38     public void onNewIntent(Intent intent);
onActivityResult(int requestCode, int resultCode, Intent data)39     public void onActivityResult(int requestCode, int resultCode, Intent data);
onWindowFocusChanged(boolean hasFocus)40     public void onWindowFocusChanged(boolean hasFocus);
onPrepareOptionsMenu(Menu menu)41     public boolean onPrepareOptionsMenu(Menu menu);
dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args)42     public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
onHomeIntent()43     public void onHomeIntent();
handleBackPressed()44     public boolean handleBackPressed();
45 
46     /*
47      * Extension points for providing custom behavior on certain user interactions.
48      */
onLauncherProviderChange()49     public void onLauncherProviderChange();
finishBindingItems(final boolean upgradePath)50     public void finishBindingItems(final boolean upgradePath);
onClickAllAppsButton(View v)51     public void onClickAllAppsButton(View v);
bindAllApplications(ArrayList<AppInfo> apps)52     public void bindAllApplications(ArrayList<AppInfo> apps);
onClickFolderIcon(View v)53     public void onClickFolderIcon(View v);
onClickAppShortcut(View v)54     public void onClickAppShortcut(View v);
onClickPagedViewIcon(View v)55     public void onClickPagedViewIcon(View v);
onClickWallpaperPicker(View v)56     public void onClickWallpaperPicker(View v);
onClickSettingsButton(View v)57     public void onClickSettingsButton(View v);
onClickAddWidgetButton(View v)58     public void onClickAddWidgetButton(View v);
onPageSwitch(View newPage, int newPageIndex)59     public void onPageSwitch(View newPage, int newPageIndex);
onWorkspaceLockedChanged()60     public void onWorkspaceLockedChanged();
onDragStarted(View view)61     public void onDragStarted(View view);
onInteractionBegin()62     public void onInteractionBegin();
onInteractionEnd()63     public void onInteractionEnd();
64 
65     /*
66      * Extension points for replacing the search experience
67      */
forceDisableVoiceButtonProxy()68     public boolean forceDisableVoiceButtonProxy();
providesSearch()69     public boolean providesSearch();
startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds)70     public boolean startSearch(String initialQuery, boolean selectInitialQuery,
71             Bundle appSearchData, Rect sourceBounds);
startVoice()72     public void startVoice();
hasCustomContentToLeft()73     public boolean hasCustomContentToLeft();
populateCustomContentContainer()74     public void populateCustomContentContainer();
getQsbBar()75     public View getQsbBar();
76 
77     /*
78      * Extensions points for adding / replacing some other aspects of the Launcher experience.
79      */
getFirstRunActivity()80     public Intent getFirstRunActivity();
hasFirstRunActivity()81     public boolean hasFirstRunActivity();
hasDismissableIntroScreen()82     public boolean hasDismissableIntroScreen();
getIntroScreen()83     public View getIntroScreen();
shouldMoveToDefaultScreenOnHomeIntent()84     public boolean shouldMoveToDefaultScreenOnHomeIntent();
hasSettings()85     public boolean hasSettings();
getWallpaperPickerComponent()86     public ComponentName getWallpaperPickerComponent();
overrideWallpaperDimensions()87     public boolean overrideWallpaperDimensions();
isLauncherPreinstalled()88     public boolean isLauncherPreinstalled();
89 
90     /**
91      * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup,
92      * com.android.launcher3.Launcher.LauncherOverlayCallbacks)}.
93      *
94      * @return true if this launcher extension will provide an overlay
95      */
hasLauncherOverlay()96     public boolean hasLauncherOverlay();
97 
98     /**
99      * Handshake to establish an overlay relationship
100      *
101      * @param container Full screen overlay ViewGroup into which custom views can be placed.
102      * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
103      * @return an interface used to make requests and notify the Launcher in relation to the overlay
104      */
setLauncherOverlayView(InsettableFrameLayout container, Launcher.LauncherOverlayCallbacks callbacks)105     public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
106             Launcher.LauncherOverlayCallbacks callbacks);
107 
108 }
109