The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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.internal.view.menu; |
| 18 | |
| 19 | import com.android.internal.view.menu.MenuBuilder; |
| 20 | import com.android.internal.view.menu.MenuItemImpl; |
| 21 | |
| 22 | import android.graphics.drawable.Drawable; |
| 23 | |
| 24 | /** |
Adam Powell | 696cba5 | 2011-03-29 10:38:16 -0700 | [diff] [blame] | 25 | * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | * menu to be functional. |
| 27 | * |
| 28 | * @hide |
| 29 | */ |
| 30 | public interface MenuView { |
| 31 | /** |
| 32 | * Initializes the menu to the given menu. This should be called after the |
| 33 | * view is inflated. |
| 34 | * |
| 35 | * @param menu The menu that this MenuView should display. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | */ |
Adam Powell | 696cba5 | 2011-03-29 10:38:16 -0700 | [diff] [blame] | 37 | public void initialize(MenuBuilder menu); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Returns the default animations to be used for this menu when entering/exiting. |
| 41 | * @return A resource ID for the default animations to be used for this menu. |
| 42 | */ |
| 43 | public int getWindowAnimations(); |
| 44 | |
| 45 | /** |
| 46 | * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be called |
| 47 | * for the item to be functional. |
| 48 | */ |
| 49 | public interface ItemView { |
| 50 | /** |
| 51 | * Initializes with the provided MenuItemData. This should be called after the view is |
| 52 | * inflated. |
| 53 | * @param itemData The item that this ItemView should display. |
| 54 | * @param menuType The type of this menu, one of |
| 55 | * {@link MenuBuilder#TYPE_ICON}, {@link MenuBuilder#TYPE_EXPANDED}, |
| 56 | * {@link MenuBuilder#TYPE_DIALOG}). |
| 57 | */ |
| 58 | public void initialize(MenuItemImpl itemData, int menuType); |
| 59 | |
| 60 | /** |
| 61 | * Gets the item data that this view is displaying. |
| 62 | * @return the item data, or null if there is not one |
| 63 | */ |
| 64 | public MenuItemImpl getItemData(); |
| 65 | |
| 66 | /** |
| 67 | * Sets the title of the item view. |
| 68 | * @param title The title to set. |
| 69 | */ |
| 70 | public void setTitle(CharSequence title); |
| 71 | |
| 72 | /** |
| 73 | * Sets the enabled state of the item view. |
| 74 | * @param enabled Whether the item view should be enabled. |
| 75 | */ |
| 76 | public void setEnabled(boolean enabled); |
| 77 | |
| 78 | /** |
| 79 | * Displays the checkbox for the item view. This does not ensure the item view will be |
| 80 | * checked, for that use {@link #setChecked}. |
| 81 | * @param checkable Whether to display the checkbox or to hide it |
| 82 | */ |
| 83 | public void setCheckable(boolean checkable); |
| 84 | |
| 85 | /** |
| 86 | * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be |
| 87 | * made visible, call {@link #setCheckable(boolean)} for that. |
| 88 | * @param checked Whether the checkbox should be checked |
| 89 | */ |
| 90 | public void setChecked(boolean checked); |
| 91 | |
| 92 | /** |
| 93 | * Sets the shortcut for the item. |
| 94 | * @param showShortcut Whether a shortcut should be shown(if false, the value of |
| 95 | * shortcutKey should be ignored). |
| 96 | * @param shortcutKey The shortcut key that should be shown on the ItemView. |
| 97 | */ |
| 98 | public void setShortcut(boolean showShortcut, char shortcutKey); |
| 99 | |
| 100 | /** |
| 101 | * Set the icon of this item view. |
| 102 | * @param icon The icon of this item. null to hide the icon. |
| 103 | */ |
| 104 | public void setIcon(Drawable icon); |
| 105 | |
| 106 | /** |
| 107 | * Whether this item view prefers displaying the condensed title rather |
| 108 | * than the normal title. If a condensed title is not available, the |
| 109 | * normal title will be used. |
| 110 | * |
| 111 | * @return Whether this item view prefers displaying the condensed |
| 112 | * title. |
| 113 | */ |
| 114 | public boolean prefersCondensedTitle(); |
| 115 | |
| 116 | /** |
| 117 | * Whether this item view shows an icon. |
| 118 | * |
| 119 | * @return Whether this item view shows an icon. |
| 120 | */ |
| 121 | public boolean showsIcon(); |
| 122 | } |
| 123 | } |