1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.launcher3; 18 19 import android.content.Intent; 20 import android.os.Bundle; 21 import android.view.Menu; 22 import android.view.View; 23 24 import com.android.launcher3.util.ComponentKeyMapper; 25 26 import java.io.FileDescriptor; 27 import java.io.PrintWriter; 28 import java.util.ArrayList; 29 import java.util.List; 30 31 /** 32 * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks 33 * in order to add additional functionality. Some of these are very general, and give extending 34 * classes the ability to react to Activity life-cycle or specific user interactions. Others 35 * are more specific and relate to replacing parts of the application, for example, the search 36 * interface or the wallpaper picker. 37 */ 38 public interface LauncherCallbacks { 39 40 /* 41 * Activity life-cycle methods. These methods are triggered after 42 * the code in the corresponding Launcher method is executed. 43 */ 44 void preOnCreate(); 45 void onCreate(Bundle savedInstanceState); 46 void preOnResume(); 47 void onResume(); 48 void onStart(); 49 void onStop(); 50 void onPause(); 51 void onDestroy(); 52 void onSaveInstanceState(Bundle outState); 53 void onPostCreate(Bundle savedInstanceState); 54 void onNewIntent(Intent intent); 55 void onActivityResult(int requestCode, int resultCode, Intent data); 56 void onRequestPermissionsResult(int requestCode, String[] permissions, 57 int[] grantResults); 58 void onWindowFocusChanged(boolean hasFocus); 59 void onAttachedToWindow(); 60 void onDetachedFromWindow(); 61 boolean onPrepareOptionsMenu(Menu menu); 62 void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args); 63 void onHomeIntent(); 64 boolean handleBackPressed(); 65 void onTrimMemory(int level); 66 67 /* 68 * Extension points for providing custom behavior on certain user interactions. 69 */ 70 void onLauncherProviderChange(); 71 void finishBindingItems(final boolean upgradePath); 72 void bindAllApplications(ArrayList<AppInfo> apps); 73 void onInteractionBegin(); 74 void onInteractionEnd(); 75 76 @Deprecated 77 void onWorkspaceLockedChanged(); 78 79 /** 80 * Starts a search with {@param initialQuery}. Return false if search was not started. 81 */ 82 boolean startSearch( 83 String initialQuery, boolean selectInitialQuery, Bundle appSearchData); 84 boolean hasCustomContentToLeft(); 85 void populateCustomContentContainer(); 86 View getQsbBar(); 87 Bundle getAdditionalSearchWidgetOptions(); 88 89 /* 90 * Extensions points for adding / replacing some other aspects of the Launcher experience. 91 */ 92 boolean shouldMoveToDefaultScreenOnHomeIntent(); 93 boolean hasSettings(); 94 List<ComponentKeyMapper<AppInfo>> getPredictedApps(); 95 int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1; 96 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */ 97 int getSearchBarHeight(); 98 } 99