Debian Codegraph @

layoutlib-api/src/main/java/com/android/ide/common/rendering/api/ActionBarCallback.java

raw
1 /*
2 * Copyright (C) 2014 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
17 package com.android.ide.common.rendering.api;
18
19 import java.util.Collections;
20 import java.util.List;
21
22 /**
23 * Callback for Action Bar information needed by the Layout Library.
24 */
25 public class ActionBarCallback {
26
27 // The Navigation mode constants correspond to their counterparts in android.app.ActionBar
28 public static final int NAVIGATION_MODE_STANDARD = 0;
29 public static final int NAVIGATION_MODE_LIST = 1;
30 public static final int NAVIGATION_MODE_TABS = 2;
31
32 // The protected constants must not be used on the LayoutLib side without incrementing
33 // the LayoutLib API version number.
34 protected static final String ATTR_MENU = "menu"; //$NON-NLS-1$
35 protected static final String ATTR_NAV_MODE = "actionBarNavMode"; //$NON-NLS-1$
36
37 // The attribute values for ATTR_NAV_MODE.
38 protected static final String VALUE_NAV_MODE_TABS = "tabs"; //$NON-NLS-1$
39 protected static final String VALUE_NAV_MODE_LIST = "list"; //$NON-NLS-1$
40
41 /**
42 * Types of navigation for home button.
43 */
44 public enum HomeButtonStyle {
45 NONE, SHOW_HOME_AS_UP
46 }
47
48 /**
49 * Returns a list of names of the IDs for menus to add to the action bar.
50 *
51 * @return the list of menu ids. The list is never null, but may be empty.
52 */
53 public List<String> getMenuIdNames() {
54 return Collections.emptyList();
55 }
56
57 /**
58 * Returns whether the Action Bar should be split for narrow screens.
59 */
60 public boolean getSplitActionBarWhenNarrow() {
61 return false;
62 }
63
64 /**
65 * Returns which navigation mode the action bar should use.
66 *
67 * @return one of {@link #NAVIGATION_MODE_STANDARD}, {@link #NAVIGATION_MODE_LIST} or
68 * {@link #NAVIGATION_MODE_TABS}
69 */
70 public int getNavigationMode() {
71 return NAVIGATION_MODE_STANDARD;
72 }
73
74 /**
75 * Returns the subtitle to be used with the action bar or null if there is no subtitle.
76 */
77 public String getSubTitle() {
78 return null;
79 }
80
81 /**
82 * Returns the type of navigation for home button to be used in the action bar.
83 * <p>
84 * For example, for showHomeAsUp, an arrow is shown alongside the "home" icon.
85 *
86 * @return navigation type for home button. Never null.
87 */
88 public HomeButtonStyle getHomeButtonStyle() {
89 return HomeButtonStyle.NONE;
90 }
91
92 /**
93 * Returns whether to draw the overflow menu popup.
94 */
95 public boolean isOverflowPopupNeeded() {
96 return false;
97 }
98 }