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 android.view.KeyEvent; 19 20 import androidx.annotation.Nullable; 21 22 import com.android.launcher3.ExtendedEditText; 23 24 /** 25 * Interface for controlling the Apps search UI. 26 */ 27 public interface SearchUiManager { 28 29 /** 30 * Initializes the search manager. 31 */ initializeSearch(ActivityAllAppsContainerView<?> containerView)32 void initializeSearch(ActivityAllAppsContainerView<?> containerView); 33 34 /** 35 * Notifies the search manager to close any active search session. 36 */ resetSearch()37 void resetSearch(); 38 39 /** 40 * Called before dispatching a key event, in case the search manager wants to initialize 41 * some UI beforehand. 42 */ preDispatchKeyEvent(KeyEvent keyEvent)43 default void preDispatchKeyEvent(KeyEvent keyEvent) { }; 44 45 /** 46 * @return the edit text object 47 */ 48 @Nullable getEditText()49 ExtendedEditText getEditText(); 50 51 /** 52 * Hint to the edit text that it is about to be focused or unfocused. This can be used to start 53 * animating the edit box accordingly, e.g. after a gesture completes. 54 * 55 * @param focused true if the edit text is about to be focused, false if it will be unfocused 56 */ prepareToFocusEditText(boolean focused)57 default void prepareToFocusEditText(boolean focused) {} 58 59 /** 60 * Sets whether EditText background should be visible 61 * @param maxAlpha defines the maximum alpha the background should animates to 62 */ setBackgroundVisibility(boolean visible, float maxAlpha)63 default void setBackgroundVisibility(boolean visible, float maxAlpha) {} 64 65 /** 66 * Returns whether a visible background is set on EditText 67 */ getBackgroundVisibility()68 default boolean getBackgroundVisibility() { 69 return false; 70 } 71 72 /** 73 * sets highlight result's title 74 */ setFocusedResultTitle( @ullable CharSequence title, @Nullable CharSequence subtitle, boolean showArrow)75 default void setFocusedResultTitle( 76 @Nullable CharSequence title, @Nullable CharSequence subtitle, boolean showArrow) {} 77 78 /** Refresh the currently displayed list of results. */ refreshResults()79 default void refreshResults() {} 80 81 /** Returns whether search is in zero state. */ inZeroState()82 default boolean inZeroState() { 83 return false; 84 } 85 } 86