blob: 34117b6b18827e2782acb4499c11b07e447881f4 [file] [log] [blame]
Adam Cohen79d90c52016-04-22 13:29:20 -07001/*
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
Adam Cohen9211d422014-10-07 18:14:53 -070017package com.android.launcher3;
18
Adam Cohen9211d422014-10-07 18:14:53 -070019import android.content.Intent;
20import android.graphics.Rect;
21import android.os.Bundle;
22import android.view.Menu;
23import android.view.View;
Hyunyoung Songddec1c72016-04-12 18:32:04 -070024
Winson Chungef7f8742015-06-04 17:18:17 -070025import com.android.launcher3.allapps.AllAppsSearchBarController;
Hyunyoung Songaa953652016-04-19 18:30:24 -070026import com.android.launcher3.logging.UserEventDispatcher;
Winson Chung6b1c73f2015-06-18 11:38:42 -070027import com.android.launcher3.util.ComponentKey;
Adam Cohen9211d422014-10-07 18:14:53 -070028
29import java.io.FileDescriptor;
30import java.io.PrintWriter;
31import java.util.ArrayList;
Winson Chung4ac30062015-05-08 17:34:17 -070032import java.util.List;
Adam Cohen9211d422014-10-07 18:14:53 -070033
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);
Dave Hawkey3a43ed62015-06-26 10:27:47 -060059 public void onRequestPermissionsResult(int requestCode, String[] permissions,
60 int[] grantResults);
Adam Cohen9211d422014-10-07 18:14:53 -070061 public void onWindowFocusChanged(boolean hasFocus);
Sunny Goyalc86df472016-02-25 09:19:38 -080062 public void onAttachedToWindow();
63 public void onDetachedFromWindow();
Adam Cohen9211d422014-10-07 18:14:53 -070064 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();
Robert Kozikowski67c30862015-03-30 23:46:46 +010068 public void onTrimMemory(int level);
Adam Cohen9211d422014-10-07 18:14:53 -070069
70 /*
71 * Extension points for providing custom behavior on certain user interactions.
72 */
73 public void onLauncherProviderChange();
74 public void finishBindingItems(final boolean upgradePath);
Adam Cohen9211d422014-10-07 18:14:53 -070075 public void bindAllApplications(ArrayList<AppInfo> apps);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080076 public void onInteractionBegin();
77 public void onInteractionEnd();
78
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080079 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070080 public void onClickSettingsButton(View v);
Hyunyoung Songfbf19cc2016-02-19 12:14:47 -080081 @Deprecated
Adam Cohen9211d422014-10-07 18:14:53 -070082 public void onWorkspaceLockedChanged();
Adam Cohen9211d422014-10-07 18:14:53 -070083
Adam Cohen9211d422014-10-07 18:14:53 -070084 public boolean providesSearch();
85 public boolean startSearch(String initialQuery, boolean selectInitialQuery,
86 Bundle appSearchData, Rect sourceBounds);
Adam Cohen9211d422014-10-07 18:14:53 -070087 public boolean hasCustomContentToLeft();
88 public void populateCustomContentContainer();
89 public View getQsbBar();
Tony Wickham775455c2015-10-16 09:49:32 -070090 public Bundle getAdditionalSearchWidgetOptions();
Adam Cohen9211d422014-10-07 18:14:53 -070091
92 /*
93 * Extensions points for adding / replacing some other aspects of the Launcher experience.
94 */
Hyunyoung Songaa953652016-04-19 18:30:24 -070095 public UserEventDispatcher getUserEventDispatcher();
Adam Cohen9211d422014-10-07 18:14:53 -070096 public Intent getFirstRunActivity();
97 public boolean hasFirstRunActivity();
98 public boolean hasDismissableIntroScreen();
99 public View getIntroScreen();
100 public boolean shouldMoveToDefaultScreenOnHomeIntent();
101 public boolean hasSettings();
Winson Chungef7f8742015-06-04 17:18:17 -0700102 public AllAppsSearchBarController getAllAppsSearchBarController();
Winson Chung6b1c73f2015-06-18 11:38:42 -0700103 public List<ComponentKey> getPredictedApps();
Tony Wickham55616cd2015-09-23 14:55:17 -0700104 public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1;
105 /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
106 public int getSearchBarHeight();
Adam Cohen9211d422014-10-07 18:14:53 -0700107
Adam Cohenc2d6e892014-10-16 09:49:24 -0700108 /**
Jun Mukai8af0cd82015-05-12 12:32:12 -0700109 * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
110 *
111 * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
112 * but for implementation purposes is passed around as an object.
113 */
114 public void setLauncherSearchCallback(Object callbacks);
Adam Cohen9211d422014-10-07 18:14:53 -0700115}