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 */ preOnCreate()44 void preOnCreate(); onCreate(Bundle savedInstanceState)45 void onCreate(Bundle savedInstanceState); preOnResume()46 void preOnResume(); onResume()47 void onResume(); onStart()48 void onStart(); onStop()49 void onStop(); onPause()50 void onPause(); onDestroy()51 void onDestroy(); onSaveInstanceState(Bundle outState)52 void onSaveInstanceState(Bundle outState); onPostCreate(Bundle savedInstanceState)53 void onPostCreate(Bundle savedInstanceState); onNewIntent(Intent intent)54 void onNewIntent(Intent intent); onActivityResult(int requestCode, int resultCode, Intent data)55 void onActivityResult(int requestCode, int resultCode, Intent data); onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)56 void onRequestPermissionsResult(int requestCode, String[] permissions, 57 int[] grantResults); onWindowFocusChanged(boolean hasFocus)58 void onWindowFocusChanged(boolean hasFocus); onAttachedToWindow()59 void onAttachedToWindow(); onDetachedFromWindow()60 void onDetachedFromWindow(); onPrepareOptionsMenu(Menu menu)61 boolean onPrepareOptionsMenu(Menu menu); dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args)62 void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args); onHomeIntent()63 void onHomeIntent(); handleBackPressed()64 boolean handleBackPressed(); onTrimMemory(int level)65 void onTrimMemory(int level); 66 67 /* 68 * Extension points for providing custom behavior on certain user interactions. 69 */ onLauncherProviderChange()70 void onLauncherProviderChange(); finishBindingItems(final boolean upgradePath)71 void finishBindingItems(final boolean upgradePath); bindAllApplications(ArrayList<AppInfo> apps)72 void bindAllApplications(ArrayList<AppInfo> apps); onInteractionBegin()73 void onInteractionBegin(); onInteractionEnd()74 void onInteractionEnd(); 75 76 @Deprecated onWorkspaceLockedChanged()77 void onWorkspaceLockedChanged(); 78 79 /** 80 * Starts a search with {@param initialQuery}. Return false if search was not started. 81 */ startSearch( String initialQuery, boolean selectInitialQuery, Bundle appSearchData)82 boolean startSearch( 83 String initialQuery, boolean selectInitialQuery, Bundle appSearchData); hasCustomContentToLeft()84 boolean hasCustomContentToLeft(); populateCustomContentContainer()85 void populateCustomContentContainer(); getQsbBar()86 View getQsbBar(); getAdditionalSearchWidgetOptions()87 Bundle getAdditionalSearchWidgetOptions(); 88 89 /* 90 * Extensions points for adding / replacing some other aspects of the Launcher experience. 91 */ shouldMoveToDefaultScreenOnHomeIntent()92 boolean shouldMoveToDefaultScreenOnHomeIntent(); hasSettings()93 boolean hasSettings(); getPredictedApps()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} */ getSearchBarHeight()97 int getSearchBarHeight(); 98 } 99