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.car.ui.toolbar; 17 18 /** 19 * This is a legacy toolbar class, that now no longer functions as a toolbar, but instead 20 * just holds deprecated inner classes. 21 * 22 * @deprecated Instead of creating this class, use Theme.CarUi.WithToolbar, and get access to it 23 * via {@link com.android.car.ui.core.CarUi#requireToolbar(android.app.Activity)} 24 */ 25 @Deprecated 26 public final class Toolbar { 27 28 /** Callback that will be issued whenever the height of toolbar is changed. */ 29 public interface OnHeightChangedListener { 30 /** 31 * Will be called when the height of the toolbar is changed. 32 * 33 * @param height new height of the toolbar 34 */ onHeightChanged(int height)35 void onHeightChanged(int height); 36 } 37 38 /** Back button listener */ 39 public interface OnBackListener { 40 /** 41 * Invoked when the user clicks on the back button. By default, the toolbar will call 42 * the Activity's {@link android.app.Activity#onBackPressed()}. Returning true from 43 * this method will absorb the back press and prevent that behavior. 44 */ onBack()45 boolean onBack(); 46 } 47 48 /** Tab selection listener */ 49 public interface OnTabSelectedListener { 50 /** Called when a {@link TabLayout.Tab} is selected */ onTabSelected(TabLayout.Tab tab)51 void onTabSelected(TabLayout.Tab tab); 52 } 53 54 /** Search listener */ 55 public interface OnSearchListener { 56 /** 57 * Invoked when the user edits a search query. 58 * 59 * <p>This is called for every letter the user types, and also empty strings if the user 60 * erases everything. 61 */ onSearch(String query)62 void onSearch(String query); 63 } 64 65 /** Search completed listener */ 66 public interface OnSearchCompletedListener { 67 /** 68 * Invoked when the user submits a search query by clicking the keyboard's search / done 69 * button. 70 */ onSearchCompleted()71 void onSearchCompleted(); 72 } 73 74 /** Enum of states the toolbar can be in. Controls what elements of the toolbar are displayed */ 75 public enum State { 76 /** 77 * In the HOME state, the logo will be displayed if there is one, and no navigation icon 78 * will be displayed. The tab bar will be visible. The title will be displayed if there 79 * is space. MenuItems will be displayed. 80 */ 81 HOME, 82 /** 83 * In the SUBPAGE state, the logo will be replaced with a back button, the tab bar won't 84 * be visible. The title and MenuItems will be displayed. 85 */ 86 SUBPAGE, 87 /** 88 * In the SEARCH state, only the back button and the search bar will be visible. 89 */ 90 SEARCH, 91 /** 92 * In the EDIT state, the search bar will look like a regular text box, but will be 93 * functionally identical to the SEARCH state. 94 */ 95 EDIT, 96 } 97 98 /** 99 * An enum of possible styles the nav button could be in. All styles will still call 100 * {@link OnBackListener#onBack()}. 101 */ 102 public enum NavButtonMode { 103 /** A back button */ 104 BACK, 105 /** A close button */ 106 CLOSE, 107 /** A down button, used to indicate that the page will animate down when navigating away */ 108 DOWN, 109 /** Don't show the nav button */ 110 DISABLED, 111 } 112 } 113