1 /*
2  * Copyright (C) 2019 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 package com.android.systemui.plugins.shared;
17 
18 import android.app.Activity;
19 import android.app.Application;
20 import android.os.Bundle;
21 
22 import java.io.PrintWriter;
23 
24 /**
25  * Interface to control the overlay on Launcher
26  */
27 public interface LauncherOverlayManager extends Application.ActivityLifecycleCallbacks {
28 
onDeviceProvideChanged()29     default void onDeviceProvideChanged() { }
30 
onAttachedToWindow()31     default void onAttachedToWindow() { }
onDetachedFromWindow()32     default void onDetachedFromWindow() { }
33 
dump(String prefix, PrintWriter w)34     default void dump(String prefix, PrintWriter w) { }
35 
openOverlay()36     default void openOverlay() { }
37 
hideOverlay(boolean animate)38     default void hideOverlay(boolean animate) {
39         hideOverlay(animate ? 200 : 0);
40     }
41 
hideOverlay(int duration)42     default void hideOverlay(int duration) { }
43 
startSearch(byte[] config, Bundle extras)44     default boolean startSearch(byte[] config, Bundle extras) {
45         return false;
46     }
47 
48     @Override
onActivityCreated(Activity activity, Bundle bundle)49     default void onActivityCreated(Activity activity, Bundle bundle) { }
50 
51     @Override
onActivityStarted(Activity activity)52     default void onActivityStarted(Activity activity) { }
53 
54     @Override
onActivityResumed(Activity activity)55     default void onActivityResumed(Activity activity) { }
56 
57     @Override
onActivityPaused(Activity activity)58     default void onActivityPaused(Activity activity) { }
59 
60     @Override
onActivityStopped(Activity activity)61     default void onActivityStopped(Activity activity) { }
62 
63     @Override
onActivitySaveInstanceState(Activity activity, Bundle bundle)64     default void onActivitySaveInstanceState(Activity activity, Bundle bundle) { }
65 
66     @Override
onActivityDestroyed(Activity activity)67     default void onActivityDestroyed(Activity activity) { }
68 
69     interface LauncherOverlay {
70 
71         /**
72          * Touch interaction leading to overscroll has begun
73          */
onScrollInteractionBegin()74         void onScrollInteractionBegin();
75 
76         /**
77          * Touch interaction related to overscroll has ended
78          */
onScrollInteractionEnd()79         void onScrollInteractionEnd();
80 
81         /**
82          * Scroll progress, between 0 and 100, when the user scrolls beyond the leftmost
83          * screen (or in the case of RTL, the rightmost screen).
84          */
onScrollChange(float progress, boolean rtl)85         void onScrollChange(float progress, boolean rtl);
86 
87         /**
88          * Called when the launcher is ready to use the overlay
89          * @param callbacks A set of callbacks provided by Launcher in relation to the overlay
90          */
setOverlayCallbacks(LauncherOverlayCallbacks callbacks)91         void setOverlayCallbacks(LauncherOverlayCallbacks callbacks);
92     }
93 
94     interface LauncherOverlayCallbacks {
95 
onScrollChanged(float progress)96         void onScrollChanged(float progress);
97     }
98 }
99