1package com.android.launcher3.testing;
2
3import android.content.Intent;
4import android.graphics.Color;
5import android.graphics.Rect;
6import android.os.Bundle;
7import android.view.Menu;
8import android.view.View;
9import android.widget.FrameLayout;
10
11import com.android.launcher3.AppInfo;
12import com.android.launcher3.Launcher;
13import com.android.launcher3.LauncherCallbacks;
14import com.android.launcher3.allapps.AllAppsSearchBarController;
15import com.android.launcher3.logging.UserEventDispatcher;
16import com.android.launcher3.util.ComponentKey;
17
18import java.io.FileDescriptor;
19import java.io.PrintWriter;
20import java.util.ArrayList;
21import java.util.List;
22
23/**
24 * This class represents a very trivial LauncherExtension. It primarily serves as a simple
25 * class to exercise the LauncherOverlay interface.
26 */
27public class LauncherExtension extends Launcher {
28
29    //------ Activity methods -------//
30    @Override
31    public void onCreate(Bundle savedInstanceState) {
32        setLauncherCallbacks(new LauncherExtensionCallbacks());
33        super.onCreate(savedInstanceState);
34    }
35
36    public class LauncherExtensionCallbacks implements LauncherCallbacks {
37
38        @Override
39        public void preOnCreate() {
40        }
41
42        @Override
43        public void onCreate(Bundle savedInstanceState) {
44        }
45
46        @Override
47        public void preOnResume() {
48        }
49
50        @Override
51        public void onResume() {
52        }
53
54        @Override
55        public void onStart() {
56        }
57
58        @Override
59        public void onStop() {
60        }
61
62        @Override
63        public void onPause() {
64        }
65
66        @Override
67        public void onDestroy() {
68        }
69
70        @Override
71        public void onSaveInstanceState(Bundle outState) {
72        }
73
74        @Override
75        public void onPostCreate(Bundle savedInstanceState) {
76        }
77
78        @Override
79        public void onNewIntent(Intent intent) {
80        }
81
82        @Override
83        public void onActivityResult(int requestCode, int resultCode, Intent data) {
84        }
85
86        @Override
87        public void onRequestPermissionsResult(int requestCode, String[] permissions,
88                int[] grantResults) {
89        }
90
91        @Override
92        public void onWindowFocusChanged(boolean hasFocus) {
93        }
94
95        @Override
96        public boolean onPrepareOptionsMenu(Menu menu) {
97            return false;
98        }
99
100        @Override
101        public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args) {
102        }
103
104        @Override
105        public void onHomeIntent() {
106        }
107
108        @Override
109        public boolean handleBackPressed() {
110            return false;
111        }
112
113        @Override
114        public void onTrimMemory(int level) {
115        }
116
117        @Override
118        public void onLauncherProviderChange() {
119        }
120
121        @Override
122        public void finishBindingItems(boolean upgradePath) {
123        }
124
125        @Override
126        public void bindAllApplications(ArrayList<AppInfo> apps) {
127        }
128
129        @Override
130        public void onWorkspaceLockedChanged() {
131        }
132
133        @Override
134        public void onInteractionBegin() {
135        }
136
137        @Override
138        public void onInteractionEnd() {
139        }
140
141        @Override
142        public boolean startSearch(String initialQuery, boolean selectInitialQuery,
143                Bundle appSearchData) {
144            return false;
145        }
146
147        CustomContentCallbacks mCustomContentCallbacks = new CustomContentCallbacks() {
148
149            // Custom content is completely shown. {@code fromResume} indicates whether this was caused
150            // by a onResume or by scrolling otherwise.
151            public void onShow(boolean fromResume) {
152            }
153
154            // Custom content is completely hidden
155            public void onHide() {
156            }
157
158            // Custom content scroll progress changed. From 0 (not showing) to 1 (fully showing).
159            public void onScrollProgressChanged(float progress) {
160
161            }
162
163            // Indicates whether the user is allowed to scroll away from the custom content.
164            public boolean isScrollingAllowed() {
165                return true;
166            }
167
168        };
169
170        @Override
171        public boolean hasCustomContentToLeft() {
172            return true;
173        }
174
175        @Override
176        public void populateCustomContentContainer() {
177            FrameLayout customContent = new FrameLayout(LauncherExtension.this);
178            customContent.setBackgroundColor(Color.GRAY);
179            addToCustomContentPage(customContent, mCustomContentCallbacks, "");
180        }
181
182        @Override
183        public View getQsbBar() {
184            return null;
185        }
186
187        @Override
188        public Bundle getAdditionalSearchWidgetOptions() {
189            return new Bundle();
190        }
191
192        @Override
193        public boolean shouldMoveToDefaultScreenOnHomeIntent() {
194            return true;
195        }
196
197        @Override
198        public boolean hasSettings() {
199            return false;
200        }
201
202        @Override
203        public AllAppsSearchBarController getAllAppsSearchBarController() {
204            return null;
205        }
206
207        @Override
208        public List<ComponentKey> getPredictedApps() {
209            // To debug app predictions, enable AlphabeticalAppsList#DEBUG_PREDICTIONS
210            return new ArrayList<>();
211        }
212
213        @Override
214        public int getSearchBarHeight() {
215            return SEARCH_BAR_HEIGHT_NORMAL;
216        }
217
218        @Override
219        public void setLauncherSearchCallback(Object callbacks) {
220            // Do nothing
221        }
222
223        @Override
224        public void onAttachedToWindow() {
225        }
226
227        @Override
228        public void onDetachedFromWindow() {
229        }
230
231        @Override
232        public boolean shouldShowDiscoveryBounce() {
233            return false;
234        }
235    }
236}
237