1 /* 2 * Copyright (C) 2017 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.launcher3.allapps; 17 18 import static com.android.launcher3.LauncherState.ALL_APPS_HEADER; 19 20 import android.graphics.Rect; 21 import android.view.KeyEvent; 22 import android.view.animation.Interpolator; 23 import android.widget.EditText; 24 25 import androidx.annotation.Nullable; 26 27 import com.android.launcher3.anim.PropertySetter; 28 29 /** 30 * Interface for controlling the Apps search UI. 31 */ 32 public interface SearchUiManager { 33 34 /** 35 * Initializes the search manager. 36 */ initialize(AllAppsContainerView containerView)37 void initialize(AllAppsContainerView containerView); 38 39 /** 40 * Notifies the search manager to close any active search session. 41 */ resetSearch()42 void resetSearch(); 43 44 /** 45 * Called before dispatching a key event, in case the search manager wants to initialize 46 * some UI beforehand. 47 */ preDispatchKeyEvent(KeyEvent keyEvent)48 void preDispatchKeyEvent(KeyEvent keyEvent); 49 50 /** 51 * Returns the vertical shift for the all-apps view, so that it aligns with the hotseat. 52 */ getScrollRangeDelta(Rect insets)53 float getScrollRangeDelta(Rect insets); 54 55 /** 56 * Called as part of state transition to update the content UI 57 */ setContentVisibility(int visibleElements, PropertySetter setter, Interpolator interpolator)58 void setContentVisibility(int visibleElements, PropertySetter setter, 59 Interpolator interpolator); 60 61 /** 62 * Returns true if the QSB should be visible for the given set of visible elements 63 */ isQsbVisible(int visibleElements)64 default boolean isQsbVisible(int visibleElements) { 65 return (visibleElements & ALL_APPS_HEADER) != 0; 66 } 67 68 /** 69 * Called to control how the search UI result should be handled. 70 * 71 * @param isEnabled when {@code true}, the search is all handled inside AOSP 72 * and is not overlayable. 73 * @return the searchbox edit text object 74 */ 75 @Nullable setTextSearchEnabled(boolean isEnabled)76 EditText setTextSearchEnabled(boolean isEnabled); 77 } 78