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 17package com.android.launcher3; 18 19import android.content.Intent; 20import android.graphics.Rect; 21import android.os.Bundle; 22import android.view.Menu; 23import android.view.View; 24 25import com.android.launcher3.allapps.AllAppsSearchBarController; 26import com.android.launcher3.logging.UserEventDispatcher; 27import com.android.launcher3.util.ComponentKey; 28 29import java.io.FileDescriptor; 30import java.io.PrintWriter; 31import java.util.ArrayList; 32import java.util.List; 33 34/** 35 * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks 36 * in order to add additional functionality. Some of these are very general, and give extending 37 * classes the ability to react to Activity life-cycle or specific user interactions. Others 38 * are more specific and relate to replacing parts of the application, for example, the search 39 * interface or the wallpaper picker. 40 */ 41public interface LauncherCallbacks { 42 43 /* 44 * Activity life-cycle methods. These methods are triggered after 45 * the code in the corresponding Launcher method is executed. 46 */ 47 public void preOnCreate(); 48 public void onCreate(Bundle savedInstanceState); 49 public void preOnResume(); 50 public void onResume(); 51 public void onStart(); 52 public void onStop(); 53 public void onPause(); 54 public void onDestroy(); 55 public void onSaveInstanceState(Bundle outState); 56 public void onPostCreate(Bundle savedInstanceState); 57 public void onNewIntent(Intent intent); 58 public void onActivityResult(int requestCode, int resultCode, Intent data); 59 public void onRequestPermissionsResult(int requestCode, String[] permissions, 60 int[] grantResults); 61 public void onWindowFocusChanged(boolean hasFocus); 62 public void onAttachedToWindow(); 63 public void onDetachedFromWindow(); 64 public boolean onPrepareOptionsMenu(Menu menu); 65 public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args); 66 public void onHomeIntent(); 67 public boolean handleBackPressed(); 68 public void onTrimMemory(int level); 69 70 /* 71 * Extension points for providing custom behavior on certain user interactions. 72 */ 73 public void onLauncherProviderChange(); 74 public void finishBindingItems(final boolean upgradePath); 75 public void bindAllApplications(ArrayList<AppInfo> apps); 76 public void onInteractionBegin(); 77 public void onInteractionEnd(); 78 79 @Deprecated 80 public void onWorkspaceLockedChanged(); 81 82 /** 83 * Starts a search with {@param initialQuery}. Return false if search was not started. 84 */ 85 public boolean startSearch( 86 String initialQuery, boolean selectInitialQuery, Bundle appSearchData); 87 public boolean hasCustomContentToLeft(); 88 public void populateCustomContentContainer(); 89 public View getQsbBar(); 90 public Bundle getAdditionalSearchWidgetOptions(); 91 92 /* 93 * Extensions points for adding / replacing some other aspects of the Launcher experience. 94 */ 95 public boolean shouldMoveToDefaultScreenOnHomeIntent(); 96 public boolean hasSettings(); 97 public AllAppsSearchBarController getAllAppsSearchBarController(); 98 public List<ComponentKey> getPredictedApps(); 99 public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1; 100 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */ 101 public int getSearchBarHeight(); 102 103 /** 104 * Sets the callbacks to allow reacting the actions of search overlays of the launcher. 105 * 106 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback, 107 * but for implementation purposes is passed around as an object. 108 */ 109 public void setLauncherSearchCallback(Object callbacks); 110 111 public boolean shouldShowDiscoveryBounce(); 112} 113