am ffa91c3c: Reconcile with jb-mr1-release - do not merge
* commit 'ffa91c3cc04e25ce044b83b58b44a6019491517e':
diff --git a/appcompat/Android.mk.disabled b/appcompat/Android.mk.disabled
new file mode 100644
index 0000000..6560bf0
--- /dev/null
+++ b/appcompat/Android.mk.disabled
@@ -0,0 +1,44 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+# Note: the source code is in java/, not src/, because this code is also part of
+# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
+
+# A helper sub-library that makes direct use of Eclair APIs.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-appcompat-eclair
+LOCAL_SDK_VERSION := 7
+LOCAL_SRC_FILES := $(call all-java-files-under, eclair)
+LOCAL_STATIC_JAVA_LIBRARIES += \
+ android-support-appcompat-res
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_KEEP_R_CLASS_IN_STATIC_JAVA_LIBRARY := true
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# -----------------------------------------------------------------------
+
+# Here is the final static library that apps can link against.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-appcopmat
+LOCAL_SDK_VERSION := 4
+LOCAL_SRC_FILES := $(call all-java-files-under, java)
+LOCAL_STATIC_JAVA_LIBRARIES += \
+ android-support-appcompat-eclair
+LOCAL_KEEP_R_CLASS_IN_STATIC_JAVA_LIBRARY := true
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Include this library in the build server's output directory
+$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-appcompat.jar)
diff --git a/appcompat/AndroidManifest.xml b/appcompat/AndroidManifest.xml
new file mode 100644
index 0000000..0a1e07e
--- /dev/null
+++ b/appcompat/AndroidManifest.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.support.appcompat">
+</manifest>
diff --git a/appcompat/eclair/android/support/appcompat/app/ActionBar.java b/appcompat/eclair/android/support/appcompat/app/ActionBar.java
new file mode 100644
index 0000000..50bc194
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/app/ActionBar.java
@@ -0,0 +1,959 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.app;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.R;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewGroup.MarginLayoutParams;
+import android.view.Window;
+import android.widget.SpinnerAdapter;
+
+/**
+ * A window feature at the top of the activity that may display the activity title, navigation
+ * modes, and other interactive items.
+ * <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an
+ * activity's window when the activity uses the system's {@link
+ * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.
+ * You may otherwise add the action bar by calling {@link
+ * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a
+ * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.
+ * <p>By default, the action bar shows the application icon on
+ * the left, followed by the activity title. If your activity has an options menu, you can make
+ * select items accessible directly from the action bar as "action items". You can also
+ * modify various characteristics of the action bar or remove it completely.</p>
+ * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
+ * android.app.Activity#getActionBar getActionBar()}.</p>
+ * <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions,
+ * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in
+ * your activity, you can enable an action mode that offers actions specific to the selected
+ * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the
+ * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for
+ * {@link ActionBar}.
+ * <div class="special reference">
+ * <h3>Developer Guides</h3>
+ * <p>For information about how to use the action bar, including how to add action items, navigation
+ * modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action
+ * Bar</a> developer guide.</p>
+ * </div>
+ */
+public abstract class ActionBar {
+ /**
+ * Standard navigation mode. Consists of either a logo or icon
+ * and title text with an optional subtitle. Clicking any of these elements
+ * will dispatch onOptionsItemSelected to the host Activity with
+ * a MenuItem with item ID android.R.id.home.
+ */
+ public static final int NAVIGATION_MODE_STANDARD = 0;
+
+ /**
+ * List navigation mode. Instead of static title text this mode
+ * presents a list menu for navigation within the activity.
+ * e.g. this might be presented to the user as a dropdown list.
+ */
+ public static final int NAVIGATION_MODE_LIST = 1;
+
+ /**
+ * Tab navigation mode. Instead of static title text this mode
+ * presents a series of tabs for navigation within the activity.
+ */
+ public static final int NAVIGATION_MODE_TABS = 2;
+
+ /**
+ * Use logo instead of icon if available. This flag will cause appropriate
+ * navigation modes to use a wider logo in place of the standard icon.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public static final int DISPLAY_USE_LOGO = 0x1;
+
+ /**
+ * Show 'home' elements in this action bar, leaving more space for other
+ * navigation elements. This includes logo and icon.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public static final int DISPLAY_SHOW_HOME = 0x2;
+
+ /**
+ * Display the 'home' element such that it appears as an 'up' affordance.
+ * e.g. show an arrow to the left indicating the action that will be taken.
+ *
+ * Set this flag if selecting the 'home' button in the action bar to return
+ * up by a single level in your UI rather than back to the top level or front page.
+ *
+ * <p>Setting this option will implicitly enable interaction with the home/up
+ * button. See {@link #setHomeButtonEnabled(boolean)}.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public static final int DISPLAY_HOME_AS_UP = 0x4;
+
+ /**
+ * Show the activity title and subtitle, if present.
+ *
+ * @see #setTitle(CharSequence)
+ * @see #setTitle(int)
+ * @see #setSubtitle(CharSequence)
+ * @see #setSubtitle(int)
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public static final int DISPLAY_SHOW_TITLE = 0x8;
+
+ /**
+ * Show the custom view if one has been set.
+ * @see #setCustomView(View)
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public static final int DISPLAY_SHOW_CUSTOM = 0x10;
+
+ /**
+ * Set the action bar into custom navigation mode, supplying a view
+ * for custom navigation.
+ *
+ * Custom navigation views appear between the application icon and
+ * any action buttons and may use any space available there. Common
+ * use cases for custom navigation views might include an auto-suggesting
+ * address bar for a browser or other navigation mechanisms that do not
+ * translate well to provided navigation modes.
+ *
+ * @param view Custom navigation view to place in the ActionBar.
+ */
+ public abstract void setCustomView(View view);
+
+ /**
+ * Set the action bar into custom navigation mode, supplying a view
+ * for custom navigation.
+ *
+ * <p>Custom navigation views appear between the application icon and
+ * any action buttons and may use any space available there. Common
+ * use cases for custom navigation views might include an auto-suggesting
+ * address bar for a browser or other navigation mechanisms that do not
+ * translate well to provided navigation modes.</p>
+ *
+ * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
+ * the custom view to be displayed.</p>
+ *
+ * @param view Custom navigation view to place in the ActionBar.
+ * @param layoutParams How this custom view should layout in the bar.
+ *
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setCustomView(View view, LayoutParams layoutParams);
+
+ /**
+ * Set the action bar into custom navigation mode, supplying a view
+ * for custom navigation.
+ *
+ * <p>Custom navigation views appear between the application icon and
+ * any action buttons and may use any space available there. Common
+ * use cases for custom navigation views might include an auto-suggesting
+ * address bar for a browser or other navigation mechanisms that do not
+ * translate well to provided navigation modes.</p>
+ *
+ * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
+ * the custom view to be displayed.</p>
+ *
+ * @param resId Resource ID of a layout to inflate into the ActionBar.
+ *
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setCustomView(int resId);
+
+ /**
+ * Set the icon to display in the 'home' section of the action bar.
+ * The action bar will use an icon specified by its style or the
+ * activity icon by default.
+ *
+ * Whether the home section shows an icon or logo is controlled
+ * by the display option {@link #DISPLAY_USE_LOGO}.
+ *
+ * @param resId Resource ID of a drawable to show as an icon.
+ *
+ * @see #setDisplayUseLogoEnabled(boolean)
+ * @see #setDisplayShowHomeEnabled(boolean)
+ */
+ public abstract void setIcon(int resId);
+
+ /**
+ * Set the icon to display in the 'home' section of the action bar.
+ * The action bar will use an icon specified by its style or the
+ * activity icon by default.
+ *
+ * Whether the home section shows an icon or logo is controlled
+ * by the display option {@link #DISPLAY_USE_LOGO}.
+ *
+ * @param icon Drawable to show as an icon.
+ *
+ * @see #setDisplayUseLogoEnabled(boolean)
+ * @see #setDisplayShowHomeEnabled(boolean)
+ */
+ public abstract void setIcon(Drawable icon);
+
+ /**
+ * Set the logo to display in the 'home' section of the action bar.
+ * The action bar will use a logo specified by its style or the
+ * activity logo by default.
+ *
+ * Whether the home section shows an icon or logo is controlled
+ * by the display option {@link #DISPLAY_USE_LOGO}.
+ *
+ * @param resId Resource ID of a drawable to show as a logo.
+ *
+ * @see #setDisplayUseLogoEnabled(boolean)
+ * @see #setDisplayShowHomeEnabled(boolean)
+ */
+ public abstract void setLogo(int resId);
+
+ /**
+ * Set the logo to display in the 'home' section of the action bar.
+ * The action bar will use a logo specified by its style or the
+ * activity logo by default.
+ *
+ * Whether the home section shows an icon or logo is controlled
+ * by the display option {@link #DISPLAY_USE_LOGO}.
+ *
+ * @param logo Drawable to show as a logo.
+ *
+ * @see #setDisplayUseLogoEnabled(boolean)
+ * @see #setDisplayShowHomeEnabled(boolean)
+ */
+ public abstract void setLogo(Drawable logo);
+
+ /**
+ * Set the adapter and navigation callback for list navigation mode.
+ *
+ * The supplied adapter will provide views for the expanded list as well as
+ * the currently selected item. (These may be displayed differently.)
+ *
+ * The supplied OnNavigationListener will alert the application when the user
+ * changes the current list selection.
+ *
+ * @param adapter An adapter that will provide views both to display
+ * the current navigation selection and populate views
+ * within the dropdown navigation menu.
+ * @param callback An OnNavigationListener that will receive events when the user
+ * selects a navigation item.
+ */
+ public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,
+ OnNavigationListener callback);
+
+ /**
+ * Set the selected navigation item in list or tabbed navigation modes.
+ *
+ * @param position Position of the item to select.
+ */
+ public abstract void setSelectedNavigationItem(int position);
+
+ /**
+ * Get the position of the selected navigation item in list or tabbed navigation modes.
+ *
+ * @return Position of the selected item.
+ */
+ public abstract int getSelectedNavigationIndex();
+
+ /**
+ * Get the number of navigation items present in the current navigation mode.
+ *
+ * @return Number of navigation items.
+ */
+ public abstract int getNavigationItemCount();
+
+ /**
+ * Set the action bar's title. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set.
+ *
+ * @param title Title to set
+ *
+ * @see #setTitle(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setTitle(CharSequence title);
+
+ /**
+ * Set the action bar's title. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set.
+ *
+ * @param resId Resource ID of title string to set
+ *
+ * @see #setTitle(CharSequence)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setTitle(int resId);
+
+ /**
+ * Set the action bar's subtitle. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the
+ * subtitle entirely.
+ *
+ * @param subtitle Subtitle to set
+ *
+ * @see #setSubtitle(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setSubtitle(CharSequence subtitle);
+
+ /**
+ * Set the action bar's subtitle. This will only be displayed if
+ * {@link #DISPLAY_SHOW_TITLE} is set.
+ *
+ * @param resId Resource ID of subtitle string to set
+ *
+ * @see #setSubtitle(CharSequence)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setSubtitle(int resId);
+
+ /**
+ * Set display options. This changes all display option bits at once. To change
+ * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.
+ *
+ * @param options A combination of the bits defined by the DISPLAY_ constants
+ * defined in ActionBar.
+ */
+ public abstract void setDisplayOptions(int options);
+
+ /**
+ * Set selected display options. Only the options specified by mask will be changed.
+ * To change all display option bits at once, see {@link #setDisplayOptions(int)}.
+ *
+ * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
+ * {@link #DISPLAY_SHOW_HOME} option.
+ * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
+ * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.
+ *
+ * @param options A combination of the bits defined by the DISPLAY_ constants
+ * defined in ActionBar.
+ * @param mask A bit mask declaring which display options should be changed.
+ */
+ public abstract void setDisplayOptions(int options, int mask);
+
+ /**
+ * Set whether to display the activity logo rather than the activity icon.
+ * A logo is often a wider, more detailed image.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param useLogo true to use the activity logo, false to use the activity icon.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayUseLogoEnabled(boolean useLogo);
+
+ /**
+ * Set whether to include the application home affordance in the action bar.
+ * Home is presented as either an activity icon or logo.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showHome true to show home, false otherwise.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayShowHomeEnabled(boolean showHome);
+
+ /**
+ * Set whether home should be displayed as an "up" affordance.
+ * Set this to true if selecting "home" returns up by a single level in your UI
+ * rather than back to the top level or front page.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showHomeAsUp true to show the user that selecting home will return one
+ * level up rather than to the top level of the app.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
+
+ /**
+ * Set whether an activity title/subtitle should be displayed.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showTitle true to display a title/subtitle if present.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayShowTitleEnabled(boolean showTitle);
+
+ /**
+ * Set whether a custom view should be displayed, if set.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showCustom true if the currently set custom view should be displayed, false otherwise.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayShowCustomEnabled(boolean showCustom);
+
+ /**
+ * Set the ActionBar's background. This will be used for the primary
+ * action bar.
+ *
+ * @param d Background drawable
+ * @see #setStackedBackgroundDrawable(Drawable)
+ * @see #setSplitBackgroundDrawable(Drawable)
+ */
+ public abstract void setBackgroundDrawable(Drawable d);
+
+ /**
+ * Set the ActionBar's stacked background. This will appear
+ * in the second row/stacked bar on some devices and configurations.
+ *
+ * @param d Background drawable for the stacked row
+ */
+ public void setStackedBackgroundDrawable(Drawable d) { }
+
+ /**
+ * Set the ActionBar's split background. This will appear in
+ * the split action bar containing menu-provided action buttons
+ * on some devices and configurations.
+ * <p>You can enable split action bar with {@link android.R.attr#uiOptions}
+ *
+ * @param d Background drawable for the split bar
+ */
+ public void setSplitBackgroundDrawable(Drawable d) { }
+
+ /**
+ * @return The current custom view.
+ */
+ public abstract View getCustomView();
+
+ /**
+ * Returns the current ActionBar title in standard mode.
+ * Returns null if {@link #getNavigationMode()} would not return
+ * {@link #NAVIGATION_MODE_STANDARD}.
+ *
+ * @return The current ActionBar title or null.
+ */
+ public abstract CharSequence getTitle();
+
+ /**
+ * Returns the current ActionBar subtitle in standard mode.
+ * Returns null if {@link #getNavigationMode()} would not return
+ * {@link #NAVIGATION_MODE_STANDARD}.
+ *
+ * @return The current ActionBar subtitle or null.
+ */
+ public abstract CharSequence getSubtitle();
+
+ /**
+ * Returns the current navigation mode. The result will be one of:
+ * <ul>
+ * <li>{@link #NAVIGATION_MODE_STANDARD}</li>
+ * <li>{@link #NAVIGATION_MODE_LIST}</li>
+ * <li>{@link #NAVIGATION_MODE_TABS}</li>
+ * </ul>
+ *
+ * @return The current navigation mode.
+ */
+ public abstract int getNavigationMode();
+
+ /**
+ * Set the current navigation mode.
+ *
+ * @param mode The new mode to set.
+ * @see #NAVIGATION_MODE_STANDARD
+ * @see #NAVIGATION_MODE_LIST
+ * @see #NAVIGATION_MODE_TABS
+ */
+ public abstract void setNavigationMode(int mode);
+
+ /**
+ * @return The current set of display options.
+ */
+ public abstract int getDisplayOptions();
+
+ /**
+ * Create and return a new {@link Tab}.
+ * This tab will not be included in the action bar until it is added.
+ *
+ * <p>Very often tabs will be used to switch between {@link Fragment}
+ * objects. Here is a typical implementation of such tabs:</p>
+ *
+ * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
+ * complete}
+ *
+ * @return A new Tab
+ *
+ * @see #addTab(Tab)
+ */
+ public abstract Tab newTab();
+
+ /**
+ * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
+ * If this is the first tab to be added it will become the selected tab.
+ *
+ * @param tab Tab to add
+ */
+ public abstract void addTab(Tab tab);
+
+ /**
+ * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.
+ *
+ * @param tab Tab to add
+ * @param setSelected True if the added tab should become the selected tab.
+ */
+ public abstract void addTab(Tab tab, boolean setSelected);
+
+ /**
+ * Add a tab for use in tabbed navigation mode. The tab will be inserted at
+ * <code>position</code>. If this is the first tab to be added it will become
+ * the selected tab.
+ *
+ * @param tab The tab to add
+ * @param position The new position of the tab
+ */
+ public abstract void addTab(Tab tab, int position);
+
+ /**
+ * Add a tab for use in tabbed navigation mode. The tab will be insterted at
+ * <code>position</code>.
+ *
+ * @param tab The tab to add
+ * @param position The new position of the tab
+ * @param setSelected True if the added tab should become the selected tab.
+ */
+ public abstract void addTab(Tab tab, int position, boolean setSelected);
+
+ /**
+ * Remove a tab from the action bar. If the removed tab was selected it will be deselected
+ * and another tab will be selected if present.
+ *
+ * @param tab The tab to remove
+ */
+ public abstract void removeTab(Tab tab);
+
+ /**
+ * Remove a tab from the action bar. If the removed tab was selected it will be deselected
+ * and another tab will be selected if present.
+ *
+ * @param position Position of the tab to remove
+ */
+ public abstract void removeTabAt(int position);
+
+ /**
+ * Remove all tabs from the action bar and deselect the current tab.
+ */
+ public abstract void removeAllTabs();
+
+ /**
+ * Select the specified tab. If it is not a child of this action bar it will be added.
+ *
+ * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>
+ *
+ * @param tab Tab to select
+ */
+ public abstract void selectTab(Tab tab);
+
+ /**
+ * Returns the currently selected tab if in tabbed navigation mode and there is at least
+ * one tab present.
+ *
+ * @return The currently selected tab or null
+ */
+ public abstract Tab getSelectedTab();
+
+ /**
+ * Returns the tab at the specified index.
+ *
+ * @param index Index value in the range 0-get
+ * @return
+ */
+ public abstract Tab getTabAt(int index);
+
+ /**
+ * Returns the number of tabs currently registered with the action bar.
+ * @return Tab count
+ */
+ public abstract int getTabCount();
+
+ /**
+ * Retrieve the current height of the ActionBar.
+ *
+ * @return The ActionBar's height
+ */
+ public abstract int getHeight();
+
+ /**
+ * Show the ActionBar if it is not currently showing.
+ * If the window hosting the ActionBar does not have the feature
+ * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
+ * content to fit the new space available.
+ *
+ * <p>If you are hiding the ActionBar through
+ * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN},
+ * you should not call this function directly.
+ */
+ public abstract void show();
+
+ /**
+ * Hide the ActionBar if it is currently showing.
+ * If the window hosting the ActionBar does not have the feature
+ * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application
+ * content to fit the new space available.
+ *
+ * <p>Instead of calling this function directly, you can also cause an
+ * ActionBar using the overlay feature to hide through
+ * {@link View#SYSTEM_UI_FLAG_FULLSCREEN View.SYSTEM_UI_FLAG_FULLSCREEN}.
+ * Hiding the ActionBar through this system UI flag allows you to more
+ * seamlessly hide it in conjunction with other screen decorations.
+ */
+ public abstract void hide();
+
+ /**
+ * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.
+ */
+ public abstract boolean isShowing();
+
+ /**
+ * Add a listener that will respond to menu visibility change events.
+ *
+ * @param listener The new listener to add
+ */
+ public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);
+
+ /**
+ * Remove a menu visibility listener. This listener will no longer receive menu
+ * visibility change events.
+ *
+ * @param listener A listener to remove that was previously added
+ */
+ public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);
+
+ /**
+ * Enable or disable the "home" button in the corner of the action bar. (Note that this
+ * is the application home/up affordance on the action bar, not the systemwide home
+ * button.)
+ *
+ * <p>This defaults to true for packages targeting < API 14. For packages targeting
+ * API 14 or greater, the application should call this method to enable interaction
+ * with the home/up affordance.
+ *
+ * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable
+ * the home button.
+ *
+ * @param enabled true to enable the home button, false to disable the home button.
+ */
+ public void setHomeButtonEnabled(boolean enabled) { }
+
+ /**
+ * Returns a {@link Context} with an appropriate theme for creating views that
+ * will appear in the action bar. If you are inflating or instantiating custom views
+ * that will appear in an action bar, you should use the Context returned by this method.
+ * (This includes adapters used for list navigation mode.)
+ * This will ensure that views contrast properly against the action bar.
+ *
+ * @return A themed Context for creating views
+ */
+ public Context getThemedContext() { return null; }
+
+ /**
+ * Listener interface for ActionBar navigation events.
+ */
+ public interface OnNavigationListener {
+ /**
+ * This method is called whenever a navigation item in your action bar
+ * is selected.
+ *
+ * @param itemPosition Position of the item clicked.
+ * @param itemId ID of the item clicked.
+ * @return True if the event was handled, false otherwise.
+ */
+ public boolean onNavigationItemSelected(int itemPosition, long itemId);
+ }
+
+ /**
+ * Listener for receiving events when action bar menus are shown or hidden.
+ */
+ public interface OnMenuVisibilityListener {
+ /**
+ * Called when an action bar menu is shown or hidden. Applications may want to use
+ * this to tune auto-hiding behavior for the action bar or pause/resume video playback,
+ * gameplay, or other activity within the main content area.
+ *
+ * @param isVisible True if an action bar menu is now visible, false if no action bar
+ * menus are visible.
+ */
+ public void onMenuVisibilityChanged(boolean isVisible);
+ }
+
+ /**
+ * A tab in the action bar.
+ *
+ * <p>Tabs manage the hiding and showing of {@link Fragment}s.
+ */
+ public static abstract class Tab {
+ /**
+ * An invalid position for a tab.
+ *
+ * @see #getPosition()
+ */
+ public static final int INVALID_POSITION = -1;
+
+ /**
+ * Return the current position of this tab in the action bar.
+ *
+ * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in
+ * the action bar.
+ */
+ public abstract int getPosition();
+
+ /**
+ * Return the icon associated with this tab.
+ *
+ * @return The tab's icon
+ */
+ public abstract Drawable getIcon();
+
+ /**
+ * Return the text of this tab.
+ *
+ * @return The tab's text
+ */
+ public abstract CharSequence getText();
+
+ /**
+ * Set the icon displayed on this tab.
+ *
+ * @param icon The drawable to use as an icon
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setIcon(Drawable icon);
+
+ /**
+ * Set the icon displayed on this tab.
+ *
+ * @param resId Resource ID referring to the drawable to use as an icon
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setIcon(int resId);
+
+ /**
+ * Set the text displayed on this tab. Text may be truncated if there is not
+ * room to display the entire string.
+ *
+ * @param text The text to display
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setText(CharSequence text);
+
+ /**
+ * Set the text displayed on this tab. Text may be truncated if there is not
+ * room to display the entire string.
+ *
+ * @param resId A resource ID referring to the text that should be displayed
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setText(int resId);
+
+ /**
+ * Set a custom view to be used for this tab. This overrides values set by
+ * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
+ *
+ * @param view Custom view to be used as a tab.
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setCustomView(View view);
+
+ /**
+ * Set a custom view to be used for this tab. This overrides values set by
+ * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.
+ *
+ * @param layoutResId A layout resource to inflate and use as a custom tab view
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setCustomView(int layoutResId);
+
+ /**
+ * Retrieve a previously set custom view for this tab.
+ *
+ * @return The custom view set by {@link #setCustomView(View)}.
+ */
+ public abstract View getCustomView();
+
+ /**
+ * Give this Tab an arbitrary object to hold for later use.
+ *
+ * @param obj Object to store
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setTag(Object obj);
+
+ /**
+ * @return This Tab's tag object.
+ */
+ public abstract Object getTag();
+
+ /**
+ * Set the {@link TabListener} that will handle switching to and from this tab.
+ * All tabs must have a TabListener set before being added to the ActionBar.
+ *
+ * @param listener Listener to handle tab selection events
+ * @return The current instance for call chaining
+ */
+ public abstract Tab setTabListener(TabListener listener);
+
+ /**
+ * Select this tab. Only valid if the tab has been added to the action bar.
+ */
+ public abstract void select();
+
+ /**
+ * Set a description of this tab's content for use in accessibility support.
+ * If no content description is provided the title will be used.
+ *
+ * @param resId A resource ID referring to the description text
+ * @return The current instance for call chaining
+ * @see #setContentDescription(CharSequence)
+ * @see #getContentDescription()
+ */
+ public abstract Tab setContentDescription(int resId);
+
+ /**
+ * Set a description of this tab's content for use in accessibility support.
+ * If no content description is provided the title will be used.
+ *
+ * @param contentDesc Description of this tab's content
+ * @return The current instance for call chaining
+ * @see #setContentDescription(int)
+ * @see #getContentDescription()
+ */
+ public abstract Tab setContentDescription(CharSequence contentDesc);
+
+ /**
+ * Gets a brief description of this tab's content for use in accessibility support.
+ *
+ * @return Description of this tab's content
+ * @see #setContentDescription(CharSequence)
+ * @see #setContentDescription(int)
+ */
+ public abstract CharSequence getContentDescription();
+ }
+
+ /**
+ * Callback interface invoked when a tab is focused, unfocused, added, or removed.
+ */
+ public interface TabListener {
+ /**
+ * Called when a tab enters the selected state.
+ *
+ * @param tab The tab that was selected
+ * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
+ * during a tab switch. The previous tab's unselect and this tab's select will be
+ * executed in a single transaction. This FragmentTransaction does not support
+ * being added to the back stack.
+ */
+ public void onTabSelected(Tab tab, FragmentTransaction ft);
+
+ /**
+ * Called when a tab exits the selected state.
+ *
+ * @param tab The tab that was unselected
+ * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
+ * during a tab switch. This tab's unselect and the newly selected tab's select
+ * will be executed in a single transaction. This FragmentTransaction does not
+ * support being added to the back stack.
+ */
+ public void onTabUnselected(Tab tab, FragmentTransaction ft);
+
+ /**
+ * Called when a tab that is already selected is chosen again by the user.
+ * Some applications may use this action to return to the top level of a category.
+ *
+ * @param tab The tab that was reselected.
+ * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute
+ * once this method returns. This FragmentTransaction does not support
+ * being added to the back stack.
+ */
+ public void onTabReselected(Tab tab, FragmentTransaction ft);
+ }
+
+ /**
+ * Per-child layout information associated with action bar custom views.
+ *
+ * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity
+ */
+ public static class LayoutParams extends MarginLayoutParams {
+ /**
+ * Gravity for the view associated with these LayoutParams.
+ *
+ * @see android.view.Gravity
+ */
+ public int gravity = -1;
+
+ public LayoutParams(Context c, AttributeSet attrs) {
+ super(c, attrs);
+
+ TypedArray a = c.obtainStyledAttributes(attrs,
+ R.styleable.ActionBarLayout);
+ gravity = a.getInt(R.styleable.ActionBarLayout_android_layout_gravity, -1);
+ a.recycle();
+ }
+
+ public LayoutParams(int width, int height) {
+ super(width, height);
+ this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
+ }
+
+ public LayoutParams(int width, int height, int gravity) {
+ super(width, height);
+ this.gravity = gravity;
+ }
+
+ public LayoutParams(int gravity) {
+ this(WRAP_CONTENT, FILL_PARENT, gravity);
+ }
+
+ public LayoutParams(LayoutParams source) {
+ super(source);
+
+ this.gravity = source.gravity;
+ }
+
+ public LayoutParams(ViewGroup.LayoutParams source) {
+ super(source);
+ }
+ }
+
+ /**
+ * Interface implemented by entities such as Activities that host action bars.
+ */
+ interface Callback {
+ FragmentManager getSupportFragmentManager();
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/app/ActionBarImplCompat.java b/appcompat/eclair/android/support/appcompat/app/ActionBarImplCompat.java
new file mode 100644
index 0000000..0828374
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/app/ActionBarImplCompat.java
@@ -0,0 +1,842 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.app;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Handler;
+import android.support.appcompat.view.ActionMode;
+import android.support.appcompat.view.menu.MenuBuilder;
+import android.support.appcompat.view.menu.SubMenuBuilder;
+import android.support.appcompat.widget.ActionBarContainer;
+import android.support.appcompat.widget.ActionBarContextView;
+import android.support.appcompat.widget.ActionBarOverlayLayout;
+import android.support.appcompat.widget.ActionBarView;
+import android.support.appcompat.widget.ScrollingTabContainerView;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+import android.widget.SpinnerAdapter;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+
+public class ActionBarImplCompat extends ActionBar {
+ private Context mContext;
+ private Context mThemedContext;
+ private ActionBarActivity mActivity;
+ private Dialog mDialog;
+
+ private ActionBarOverlayLayout mOverlayLayout;
+ private ActionBarContainer mContainerView;
+ private ViewGroup mTopVisibilityView;
+ private ActionBarView mActionView;
+ private ActionBarContextView mContextView;
+ private ActionBarContainer mSplitView;
+ private View mContentView;
+ private ScrollingTabContainerView mTabScrollView;
+
+ private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>();
+
+ private TabImpl mSelectedTab;
+ private int mSavedTabPosition = INVALID_POSITION;
+
+ private boolean mDisplayHomeAsUpSet;
+
+ ActionModeImpl mActionMode;
+ ActionMode mDeferredDestroyActionMode;
+ ActionMode.Callback mDeferredModeDestroyCallback;
+
+ private boolean mLastMenuVisibility;
+ private ArrayList<OnMenuVisibilityListener> mMenuVisibilityListeners =
+ new ArrayList<OnMenuVisibilityListener>();
+
+ private static final int CONTEXT_DISPLAY_NORMAL = 0;
+ private static final int CONTEXT_DISPLAY_SPLIT = 1;
+
+ private static final int INVALID_POSITION = -1;
+
+ private int mContextDisplayMode;
+ private boolean mHasEmbeddedTabs;
+
+ final Handler mHandler = new Handler();
+ Runnable mTabSelector;
+
+ private int mCurWindowVisibility = View.VISIBLE;
+
+ private boolean mHiddenByApp;
+ private boolean mHiddenBySystem;
+ private boolean mShowingForMode;
+
+ private boolean mNowShowing = true;
+
+ // TODO: What to do about animations?
+ // private Animator mCurrentShowAnim;
+ private boolean mShowHideAnimationEnabled;
+
+ private Callback mCallback;
+
+ public ActionBarImplCompat(ActionBarActivity activity, Callback callback) {
+ mActivity = activity;
+ mCallback = callback;
+ }
+
+ @Override
+ public void setCustomView(View view) {
+ mActionView.setCustomNavigationView(view);
+ }
+
+ @Override
+ public void setCustomView(View view, LayoutParams layoutParams) {
+ view.setLayoutParams(layoutParams);
+ mActionView.setCustomNavigationView(view);
+
+ }
+
+ @Override
+ public void setCustomView(int resId) {
+ setCustomView(LayoutInflater.from(getThemedContext())
+ .inflate(resId, mActionView, false));
+
+ }
+
+ @Override
+ public void setIcon(int resId) {
+ mActionView.setIcon(resId);
+ }
+
+ @Override
+ public void setIcon(Drawable icon) {
+ mActionView.setIcon(icon);
+ }
+
+ @Override
+ public void setLogo(int resId) {
+ mActionView.setLogo(resId);
+ }
+
+ @Override
+ public void setLogo(Drawable logo) {
+ mActionView.setLogo(logo);
+ }
+
+ @Override
+ public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
+ mActionView.setDropdownAdapter(adapter);
+ mActionView.setCallback(callback);
+ }
+
+ @Override
+ public void setSelectedNavigationItem(int position) {
+ switch (mActionView.getNavigationMode()) {
+ case NAVIGATION_MODE_TABS:
+ selectTab(mTabs.get(position));
+ break;
+ case NAVIGATION_MODE_LIST:
+ mActionView.setDropdownSelectedPosition(position);
+ break;
+ default:
+ throw new IllegalStateException(
+ "setSelectedNavigationIndex not valid for current navigation mode");
+ }
+ }
+
+ @Override
+ public int getSelectedNavigationIndex() {
+ switch (mActionView.getNavigationMode()) {
+ case NAVIGATION_MODE_TABS:
+ return mSelectedTab != null ? mSelectedTab.getPosition() : -1;
+ case NAVIGATION_MODE_LIST:
+ return mActionView.getDropdownSelectedPosition();
+ default:
+ return -1;
+ }
+ }
+
+ @Override
+ public int getNavigationItemCount() {
+ switch (mActionView.getNavigationMode()) {
+ case NAVIGATION_MODE_TABS:
+ return mTabs.size();
+ case NAVIGATION_MODE_LIST:
+ SpinnerAdapter adapter = mActionView.getDropdownAdapter();
+ return adapter != null ? adapter.getCount() : 0;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mActionView.setTitle(title);
+ }
+
+ @Override
+ public void setTitle(int resId) {
+ setTitle(mContext.getString(resId));
+ }
+
+ @Override
+ public void setSubtitle(CharSequence subtitle) {
+ mActionView.setSubtitle(subtitle);
+ }
+
+ @Override
+ public void setSubtitle(int resId) {
+ setSubtitle(mContext.getString(resId));
+ }
+
+ @Override
+ public void setDisplayOptions(int options) {
+ if ((options & DISPLAY_HOME_AS_UP) != 0) {
+ mDisplayHomeAsUpSet = true;
+ }
+ mActionView.setDisplayOptions(options);
+ }
+
+ @Override
+ public void setDisplayOptions(int options, int mask) {
+ final int current = mActionView.getDisplayOptions();
+ if ((mask & DISPLAY_HOME_AS_UP) != 0) {
+ mDisplayHomeAsUpSet = true;
+ }
+ mActionView.setDisplayOptions((options & mask) | (current & ~mask));
+ }
+
+ @Override
+ public void setDisplayUseLogoEnabled(boolean useLogo) {
+ setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO);
+ }
+
+ @Override
+ public void setDisplayShowHomeEnabled(boolean showHome) {
+ setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME);
+ }
+
+ @Override
+ public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
+ setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP);
+ }
+
+ @Override
+ public void setDisplayShowTitleEnabled(boolean showTitle) {
+ setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE);
+ }
+
+ @Override
+ public void setDisplayShowCustomEnabled(boolean showCustom) {
+ setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM);
+ }
+
+ @Override
+ public void setBackgroundDrawable(Drawable d) {
+ mContainerView.setPrimaryBackground(d);
+ }
+
+ @Override
+ public View getCustomView() {
+ return mActionView.getCustomNavigationView();
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mActionView.getTitle();
+ }
+
+ @Override
+ public CharSequence getSubtitle() {
+ return mActionView.getSubtitle();
+ }
+
+ @Override
+ public int getNavigationMode() {
+ return mActionView.getNavigationMode();
+ }
+
+ @Override
+ public void setNavigationMode(int mode) {
+ final int oldMode = mActionView.getNavigationMode();
+ switch (oldMode) {
+ case NAVIGATION_MODE_TABS:
+ mSavedTabPosition = getSelectedNavigationIndex();
+ selectTab(null);
+ mTabScrollView.setVisibility(View.GONE);
+ break;
+ }
+ // Removed: Not needed on older devices.
+ /*if (oldMode != mode && !mHasEmbeddedTabs) {
+ if (mOverlayLayout != null) {
+ mOverlayLayout.requestFitSystemWindows();
+ }
+ }*/
+ mActionView.setNavigationMode(mode);
+ switch (mode) {
+ case NAVIGATION_MODE_TABS:
+ ensureTabsExist();
+ mTabScrollView.setVisibility(View.VISIBLE);
+ if (mSavedTabPosition != INVALID_POSITION) {
+ setSelectedNavigationItem(mSavedTabPosition);
+ mSavedTabPosition = INVALID_POSITION;
+ }
+ break;
+ }
+ mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
+ }
+
+ @Override
+ public int getDisplayOptions() {
+ return mActionView.getDisplayOptions();
+ }
+
+ @Override
+ public Tab newTab() {
+ return new TabImpl();
+ }
+
+ @Override
+ public void addTab(Tab tab) {
+ addTab(tab, mTabs.isEmpty());
+ }
+
+ @Override
+ public void addTab(Tab tab, boolean setSelected) {
+ ensureTabsExist();
+ mTabScrollView.addTab(tab, setSelected);
+ configureTab(tab, mTabs.size());
+ if (setSelected) {
+ selectTab(tab);
+ }
+ }
+
+ @Override
+ public void addTab(Tab tab, int position) {
+ addTab(tab, position, mTabs.isEmpty());
+ }
+
+ @Override
+ public void addTab(Tab tab, int position, boolean setSelected) {
+ ensureTabsExist();
+ mTabScrollView.addTab(tab, position, setSelected);
+ configureTab(tab, position);
+ if (setSelected) {
+ selectTab(tab);
+ }
+ }
+
+ @Override
+ public void removeTab(Tab tab) {
+ removeTabAt(tab.getPosition());
+ }
+
+ @Override
+ public void removeTabAt(int position) {
+ if (mTabScrollView == null) {
+ // No tabs around to remove
+ return;
+ }
+
+ int selectedTabPosition = mSelectedTab != null
+ ? mSelectedTab.getPosition() : mSavedTabPosition;
+ mTabScrollView.removeTabAt(position);
+ TabImpl removedTab = mTabs.remove(position);
+ if (removedTab != null) {
+ removedTab.setPosition(-1);
+ }
+
+ final int newTabCount = mTabs.size();
+ for (int i = position; i < newTabCount; i++) {
+ mTabs.get(i).setPosition(i);
+ }
+
+ if (selectedTabPosition == position) {
+ selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
+ }
+ }
+
+ @Override
+ public void removeAllTabs() {
+ cleanupTabs();
+ }
+
+ @Override
+ public void selectTab(Tab tab) {
+ if (getNavigationMode() != NAVIGATION_MODE_TABS) {
+ mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION;
+ return;
+ }
+
+ final FragmentTransaction trans = mActivity.getSupportFragmentManager().beginTransaction()
+ .disallowAddToBackStack();
+
+ if (mSelectedTab == tab) {
+ if (mSelectedTab != null) {
+ mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
+ mTabScrollView.animateToTab(tab.getPosition());
+ }
+ } else {
+ mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
+ if (mSelectedTab != null) {
+ mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
+ }
+ mSelectedTab = (TabImpl) tab;
+ if (mSelectedTab != null) {
+ mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
+ }
+ }
+
+ if (!trans.isEmpty()) {
+ trans.commit();
+ }
+ }
+
+ @Override
+ public Tab getSelectedTab() {
+ return mSelectedTab;
+ }
+
+ @Override
+ public Tab getTabAt(int index) {
+ return mTabs.get(index);
+ }
+
+ @Override
+ public int getTabCount() {
+ return mTabs.size();
+ }
+
+ @Override
+ public int getHeight() {
+ return mContainerView.getHeight();
+ }
+
+ @Override
+ public void show() {
+ if (mHiddenByApp) {
+ mHiddenByApp = false;
+ updateVisibility(false);
+ }
+ }
+
+ @Override
+ public void hide() {
+ if (!mHiddenByApp) {
+ mHiddenByApp = true;
+ updateVisibility(false);
+ }
+ }
+
+ @Override
+ public boolean isShowing() {
+ return mNowShowing;
+ }
+
+ @Override
+ public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
+ mMenuVisibilityListeners.add(listener);
+ }
+
+ @Override
+ public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
+ mMenuVisibilityListeners.remove(listener);
+ }
+
+ /**
+ * @hide
+ */
+ public class TabImpl extends ActionBar.Tab {
+ private ActionBar.TabListener mCallback;
+ private Object mTag;
+ private Drawable mIcon;
+ private CharSequence mText;
+ private CharSequence mContentDesc;
+ private int mPosition = -1;
+ private View mCustomView;
+
+ @Override
+ public Object getTag() {
+ return mTag;
+ }
+
+ @Override
+ public Tab setTag(Object tag) {
+ mTag = tag;
+ return this;
+ }
+
+ public ActionBar.TabListener getCallback() {
+ return mCallback;
+ }
+
+ @Override
+ public Tab setTabListener(ActionBar.TabListener callback) {
+ mCallback = callback;
+ return this;
+ }
+
+ @Override
+ public View getCustomView() {
+ return mCustomView;
+ }
+
+ @Override
+ public Tab setCustomView(View view) {
+ mCustomView = view;
+ if (mPosition >= 0) {
+ mTabScrollView.updateTab(mPosition);
+ }
+ return this;
+ }
+
+ @Override
+ public Tab setCustomView(int layoutResId) {
+ return setCustomView(LayoutInflater.from(getThemedContext())
+ .inflate(layoutResId, null));
+ }
+
+ @Override
+ public Drawable getIcon() {
+ return mIcon;
+ }
+
+ @Override
+ public int getPosition() {
+ return mPosition;
+ }
+
+ public void setPosition(int position) {
+ mPosition = position;
+ }
+
+ @Override
+ public CharSequence getText() {
+ return mText;
+ }
+
+ @Override
+ public Tab setIcon(Drawable icon) {
+ mIcon = icon;
+ if (mPosition >= 0) {
+ mTabScrollView.updateTab(mPosition);
+ }
+ return this;
+ }
+
+ @Override
+ public Tab setIcon(int resId) {
+ return setIcon(mContext.getResources().getDrawable(resId));
+ }
+
+ @Override
+ public Tab setText(CharSequence text) {
+ mText = text;
+ if (mPosition >= 0) {
+ mTabScrollView.updateTab(mPosition);
+ }
+ return this;
+ }
+
+ @Override
+ public Tab setText(int resId) {
+ return setText(mContext.getResources().getText(resId));
+ }
+
+ @Override
+ public void select() {
+ selectTab(this);
+ }
+
+ @Override
+ public Tab setContentDescription(int resId) {
+ return setContentDescription(mContext.getResources().getText(resId));
+ }
+
+ @Override
+ public Tab setContentDescription(CharSequence contentDesc) {
+ mContentDesc = contentDesc;
+ if (mPosition >= 0) {
+ mTabScrollView.updateTab(mPosition);
+ }
+ return this;
+ }
+
+ @Override
+ public CharSequence getContentDescription() {
+ return mContentDesc;
+ }
+ }
+
+ /**
+ * @hide
+ */
+ //public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
+ public class ActionModeImpl extends ActionMode {
+ private ActionMode.Callback mCallback;
+ private MenuBuilder mMenu;
+ private WeakReference<View> mCustomView;
+
+ public ActionModeImpl(ActionMode.Callback callback) {
+ mCallback = callback;
+ mMenu = new MenuBuilder(getThemedContext())
+ .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ mMenu.setCallback(this);
+ }
+
+ @Override
+ public MenuInflater getMenuInflater() {
+ return new MenuInflater(getThemedContext());
+ }
+
+ @Override
+ public Menu getMenu() {
+ return mMenu;
+ }
+
+ @Override
+ public void finish() {
+ if (mActionMode != this) {
+ // Not the active action mode - no-op
+ return;
+ }
+
+ // If this change in state is going to cause the action bar
+ // to be hidden, defer the onDestroy callback until the animation
+ // is finished and associated relayout is about to happen. This lets
+ // apps better anticipate visibility and layout behavior.
+ if (!checkShowingFlags(mHiddenByApp, mHiddenBySystem, false)) {
+ // With the current state but the action bar hidden, our
+ // overall showing state is going to be false.
+ mDeferredDestroyActionMode = this;
+ mDeferredModeDestroyCallback = mCallback;
+ } else {
+ mCallback.onDestroyActionMode(this);
+ }
+ mCallback = null;
+ //animateToMode(false);
+
+ // Clear out the context mode views after the animation finishes
+ mContextView.closeMode();
+ mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+
+ mActionMode = null;
+ }
+
+ @Override
+ public void invalidate() {
+ //mMenu.stopDispatchingItemsChanged();
+ try {
+ mCallback.onPrepareActionMode(this, mMenu);
+ } finally {
+ mMenu.startDispatchingItemsChanged();
+ }
+ }
+
+ public boolean dispatchOnCreate() {
+ mMenu.stopDispatchingItemsChanged();
+ try {
+ return mCallback.onCreateActionMode(this, mMenu);
+ } finally {
+ //mMenu.startDispatchingItemsChanged();
+ }
+ }
+
+ @Override
+ public void setCustomView(View view) {
+ mContextView.setCustomView(view);
+ mCustomView = new WeakReference<View>(view);
+ }
+
+ @Override
+ public void setSubtitle(CharSequence subtitle) {
+ mContextView.setSubtitle(subtitle);
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mContextView.setTitle(title);
+ }
+
+ @Override
+ public void setTitle(int resId) {
+ setTitle(mContext.getResources().getString(resId));
+ }
+
+ @Override
+ public void setSubtitle(int resId) {
+ setSubtitle(mContext.getResources().getString(resId));
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mContextView.getTitle();
+ }
+
+ @Override
+ public CharSequence getSubtitle() {
+ return mContextView.getSubtitle();
+ }
+
+ @Override
+ public void setTitleOptionalHint(boolean titleOptional) {
+ super.setTitleOptionalHint(titleOptional);
+ mContextView.setTitleOptional(titleOptional);
+ }
+
+ @Override
+ public boolean isTitleOptional() {
+ return mContextView.isTitleOptional();
+ }
+
+ @Override
+ public View getCustomView() {
+ return mCustomView != null ? mCustomView.get() : null;
+ }
+
+ public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
+ if (mCallback != null) {
+ return mCallback.onActionItemClicked(this, item);
+ } else {
+ return false;
+ }
+ }
+
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ }
+
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
+ if (mCallback == null) {
+ return false;
+ }
+
+ if (!subMenu.hasVisibleItems()) {
+ return true;
+ }
+
+ //new MenuPopupHelper(getThemedContext(), subMenu).show();
+ return true;
+ }
+
+ public void onCloseSubMenu(SubMenuBuilder menu) {
+ }
+
+ public void onMenuModeChange(Menu menu) {
+ if (mCallback == null) {
+ return;
+ }
+ invalidate();
+ mContextView.showOverflowMenu();
+ }
+ }
+
+ /** TODO(trevorjohns): Methods below this line were missing! ***********************************/
+
+ private void ensureTabsExist() {
+ if (mTabScrollView != null) {
+ return;
+ }
+
+ ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext);
+
+ if (mHasEmbeddedTabs) {
+ tabScroller.setVisibility(View.VISIBLE);
+ mActionView.setEmbeddedTabView(tabScroller);
+ } else {
+ if (getNavigationMode() == NAVIGATION_MODE_TABS) {
+ tabScroller.setVisibility(View.VISIBLE);
+ // Removed: Not needed on older devices.
+ /*if (mOverlayLayout != null) {
+ mOverlayLayout.requestFitSystemWindows();
+ }*/
+ } else {
+ tabScroller.setVisibility(View.GONE);
+ }
+ mContainerView.setTabContainer(tabScroller);
+ }
+ mTabScrollView = tabScroller;
+ }
+
+ private void configureTab(Tab tab, int position) {
+ final TabImpl tabi = (TabImpl) tab;
+ final ActionBar.TabListener callback = tabi.getCallback();
+
+ if (callback == null) {
+ throw new IllegalStateException("Action Bar Tab must have a Callback");
+ }
+
+ tabi.setPosition(position);
+ mTabs.add(position, tabi);
+
+ final int count = mTabs.size();
+ for (int i = position + 1; i < count; i++) {
+ mTabs.get(i).setPosition(i);
+ }
+ }
+
+ private void cleanupTabs() {
+ if (mSelectedTab != null) {
+ selectTab(null);
+ }
+ mTabs.clear();
+ if (mTabScrollView != null) {
+ mTabScrollView.removeAllTabs();
+ }
+ mSavedTabPosition = INVALID_POSITION;
+ }
+
+ private static boolean checkShowingFlags(boolean hiddenByApp, boolean hiddenBySystem,
+ boolean showingForMode) {
+ if (showingForMode) {
+ return true;
+ } else if (hiddenByApp || hiddenBySystem) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private void updateVisibility(boolean fromSystem) {
+ // Based on the current state, should we be hidden or shown?
+ final boolean shown = checkShowingFlags(mHiddenByApp, mHiddenBySystem,
+ mShowingForMode);
+
+ if (shown) {
+ if (!mNowShowing) {
+ mNowShowing = true;
+ doShow(fromSystem);
+ }
+ } else {
+ if (mNowShowing) {
+ mNowShowing = false;
+ doHide(fromSystem);
+ }
+ }
+ }
+ public void doShow(boolean fromSystem) {
+ // TODO(trevorjohns): Animation removed from doShow/doHide. Verify that this is correct.
+ mTopVisibilityView.setVisibility(View.VISIBLE);
+ }
+
+ public void doHide(boolean fromSystem) {
+ mTopVisibilityView.setVisibility(View.INVISIBLE);
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/ActionBarPolicy.java b/appcompat/eclair/android/support/appcompat/view/ActionBarPolicy.java
new file mode 100644
index 0000000..976ae6a
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/ActionBarPolicy.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view;
+
+import android.support.appcompat.R;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+
+/**
+ * Allows components to query for various configuration policy decisions
+ * about how the action bar should lay out and behave on the current device.
+ */
+public class ActionBarPolicy {
+ private Context mContext;
+
+ public static ActionBarPolicy get(Context context) {
+ return new ActionBarPolicy(context);
+ }
+
+ private ActionBarPolicy(Context context) {
+ mContext = context;
+ }
+
+ public int getMaxActionButtons() {
+ return mContext.getResources().getInteger(R.integer.max_action_buttons);
+ }
+
+ public boolean showsOverflowMenuButton() {
+ // Permanent menu key is always present on pre-HC devices
+ // return !ViewConfiguration.get(mContext).hasPermanentMenuKey();
+ return false;
+ }
+
+ public int getEmbeddedMenuWidthLimit() {
+ return mContext.getResources().getDisplayMetrics().widthPixels / 2;
+ }
+
+ public boolean hasEmbeddedTabs() {
+ final int targetSdk = mContext.getApplicationInfo().targetSdkVersion;
+ // DISABLED: Compatibility implementation will not be used on JB
+ /*if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) {
+ return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs);
+ }*/
+
+ // The embedded tabs policy changed in Jellybean; give older apps the old policy
+ // so they get what they expect.
+ return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs_pre_jb);
+ }
+
+ public int getTabContainerHeight() {
+ TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar,
+ R.attr.actionBarStyle, 0);
+ int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
+ Resources r = mContext.getResources();
+ if (!hasEmbeddedTabs()) {
+ // Stacked tabs; limit the height
+ height = Math.min(height,
+ r.getDimensionPixelSize(R.dimen.action_bar_stacked_max_height));
+ }
+ a.recycle();
+ return height;
+ }
+
+ public boolean enableHomeButtonByDefault() {
+ // Older apps get the home button interaction enabled by default.
+ // Newer apps need to enable it explicitly.
+ return mContext.getApplicationInfo().targetSdkVersion < 14; // ICE_CREAM_SANDWICH
+ }
+
+ public int getStackedTabMaxWidth() {
+ return mContext.getResources().getDimensionPixelSize(
+ R.dimen.action_bar_stacked_tab_max_width);
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/ActionMode.java b/appcompat/eclair/android/support/appcompat/view/ActionMode.java
new file mode 100644
index 0000000..9f64c20
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/ActionMode.java
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view;
+
+
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+
+/**
+ * Represents a contextual mode of the user interface. Action modes can be used to provide
+ * alternative interaction modes and replace parts of the normal UI until finished.
+ * Examples of good action modes include text selection and contextual actions.
+ * <div class="special reference">
+ * <h3>Developer Guides</h3>
+ * <p>For information about how to provide contextual actions with {@code ActionMode},
+ * read the <a href="{@docRoot}guide/topics/ui/menus.html#context-menu">Menus</a>
+ * developer guide.</p>
+ * </div>
+ */
+public abstract class ActionMode {
+ private Object mTag;
+ private boolean mTitleOptionalHint;
+
+ /**
+ * Set a tag object associated with this ActionMode.
+ *
+ * <p>Like the tag available to views, this allows applications to associate arbitrary
+ * data with an ActionMode for later reference.
+ *
+ * @param tag Tag to associate with this ActionMode
+ *
+ * @see #getTag()
+ */
+ public void setTag(Object tag) {
+ mTag = tag;
+ }
+
+ /**
+ * Retrieve the tag object associated with this ActionMode.
+ *
+ * <p>Like the tag available to views, this allows applications to associate arbitrary
+ * data with an ActionMode for later reference.
+ *
+ * @return Tag associated with this ActionMode
+ *
+ * @see #setTag(Object)
+ */
+ public Object getTag() {
+ return mTag;
+ }
+
+ /**
+ * Set the title of the action mode. This method will have no visible effect if
+ * a custom view has been set.
+ *
+ * @param title Title string to set
+ *
+ * @see #setTitle(int)
+ * @see #setCustomView(View)
+ */
+ public abstract void setTitle(CharSequence title);
+
+ /**
+ * Set the title of the action mode. This method will have no visible effect if
+ * a custom view has been set.
+ *
+ * @param resId Resource ID of a string to set as the title
+ *
+ * @see #setTitle(CharSequence)
+ * @see #setCustomView(View)
+ */
+ public abstract void setTitle(int resId);
+
+ /**
+ * Set the subtitle of the action mode. This method will have no visible effect if
+ * a custom view has been set.
+ *
+ * @param subtitle Subtitle string to set
+ *
+ * @see #setSubtitle(int)
+ * @see #setCustomView(View)
+ */
+ public abstract void setSubtitle(CharSequence subtitle);
+
+ /**
+ * Set the subtitle of the action mode. This method will have no visible effect if
+ * a custom view has been set.
+ *
+ * @param resId Resource ID of a string to set as the subtitle
+ *
+ * @see #setSubtitle(CharSequence)
+ * @see #setCustomView(View)
+ */
+ public abstract void setSubtitle(int resId);
+
+ /**
+ * Set whether or not the title/subtitle display for this action mode
+ * is optional.
+ *
+ * <p>In many cases the supplied title for an action mode is merely
+ * meant to add context and is not strictly required for the action
+ * mode to be useful. If the title is optional, the system may choose
+ * to hide the title entirely rather than truncate it due to a lack
+ * of available space.</p>
+ *
+ * <p>Note that this is merely a hint; the underlying implementation
+ * may choose to ignore this setting under some circumstances.</p>
+ *
+ * @param titleOptional true if the title only presents optional information.
+ */
+ public void setTitleOptionalHint(boolean titleOptional) {
+ mTitleOptionalHint = titleOptional;
+ }
+
+ /**
+ * @return true if this action mode has been given a hint to consider the
+ * title/subtitle display to be optional.
+ *
+ * @see #setTitleOptionalHint(boolean)
+ * @see #isTitleOptional()
+ */
+ public boolean getTitleOptionalHint() {
+ return mTitleOptionalHint;
+ }
+
+ /**
+ * @return true if this action mode considers the title and subtitle fields
+ * as optional. Optional titles may not be displayed to the user.
+ */
+ public boolean isTitleOptional() {
+ return false;
+ }
+
+ /**
+ * Set a custom view for this action mode. The custom view will take the place of
+ * the title and subtitle. Useful for things like search boxes.
+ *
+ * @param view Custom view to use in place of the title/subtitle.
+ *
+ * @see #setTitle(CharSequence)
+ * @see #setSubtitle(CharSequence)
+ */
+ public abstract void setCustomView(View view);
+
+ /**
+ * Invalidate the action mode and refresh menu content. The mode's
+ * {@link ActionMode.Callback} will have its
+ * {@link Callback#onPrepareActionMode(ActionMode, Menu)} method called.
+ * If it returns true the menu will be scanned for updated content and any relevant changes
+ * will be reflected to the user.
+ */
+ public abstract void invalidate();
+
+ /**
+ * Finish and close this action mode. The action mode's {@link ActionMode.Callback} will
+ * have its {@link Callback#onDestroyActionMode(ActionMode)} method called.
+ */
+ public abstract void finish();
+
+ /**
+ * Returns the menu of actions that this action mode presents.
+ * @return The action mode's menu.
+ */
+ public abstract Menu getMenu();
+
+ /**
+ * Returns the current title of this action mode.
+ * @return Title text
+ */
+ public abstract CharSequence getTitle();
+
+ /**
+ * Returns the current subtitle of this action mode.
+ * @return Subtitle text
+ */
+ public abstract CharSequence getSubtitle();
+
+ /**
+ * Returns the current custom view for this action mode.
+ * @return The current custom view
+ */
+ public abstract View getCustomView();
+
+ /**
+ * Returns a {@link MenuInflater} with the ActionMode's context.
+ */
+ public abstract MenuInflater getMenuInflater();
+
+ /**
+ * Returns whether the UI presenting this action mode can take focus or not.
+ * This is used by internal components within the framework that would otherwise
+ * present an action mode UI that requires focus, such as an EditText as a custom view.
+ *
+ * @return true if the UI used to show this action mode can take focus
+ * @hide Internal use only
+ */
+ public boolean isUiFocusable() {
+ return true;
+ }
+
+ /**
+ * Callback interface for action modes. Supplied to
+ * {@link View#startActionMode(Callback)}, a Callback
+ * configures and handles events raised by a user's interaction with an action mode.
+ *
+ * <p>An action mode's lifecycle is as follows:
+ * <ul>
+ * <li>{@link Callback#onCreateActionMode(ActionMode, Menu)} once on initial
+ * creation</li>
+ * <li>{@link Callback#onPrepareActionMode(ActionMode, Menu)} after creation
+ * and any time the {@link ActionMode} is invalidated</li>
+ * <li>{@link Callback#onActionItemClicked(ActionMode, MenuItem)} any time a
+ * contextual action button is clicked</li>
+ * <li>{@link Callback#onDestroyActionMode(ActionMode)} when the action mode
+ * is closed</li>
+ * </ul>
+ */
+ public interface Callback {
+ /**
+ * Called when action mode is first created. The menu supplied will be used to
+ * generate action buttons for the action mode.
+ *
+ * @param mode ActionMode being created
+ * @param menu Menu used to populate action buttons
+ * @return true if the action mode should be created, false if entering this
+ * mode should be aborted.
+ */
+ public boolean onCreateActionMode(ActionMode mode, Menu menu);
+
+ /**
+ * Called to refresh an action mode's action menu whenever it is invalidated.
+ *
+ * @param mode ActionMode being prepared
+ * @param menu Menu used to populate action buttons
+ * @return true if the menu or action mode was updated, false otherwise.
+ */
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu);
+
+ /**
+ * Called to report a user click on an action button.
+ *
+ * @param mode The current ActionMode
+ * @param item The item that was clicked
+ * @return true if this callback handled the event, false if the standard MenuItem
+ * invocation should continue.
+ */
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item);
+
+ /**
+ * Called when an action mode is about to be exited and destroyed.
+ *
+ * @param mode The current ActionMode being destroyed
+ */
+ public void onDestroyActionMode(ActionMode mode);
+ }
+}
\ No newline at end of file
diff --git a/appcompat/eclair/android/support/appcompat/view/ActionProvider.java b/appcompat/eclair/android/support/appcompat/view/ActionProvider.java
new file mode 100644
index 0000000..b1e9a6b
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/ActionProvider.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view;
+
+import android.content.Context;
+import android.view.SubMenu;
+import android.view.View;
+
+/**
+ * This class is a mediator for accomplishing a given task, for example sharing a file.
+ * It is responsible for creating a view that performs an action that accomplishes the task.
+ * This class also implements other functions such a performing a default action.
+ * <p>
+ * An ActionProvider can be optionally specified for a {@link MenuItem} and in such a
+ * case it will be responsible for creating the action view that appears in the
+ * {@link android.app.ActionBar} as a substitute for the menu item when the item is
+ * displayed as an action item. Also the provider is responsible for performing a
+ * default action if a menu item placed on the overflow menu of the ActionBar is
+ * selected and none of the menu item callbacks has handled the selection. For this
+ * case the provider can also optionally provide a sub-menu for accomplishing the
+ * task at hand.
+ * </p>
+ * <p>
+ * There are two ways for using an action provider for creating and handling of action views:
+ * <ul>
+ * <li>
+ * Setting the action provider on a {@link MenuItem} directly by calling
+ * {@link MenuItem#setActionProvider(ActionProvider)}.
+ * </li>
+ * <li>
+ * Declaring the action provider in the menu XML resource. For example:
+ * <pre>
+ * <code>
+ * <item android:id="@+id/my_menu_item"
+ * android:title="Title"
+ * android:icon="@drawable/my_menu_item_icon"
+ * android:showAsAction="ifRoom"
+ * android:actionProviderClass="foo.bar.SomeActionProvider" />
+ * </code>
+ * </pre>
+ * </li>
+ * </ul>
+ * </p>
+ *
+ * @see MenuItem#setActionProvider(ActionProvider)
+ * @see MenuItem#getActionProvider()
+ */
+public abstract class ActionProvider {
+ private SubUiVisibilityListener mSubUiVisibilityListener;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param context Context for accessing resources.
+ */
+ public ActionProvider(Context context) {
+ }
+
+ /**
+ * Factory method for creating new action views.
+ *
+ * @return A new action view.
+ */
+ public abstract View onCreateActionView();
+
+ /**
+ * Performs an optional default action.
+ * <p>
+ * For the case of an action provider placed in a menu item not shown as an action this
+ * method is invoked if previous callbacks for processing menu selection has handled
+ * the event.
+ * </p>
+ * <p>
+ * A menu item selection is processed in the following order:
+ * <ul>
+ * <li>
+ * Receiving a call to {@link MenuItem.OnMenuItemClickListener#onMenuItemClick
+ * MenuItem.OnMenuItemClickListener.onMenuItemClick}.
+ * </li>
+ * <li>
+ * Receiving a call to {@link android.app.Activity#onOptionsItemSelected(MenuItem)
+ * Activity.onOptionsItemSelected(MenuItem)}
+ * </li>
+ * <li>
+ * Receiving a call to {@link android.app.Fragment#onOptionsItemSelected(MenuItem)
+ * Fragment.onOptionsItemSelected(MenuItem)}
+ * </li>
+ * <li>
+ * Launching the {@link android.content.Intent} set via
+ * {@link MenuItem#setIntent(android.content.Intent) MenuItem.setIntent(android.content.Intent)}
+ * </li>
+ * <li>
+ * Invoking this method.
+ * </li>
+ * </ul>
+ * </p>
+ * <p>
+ * The default implementation does not perform any action and returns false.
+ * </p>
+ */
+ public boolean onPerformDefaultAction() {
+ return false;
+ }
+
+ /**
+ * Determines if this ActionProvider has a submenu associated with it.
+ *
+ * <p>Associated submenus will be shown when an action view is not. This
+ * provider instance will receive a call to {@link #onPrepareSubMenu(SubMenu)}
+ * after the call to {@link #onPerformDefaultAction()} and before a submenu is
+ * displayed to the user.
+ *
+ * @return true if the item backed by this provider should have an associated submenu
+ */
+ public boolean hasSubMenu() {
+ return false;
+ }
+
+ /**
+ * Called to prepare an associated submenu for the menu item backed by this ActionProvider.
+ *
+ * <p>if {@link #hasSubMenu()} returns true, this method will be called when the
+ * menu item is selected to prepare the submenu for presentation to the user. Apps
+ * may use this to create or alter submenu content right before display.
+ *
+ * @param subMenu Submenu that will be displayed
+ */
+ public void onPrepareSubMenu(SubMenu subMenu) {
+ }
+
+ /**
+ * Notify the system that the visibility of an action view's sub-UI such as
+ * an anchored popup has changed. This will affect how other system
+ * visibility notifications occur.
+ *
+ * @hide Pending future API approval
+ */
+ public void subUiVisibilityChanged(boolean isVisible) {
+ if (mSubUiVisibilityListener != null) {
+ mSubUiVisibilityListener.onSubUiVisibilityChanged(isVisible);
+ }
+ }
+
+ /**
+ * @hide Internal use only
+ */
+ public void setSubUiVisibilityListener(SubUiVisibilityListener listener) {
+ mSubUiVisibilityListener = listener;
+ }
+
+ /**
+ * @hide Internal use only
+ */
+ public interface SubUiVisibilityListener {
+ public void onSubUiVisibilityChanged(boolean isVisible);
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/Menu.java b/appcompat/eclair/android/support/appcompat/view/Menu.java
new file mode 100644
index 0000000..fd9d8ec
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/Menu.java
@@ -0,0 +1,448 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.view.KeyEvent;
+
+/**
+ * Interface for managing the items in a menu.
+ * <p>
+ * By default, every Activity supports an options menu of actions or options.
+ * You can add items to this menu and handle clicks on your additions. The
+ * easiest way of adding menu items is inflating an XML file into the
+ * {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to
+ * clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and
+ * {@link Activity#onContextItemSelected(MenuItem)}.
+ * <p>
+ * Different menu types support different features:
+ * <ol>
+ * <li><b>Context menus</b>: Do not support item shortcuts and item icons.
+ * <li><b>Options menus</b>: The <b>icon menus</b> do not support item check
+ * marks and only show the item's
+ * {@link MenuItem#setTitleCondensed(CharSequence) condensed title}. The
+ * <b>expanded menus</b> (only available if six or more menu items are visible,
+ * reached via the 'More' item in the icon menu) do not show item icons, and
+ * item check marks are discouraged.
+ * <li><b>Sub menus</b>: Do not support item icons, or nested sub menus.
+ * </ol>
+ *
+ * <div class="special reference">
+ * <h3>Developer Guides</h3>
+ * <p>For more information about creating menus, read the
+ * <a href="{@docRoot}guide/topics/ui/menus.html">Menus</a> developer guide.</p>
+ * </div>
+ */
+public interface Menu {
+
+ /**
+ * This is the part of an order integer that the user can provide.
+ * @hide
+ */
+ static final int USER_MASK = 0x0000ffff;
+ /**
+ * Bit shift of the user portion of the order integer.
+ * @hide
+ */
+ static final int USER_SHIFT = 0;
+
+ /**
+ * This is the part of an order integer that supplies the category of the
+ * item.
+ * @hide
+ */
+ static final int CATEGORY_MASK = 0xffff0000;
+ /**
+ * Bit shift of the category portion of the order integer.
+ * @hide
+ */
+ static final int CATEGORY_SHIFT = 16;
+
+ /**
+ * Value to use for group and item identifier integers when you don't care
+ * about them.
+ */
+ static final int NONE = 0;
+
+ /**
+ * First value for group and item identifier integers.
+ */
+ static final int FIRST = 1;
+
+ // Implementation note: Keep these CATEGORY_* in sync with the category enum
+ // in attrs.xml
+
+ /**
+ * Category code for the order integer for items/groups that are part of a
+ * container -- or/add this with your base value.
+ */
+ static final int CATEGORY_CONTAINER = 0x00010000;
+
+ /**
+ * Category code for the order integer for items/groups that are provided by
+ * the system -- or/add this with your base value.
+ */
+ static final int CATEGORY_SYSTEM = 0x00020000;
+
+ /**
+ * Category code for the order integer for items/groups that are
+ * user-supplied secondary (infrequently used) options -- or/add this with
+ * your base value.
+ */
+ static final int CATEGORY_SECONDARY = 0x00030000;
+
+ /**
+ * Category code for the order integer for items/groups that are
+ * alternative actions on the data that is currently displayed -- or/add
+ * this with your base value.
+ */
+ static final int CATEGORY_ALTERNATIVE = 0x00040000;
+
+ /**
+ * Flag for {@link #addIntentOptions}: if set, do not automatically remove
+ * any existing menu items in the same group.
+ */
+ static final int FLAG_APPEND_TO_GROUP = 0x0001;
+
+ /**
+ * Flag for {@link #performShortcut}: if set, do not close the menu after
+ * executing the shortcut.
+ */
+ static final int FLAG_PERFORM_NO_CLOSE = 0x0001;
+
+ /**
+ * Flag for {@link #performShortcut(int, KeyEvent, int)}: if set, always
+ * close the menu after executing the shortcut. Closing the menu also resets
+ * the prepared state.
+ */
+ static final int FLAG_ALWAYS_PERFORM_CLOSE = 0x0002;
+
+ /**
+ * Add a new item to the menu. This item displays the given title for its
+ * label.
+ *
+ * @param title The text to display for the item.
+ * @return The newly added menu item.
+ */
+ public MenuItem add(CharSequence title);
+
+ /**
+ * Add a new item to the menu. This item displays the given title for its
+ * label.
+ *
+ * @param titleRes Resource identifier of title string.
+ * @return The newly added menu item.
+ */
+ public MenuItem add(int titleRes);
+
+ /**
+ * Add a new item to the menu. This item displays the given title for its
+ * label.
+ *
+ * @param groupId The group identifier that this item should be part of.
+ * This can be used to define groups of items for batch state
+ * changes. Normally use {@link #NONE} if an item should not be in a
+ * group.
+ * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
+ * unique ID.
+ * @param order The order for the item. Use {@link #NONE} if you do not care
+ * about the order. See {@link MenuItem#getOrder()}.
+ * @param title The text to display for the item.
+ * @return The newly added menu item.
+ */
+ public MenuItem add(int groupId, int itemId, int order, CharSequence title);
+
+ /**
+ * Variation on {@link #add(int, int, int, CharSequence)} that takes a
+ * string resource identifier instead of the string itself.
+ *
+ * @param groupId The group identifier that this item should be part of.
+ * This can also be used to define groups of items for batch state
+ * changes. Normally use {@link #NONE} if an item should not be in a
+ * group.
+ * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
+ * unique ID.
+ * @param order The order for the item. Use {@link #NONE} if you do not care
+ * about the order. See {@link MenuItem#getOrder()}.
+ * @param titleRes Resource identifier of title string.
+ * @return The newly added menu item.
+ */
+ public MenuItem add(int groupId, int itemId, int order, int titleRes);
+
+ /**
+ * Add a new sub-menu to the menu. This item displays the given title for
+ * its label. To modify other attributes on the submenu's menu item, use
+ * {@link SubMenu#getItem()}.
+ *
+ * @param title The text to display for the item.
+ * @return The newly added sub-menu
+ */
+ SubMenu addSubMenu(final CharSequence title);
+
+ /**
+ * Add a new sub-menu to the menu. This item displays the given title for
+ * its label. To modify other attributes on the submenu's menu item, use
+ * {@link SubMenu#getItem()}.
+ *
+ * @param titleRes Resource identifier of title string.
+ * @return The newly added sub-menu
+ */
+ SubMenu addSubMenu(final int titleRes);
+
+ /**
+ * Add a new sub-menu to the menu. This item displays the given
+ * <var>title</var> for its label. To modify other attributes on the
+ * submenu's menu item, use {@link SubMenu#getItem()}.
+ *<p>
+ * Note that you can only have one level of sub-menus, i.e. you cannnot add
+ * a subMenu to a subMenu: An {@link UnsupportedOperationException} will be
+ * thrown if you try.
+ *
+ * @param groupId The group identifier that this item should be part of.
+ * This can also be used to define groups of items for batch state
+ * changes. Normally use {@link #NONE} if an item should not be in a
+ * group.
+ * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
+ * unique ID.
+ * @param order The order for the item. Use {@link #NONE} if you do not care
+ * about the order. See {@link MenuItem#getOrder()}.
+ * @param title The text to display for the item.
+ * @return The newly added sub-menu
+ */
+ SubMenu addSubMenu(final int groupId, final int itemId, int order, final CharSequence title);
+
+ /**
+ * Variation on {@link #addSubMenu(int, int, int, CharSequence)} that takes
+ * a string resource identifier for the title instead of the string itself.
+ *
+ * @param groupId The group identifier that this item should be part of.
+ * This can also be used to define groups of items for batch state
+ * changes. Normally use {@link #NONE} if an item should not be in a group.
+ * @param itemId Unique item ID. Use {@link #NONE} if you do not need a unique ID.
+ * @param order The order for the item. Use {@link #NONE} if you do not care about the
+ * order. See {@link MenuItem#getOrder()}.
+ * @param titleRes Resource identifier of title string.
+ * @return The newly added sub-menu
+ */
+ SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes);
+
+ /**
+ * Add a group of menu items corresponding to actions that can be performed
+ * for a particular Intent. The Intent is most often configured with a null
+ * action, the data that the current activity is working with, and includes
+ * either the {@link Intent#CATEGORY_ALTERNATIVE} or
+ * {@link Intent#CATEGORY_SELECTED_ALTERNATIVE} to find activities that have
+ * said they would like to be included as optional action. You can, however,
+ * use any Intent you want.
+ *
+ * <p>
+ * See {@link android.content.pm.PackageManager#queryIntentActivityOptions}
+ * for more * details on the <var>caller</var>, <var>specifics</var>, and
+ * <var>intent</var> arguments. The list returned by that function is used
+ * to populate the resulting menu items.
+ *
+ * <p>
+ * All of the menu items of possible options for the intent will be added
+ * with the given group and id. You can use the group to control ordering of
+ * the items in relation to other items in the menu. Normally this function
+ * will automatically remove any existing items in the menu in the same
+ * group and place a divider above and below the added items; this behavior
+ * can be modified with the <var>flags</var> parameter. For each of the
+ * generated items {@link MenuItem#setIntent} is called to associate the
+ * appropriate Intent with the item; this means the activity will
+ * automatically be started for you without having to do anything else.
+ *
+ * @param groupId The group identifier that the items should be part of.
+ * This can also be used to define groups of items for batch state
+ * changes. Normally use {@link #NONE} if the items should not be in
+ * a group.
+ * @param itemId Unique item ID. Use {@link #NONE} if you do not need a
+ * unique ID.
+ * @param order The order for the items. Use {@link #NONE} if you do not
+ * care about the order. See {@link MenuItem#getOrder()}.
+ * @param caller The current activity component name as defined by
+ * queryIntentActivityOptions().
+ * @param specifics Specific items to place first as defined by
+ * queryIntentActivityOptions().
+ * @param intent Intent describing the kinds of items to populate in the
+ * list as defined by queryIntentActivityOptions().
+ * @param flags Additional options controlling how the items are added.
+ * @param outSpecificItems Optional array in which to place the menu items
+ * that were generated for each of the <var>specifics</var> that were
+ * requested. Entries may be null if no activity was found for that
+ * specific action.
+ * @return The number of menu items that were added.
+ *
+ * @see #FLAG_APPEND_TO_GROUP
+ * @see MenuItem#setIntent
+ * @see android.content.pm.PackageManager#queryIntentActivityOptions
+ */
+ public int addIntentOptions(int groupId, int itemId, int order,
+ ComponentName caller, Intent[] specifics,
+ Intent intent, int flags, MenuItem[] outSpecificItems);
+
+ /**
+ * Remove the item with the given identifier.
+ *
+ * @param id The item to be removed. If there is no item with this
+ * identifier, nothing happens.
+ */
+ public void removeItem(int id);
+
+ /**
+ * Remove all items in the given group.
+ *
+ * @param groupId The group to be removed. If there are no items in this
+ * group, nothing happens.
+ */
+ public void removeGroup(int groupId);
+
+ /**
+ * Remove all existing items from the menu, leaving it empty as if it had
+ * just been created.
+ */
+ public void clear();
+
+ /**
+ * Control whether a particular group of items can show a check mark. This
+ * is similar to calling {@link MenuItem#setCheckable} on all of the menu items
+ * with the given group identifier, but in addition you can control whether
+ * this group contains a mutually-exclusive set items. This should be called
+ * after the items of the group have been added to the menu.
+ *
+ * @param group The group of items to operate on.
+ * @param checkable Set to true to allow a check mark, false to
+ * disallow. The default is false.
+ * @param exclusive If set to true, only one item in this group can be
+ * checked at a time; checking an item will automatically
+ * uncheck all others in the group. If set to false, each
+ * item can be checked independently of the others.
+ *
+ * @see MenuItem#setCheckable
+ * @see MenuItem#setChecked
+ */
+ public void setGroupCheckable(int group, boolean checkable, boolean exclusive);
+
+ /**
+ * Show or hide all menu items that are in the given group.
+ *
+ * @param group The group of items to operate on.
+ * @param visible If true the items are visible, else they are hidden.
+ *
+ * @see MenuItem#setVisible
+ */
+ public void setGroupVisible(int group, boolean visible);
+
+ /**
+ * Enable or disable all menu items that are in the given group.
+ *
+ * @param group The group of items to operate on.
+ * @param enabled If true the items will be enabled, else they will be disabled.
+ *
+ * @see MenuItem#setEnabled
+ */
+ public void setGroupEnabled(int group, boolean enabled);
+
+ /**
+ * Return whether the menu currently has item items that are visible.
+ *
+ * @return True if there is one or more item visible,
+ * else false.
+ */
+ public boolean hasVisibleItems();
+
+ /**
+ * Return the menu item with a particular identifier.
+ *
+ * @param id The identifier to find.
+ *
+ * @return The menu item object, or null if there is no item with
+ * this identifier.
+ */
+ public MenuItem findItem(int id);
+
+ /**
+ * Get the number of items in the menu. Note that this will change any
+ * times items are added or removed from the menu.
+ *
+ * @return The item count.
+ */
+ public int size();
+
+ /**
+ * Gets the menu item at the given index.
+ *
+ * @param index The index of the menu item to return.
+ * @return The menu item.
+ * @exception IndexOutOfBoundsException
+ * when {@code index < 0 || >= size()}
+ */
+ public MenuItem getItem(int index);
+
+ /**
+ * Closes the menu, if open.
+ */
+ public void close();
+
+ /**
+ * Execute the menu item action associated with the given shortcut
+ * character.
+ *
+ * @param keyCode The keycode of the shortcut key.
+ * @param event Key event message.
+ * @param flags Additional option flags or 0.
+ *
+ * @return If the given shortcut exists and is shown, returns
+ * true; else returns false.
+ *
+ * @see #FLAG_PERFORM_NO_CLOSE
+ */
+ public boolean performShortcut(int keyCode, KeyEvent event, int flags);
+
+ /**
+ * Is a keypress one of the defined shortcut keys for this window.
+ * @param keyCode the key code from {@link KeyEvent} to check.
+ * @param event the {@link KeyEvent} to use to help check.
+ */
+ boolean isShortcutKey(int keyCode, KeyEvent event);
+
+ /**
+ * Execute the menu item action associated with the given menu identifier.
+ *
+ * @param id Identifier associated with the menu item.
+ * @param flags Additional option flags or 0.
+ *
+ * @return If the given identifier exists and is shown, returns
+ * true; else returns false.
+ *
+ * @see #FLAG_PERFORM_NO_CLOSE
+ */
+ public boolean performIdentifierAction(int id, int flags);
+
+
+ /**
+ * Control whether the menu should be running in qwerty mode (alphabetic
+ * shortcuts) or 12-key mode (numeric shortcuts).
+ *
+ * @param isQwerty If true the menu will use alphabetic shortcuts; else it
+ * will use numeric shortcuts.
+ */
+ public void setQwertyMode(boolean isQwerty);
+}
+
diff --git a/appcompat/eclair/android/support/appcompat/view/MenuCompat.java b/appcompat/eclair/android/support/appcompat/view/MenuCompat.java
new file mode 100644
index 0000000..98c592e
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/MenuCompat.java
@@ -0,0 +1,31 @@
+// Copyright 2012 Google Inc. All Rights Reserved.
+
+package android.support.appcompat.view;
+
+import android.view.Menu;
+
+/**
+ * @author trevorjohns@google.com (Trevor Johns)
+ */
+public abstract class MenuCompat implements Menu {
+
+ /**
+ * This is the part of an order integer that the user can provide.
+ * @hide
+ */
+ protected static final int USER_MASK = 0x0000ffff;
+
+ /**
+ * This is the part of an order integer that supplies the category of the
+ * item.
+ * @hide
+ */
+ protected static final int CATEGORY_MASK = 0xffff0000;
+
+ /**
+ * Bit shift of the category portion of the order integer.
+ * @hide
+ */
+ protected static final int CATEGORY_SHIFT = 16;
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/MenuItem.java b/appcompat/eclair/android/support/appcompat/view/MenuItem.java
new file mode 100644
index 0000000..33e7b36
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/MenuItem.java
@@ -0,0 +1,600 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.View;
+import android.view.View.OnCreateContextMenuListener;
+
+/**
+ * Interface for direct access to a previously created menu item.
+ * <p>
+ * An Item is returned by calling one of the {@link android.view.Menu#add}
+ * methods.
+ * <p>
+ * For a feature set of specific menu types, see {@link android.support.appcompat.view.Menu}.
+ *
+ * <div class="special reference">
+ * <h3>Developer Guides</h3>
+ * <p>For information about creating menus, read the
+ * <a href="{@docRoot}guide/topics/ui/menus.html">Menus</a> developer guide.</p>
+ * </div>
+ */
+public interface MenuItem {
+ /*
+ * These should be kept in sync with attrs.xml enum constants for showAsAction
+ */
+ /** Never show this item as a button in an Action Bar. */
+ public static final int SHOW_AS_ACTION_NEVER = 0;
+ /** Show this item as a button in an Action Bar if the system decides there is room for it. */
+ public static final int SHOW_AS_ACTION_IF_ROOM = 1;
+ /**
+ * Always show this item as a button in an Action Bar.
+ * Use sparingly! If too many items are set to always show in the Action Bar it can
+ * crowd the Action Bar and degrade the user experience on devices with smaller screens.
+ * A good rule of thumb is to have no more than 2 items set to always show at a time.
+ */
+ public static final int SHOW_AS_ACTION_ALWAYS = 2;
+
+ /**
+ * When this item is in the action bar, always show it with a text label even if
+ * it also has an icon specified.
+ */
+ public static final int SHOW_AS_ACTION_WITH_TEXT = 4;
+
+ /**
+ * This item's action view collapses to a normal menu item.
+ * When expanded, the action view temporarily takes over
+ * a larger segment of its container.
+ */
+ public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = 8;
+
+ /**
+ * Interface definition for a callback to be invoked when a menu item is
+ * clicked.
+ *
+ * @see Activity#onContextItemSelected(MenuItem)
+ * @see Activity#onOptionsItemSelected(MenuItem)
+ */
+ public interface OnMenuItemClickListener {
+ /**
+ * Called when a menu item has been invoked. This is the first code
+ * that is executed; if it returns true, no other callbacks will be
+ * executed.
+ *
+ * @param item The menu item that was invoked.
+ *
+ * @return Return true to consume this click and prevent others from
+ * executing.
+ */
+ public boolean onMenuItemClick(MenuItem item);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when a menu item
+ * marked with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is
+ * expanded or collapsed.
+ *
+ * @see MenuItem#expandActionView()
+ * @see MenuItem#collapseActionView()
+ * @see MenuItem#setShowAsActionFlags(int)
+ */
+ public interface OnActionExpandListener {
+ /**
+ * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
+ * is expanded.
+ * @param item Item that was expanded
+ * @return true if the item should expand, false if expansion should be suppressed.
+ */
+ public boolean onMenuItemActionExpand(MenuItem item);
+
+ /**
+ * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
+ * is collapsed.
+ * @param item Item that was collapsed
+ * @return true if the item should collapse, false if collapsing should be suppressed.
+ */
+ public boolean onMenuItemActionCollapse(MenuItem item);
+ }
+
+ /**
+ * Return the identifier for this menu item. The identifier can not
+ * be changed after the menu is created.
+ *
+ * @return The menu item's identifier.
+ */
+ public int getItemId();
+
+ /**
+ * Return the group identifier that this menu item is part of. The group
+ * identifier can not be changed after the menu is created.
+ *
+ * @return The menu item's group identifier.
+ */
+ public int getGroupId();
+
+ /**
+ * Return the category and order within the category of this item. This
+ * item will be shown before all items (within its category) that have
+ * order greater than this value.
+ * <p>
+ * An order integer contains the item's category (the upper bits of the
+ * integer; set by or/add the category with the order within the
+ * category) and the ordering of the item within that category (the
+ * lower bits). Example categories are {@link android.support.appcompat.view.Menu#CATEGORY_SYSTEM},
+ * {@link android.support.appcompat.view.Menu#CATEGORY_SECONDARY}, {@link android.support.appcompat.view.Menu#CATEGORY_ALTERNATIVE},
+ * {@link android.support.appcompat.view.Menu#CATEGORY_CONTAINER}. See {@link android.support.appcompat.view.Menu} for a full list.
+ *
+ * @return The order of this item.
+ */
+ public int getOrder();
+
+ /**
+ * Change the title associated with this item.
+ *
+ * @param title The new text to be displayed.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setTitle(CharSequence title);
+
+ /**
+ * Change the title associated with this item.
+ * <p>
+ * Some menu types do not sufficient space to show the full title, and
+ * instead a condensed title is preferred. See {@link android.support.appcompat.view.Menu} for more
+ * information.
+ *
+ * @param title The resource id of the new text to be displayed.
+ * @return This Item so additional setters can be called.
+ * @see #setTitleCondensed(CharSequence)
+ */
+
+ public MenuItem setTitle(int title);
+
+ /**
+ * Retrieve the current title of the item.
+ *
+ * @return The title.
+ */
+ public CharSequence getTitle();
+
+ /**
+ * Change the condensed title associated with this item. The condensed
+ * title is used in situations where the normal title may be too long to
+ * be displayed.
+ *
+ * @param title The new text to be displayed as the condensed title.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setTitleCondensed(CharSequence title);
+
+ /**
+ * Retrieve the current condensed title of the item. If a condensed
+ * title was never set, it will return the normal title.
+ *
+ * @return The condensed title, if it exists.
+ * Otherwise the normal title.
+ */
+ public CharSequence getTitleCondensed();
+
+ /**
+ * Change the icon associated with this item. This icon will not always be
+ * shown, so the title should be sufficient in describing this item. See
+ * {@link android.support.appcompat.view.Menu} for the menu types that support icons.
+ *
+ * @param icon The new icon (as a Drawable) to be displayed.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setIcon(Drawable icon);
+
+ /**
+ * Change the icon associated with this item. This icon will not always be
+ * shown, so the title should be sufficient in describing this item. See
+ * {@link android.support.appcompat.view.Menu} for the menu types that support icons.
+ * <p>
+ * This method will set the resource ID of the icon which will be used to
+ * lazily get the Drawable when this item is being shown.
+ *
+ * @param iconRes The new icon (as a resource ID) to be displayed.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setIcon(int iconRes);
+
+ /**
+ * Returns the icon for this item as a Drawable (getting it from resources if it hasn't been
+ * loaded before).
+ *
+ * @return The icon as a Drawable.
+ */
+ public Drawable getIcon();
+
+ /**
+ * Change the Intent associated with this item. By default there is no
+ * Intent associated with a menu item. If you set one, and nothing
+ * else handles the item, then the default behavior will be to call
+ * {@link android.content.Context#startActivity} with the given Intent.
+ *
+ * <p>Note that setIntent() can not be used with the versions of
+ * {@link android.support.appcompat.view.Menu#add} that take a Runnable, because {@link Runnable#run}
+ * does not return a value so there is no way to tell if it handled the
+ * item. In this case it is assumed that the Runnable always handles
+ * the item, and the intent will never be started.
+ *
+ * @see #getIntent
+ * @param intent The Intent to associated with the item. This Intent
+ * object is <em>not</em> copied, so be careful not to
+ * modify it later.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setIntent(Intent intent);
+
+ /**
+ * Return the Intent associated with this item. This returns a
+ * reference to the Intent which you can change as desired to modify
+ * what the Item is holding.
+ *
+ * @see #setIntent
+ * @return Returns the last value supplied to {@link #setIntent}, or
+ * null.
+ */
+ public Intent getIntent();
+
+ /**
+ * Change both the numeric and alphabetic shortcut associated with this
+ * item. Note that the shortcut will be triggered when the key that
+ * generates the given character is pressed alone or along with with the alt
+ * key. Also note that case is not significant and that alphabetic shortcut
+ * characters will be displayed in lower case.
+ * <p>
+ * See {@link android.support.appcompat.view.Menu} for the menu types that support shortcuts.
+ *
+ * @param numericChar The numeric shortcut key. This is the shortcut when
+ * using a numeric (e.g., 12-key) keyboard.
+ * @param alphaChar The alphabetic shortcut key. This is the shortcut when
+ * using a keyboard with alphabetic keys.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setShortcut(char numericChar, char alphaChar);
+
+ /**
+ * Change the numeric shortcut associated with this item.
+ * <p>
+ * See {@link android.support.appcompat.view.Menu} for the menu types that support shortcuts.
+ *
+ * @param numericChar The numeric shortcut key. This is the shortcut when
+ * using a 12-key (numeric) keyboard.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setNumericShortcut(char numericChar);
+
+ /**
+ * Return the char for this menu item's numeric (12-key) shortcut.
+ *
+ * @return Numeric character to use as a shortcut.
+ */
+ public char getNumericShortcut();
+
+ /**
+ * Change the alphabetic shortcut associated with this item. The shortcut
+ * will be triggered when the key that generates the given character is
+ * pressed alone or along with with the alt key. Case is not significant and
+ * shortcut characters will be displayed in lower case. Note that menu items
+ * with the characters '\b' or '\n' as shortcuts will get triggered by the
+ * Delete key or Carriage Return key, respectively.
+ * <p>
+ * See {@link android.support.appcompat.view.Menu} for the menu types that support shortcuts.
+ *
+ * @param alphaChar The alphabetic shortcut key. This is the shortcut when
+ * using a keyboard with alphabetic keys.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setAlphabeticShortcut(char alphaChar);
+
+ /**
+ * Return the char for this menu item's alphabetic shortcut.
+ *
+ * @return Alphabetic character to use as a shortcut.
+ */
+ public char getAlphabeticShortcut();
+
+ /**
+ * Control whether this item can display a check mark. Setting this does
+ * not actually display a check mark (see {@link #setChecked} for that);
+ * rather, it ensures there is room in the item in which to display a
+ * check mark.
+ * <p>
+ * See {@link android.support.appcompat.view.Menu} for the menu types that support check marks.
+ *
+ * @param checkable Set to true to allow a check mark, false to
+ * disallow. The default is false.
+ * @see #setChecked
+ * @see #isCheckable
+ * @see android.support.appcompat.view.Menu#setGroupCheckable
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setCheckable(boolean checkable);
+
+ /**
+ * Return whether the item can currently display a check mark.
+ *
+ * @return If a check mark can be displayed, returns true.
+ *
+ * @see #setCheckable
+ */
+ public boolean isCheckable();
+
+ /**
+ * Control whether this item is shown with a check mark. Note that you
+ * must first have enabled checking with {@link #setCheckable} or else
+ * the check mark will not appear. If this item is a member of a group that contains
+ * mutually-exclusive items (set via {@link android.support.appcompat.view.Menu#setGroupCheckable(int, boolean, boolean)},
+ * the other items in the group will be unchecked.
+ * <p>
+ * See {@link android.support.appcompat.view.Menu} for the menu types that support check marks.
+ *
+ * @see #setCheckable
+ * @see #isChecked
+ * @see android.support.appcompat.view.Menu#setGroupCheckable
+ * @param checked Set to true to display a check mark, false to hide
+ * it. The default value is false.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setChecked(boolean checked);
+
+ /**
+ * Return whether the item is currently displaying a check mark.
+ *
+ * @return If a check mark is displayed, returns true.
+ *
+ * @see #setChecked
+ */
+ public boolean isChecked();
+
+ /**
+ * Sets the visibility of the menu item. Even if a menu item is not visible,
+ * it may still be invoked via its shortcut (to completely disable an item,
+ * set it to invisible and {@link #setEnabled(boolean) disabled}).
+ *
+ * @param visible If true then the item will be visible; if false it is
+ * hidden.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setVisible(boolean visible);
+
+ /**
+ * Return the visibility of the menu item.
+ *
+ * @return If true the item is visible; else it is hidden.
+ */
+ public boolean isVisible();
+
+ /**
+ * Sets whether the menu item is enabled. Disabling a menu item will not
+ * allow it to be invoked via its shortcut. The menu item will still be
+ * visible.
+ *
+ * @param enabled If true then the item will be invokable; if false it is
+ * won't be invokable.
+ * @return This Item so additional setters can be called.
+ */
+ public MenuItem setEnabled(boolean enabled);
+
+ /**
+ * Return the enabled state of the menu item.
+ *
+ * @return If true the item is enabled and hence invokable; else it is not.
+ */
+ public boolean isEnabled();
+
+ /**
+ * Check whether this item has an associated sub-menu. I.e. it is a
+ * sub-menu of another menu.
+ *
+ * @return If true this item has a menu; else it is a
+ * normal item.
+ */
+ public boolean hasSubMenu();
+
+ /**
+ * Get the sub-menu to be invoked when this item is selected, if it has
+ * one. See {@link #hasSubMenu()}.
+ *
+ * @return The associated menu if there is one, else null
+ */
+ public SubMenu getSubMenu();
+
+ /**
+ * Set a custom listener for invocation of this menu item. In most
+ * situations, it is more efficient and easier to use
+ * {@link Activity#onOptionsItemSelected(MenuItem)} or
+ * {@link Activity#onContextItemSelected(MenuItem)}.
+ *
+ * @param menuItemClickListener The object to receive invokations.
+ * @return This Item so additional setters can be called.
+ * @see Activity#onOptionsItemSelected(MenuItem)
+ * @see Activity#onContextItemSelected(MenuItem)
+ */
+ public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener);
+
+ /**
+ * Gets the extra information linked to this menu item. This extra
+ * information is set by the View that added this menu item to the
+ * menu.
+ *
+ * @see OnCreateContextMenuListener
+ * @return The extra information linked to the View that added this
+ * menu item to the menu. This can be null.
+ */
+ public ContextMenuInfo getMenuInfo();
+
+ /**
+ * Sets how this item should display in the presence of an Action Bar.
+ * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS},
+ * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should
+ * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}.
+ * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
+ * it should be shown with a text label.
+ *
+ * @param actionEnum How the item should display. One of
+ * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or
+ * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default.
+ *
+ * @see android.app.ActionBar
+ * @see #setActionView(View)
+ */
+ public void setShowAsAction(int actionEnum);
+
+ /**
+ * Sets how this item should display in the presence of an Action Bar.
+ * The parameter actionEnum is a flag set. One of {@link #SHOW_AS_ACTION_ALWAYS},
+ * {@link #SHOW_AS_ACTION_IF_ROOM}, or {@link #SHOW_AS_ACTION_NEVER} should
+ * be used, and you may optionally OR the value with {@link #SHOW_AS_ACTION_WITH_TEXT}.
+ * SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
+ * it should be shown with a text label.
+ *
+ * <p>Note: This method differs from {@link #setShowAsAction(int)} only in that it
+ * returns the current MenuItem instance for call chaining.
+ *
+ * @param actionEnum How the item should display. One of
+ * {@link #SHOW_AS_ACTION_ALWAYS}, {@link #SHOW_AS_ACTION_IF_ROOM}, or
+ * {@link #SHOW_AS_ACTION_NEVER}. SHOW_AS_ACTION_NEVER is the default.
+ *
+ * @see android.app.ActionBar
+ * @see #setActionView(View)
+ * @return This MenuItem instance for call chaining.
+ */
+ public MenuItem setShowAsActionFlags(int actionEnum);
+
+ /**
+ * Set an action view for this menu item. An action view will be displayed in place
+ * of an automatically generated menu item element in the UI when this item is shown
+ * as an action within a parent.
+ * <p>
+ * <strong>Note:</strong> Setting an action view overrides the action provider
+ * set via {@link #setActionProvider(ActionProvider)}.
+ * </p>
+ *
+ * @param view View to use for presenting this item to the user.
+ * @return This Item so additional setters can be called.
+ *
+ * @see #setShowAsAction(int)
+ */
+ public MenuItem setActionView(View view);
+
+ /**
+ * Set an action view for this menu item. An action view will be displayed in place
+ * of an automatically generated menu item element in the UI when this item is shown
+ * as an action within a parent.
+ * <p>
+ * <strong>Note:</strong> Setting an action view overrides the action provider
+ * set via {@link #setActionProvider(ActionProvider)}.
+ * </p>
+ *
+ * @param resId Layout resource to use for presenting this item to the user.
+ * @return This Item so additional setters can be called.
+ *
+ * @see #setShowAsAction(int)
+ */
+ public MenuItem setActionView(int resId);
+
+ /**
+ * Returns the currently set action view for this menu item.
+ *
+ * @return This item's action view
+ *
+ * @see #setActionView(View)
+ * @see #setShowAsAction(int)
+ */
+ public View getActionView();
+
+ /**
+ * Sets the {@link ActionProvider} responsible for creating an action view if
+ * the item is placed on the action bar. The provider also provides a default
+ * action invoked if the item is placed in the overflow menu.
+ * <p>
+ * <strong>Note:</strong> Setting an action provider overrides the action view
+ * set via {@link #setActionView(int)} or {@link #setActionView(View)}.
+ * </p>
+ *
+ * @param actionProvider The action provider.
+ * @return This Item so additional setters can be called.
+ *
+ * @see ActionProvider
+ */
+ public MenuItem setActionProvider(ActionProvider actionProvider);
+
+ /**
+ * Gets the {@link ActionProvider}.
+ *
+ * @return The action provider.
+ *
+ * @see ActionProvider
+ * @see #setActionProvider(ActionProvider)
+ */
+ public ActionProvider getActionProvider();
+
+ /**
+ * Expand the action view associated with this menu item.
+ * The menu item must have an action view set, as well as
+ * the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
+ * If a listener has been set using {@link #setOnActionExpandListener(OnActionExpandListener)}
+ * it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)}
+ * method invoked. The listener may return false from this method to prevent expanding
+ * the action view.
+ *
+ * @return true if the action view was expanded, false otherwise.
+ */
+ public boolean expandActionView();
+
+ /**
+ * Collapse the action view associated with this menu item.
+ * The menu item must have an action view set, as well as the showAsAction flag
+ * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a listener has been set using
+ * {@link #setOnActionExpandListener(OnActionExpandListener)} it will have its
+ * {@link OnActionExpandListener#onMenuItemActionCollapse(MenuItem)} method invoked.
+ * The listener may return false from this method to prevent collapsing the action view.
+ *
+ * @return true if the action view was collapsed, false otherwise.
+ */
+ public boolean collapseActionView();
+
+ /**
+ * Returns true if this menu item's action view has been expanded.
+ *
+ * @return true if the item's action view is expanded, false otherwise.
+ *
+ * @see #expandActionView()
+ * @see #collapseActionView()
+ * @see #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
+ * @see OnActionExpandListener
+ */
+ public boolean isActionViewExpanded();
+
+ /**
+ * Set an {@link OnActionExpandListener} on this menu item to be notified when
+ * the associated action view is expanded or collapsed. The menu item must
+ * be configured to expand or collapse its action view using the flag
+ * {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
+ *
+ * @param listener Listener that will respond to expand/collapse events
+ * @return This menu item instance for call chaining
+ */
+ public MenuItem setOnActionExpandListener(OnActionExpandListener listener);
+}
\ No newline at end of file
diff --git a/appcompat/eclair/android/support/appcompat/view/SubMenu.java b/appcompat/eclair/android/support/appcompat/view/SubMenu.java
new file mode 100644
index 0000000..290c67f
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/SubMenu.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view;
+
+import android.graphics.drawable.Drawable;
+import android.view.View;
+
+/**
+ * Subclass of {@link Menu} for sub menus.
+ * <p>
+ * Sub menus do not support item icons, or nested sub menus.
+ *
+ * <div class="special reference">
+ * <h3>Developer Guides</h3>
+ * <p>For information about creating menus, read the
+ * <a href="{@docRoot}guide/topics/ui/menus.html">Menus</a> developer guide.</p>
+ * </div>
+ */
+
+public interface SubMenu extends Menu {
+ /**
+ * Sets the submenu header's title to the title given in <var>titleRes</var>
+ * resource identifier.
+ *
+ * @param titleRes The string resource identifier used for the title.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setHeaderTitle(int titleRes);
+
+ /**
+ * Sets the submenu header's title to the title given in <var>title</var>.
+ *
+ * @param title The character sequence used for the title.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setHeaderTitle(CharSequence title);
+
+ /**
+ * Sets the submenu header's icon to the icon given in <var>iconRes</var>
+ * resource id.
+ *
+ * @param iconRes The resource identifier used for the icon.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setHeaderIcon(int iconRes);
+
+ /**
+ * Sets the submenu header's icon to the icon given in <var>icon</var>
+ * {@link Drawable}.
+ *
+ * @param icon The {@link Drawable} used for the icon.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setHeaderIcon(Drawable icon);
+
+ /**
+ * Sets the header of the submenu to the {@link View} given in
+ * <var>view</var>. This replaces the header title and icon (and those
+ * replace this).
+ *
+ * @param view The {@link View} used for the header.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setHeaderView(View view);
+
+ /**
+ * Clears the header of the submenu.
+ */
+ public void clearHeader();
+
+ /**
+ * Change the icon associated with this submenu's item in its parent menu.
+ *
+ * @see MenuItem#setIcon(int)
+ * @param iconRes The new icon (as a resource ID) to be displayed.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setIcon(int iconRes);
+
+ /**
+ * Change the icon associated with this submenu's item in its parent menu.
+ *
+ * @see MenuItem#setIcon(Drawable)
+ * @param icon The new icon (as a Drawable) to be displayed.
+ * @return This SubMenu so additional setters can be called.
+ */
+ public SubMenu setIcon(Drawable icon);
+
+ /**
+ * Gets the {@link MenuItem} that represents this submenu in the parent
+ * menu. Use this for setting additional item attributes.
+ *
+ * @return The {@link MenuItem} that launches the submenu when invoked.
+ */
+ public MenuItem getItem();
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItem.java b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItem.java
new file mode 100644
index 0000000..a6e8ef7
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItem.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.view.ActionProvider;
+import android.support.appcompat.view.MenuItem;
+import android.support.appcompat.view.SubMenu;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.View;
+
+/**
+ * @hide
+ */
+public class ActionMenuItem implements MenuItem {
+ private final int mId;
+ private final int mGroup;
+ private final int mCategoryOrder;
+ private final int mOrdering;
+
+ private CharSequence mTitle;
+ private CharSequence mTitleCondensed;
+ private Intent mIntent;
+ private char mShortcutNumericChar;
+ private char mShortcutAlphabeticChar;
+
+ private Drawable mIconDrawable;
+ private int mIconResId = NO_ICON;
+
+ private Context mContext;
+
+ private MenuItem.OnMenuItemClickListener mClickListener;
+
+ private static final int NO_ICON = 0;
+
+ private int mFlags = ENABLED;
+ private static final int CHECKABLE = 0x00000001;
+ private static final int CHECKED = 0x00000002;
+ private static final int EXCLUSIVE = 0x00000004;
+ private static final int HIDDEN = 0x00000008;
+ private static final int ENABLED = 0x00000010;
+
+ public ActionMenuItem(Context context, int group, int id, int categoryOrder, int ordering,
+ CharSequence title) {
+ mContext = context;
+ mId = id;
+ mGroup = group;
+ mCategoryOrder = categoryOrder;
+ mOrdering = ordering;
+ mTitle = title;
+ }
+
+ public char getAlphabeticShortcut() {
+ return mShortcutAlphabeticChar;
+ }
+
+ public int getGroupId() {
+ return mGroup;
+ }
+
+ public Drawable getIcon() {
+ return mIconDrawable;
+ }
+
+ public Intent getIntent() {
+ return mIntent;
+ }
+
+ public int getItemId() {
+ return mId;
+ }
+
+ public ContextMenuInfo getMenuInfo() {
+ return null;
+ }
+
+ public char getNumericShortcut() {
+ return mShortcutNumericChar;
+ }
+
+ public int getOrder() {
+ return mOrdering;
+ }
+
+ public SubMenu getSubMenu() {
+ return null;
+ }
+
+ public CharSequence getTitle() {
+ return mTitle;
+ }
+
+ public CharSequence getTitleCondensed() {
+ return mTitleCondensed;
+ }
+
+ public boolean hasSubMenu() {
+ return false;
+ }
+
+ public boolean isCheckable() {
+ return (mFlags & CHECKABLE) != 0;
+ }
+
+ public boolean isChecked() {
+ return (mFlags & CHECKED) != 0;
+ }
+
+ public boolean isEnabled() {
+ return (mFlags & ENABLED) != 0;
+ }
+
+ public boolean isVisible() {
+ return (mFlags & HIDDEN) == 0;
+ }
+
+ public MenuItem setAlphabeticShortcut(char alphaChar) {
+ mShortcutAlphabeticChar = alphaChar;
+ return this;
+ }
+
+ public MenuItem setCheckable(boolean checkable) {
+ mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
+ return this;
+ }
+
+ public ActionMenuItem setExclusiveCheckable(boolean exclusive) {
+ mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0);
+ return this;
+ }
+
+ public MenuItem setChecked(boolean checked) {
+ mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0);
+ return this;
+ }
+
+ public MenuItem setEnabled(boolean enabled) {
+ mFlags = (mFlags & ~ENABLED) | (enabled ? ENABLED : 0);
+ return this;
+ }
+
+ public MenuItem setIcon(Drawable icon) {
+ mIconDrawable = icon;
+ mIconResId = NO_ICON;
+ return this;
+ }
+
+ public MenuItem setIcon(int iconRes) {
+ mIconResId = iconRes;
+ mIconDrawable = mContext.getResources().getDrawable(iconRes);
+ return this;
+ }
+
+ public MenuItem setIntent(Intent intent) {
+ mIntent = intent;
+ return this;
+ }
+
+ public MenuItem setNumericShortcut(char numericChar) {
+ mShortcutNumericChar = numericChar;
+ return this;
+ }
+
+ public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) {
+ mClickListener = menuItemClickListener;
+ return this;
+ }
+
+ public MenuItem setShortcut(char numericChar, char alphaChar) {
+ mShortcutNumericChar = numericChar;
+ mShortcutAlphabeticChar = alphaChar;
+ return this;
+ }
+
+ public MenuItem setTitle(CharSequence title) {
+ mTitle = title;
+ return this;
+ }
+
+ public MenuItem setTitle(int title) {
+ mTitle = mContext.getResources().getString(title);
+ return this;
+ }
+
+ public MenuItem setTitleCondensed(CharSequence title) {
+ mTitleCondensed = title;
+ return this;
+ }
+
+ public MenuItem setVisible(boolean visible) {
+ mFlags = (mFlags & HIDDEN) | (visible ? 0 : HIDDEN);
+ return this;
+ }
+
+ public boolean invoke() {
+ if (mClickListener != null && mClickListener.onMenuItemClick(this)) {
+ return true;
+ }
+
+ if (mIntent != null) {
+ mContext.startActivity(mIntent);
+ return true;
+ }
+
+ return false;
+ }
+
+ public void setShowAsAction(int show) {
+ // Do nothing. ActionMenuItems always show as action buttons.
+ }
+
+ public MenuItem setActionView(View actionView) {
+ throw new UnsupportedOperationException();
+ }
+
+ public View getActionView() {
+ return null;
+ }
+
+ @Override
+ public MenuItem setActionView(int resId) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ActionProvider getActionProvider() {
+ return null;
+ }
+
+ @Override
+ public MenuItem setActionProvider(ActionProvider actionProvider) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public MenuItem setShowAsActionFlags(int actionEnum) {
+ setShowAsAction(actionEnum);
+ return this;
+ }
+
+ @Override
+ public boolean expandActionView() {
+ return false;
+ }
+
+ @Override
+ public boolean collapseActionView() {
+ return false;
+ }
+
+ @Override
+ public boolean isActionViewExpanded() {
+ return false;
+ }
+
+ @Override
+ public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
+ // No need to save the listener; ActionMenuItem does not support collapsing items.
+ return this;
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItemView.java b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItemView.java
new file mode 100644
index 0000000..cd2558d
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItemView.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.R;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.widget.TextView;
+import android.widget.Toast;
+
+// TODO(trevorjohns): Lots of things here have been commented out. This needs to be addressed.
+
+/**
+ * @hide
+ */
+public class ActionMenuItemView extends TextView
+ implements MenuView.ItemView, View.OnClickListener, View.OnLongClickListener,
+ ActionMenuView.ActionMenuChildView {
+ private static final String TAG = "ActionMenuItemView";
+
+ private MenuItemImpl mItemData;
+ private CharSequence mTitle;
+ private Drawable mIcon;
+ //private MenuBuilder.ItemInvoker mItemInvoker;
+
+ private boolean mAllowTextWithIcon;
+ private boolean mExpandedFormat;
+ private int mMinWidth;
+ private int mSavedPaddingLeft;
+
+ public ActionMenuItemView(Context context) {
+ this(context, null);
+ }
+
+ public ActionMenuItemView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ final Resources res = context.getResources();
+ mAllowTextWithIcon = res.getBoolean(
+ android.support.appcompat.R.bool.config_allowActionMenuItemTextWithIcon);
+ TypedArray a = context.obtainStyledAttributes(attrs,
+ android.support.appcompat.R.styleable.ActionMenuItemView, 0, 0);
+ mMinWidth = a.getDimensionPixelSize(
+ R.styleable.ActionMenuItemView_android_minWidth, 0);
+ a.recycle();
+
+ setOnClickListener(this);
+ setOnLongClickListener(this);
+
+ mSavedPaddingLeft = -1;
+ }
+
+ @Override
+ public void setPadding(int l, int t, int r, int b) {
+ mSavedPaddingLeft = l;
+ super.setPadding(l, t, r, b);
+ }
+
+ public MenuItemImpl getItemData() {
+ return mItemData;
+ }
+
+ public void initialize(MenuItemImpl itemData, int menuType) {
+ mItemData = itemData;
+
+ setIcon(itemData.getIcon());
+ setTitle(itemData.getTitleForItemView(this)); // Title only takes effect if there is no icon
+ setId(itemData.getItemId());
+
+ setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
+ setEnabled(itemData.isEnabled());
+ }
+
+ public void onClick(View v) {
+ /*if (mItemInvoker != null) {
+ // TODO(trevorjohns): Implement menu invocation!
+ mItemInvoker.invokeItem(mItemData);
+ }/*
+ }
+
+ /* TODO(trevorjohns): Remove this
+ public void setItemInvoker(MenuBuilder.ItemInvoker invoker) {
+ mItemInvoker = invoker;*/
+ }
+
+ public boolean prefersCondensedTitle() {
+ return true;
+ }
+
+ public void setCheckable(boolean checkable) {
+ // TODO Support checkable action items
+ }
+
+ public void setChecked(boolean checked) {
+ // TODO Support checkable action items
+ }
+
+ public void setExpandedFormat(boolean expandedFormat) {
+ if (mExpandedFormat != expandedFormat) {
+ mExpandedFormat = expandedFormat;
+ if (mItemData != null) {
+ mItemData.actionFormatChanged();
+ }
+ }
+ }
+
+ private void updateTextButtonVisibility() {
+ boolean visible = !TextUtils.isEmpty(mTitle);
+ visible &= mIcon == null ||
+ (mItemData.showsTextAsAction() && (mAllowTextWithIcon || mExpandedFormat));
+
+ setText(visible ? mTitle : null);
+ }
+
+ public void setIcon(Drawable icon) {
+ mIcon = icon;
+ setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
+
+ updateTextButtonVisibility();
+ }
+
+ public boolean hasText() {
+ return !TextUtils.isEmpty(getText());
+ }
+
+ public void setShortcut(boolean showShortcut, char shortcutKey) {
+ // Action buttons don't show text for shortcut keys.
+ }
+
+ public void setTitle(CharSequence title) {
+ mTitle = title;
+
+ setContentDescription(mTitle);
+ updateTextButtonVisibility();
+ }
+
+ public boolean showsIcon() {
+ return true;
+ }
+
+ public boolean needsDividerBefore() {
+ return hasText() && mItemData.getIcon() == null;
+ }
+
+ public boolean needsDividerAfter() {
+ return hasText();
+ }
+
+ @Override
+ public boolean onLongClick(View v) {
+ if (hasText()) {
+ // Don't show the cheat sheet for items that already show text.
+ return false;
+ }
+
+ final int[] screenPos = new int[2];
+ final Rect displayFrame = new Rect();
+ getLocationOnScreen(screenPos);
+ getWindowVisibleDisplayFrame(displayFrame);
+
+ final Context context = getContext();
+ final int width = getWidth();
+ final int height = getHeight();
+ final int midy = screenPos[1] + height / 2;
+ final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
+
+ Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT);
+ if (midy < displayFrame.height()) {
+ // Show along the top; follow action buttons
+ cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,
+ screenWidth - screenPos[0] - width / 2, height);
+ } else {
+ // Show along the bottom center
+ cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
+ }
+ cheatSheet.show();
+ return true;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final boolean textVisible = hasText();
+ if (textVisible && mSavedPaddingLeft >= 0) {
+ super.setPadding(mSavedPaddingLeft, getPaddingTop(),
+ getPaddingRight(), getPaddingBottom());
+ }
+
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ final int oldMeasuredWidth = getMeasuredWidth();
+ final int targetWidth = widthMode == MeasureSpec.AT_MOST ? Math.min(widthSize, mMinWidth)
+ : mMinWidth;
+
+ if (widthMode != MeasureSpec.EXACTLY && mMinWidth > 0 && oldMeasuredWidth < targetWidth) {
+ // Remeasure at exactly the minimum width.
+ super.onMeasure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY),
+ heightMeasureSpec);
+ }
+
+ if (!textVisible && mIcon != null) {
+ // TextView won't center compound drawables in both dimensions without
+ // a little coercion. Pad in to center the icon after we've measured.
+ final int w = getMeasuredWidth();
+ final int dw = mIcon.getIntrinsicWidth();
+ super.setPadding((w - dw) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom());
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuPresenter.java b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuPresenter.java
new file mode 100644
index 0000000..afb785f
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuPresenter.java
@@ -0,0 +1,668 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.R;
+import android.support.appcompat.view.ActionBarPolicy;
+import android.support.appcompat.view.MenuItem;
+import android.support.appcompat.view.menu.ActionMenuView.ActionMenuChildView;
+import android.support.appcompat.view.ActionProvider;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.SparseBooleanArray;
+import android.view.SoundEffectConstants;
+import android.view.View;
+import android.view.View.MeasureSpec;
+import android.view.ViewGroup;
+import android.widget.ImageButton;
+
+import java.util.ArrayList;
+
+/**
+ * MenuPresenter for building action menus as seen in the action bar and action modes.
+ */
+public class ActionMenuPresenter extends BaseMenuPresenter
+ implements ActionProvider.SubUiVisibilityListener {
+ private static final String TAG = "ActionMenuPresenter";
+
+ private View mOverflowButton;
+ private boolean mReserveOverflow;
+ private boolean mReserveOverflowSet;
+ private int mWidthLimit;
+ private int mActionItemWidthLimit;
+ private int mMaxItems;
+ private boolean mMaxItemsSet;
+ private boolean mStrictWidthLimit;
+ private boolean mWidthLimitSet;
+ private boolean mExpandedActionViewsExclusive;
+
+ private int mMinCellSize;
+
+ // Group IDs that have been added as actions - used temporarily, allocated here for reuse.
+ private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray();
+
+ private View mScrapActionButtonView;
+
+ private OverflowPopup mOverflowPopup;
+ private ActionButtonSubmenu mActionButtonPopup;
+
+ private OpenOverflowRunnable mPostedOpenRunnable;
+
+ final PopupPresenterCallback mPopupPresenterCallback = new PopupPresenterCallback();
+ int mOpenSubMenuId;
+
+ public ActionMenuPresenter(Context context) {
+ super(context, android.support.appcompat.R.layout.action_menu_layout,
+ android.support.appcompat.R.layout.action_menu_item_layout);
+ }
+
+ @Override
+ public void initForMenu(Context context, MenuBuilder menu) {
+ super.initForMenu(context, menu);
+
+ final Resources res = context.getResources();
+
+ final ActionBarPolicy abp = ActionBarPolicy.get(context);
+ if (!mReserveOverflowSet) {
+ mReserveOverflow = abp.showsOverflowMenuButton();
+ }
+
+ if (!mWidthLimitSet) {
+ mWidthLimit = abp.getEmbeddedMenuWidthLimit();
+ }
+
+ // Measure for initial configuration
+ if (!mMaxItemsSet) {
+ mMaxItems = abp.getMaxActionButtons();
+ }
+
+ int width = mWidthLimit;
+ if (mReserveOverflow) {
+ if (mOverflowButton == null) {
+ mOverflowButton = new OverflowMenuButton(mSystemContext);
+ final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ mOverflowButton.measure(spec, spec);
+ }
+ width -= mOverflowButton.getMeasuredWidth();
+ } else {
+ mOverflowButton = null;
+ }
+
+ mActionItemWidthLimit = width;
+
+ mMinCellSize = (int) (ActionMenuView.MIN_CELL_SIZE * res.getDisplayMetrics().density);
+
+ // Drop a scrap view as it may no longer reflect the proper context/config.
+ mScrapActionButtonView = null;
+ }
+
+ public void onConfigurationChanged(Configuration newConfig) {
+ if (!mMaxItemsSet) {
+ mMaxItems = mContext.getResources().getInteger(
+ R.integer.max_action_buttons);
+ }
+ if (mMenu != null) {
+ // TODO(trevorjohns): Figure out what to do about mMenu.onItemsChanged()
+ //mMenu.onItemsChanged(true);
+ }
+ }
+
+ public void setWidthLimit(int width, boolean strict) {
+ mWidthLimit = width;
+ mStrictWidthLimit = strict;
+ mWidthLimitSet = true;
+ }
+
+ public void setReserveOverflow(boolean reserveOverflow) {
+ mReserveOverflow = reserveOverflow;
+ mReserveOverflowSet = true;
+ }
+
+ public void setItemLimit(int itemCount) {
+ mMaxItems = itemCount;
+ mMaxItemsSet = true;
+ }
+
+ public void setExpandedActionViewsExclusive(boolean isExclusive) {
+ mExpandedActionViewsExclusive = isExclusive;
+ }
+
+ @Override
+ public MenuView getMenuView(ViewGroup root) {
+ MenuView result = super.getMenuView(root);
+ ((ActionMenuView) result).setPresenter(this);
+ return result;
+ }
+
+ @Override
+ public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
+ View actionView = item.getActionView();
+ if (actionView == null || item.hasCollapsibleActionView()) {
+ if (!(convertView instanceof ActionMenuItemView)) {
+ convertView = null;
+ }
+ actionView = super.getItemView(item, convertView, parent);
+ }
+ actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE);
+
+ final ActionMenuView menuParent = (ActionMenuView) parent;
+ final ViewGroup.LayoutParams lp = actionView.getLayoutParams();
+ if (!menuParent.checkLayoutParams(lp)) {
+ actionView.setLayoutParams(menuParent.generateLayoutParams(lp));
+ }
+ return actionView;
+ }
+
+ @Override
+ public void bindItemView(MenuItemImpl item, MenuView.ItemView itemView) {
+ itemView.initialize(item, 0);
+
+ final ActionMenuView menuView = (ActionMenuView) mMenuView;
+ ActionMenuItemView actionItemView = (ActionMenuItemView) itemView;
+ // TODO(trevorjohns): setItemInvoker was commented out, what to do with this?
+ //actionItemView.setItemInvoker(menuView);
+ }
+
+ @Override
+ public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) {
+ return item.isActionButton();
+ }
+
+ @Override
+ public void updateMenuView(boolean cleared) {
+ super.updateMenuView(cleared);
+
+ if (mMenu != null) {
+ final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems();
+ final int count = actionItems.size();
+ for (int i = 0; i < count; i++) {
+ final ActionProvider provider = actionItems.get(i).getActionProvider();
+ if (provider != null) {
+ provider.setSubUiVisibilityListener(this);
+ }
+ }
+ }
+
+ final ArrayList<MenuItemImpl> nonActionItems = mMenu != null ?
+ mMenu.getNonActionItems() : null;
+
+ boolean hasOverflow = false;
+ if (mReserveOverflow && nonActionItems != null) {
+ final int count = nonActionItems.size();
+ if (count == 1) {
+ hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
+ } else {
+ hasOverflow = count > 0;
+ }
+ }
+
+ if (hasOverflow) {
+ if (mOverflowButton == null) {
+ mOverflowButton = new OverflowMenuButton(mSystemContext);
+ }
+ ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
+ if (parent != mMenuView) {
+ if (parent != null) {
+ parent.removeView(mOverflowButton);
+ }
+ ActionMenuView menuView = (ActionMenuView) mMenuView;
+ menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams());
+ }
+ } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) {
+ ((ViewGroup) mMenuView).removeView(mOverflowButton);
+ }
+
+ ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow);
+ }
+
+ @Override
+ public boolean filterLeftoverView(ViewGroup parent, int childIndex) {
+ if (parent.getChildAt(childIndex) == mOverflowButton) return false;
+ return super.filterLeftoverView(parent, childIndex);
+ }
+
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
+ if (!subMenu.hasVisibleItems()) return false;
+
+ SubMenuBuilder topSubMenu = subMenu;
+ while (topSubMenu.getParentMenu() != mMenu) {
+ topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu();
+ }
+ View anchor = findViewForItem(topSubMenu.getItem());
+ if (anchor == null) {
+ if (mOverflowButton == null) return false;
+ anchor = mOverflowButton;
+ }
+
+ mOpenSubMenuId = subMenu.getItem().getItemId();
+ mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu);
+ mActionButtonPopup.setAnchorView(anchor);
+ mActionButtonPopup.show();
+ super.onSubMenuSelected(subMenu);
+ return true;
+ }
+
+ private View findViewForItem(MenuItem item) {
+ final ViewGroup parent = (ViewGroup) mMenuView;
+ if (parent == null) return null;
+
+ final int count = parent.getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = parent.getChildAt(i);
+ if (child instanceof MenuView.ItemView &&
+ ((MenuView.ItemView) child).getItemData() == item) {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Display the overflow menu if one is present.
+ * @return true if the overflow menu was shown, false otherwise.
+ */
+ public boolean showOverflowMenu() {
+ if (mReserveOverflow && !isOverflowMenuShowing() && mMenu != null && mMenuView != null &&
+ mPostedOpenRunnable == null) {
+ OverflowPopup popup = new OverflowPopup(mContext, mMenu, mOverflowButton, true);
+ mPostedOpenRunnable = new OpenOverflowRunnable(popup);
+ // Post this for later; we might still need a layout for the anchor to be right.
+ ((View) mMenuView).post(mPostedOpenRunnable);
+
+ // ActionMenuPresenter uses null as a callback argument here
+ // to indicate overflow is opening.
+ super.onSubMenuSelected(null);
+
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Hide the overflow menu if it is currently showing.
+ *
+ * @return true if the overflow menu was hidden, false otherwise.
+ */
+ public boolean hideOverflowMenu() {
+ if (mPostedOpenRunnable != null && mMenuView != null) {
+ ((View) mMenuView).removeCallbacks(mPostedOpenRunnable);
+ mPostedOpenRunnable = null;
+ return true;
+ }
+
+ MenuPopupHelper popup = mOverflowPopup;
+ if (popup != null) {
+ popup.dismiss();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Dismiss all popup menus - overflow and submenus.
+ * @return true if popups were dismissed, false otherwise. (This can be because none were open.)
+ */
+ public boolean dismissPopupMenus() {
+ boolean result = hideOverflowMenu();
+ result |= hideSubMenus();
+ return result;
+ }
+
+ /**
+ * Dismiss all submenu popups.
+ *
+ * @return true if popups were dismissed, false otherwise. (This can be because none were open.)
+ */
+ public boolean hideSubMenus() {
+ if (mActionButtonPopup != null) {
+ mActionButtonPopup.dismiss();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @return true if the overflow menu is currently showing
+ */
+ public boolean isOverflowMenuShowing() {
+ return mOverflowPopup != null && mOverflowPopup.isShowing();
+ }
+
+ /**
+ * @return true if space has been reserved in the action menu for an overflow item.
+ */
+ public boolean isOverflowReserved() {
+ return mReserveOverflow;
+ }
+
+ public boolean flagActionItems() {
+ final ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems();
+ final int itemsSize = visibleItems.size();
+ int maxActions = mMaxItems;
+ int widthLimit = mActionItemWidthLimit;
+ final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ final ViewGroup parent = (ViewGroup) mMenuView;
+
+ int requiredItems = 0;
+ int requestedItems = 0;
+ int firstActionWidth = 0;
+ boolean hasOverflow = false;
+ for (int i = 0; i < itemsSize; i++) {
+ MenuItemImpl item = visibleItems.get(i);
+ if (item.requiresActionButton()) {
+ requiredItems++;
+ } else if (item.requestsActionButton()) {
+ requestedItems++;
+ } else {
+ hasOverflow = true;
+ }
+ if (mExpandedActionViewsExclusive && item.isActionViewExpanded()) {
+ // Overflow everything if we have an expanded action view and we're
+ // space constrained.
+ maxActions = 0;
+ }
+ }
+
+ // Reserve a spot for the overflow item if needed.
+ if (mReserveOverflow &&
+ (hasOverflow || requiredItems + requestedItems > maxActions)) {
+ maxActions--;
+ }
+ maxActions -= requiredItems;
+
+ final SparseBooleanArray seenGroups = mActionButtonGroups;
+ seenGroups.clear();
+
+ int cellSize = 0;
+ int cellsRemaining = 0;
+ if (mStrictWidthLimit) {
+ cellsRemaining = widthLimit / mMinCellSize;
+ final int cellSizeRemaining = widthLimit % mMinCellSize;
+ cellSize = mMinCellSize + cellSizeRemaining / cellsRemaining;
+ }
+
+ // Flag as many more requested items as will fit.
+ for (int i = 0; i < itemsSize; i++) {
+ MenuItemImpl item = visibleItems.get(i);
+
+ if (item.requiresActionButton()) {
+ View v = getItemView(item, mScrapActionButtonView, parent);
+ if (mScrapActionButtonView == null) {
+ mScrapActionButtonView = v;
+ }
+ if (mStrictWidthLimit) {
+ cellsRemaining -= ActionMenuView.measureChildForCells(v,
+ cellSize, cellsRemaining, querySpec, 0);
+ } else {
+ v.measure(querySpec, querySpec);
+ }
+ final int measuredWidth = v.getMeasuredWidth();
+ widthLimit -= measuredWidth;
+ if (firstActionWidth == 0) {
+ firstActionWidth = measuredWidth;
+ }
+ final int groupId = item.getGroupId();
+ if (groupId != 0) {
+ seenGroups.put(groupId, true);
+ }
+ item.setIsActionButton(true);
+ } else if (item.requestsActionButton()) {
+ // Items in a group with other items that already have an action slot
+ // can break the max actions rule, but not the width limit.
+ final int groupId = item.getGroupId();
+ final boolean inGroup = seenGroups.get(groupId);
+ boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0 &&
+ (!mStrictWidthLimit || cellsRemaining > 0);
+
+ if (isAction) {
+ View v = getItemView(item, mScrapActionButtonView, parent);
+ if (mScrapActionButtonView == null) {
+ mScrapActionButtonView = v;
+ }
+ if (mStrictWidthLimit) {
+ final int cells = ActionMenuView.measureChildForCells(v,
+ cellSize, cellsRemaining, querySpec, 0);
+ cellsRemaining -= cells;
+ if (cells == 0) {
+ isAction = false;
+ }
+ } else {
+ v.measure(querySpec, querySpec);
+ }
+ final int measuredWidth = v.getMeasuredWidth();
+ widthLimit -= measuredWidth;
+ if (firstActionWidth == 0) {
+ firstActionWidth = measuredWidth;
+ }
+
+ if (mStrictWidthLimit) {
+ isAction &= widthLimit >= 0;
+ } else {
+ // Did this push the entire first item past the limit?
+ isAction &= widthLimit + firstActionWidth > 0;
+ }
+ }
+
+ if (isAction && groupId != 0) {
+ seenGroups.put(groupId, true);
+ } else if (inGroup) {
+ // We broke the width limit. Demote the whole group, they all overflow now.
+ seenGroups.put(groupId, false);
+ for (int j = 0; j < i; j++) {
+ MenuItemImpl areYouMyGroupie = visibleItems.get(j);
+ if (areYouMyGroupie.getGroupId() == groupId) {
+ // Give back the action slot
+ if (areYouMyGroupie.isActionButton()) maxActions++;
+ areYouMyGroupie.setIsActionButton(false);
+ }
+ }
+ }
+
+ if (isAction) maxActions--;
+
+ item.setIsActionButton(isAction);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ dismissPopupMenus();
+ super.onCloseMenu(menu, allMenusAreClosing);
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ SavedState state = new SavedState();
+ state.openSubMenuId = mOpenSubMenuId;
+ return state;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ SavedState saved = (SavedState) state;
+ if (saved.openSubMenuId > 0) {
+ MenuItem item = mMenu.findItem(saved.openSubMenuId);
+ if (item != null) {
+ SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
+ onSubMenuSelected(subMenu);
+ }
+ }
+ }
+
+ @Override
+ public void onSubUiVisibilityChanged(boolean isVisible) {
+ if (isVisible) {
+ // Not a submenu, but treat it like one.
+ super.onSubMenuSelected(null);
+ } else {
+ mMenu.close(false);
+ }
+ }
+
+ private static class SavedState implements Parcelable {
+ public int openSubMenuId;
+
+ SavedState() {
+ }
+
+ SavedState(Parcel in) {
+ openSubMenuId = in.readInt();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(openSubMenuId);
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR
+ = new Parcelable.Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+
+ private class OverflowMenuButton extends ImageButton implements ActionMenuChildView {
+ public OverflowMenuButton(Context context) {
+ super(context, null, R.attr.actionOverflowButtonStyle);
+
+ setClickable(true);
+ setFocusable(true);
+ setVisibility(VISIBLE);
+ setEnabled(true);
+ }
+
+ @Override
+ public boolean performClick() {
+ if (super.performClick()) {
+ return true;
+ }
+
+ playSoundEffect(SoundEffectConstants.CLICK);
+ showOverflowMenu();
+ return true;
+ }
+
+ public boolean needsDividerBefore() {
+ return false;
+ }
+
+ public boolean needsDividerAfter() {
+ return false;
+ }
+ }
+
+ private class OverflowPopup extends MenuPopupHelper {
+ public OverflowPopup(Context context, MenuBuilder menu, View anchorView,
+ boolean overflowOnly) {
+ super(context, menu, anchorView, overflowOnly);
+ setCallback(mPopupPresenterCallback);
+ }
+
+ @Override
+ public void onDismiss() {
+ super.onDismiss();
+ mMenu.close();
+ mOverflowPopup = null;
+ }
+ }
+
+ private class ActionButtonSubmenu extends MenuPopupHelper {
+ private SubMenuBuilder mSubMenu;
+
+ public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
+ super(context, subMenu);
+ mSubMenu = subMenu;
+
+ MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
+ if (!item.isActionButton()) {
+ // Give a reasonable anchor to nested submenus.
+ setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton);
+ }
+
+ setCallback(mPopupPresenterCallback);
+
+ boolean preserveIconSpacing = false;
+ final int count = subMenu.size();
+ for (int i = 0; i < count; i++) {
+ MenuItem childItem = subMenu.getItem(i);
+ if (childItem.isVisible() && childItem.getIcon() != null) {
+ preserveIconSpacing = true;
+ break;
+ }
+ }
+ setForceShowIcon(preserveIconSpacing);
+ }
+
+ @Override
+ public void onDismiss() {
+ super.onDismiss();
+ mActionButtonPopup = null;
+ mOpenSubMenuId = 0;
+ }
+ }
+
+ private class PopupPresenterCallback implements MenuPresenter.Callback {
+
+ @Override
+ public boolean onOpenSubMenu(MenuBuilder subMenu) {
+ if (subMenu == null) return false;
+
+ mOpenSubMenuId = ((SubMenuBuilder) subMenu).getItem().getItemId();
+ return false;
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ if (menu instanceof SubMenuBuilder) {
+ ((SubMenuBuilder) menu).getRootMenu().close(false);
+ }
+ }
+ }
+
+ private class OpenOverflowRunnable implements Runnable {
+ private OverflowPopup mPopup;
+
+ public OpenOverflowRunnable(OverflowPopup popup) {
+ mPopup = popup;
+ }
+
+ public void run() {
+ mMenu.changeMenuMode();
+ final View menuView = (View) mMenuView;
+ if (menuView != null && menuView.getWindowToken() != null && mPopup.tryShow()) {
+ mOverflowPopup = mPopup;
+ }
+ mPostedOpenRunnable = null;
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuView.java b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuView.java
new file mode 100644
index 0000000..49d5837
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuView.java
@@ -0,0 +1,585 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.support.appcompat.view.menu;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.support.appcompat.R;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewDebug;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+import android.widget.LinearLayout;
+
+/**
+ * @hide
+ */
+public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvoker, MenuView {
+ private static final String TAG = "ActionMenuView";
+
+ static final int MIN_CELL_SIZE = 56; // dips
+ static final int GENERATED_ITEM_PADDING = 4; // dips
+
+ private MenuBuilder mMenu;
+
+ private boolean mReserveOverflow;
+ private ActionMenuPresenter mPresenter;
+ private boolean mFormatItems;
+ private int mFormatItemsWidth;
+ private int mMinCellSize;
+ private int mGeneratedItemPadding;
+ private int mMeasuredExtraWidth;
+ private int mMaxItemHeight;
+
+ public ActionMenuView(Context context) {
+ this(context, null);
+ }
+
+ public ActionMenuView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setBaselineAligned(false);
+ final float density = context.getResources().getDisplayMetrics().density;
+ mMinCellSize = (int) (MIN_CELL_SIZE * density);
+ mGeneratedItemPadding = (int) (GENERATED_ITEM_PADDING * density);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar,
+ R.attr.actionBarStyle, 0);
+ mMaxItemHeight = a.getDimensionPixelSize(R.styleable.ActionBar_height, 0);
+ a.recycle();
+ }
+
+ public void setPresenter(ActionMenuPresenter presenter) {
+ mPresenter = presenter;
+ }
+
+ public boolean isExpandedFormat() {
+ return mFormatItems;
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ if (Build.VERSION.SDK_INT >= 8) {
+ super.onConfigurationChanged(newConfig);
+ }
+
+ mPresenter.updateMenuView(false);
+
+ if (mPresenter != null && mPresenter.isOverflowMenuShowing()) {
+ mPresenter.hideOverflowMenu();
+ mPresenter.showOverflowMenu();
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // If we've been given an exact size to match, apply special formatting during layout.
+ final boolean wasFormatted = mFormatItems;
+ mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
+
+ if (wasFormatted != mFormatItems) {
+ mFormatItemsWidth = 0; // Reset this when switching modes
+ }
+
+ // Special formatting can change whether items can fit as action buttons.
+ // Kick the menu and update presenters when this changes.
+ final int widthSize = MeasureSpec.getMode(widthMeasureSpec);
+ if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) {
+ mFormatItemsWidth = widthSize;
+ mMenu.onItemsChanged(true);
+ }
+
+ if (mFormatItems) {
+ onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec);
+ } else {
+ // Previous measurement at exact format may have set margins - reset them.
+ final int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ lp.leftMargin = lp.rightMargin = 0;
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
+ private void onMeasureExactFormat(int widthMeasureSpec, int heightMeasureSpec) {
+ // We already know the width mode is EXACTLY if we're here.
+ final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+
+ final int widthPadding = getPaddingLeft() + getPaddingRight();
+ final int heightPadding = getPaddingTop() + getPaddingBottom();
+
+ final int itemHeightSpec = heightMode == MeasureSpec.EXACTLY
+ ? MeasureSpec.makeMeasureSpec(heightSize - heightPadding, MeasureSpec.EXACTLY)
+ : MeasureSpec.makeMeasureSpec(
+ Math.min(mMaxItemHeight, heightSize - heightPadding), MeasureSpec.AT_MOST);
+
+ widthSize -= widthPadding;
+
+ // Divide the view into cells.
+ final int cellCount = widthSize / mMinCellSize;
+ final int cellSizeRemaining = widthSize % mMinCellSize;
+
+ if (cellCount == 0) {
+ // Give up, nothing fits.
+ setMeasuredDimension(widthSize, 0);
+ return;
+ }
+
+ final int cellSize = mMinCellSize + cellSizeRemaining / cellCount;
+
+ int cellsRemaining = cellCount;
+ int maxChildHeight = 0;
+ int maxCellsUsed = 0;
+ int expandableItemCount = 0;
+ int visibleItemCount = 0;
+ boolean hasOverflow = false;
+
+ // This is used as a bitfield to locate the smallest items present. Assumes childCount < 64.
+ long smallestItemsAt = 0;
+
+ final int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ if (child.getVisibility() == GONE) continue;
+
+ final boolean isGeneratedItem = child instanceof ActionMenuItemView;
+ visibleItemCount++;
+
+ if (isGeneratedItem) {
+ // Reset padding for generated menu item views; it may change below
+ // and views are recycled.
+ child.setPadding(mGeneratedItemPadding, 0, mGeneratedItemPadding, 0);
+ }
+
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ lp.expanded = false;
+ lp.extraPixels = 0;
+ lp.cellsUsed = 0;
+ lp.expandable = false;
+ lp.leftMargin = 0;
+ lp.rightMargin = 0;
+ lp.preventEdgeOffset = isGeneratedItem && ((ActionMenuItemView) child).hasText();
+
+ // Overflow always gets 1 cell. No more, no less.
+ final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining;
+
+ final int cellsUsed = measureChildForCells(child, cellSize, cellsAvailable,
+ itemHeightSpec, heightPadding);
+
+ maxCellsUsed = Math.max(maxCellsUsed, cellsUsed);
+ if (lp.expandable) expandableItemCount++;
+ if (lp.isOverflowButton) hasOverflow = true;
+
+ cellsRemaining -= cellsUsed;
+ maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight());
+ if (cellsUsed == 1) smallestItemsAt |= (1 << i);
+ }
+
+ // When we have overflow and a single expanded (text) item, we want to try centering it
+ // visually in the available space even though overflow consumes some of it.
+ final boolean centerSingleExpandedItem = hasOverflow && visibleItemCount == 2;
+
+ // Divide space for remaining cells if we have items that can expand.
+ // Try distributing whole leftover cells to smaller items first.
+
+ boolean needsExpansion = false;
+ while (expandableItemCount > 0 && cellsRemaining > 0) {
+ int minCells = Integer.MAX_VALUE;
+ long minCellsAt = 0; // Bit locations are indices of relevant child views
+ int minCellsItemCount = 0;
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+ // Don't try to expand items that shouldn't.
+ if (!lp.expandable) continue;
+
+ // Mark indices of children that can receive an extra cell.
+ if (lp.cellsUsed < minCells) {
+ minCells = lp.cellsUsed;
+ minCellsAt = 1 << i;
+ minCellsItemCount = 1;
+ } else if (lp.cellsUsed == minCells) {
+ minCellsAt |= 1 << i;
+ minCellsItemCount++;
+ }
+ }
+
+ // Items that get expanded will always be in the set of smallest items when we're done.
+ smallestItemsAt |= minCellsAt;
+
+ if (minCellsItemCount > cellsRemaining) break; // Couldn't expand anything evenly. Stop.
+
+ // We have enough cells, all minimum size items will be incremented.
+ minCells++;
+
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ if ((minCellsAt & (1 << i)) == 0) {
+ // If this item is already at our small item count, mark it for later.
+ if (lp.cellsUsed == minCells) smallestItemsAt |= 1 << i;
+ continue;
+ }
+
+ if (centerSingleExpandedItem && lp.preventEdgeOffset && cellsRemaining == 1) {
+ // Add padding to this item such that it centers.
+ child.setPadding(mGeneratedItemPadding + cellSize, 0, mGeneratedItemPadding, 0);
+ }
+ lp.cellsUsed++;
+ lp.expanded = true;
+ cellsRemaining--;
+ }
+
+ needsExpansion = true;
+ }
+
+ // Divide any space left that wouldn't divide along cell boundaries
+ // evenly among the smallest items
+
+ final boolean singleItem = !hasOverflow && visibleItemCount == 1;
+ if (cellsRemaining > 0 && smallestItemsAt != 0 &&
+ (cellsRemaining < visibleItemCount - 1 || singleItem || maxCellsUsed > 1)) {
+ float expandCount = Long.bitCount(smallestItemsAt);
+
+ if (!singleItem) {
+ // The items at the far edges may only expand by half in order to pin to either side.
+ if ((smallestItemsAt & 1) != 0) {
+ LayoutParams lp = (LayoutParams) getChildAt(0).getLayoutParams();
+ if (!lp.preventEdgeOffset) expandCount -= 0.5f;
+ }
+ if ((smallestItemsAt & (1 << (childCount - 1))) != 0) {
+ LayoutParams lp = ((LayoutParams) getChildAt(childCount - 1).getLayoutParams());
+ if (!lp.preventEdgeOffset) expandCount -= 0.5f;
+ }
+ }
+
+ final int extraPixels = expandCount > 0 ?
+ (int) (cellsRemaining * cellSize / expandCount) : 0;
+
+ for (int i = 0; i < childCount; i++) {
+ if ((smallestItemsAt & (1 << i)) == 0) continue;
+
+ final View child = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ if (child instanceof ActionMenuItemView) {
+ // If this is one of our views, expand and measure at the larger size.
+ lp.extraPixels = extraPixels;
+ lp.expanded = true;
+ if (i == 0 && !lp.preventEdgeOffset) {
+ // First item gets part of its new padding pushed out of sight.
+ // The last item will get this implicitly from layout.
+ lp.leftMargin = -extraPixels / 2;
+ }
+ needsExpansion = true;
+ } else if (lp.isOverflowButton) {
+ lp.extraPixels = extraPixels;
+ lp.expanded = true;
+ lp.rightMargin = -extraPixels / 2;
+ needsExpansion = true;
+ } else {
+ // If we don't know what it is, give it some margins instead
+ // and let it center within its space. We still want to pin
+ // against the edges.
+ if (i != 0) {
+ lp.leftMargin = extraPixels / 2;
+ }
+ if (i != childCount - 1) {
+ lp.rightMargin = extraPixels / 2;
+ }
+ }
+ }
+
+ cellsRemaining = 0;
+ }
+
+ // Remeasure any items that have had extra space allocated to them.
+ if (needsExpansion) {
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+ if (!lp.expanded) continue;
+
+ final int width = lp.cellsUsed * cellSize + lp.extraPixels;
+ child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+ itemHeightSpec);
+ }
+ }
+
+ if (heightMode != MeasureSpec.EXACTLY) {
+ heightSize = maxChildHeight;
+ }
+
+ setMeasuredDimension(widthSize, heightSize);
+ mMeasuredExtraWidth = cellsRemaining * cellSize;
+ }
+
+ /**
+ * Measure a child view to fit within cell-based formatting. The child's width
+ * will be measured to a whole multiple of cellSize.
+ *
+ * <p>Sets the expandable and cellsUsed fields of LayoutParams.
+ *
+ * @param child Child to measure
+ * @param cellSize Size of one cell
+ * @param cellsRemaining Number of cells remaining that this view can expand to fill
+ * @param parentHeightMeasureSpec MeasureSpec used by the parent view
+ * @param parentHeightPadding Padding present in the parent view
+ * @return Number of cells this child was measured to occupy
+ */
+ static int measureChildForCells(View child, int cellSize, int cellsRemaining,
+ int parentHeightMeasureSpec, int parentHeightPadding) {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+ final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) -
+ parentHeightPadding;
+ final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec);
+ final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode);
+
+ final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
+ (ActionMenuItemView) child : null;
+ final boolean hasText = itemView != null && itemView.hasText();
+
+ int cellsUsed = 0;
+ if (cellsRemaining > 0 && (!hasText || cellsRemaining >= 2)) {
+ final int childWidthSpec = MeasureSpec.makeMeasureSpec(
+ cellSize * cellsRemaining, MeasureSpec.AT_MOST);
+ child.measure(childWidthSpec, childHeightSpec);
+
+ final int measuredWidth = child.getMeasuredWidth();
+ cellsUsed = measuredWidth / cellSize;
+ if (measuredWidth % cellSize != 0) cellsUsed++;
+ if (hasText && cellsUsed < 2) cellsUsed = 2;
+ }
+
+ final boolean expandable = !lp.isOverflowButton && hasText;
+ lp.expandable = expandable;
+
+ lp.cellsUsed = cellsUsed;
+ final int targetWidth = cellsUsed * cellSize;
+ child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY),
+ childHeightSpec);
+ return cellsUsed;
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ if (!mFormatItems) {
+ super.onLayout(changed, left, top, right, bottom);
+ return;
+ }
+
+ final int childCount = getChildCount();
+ final int midVertical = (top + bottom) / 2;
+ //final int dividerWidth = getDividerWidth(); No access outside framework
+ int overflowWidth = 0;
+ int nonOverflowWidth = 0;
+ int nonOverflowCount = 0;
+ int widthRemaining = right - left - getPaddingRight() - getPaddingLeft();
+ boolean hasOverflow = false;
+ for (int i = 0; i < childCount; i++) {
+ final View v = getChildAt(i);
+ if (v.getVisibility() == GONE) {
+ continue;
+ }
+
+ LayoutParams p = (LayoutParams) v.getLayoutParams();
+ if (p.isOverflowButton) {
+ overflowWidth = v.getMeasuredWidth();
+// No access to dividerWidth
+// if (hasDividerBeforeChildAt(i)) {
+// overflowWidth += dividerWidth;
+// }
+
+ int height = v.getMeasuredHeight();
+ int r = getWidth() - getPaddingRight() - p.rightMargin;
+ int l = r - overflowWidth;
+ int t = midVertical - (height / 2);
+ int b = t + height;
+ v.layout(l, t, r, b);
+
+ widthRemaining -= overflowWidth;
+ hasOverflow = true;
+ } else {
+ final int size = v.getMeasuredWidth() + p.leftMargin + p.rightMargin;
+ nonOverflowWidth += size;
+ widthRemaining -= size;
+// No access to dividerWidth
+// if (hasDividerBeforeChildAt(i)) {
+// nonOverflowWidth += dividerWidth;
+// }
+ nonOverflowCount++;
+ }
+ }
+
+ if (childCount == 1 && !hasOverflow) {
+ // Center a single child
+ final View v = getChildAt(0);
+ final int width = v.getMeasuredWidth();
+ final int height = v.getMeasuredHeight();
+ final int midHorizontal = (right - left) / 2;
+ final int l = midHorizontal - width / 2;
+ final int t = midVertical - height / 2;
+ v.layout(l, t, l + width, t + height);
+ return;
+ }
+
+ final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1);
+ final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0);
+
+ int startLeft = getPaddingLeft();
+ for (int i = 0; i < childCount; i++) {
+ final View v = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) v.getLayoutParams();
+ if (v.getVisibility() == GONE || lp.isOverflowButton) {
+ continue;
+ }
+
+ startLeft += lp.leftMargin;
+ int width = v.getMeasuredWidth();
+ int height = v.getMeasuredHeight();
+ int t = midVertical - height / 2;
+ v.layout(startLeft, t, startLeft + width, t + height);
+ startLeft += width + lp.rightMargin + spacerSize;
+ }
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ mPresenter.dismissPopupMenus();
+ }
+
+ public boolean isOverflowReserved() {
+ return mReserveOverflow;
+ }
+
+ public void setOverflowReserved(boolean reserveOverflow) {
+ mReserveOverflow = reserveOverflow;
+ }
+
+ @Override
+ protected LayoutParams generateDefaultLayoutParams() {
+ LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT);
+ params.gravity = Gravity.CENTER_VERTICAL;
+ return params;
+ }
+
+ @Override
+ public LayoutParams generateLayoutParams(AttributeSet attrs) {
+ return new LayoutParams(getContext(), attrs);
+ }
+
+ @Override
+ protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
+ if (p instanceof LayoutParams) {
+ LayoutParams result = new LayoutParams((LayoutParams) p);
+ if (result.gravity <= Gravity.NO_GRAVITY) {
+ result.gravity = Gravity.CENTER_VERTICAL;
+ }
+ return result;
+ }
+ return generateDefaultLayoutParams();
+ }
+
+ @Override
+ protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
+ return p != null && p instanceof LayoutParams;
+ }
+
+ public LayoutParams generateOverflowButtonLayoutParams() {
+ LayoutParams result = generateDefaultLayoutParams();
+ result.isOverflowButton = true;
+ return result;
+ }
+
+ public boolean invokeItem(MenuItemImpl item) {
+ return mMenu.performItemAction(item, 0);
+ }
+
+ public int getWindowAnimations() {
+ return 0;
+ }
+
+ public void initialize(MenuBuilder menu) {
+ mMenu = menu;
+ }
+
+ protected boolean hasDividerBeforeChildAt(int childIndex) {
+ final View childBefore = getChildAt(childIndex - 1);
+ final View child = getChildAt(childIndex);
+ boolean result = false;
+ if (childIndex < getChildCount() && childBefore instanceof ActionMenuChildView) {
+ result |= ((ActionMenuChildView) childBefore).needsDividerAfter();
+ }
+ if (childIndex > 0 && child instanceof ActionMenuChildView) {
+ result |= ((ActionMenuChildView) child).needsDividerBefore();
+ }
+ return result;
+ }
+
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ return false;
+ }
+
+ public interface ActionMenuChildView {
+ public boolean needsDividerBefore();
+ public boolean needsDividerAfter();
+ }
+
+ public static class LayoutParams extends LinearLayout.LayoutParams {
+ @ViewDebug.ExportedProperty()
+ public boolean isOverflowButton;
+ @ViewDebug.ExportedProperty()
+ public int cellsUsed;
+ @ViewDebug.ExportedProperty()
+ public int extraPixels;
+ @ViewDebug.ExportedProperty()
+ public boolean expandable;
+ @ViewDebug.ExportedProperty()
+ public boolean preventEdgeOffset;
+
+ public boolean expanded;
+
+ public LayoutParams(Context c, AttributeSet attrs) {
+ super(c, attrs);
+ }
+
+ public LayoutParams(LayoutParams other) {
+ super((LinearLayout.LayoutParams) other);
+ isOverflowButton = other.isOverflowButton;
+ }
+
+ public LayoutParams(int width, int height) {
+ super(width, height);
+ isOverflowButton = false;
+ }
+
+ public LayoutParams(int width, int height, boolean isOverflowButton) {
+ super(width, height);
+ this.isOverflowButton = isOverflowButton;
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/BaseMenuPresenter.java b/appcompat/eclair/android/support/appcompat/view/menu/BaseMenuPresenter.java
new file mode 100644
index 0000000..9d60789
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/BaseMenuPresenter.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+
+/**
+ * Base class for MenuPresenters that have a consistent container view and item
+ * views. Behaves similarly to an AdapterView in that existing item views will
+ * be reused if possible when items change.
+ */
+public abstract class BaseMenuPresenter implements MenuPresenter {
+ protected Context mSystemContext;
+ protected Context mContext;
+ protected MenuBuilder mMenu;
+ protected LayoutInflater mSystemInflater;
+ protected LayoutInflater mInflater;
+ private Callback mCallback;
+
+ private int mMenuLayoutRes;
+ private int mItemLayoutRes;
+
+ protected MenuView mMenuView;
+
+ private int mId;
+
+ /**
+ * Construct a new BaseMenuPresenter.
+ *
+ * @param context Context for generating system-supplied views
+ * @param menuLayoutRes Layout resource ID for the menu container view
+ * @param itemLayoutRes Layout resource ID for a single item view
+ */
+ public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) {
+ mSystemContext = context;
+ mSystemInflater = LayoutInflater.from(context);
+ mMenuLayoutRes = menuLayoutRes;
+ mItemLayoutRes = itemLayoutRes;
+ }
+
+ @Override
+ public void initForMenu(Context context, MenuBuilder menu) {
+ mContext = context;
+ mInflater = LayoutInflater.from(mContext);
+ mMenu = menu;
+ }
+
+ public MenuView getMenuView(ViewGroup root) {
+ if (mMenuView == null) {
+ mMenuView = (MenuView) mSystemInflater.inflate(mMenuLayoutRes, root, false);
+ mMenuView.initialize(mMenu);
+ updateMenuView(true);
+ }
+
+ return mMenuView;
+ }
+
+ /**
+ * Reuses item views when it can
+ */
+ public void updateMenuView(boolean cleared) {
+ final ViewGroup parent = (ViewGroup) mMenuView;
+ if (parent == null) return;
+
+ int childIndex = 0;
+ if (mMenu != null) {
+ mMenu.flagActionItems();
+ ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems();
+ final int itemCount = visibleItems.size();
+ for (int i = 0; i < itemCount; i++) {
+ MenuItemImpl item = visibleItems.get(i);
+ if (shouldIncludeItem(childIndex, item)) {
+ final View convertView = parent.getChildAt(childIndex);
+ final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ?
+ ((MenuView.ItemView) convertView).getItemData() : null;
+ final View itemView = getItemView(item, convertView, parent);
+ if (item != oldItem) {
+ // Don't let old states linger with new data.
+ itemView.setPressed(false);
+ // itemView.jumpDrawablesToCurrentState();
+ // Animation API: Not available on API < 11
+ }
+ if (itemView != convertView) {
+ addItemView(itemView, childIndex);
+ }
+ childIndex++;
+ }
+ }
+ }
+
+ // Remove leftover views.
+ while (childIndex < parent.getChildCount()) {
+ if (!filterLeftoverView(parent, childIndex)) {
+ childIndex++;
+ }
+ }
+ }
+
+ /**
+ * Add an item view at the given index.
+ *
+ * @param itemView View to add
+ * @param childIndex Index within the parent to insert at
+ */
+ protected void addItemView(View itemView, int childIndex) {
+ final ViewGroup currentParent = (ViewGroup) itemView.getParent();
+ if (currentParent != null) {
+ currentParent.removeView(itemView);
+ }
+ ((ViewGroup) mMenuView).addView(itemView, childIndex);
+ }
+
+ /**
+ * Filter the child view at index and remove it if appropriate.
+ * @param parent Parent to filter from
+ * @param childIndex Index to filter
+ * @return true if the child view at index was removed
+ */
+ protected boolean filterLeftoverView(ViewGroup parent, int childIndex) {
+ parent.removeViewAt(childIndex);
+ return true;
+ }
+
+ public void setCallback(Callback cb) {
+ mCallback = cb;
+ }
+
+ /**
+ * Create a new item view that can be re-bound to other item data later.
+ *
+ * @return The new item view
+ */
+ public MenuView.ItemView createItemView(ViewGroup parent) {
+ return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false);
+ }
+
+ /**
+ * Prepare an item view for use. See AdapterView for the basic idea at work here.
+ * This may require creating a new item view, but well-behaved implementations will
+ * re-use the view passed as convertView if present. The returned view will be populated
+ * with data from the item parameter.
+ *
+ * @param item Item to present
+ * @param convertView Existing view to reuse
+ * @param parent Intended parent view - use for inflation.
+ * @return View that presents the requested menu item
+ */
+ public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
+ MenuView.ItemView itemView;
+ if (convertView instanceof MenuView.ItemView) {
+ itemView = (MenuView.ItemView) convertView;
+ } else {
+ itemView = createItemView(parent);
+ }
+ bindItemView(item, itemView);
+ return (View) itemView;
+ }
+
+ /**
+ * Bind item data to an existing item view.
+ *
+ * @param item Item to bind
+ * @param itemView View to populate with item data
+ */
+ public abstract void bindItemView(MenuItemImpl item, MenuView.ItemView itemView);
+
+ /**
+ * Filter item by child index and item data.
+ *
+ * @param childIndex Indended presentation index of this item
+ * @param item Item to present
+ * @return true if this item should be included in this menu presentation; false otherwise
+ */
+ public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) {
+ return true;
+ }
+
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ if (mCallback != null) {
+ mCallback.onCloseMenu(menu, allMenusAreClosing);
+ }
+ }
+
+ public boolean onSubMenuSelected(SubMenuBuilder menu) {
+ if (mCallback != null) {
+ return mCallback.onOpenSubMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean flagActionItems() {
+ return false;
+ }
+
+ public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ return false;
+ }
+
+ public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ return false;
+ }
+
+ public int getId() {
+ return mId;
+ }
+
+ public void setId(int id) {
+ mId = id;
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ListMenuItemView.java b/appcompat/eclair/android/support/appcompat/view/menu/ListMenuItemView.java
new file mode 100644
index 0000000..32f53a8
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/ListMenuItemView.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.R;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RadioButton;
+import android.widget.TextView;
+
+/**
+ * The item view for each item in the ListView-based MenuViews.
+ */
+public class ListMenuItemView extends LinearLayout implements MenuView.ItemView {
+ private static final String TAG = "ListMenuItemView";
+ private MenuItemImpl mItemData;
+
+ private ImageView mIconView;
+ private RadioButton mRadioButton;
+ private TextView mTitleView;
+ private CheckBox mCheckBox;
+ private TextView mShortcutView;
+
+ private Drawable mBackground;
+ private int mTextAppearance;
+ private Context mTextAppearanceContext;
+ private boolean mPreserveIconSpacing;
+
+ private int mMenuType;
+
+ private Context mContext;
+ private LayoutInflater mInflater;
+
+ private boolean mForceShowIcon;
+
+ public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs);
+ mContext = context;
+
+ TypedArray a =
+ context.obtainStyledAttributes(
+ attrs, R.styleable.MenuView, defStyle, 0);
+
+ mBackground = a.getDrawable(R.styleable.MenuView_itemBackground);
+ mTextAppearance = a.getResourceId(R.styleable.
+ MenuView_itemTextAppearance, -1);
+ mPreserveIconSpacing = a.getBoolean(
+ R.styleable.MenuView_preserveIconSpacing, false);
+ mTextAppearanceContext = context;
+
+ a.recycle();
+ }
+
+ public ListMenuItemView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ setBackgroundDrawable(mBackground);
+
+ mTitleView = (TextView) findViewById(R.id.title);
+ if (mTextAppearance != -1) {
+ mTitleView.setTextAppearance(mTextAppearanceContext,
+ mTextAppearance);
+ }
+
+ mShortcutView = (TextView) findViewById(R.id.shortcut);
+ }
+
+ public void initialize(MenuItemImpl itemData, int menuType) {
+ mItemData = itemData;
+ mMenuType = menuType;
+
+ setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
+
+ setTitle(itemData.getTitleForItemView(this));
+ setCheckable(itemData.isCheckable());
+ setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut());
+ setIcon(itemData.getIcon());
+ setEnabled(itemData.isEnabled());
+ }
+
+ public void setForceShowIcon(boolean forceShow) {
+ mPreserveIconSpacing = mForceShowIcon = forceShow;
+ }
+
+ public void setTitle(CharSequence title) {
+ if (title != null) {
+ mTitleView.setText(title);
+
+ if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE);
+ } else {
+ if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE);
+ }
+ }
+
+ public MenuItemImpl getItemData() {
+ return mItemData;
+ }
+
+ public void setCheckable(boolean checkable) {
+ if (!checkable && mRadioButton == null && mCheckBox == null) {
+ return;
+ }
+
+ // Depending on whether its exclusive check or not, the checkbox or
+ // radio button will be the one in use (and the other will be otherCompoundButton)
+ final CompoundButton compoundButton;
+ final CompoundButton otherCompoundButton;
+
+ if (mItemData.isExclusiveCheckable()) {
+ if (mRadioButton == null) {
+ insertRadioButton();
+ }
+ compoundButton = mRadioButton;
+ otherCompoundButton = mCheckBox;
+ } else {
+ if (mCheckBox == null) {
+ insertCheckBox();
+ }
+ compoundButton = mCheckBox;
+ otherCompoundButton = mRadioButton;
+ }
+
+ if (checkable) {
+ compoundButton.setChecked(mItemData.isChecked());
+
+ final int newVisibility = checkable ? VISIBLE : GONE;
+ if (compoundButton.getVisibility() != newVisibility) {
+ compoundButton.setVisibility(newVisibility);
+ }
+
+ // Make sure the other compound button isn't visible
+ if (otherCompoundButton != null && otherCompoundButton.getVisibility() != GONE) {
+ otherCompoundButton.setVisibility(GONE);
+ }
+ } else {
+ if (mCheckBox != null) mCheckBox.setVisibility(GONE);
+ if (mRadioButton != null) mRadioButton.setVisibility(GONE);
+ }
+ }
+
+ public void setChecked(boolean checked) {
+ CompoundButton compoundButton;
+
+ if (mItemData.isExclusiveCheckable()) {
+ if (mRadioButton == null) {
+ insertRadioButton();
+ }
+ compoundButton = mRadioButton;
+ } else {
+ if (mCheckBox == null) {
+ insertCheckBox();
+ }
+ compoundButton = mCheckBox;
+ }
+
+ compoundButton.setChecked(checked);
+ }
+
+ public void setShortcut(boolean showShortcut, char shortcutKey) {
+ final int newVisibility = (showShortcut && mItemData.shouldShowShortcut())
+ ? VISIBLE : GONE;
+
+ if (newVisibility == VISIBLE) {
+ mShortcutView.setText(mItemData.getShortcutLabel());
+ }
+
+ if (mShortcutView.getVisibility() != newVisibility) {
+ mShortcutView.setVisibility(newVisibility);
+ }
+ }
+
+ public void setIcon(Drawable icon) {
+ final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon;
+ if (!showIcon && !mPreserveIconSpacing) {
+ return;
+ }
+
+ if (mIconView == null && icon == null && !mPreserveIconSpacing) {
+ return;
+ }
+
+ if (mIconView == null) {
+ insertIconView();
+ }
+
+ if (icon != null || mPreserveIconSpacing) {
+ mIconView.setImageDrawable(showIcon ? icon : null);
+
+ if (mIconView.getVisibility() != VISIBLE) {
+ mIconView.setVisibility(VISIBLE);
+ }
+ } else {
+ mIconView.setVisibility(GONE);
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (mIconView != null && mPreserveIconSpacing) {
+ // Enforce minimum icon spacing
+ ViewGroup.LayoutParams lp = getLayoutParams();
+ LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
+ if (lp.height > 0 && iconLp.width <= 0) {
+ iconLp.width = lp.height;
+ }
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ private void insertIconView() {
+ LayoutInflater inflater = getInflater();
+ mIconView = (ImageView) inflater.inflate(R.layout.list_menu_item_icon,
+ this, false);
+ addView(mIconView, 0);
+ }
+
+ private void insertRadioButton() {
+ LayoutInflater inflater = getInflater();
+ mRadioButton =
+ (RadioButton) inflater.inflate(R.layout.list_menu_item_radio,
+ this, false);
+ addView(mRadioButton);
+ }
+
+ private void insertCheckBox() {
+ LayoutInflater inflater = getInflater();
+ mCheckBox =
+ (CheckBox) inflater.inflate(R.layout.list_menu_item_checkbox,
+ this, false);
+ addView(mCheckBox);
+ }
+
+ public boolean prefersCondensedTitle() {
+ return false;
+ }
+
+ public boolean showsIcon() {
+ return mForceShowIcon;
+ }
+
+ private LayoutInflater getInflater() {
+ if (mInflater == null) {
+ mInflater = LayoutInflater.from(mContext);
+ }
+ return mInflater;
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuBuilder.java b/appcompat/eclair/android/support/appcompat/view/menu/MenuBuilder.java
new file mode 100644
index 0000000..a8d01bc
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/MenuBuilder.java
@@ -0,0 +1,248 @@
+// Copyright 2012 Google Inc. All Rights Reserved.
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.view.Menu;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.view.MenuItem;
+import android.support.appcompat.view.SubMenu;
+import android.view.KeyEvent;
+import android.view.View;
+
+import java.util.ArrayList;
+
+/**
+ * @author trevorjohns@google.com (Trevor Johns)
+ */
+public class MenuBuilder implements Menu {
+
+ public void flagActionItems() {
+ }
+
+ public ArrayList<MenuItemImpl> getVisibleItems() {
+ return null; //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public ArrayList<MenuItemImpl> getActionItems() {
+ return null; //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public ArrayList<MenuItemImpl> getNonActionItems() {
+ return null; //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public void addMenuPresenter(MenuPresenter presenter) {
+ //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public MenuItemImpl getExpandedItem() {
+ return null; //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public void close(boolean b) {
+ }
+
+ public void changeMenuMode() {
+ //To change body of created methods use File | Settings | File Templates.
+ }
+
+ /**
+ * Called by menu items to execute their associated action
+ */
+ public interface ItemInvoker {
+ public boolean invokeItem(MenuItemImpl item);
+ }
+
+ public MenuBuilder(Context themedContext) {
+ }
+
+ @Override
+ public MenuItem add(CharSequence charSequence) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public MenuItem add(int i) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public MenuItem add(int i, int i1, int i2, CharSequence charSequence) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public MenuItem add(int i, int i1, int i2, int i3) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public SubMenu addSubMenu(CharSequence charSequence) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public SubMenu addSubMenu(int i) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public SubMenu addSubMenu(int i, int i1, int i2, CharSequence charSequence) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public SubMenu addSubMenu(int i, int i1, int i2, int i3) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public int addIntentOptions(int i, int i1, int i2, ComponentName componentName, Intent[] intents,
+ Intent intent, int i3, MenuItem[] menuItems) {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void removeItem(int i) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void removeGroup(int i) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void clear() {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setGroupCheckable(int i, boolean b, boolean b1) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setGroupVisible(int i, boolean b) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setGroupEnabled(int i, boolean b) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean hasVisibleItems() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public MenuItem findItem(int i) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public int size() {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public MenuItem getItem(int i) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void close() {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean performShortcut(int i, KeyEvent keyEvent, int i1) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean isShortcutKey(int i, KeyEvent keyEvent) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean performIdentifierAction(int i, int i1) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setQwertyMode(boolean b) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public MenuBuilder setDefaultShowAsAction(int showAsActionIfRoom) {
+ return null;
+ }
+
+ public void setCallback(MenuPresenter.Callback actionMode) {
+ }
+
+ public void startDispatchingItemsChanged() {
+ }
+
+ public void stopDispatchingItemsChanged() {
+ //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public boolean isQwertyMode() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setShortcutsVisible(boolean shortcutsVisible) {
+ }
+
+ public boolean isShortcutsVisible() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setHeaderIconInt(Drawable icon) {
+ }
+
+ public void setHeaderTitleInt(CharSequence title) {
+ }
+
+ public void setHeaderViewInt(View view) {
+ }
+
+ public boolean expandItemActionView(MenuItemImpl item) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean collapseItemActionView(MenuItemImpl item) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getActionViewStatesKey() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean getOptionalIconsVisible() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Context getContext() {
+ return null; //To change body of created methods use File | Settings | File Templates.
+ }
+
+ public void onItemsChanged(boolean b) {
+ }
+
+ public boolean performItemAction(MenuItemImpl item, int i) {
+ return false; //To change body of created methods use File | Settings | File Templates.
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuItemImpl.java b/appcompat/eclair/android/support/appcompat/view/menu/MenuItemImpl.java
new file mode 100644
index 0000000..fcdb9aa
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/MenuItemImpl.java
@@ -0,0 +1,648 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.view.ActionProvider;
+import android.support.appcompat.view.MenuItem;
+import android.support.appcompat.view.SubMenu;
+
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.View;
+import android.view.ViewDebug;
+
+/**
+ * @hide
+ */
+public final class MenuItemImpl implements MenuItem {
+ private static final String TAG = "MenuItemImpl";
+
+ private static final int SHOW_AS_ACTION_MASK = SHOW_AS_ACTION_NEVER |
+ SHOW_AS_ACTION_IF_ROOM |
+ SHOW_AS_ACTION_ALWAYS;
+
+ private final int mId;
+ private final int mGroup;
+ private final int mCategoryOrder;
+ private final int mOrdering;
+ private CharSequence mTitle;
+ private CharSequence mTitleCondensed;
+ private Intent mIntent;
+ private char mShortcutNumericChar;
+ private char mShortcutAlphabeticChar;
+
+ /** The icon's drawable which is only created as needed */
+ private Drawable mIconDrawable;
+ /**
+ * The icon's resource ID which is used to get the Drawable when it is
+ * needed (if the Drawable isn't already obtained--only one of the two is
+ * needed).
+ */
+ private int mIconResId = NO_ICON;
+
+ /** The menu to which this item belongs */
+ private MenuBuilder mMenu;
+ /** If this item should launch a sub menu, this is the sub menu to launch */
+ private SubMenuBuilder mSubMenu;
+
+ private Runnable mItemCallback;
+ private MenuItem.OnMenuItemClickListener mClickListener;
+
+ private int mFlags = ENABLED;
+ private static final int CHECKABLE = 0x00000001;
+ private static final int CHECKED = 0x00000002;
+ private static final int EXCLUSIVE = 0x00000004;
+ private static final int HIDDEN = 0x00000008;
+ private static final int ENABLED = 0x00000010;
+ private static final int IS_ACTION = 0x00000020;
+
+ private int mShowAsAction = SHOW_AS_ACTION_NEVER;
+
+ private View mActionView;
+ private ActionProvider mActionProvider;
+ private OnActionExpandListener mOnActionExpandListener;
+ private boolean mIsActionViewExpanded = false;
+
+ /** Used for the icon resource ID if this item does not have an icon */
+ static final int NO_ICON = 0;
+
+ /**
+ * Current use case is for context menu: Extra information linked to the
+ * View that added this item to the context menu.
+ */
+ private ContextMenuInfo mMenuInfo;
+
+ private static String sPrependShortcutLabel;
+ private static String sEnterShortcutLabel;
+ private static String sDeleteShortcutLabel;
+ private static String sSpaceShortcutLabel;
+
+
+ /**
+ * Instantiates this menu item.
+ *
+ * @param menu
+ * @param group Item ordering grouping control. The item will be added after
+ * all other items whose order is <= this number, and before any
+ * that are larger than it. This can also be used to define
+ * groups of items for batch state changes. Normally use 0.
+ * @param id Unique item ID. Use 0 if you do not need a unique ID.
+ * @param categoryOrder The ordering for this item.
+ * @param title The text to display for the item.
+ */
+ MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering,
+ CharSequence title, int showAsAction) {
+
+ /*if (sPrependShortcutLabel == null) {
+ // This is instantiated from the UI thread, so no chance of sync issues
+ sPrependShortcutLabel = menu.getContext().getResources().getString(
+ com.android.internal.R.string.prepend_shortcut_label);
+ sEnterShortcutLabel = menu.getContext().getResources().getString(
+ com.android.internal.R.string.menu_enter_shortcut_label);
+ sDeleteShortcutLabel = menu.getContext().getResources().getString(
+ com.android.internal.R.string.menu_delete_shortcut_label);
+ sSpaceShortcutLabel = menu.getContext().getResources().getString(
+ com.android.internal.R.string.menu_space_shortcut_label);
+ }*/
+
+ mMenu = menu;
+ mId = id;
+ mGroup = group;
+ mCategoryOrder = categoryOrder;
+ mOrdering = ordering;
+ mTitle = title;
+ mShowAsAction = showAsAction;
+ }
+
+ /**
+ * Invokes the item by calling various listeners or callbacks.
+ *
+ * @return true if the invocation was handled, false otherwise
+ */
+ public boolean invoke() {
+ if (mClickListener != null &&
+ mClickListener.onMenuItemClick(this)) {
+ return true;
+ }
+
+ //if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
+ // return true;
+ //}
+
+ if (mItemCallback != null) {
+ mItemCallback.run();
+ return true;
+ }
+
+ if (mIntent != null) {
+ try {
+ //mMenu.getContext().startActivity(mIntent);
+ return true;
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
+ }
+ }
+
+ if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean isEnabled() {
+ return (mFlags & ENABLED) != 0;
+ }
+
+ public MenuItem setEnabled(boolean enabled) {
+ if (enabled) {
+ mFlags |= ENABLED;
+ } else {
+ mFlags &= ~ENABLED;
+ }
+
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ public int getGroupId() {
+ return mGroup;
+ }
+
+ @ViewDebug.CapturedViewProperty
+ public int getItemId() {
+ return mId;
+ }
+
+ public int getOrder() {
+ return mCategoryOrder;
+ }
+
+ public int getOrdering() {
+ return mOrdering;
+ }
+
+ public Intent getIntent() {
+ return mIntent;
+ }
+
+ public MenuItem setIntent(Intent intent) {
+ mIntent = intent;
+ return this;
+ }
+
+ Runnable getCallback() {
+ return mItemCallback;
+ }
+
+ public MenuItem setCallback(Runnable callback) {
+ mItemCallback = callback;
+ return this;
+ }
+
+ public char getAlphabeticShortcut() {
+ return mShortcutAlphabeticChar;
+ }
+
+ public MenuItem setAlphabeticShortcut(char alphaChar) {
+ if (mShortcutAlphabeticChar == alphaChar) return this;
+
+ mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
+
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ public char getNumericShortcut() {
+ return mShortcutNumericChar;
+ }
+
+ public MenuItem setNumericShortcut(char numericChar) {
+ if (mShortcutNumericChar == numericChar) return this;
+
+ mShortcutNumericChar = numericChar;
+
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ public MenuItem setShortcut(char numericChar, char alphaChar) {
+ mShortcutNumericChar = numericChar;
+ mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
+
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ /**
+ * @return The active shortcut (based on QWERTY-mode of the menu).
+ */
+ char getShortcut() {
+ //return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar);
+ return mShortcutAlphabeticChar;
+ }
+
+ /**
+ * @return The label to show for the shortcut. This includes the chording
+ * key (for example 'Menu+a'). Also, any non-human readable
+ * characters should be human readable (for example 'Menu+enter').
+ */
+ String getShortcutLabel() {
+
+ char shortcut = getShortcut();
+ if (shortcut == 0) {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder(sPrependShortcutLabel);
+ switch (shortcut) {
+
+ case '\n':
+ sb.append(sEnterShortcutLabel);
+ break;
+
+ case '\b':
+ sb.append(sDeleteShortcutLabel);
+ break;
+
+ case ' ':
+ sb.append(sSpaceShortcutLabel);
+ break;
+
+ default:
+ sb.append(shortcut);
+ break;
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * @return Whether this menu item should be showing shortcuts (depends on
+ * whether the menu should show shortcuts and whether this item has
+ * a shortcut defined)
+ */
+ boolean shouldShowShortcut() {
+ // Show shortcuts if the menu is supposed to show shortcuts AND this item has a shortcut
+ return mMenu.isShortcutsVisible() && (getShortcut() != 0);
+ }
+
+ public SubMenu getSubMenu() {
+ return mSubMenu;
+ }
+
+ public boolean hasSubMenu() {
+ return mSubMenu != null;
+ }
+
+ void setSubMenu(SubMenuBuilder subMenu) {
+ mSubMenu = subMenu;
+
+ subMenu.setHeaderTitle(getTitle());
+ }
+
+ @ViewDebug.CapturedViewProperty
+ public CharSequence getTitle() {
+ return mTitle;
+ }
+
+ /**
+ * Gets the title for a particular {@link ItemView}
+ *
+ * @param itemView The ItemView that is receiving the title
+ * @return Either the title or condensed title based on what the ItemView
+ * prefers
+ */
+ CharSequence getTitleForItemView(MenuView.ItemView itemView) {
+ return ((itemView != null) && itemView.prefersCondensedTitle())
+ ? getTitleCondensed()
+ : getTitle();
+ }
+
+ public MenuItem setTitle(CharSequence title) {
+ mTitle = title;
+
+ //mMenu.onItemsChanged(false);
+
+ if (mSubMenu != null) {
+ mSubMenu.setHeaderTitle(title);
+ }
+
+ return this;
+ }
+
+ public MenuItem setTitle(int title) {
+ return setTitle(mMenu.getContext().getString(title));
+ }
+
+ public CharSequence getTitleCondensed() {
+ return mTitleCondensed != null ? mTitleCondensed : mTitle;
+ }
+
+ public MenuItem setTitleCondensed(CharSequence title) {
+ mTitleCondensed = title;
+
+ // Could use getTitle() in the loop below, but just cache what it would do here
+ if (title == null) {
+ title = mTitle;
+ }
+
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ public Drawable getIcon() {
+ if (mIconDrawable != null) {
+ return mIconDrawable;
+ }
+
+ if (mIconResId != NO_ICON) {
+ //Drawable icon = mMenu.getResources().getDrawable(mIconResId);
+ // mIconResId = NO_ICON;
+ //mIconDrawable = icon;
+ //return icon;
+ }
+
+ return null;
+ }
+
+ public MenuItem setIcon(Drawable icon) {
+ mIconResId = NO_ICON;
+ mIconDrawable = icon;
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ public MenuItem setIcon(int iconResId) {
+ mIconDrawable = null;
+ mIconResId = iconResId;
+
+ // If we have a view, we need to push the Drawable to them
+ //mMenu.onItemsChanged(false);
+
+ return this;
+ }
+
+ public boolean isCheckable() {
+ return (mFlags & CHECKABLE) == CHECKABLE;
+ }
+
+ public MenuItem setCheckable(boolean checkable) {
+ final int oldFlags = mFlags;
+ mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
+ if (oldFlags != mFlags) {
+ //mMenu.onItemsChanged(false);
+ }
+
+ return this;
+ }
+
+ public void setExclusiveCheckable(boolean exclusive) {
+ mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0);
+ }
+
+ public boolean isExclusiveCheckable() {
+ return (mFlags & EXCLUSIVE) != 0;
+ }
+
+ public boolean isChecked() {
+ return (mFlags & CHECKED) == CHECKED;
+ }
+
+ public MenuItem setChecked(boolean checked) {
+ if ((mFlags & EXCLUSIVE) != 0) {
+ // Call the method on the Menu since it knows about the others in this
+ // exclusive checkable group
+ //mMenu.setExclusiveItemChecked(this);
+ } else {
+ setCheckedInt(checked);
+ }
+
+ return this;
+ }
+
+ void setCheckedInt(boolean checked) {
+ final int oldFlags = mFlags;
+ mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0);
+ if (oldFlags != mFlags) {
+ //mMenu.onItemsChanged(false);
+ }
+ }
+
+ public boolean isVisible() {
+ return (mFlags & HIDDEN) == 0;
+ }
+
+ /**
+ * Changes the visibility of the item. This method DOES NOT notify the
+ * parent menu of a change in this item, so this should only be called from
+ * methods that will eventually trigger this change. If unsure, use {@link #setVisible(boolean)}
+ * instead.
+ *
+ * @param shown Whether to show (true) or hide (false).
+ * @return Whether the item's shown state was changed
+ */
+ boolean setVisibleInt(boolean shown) {
+ final int oldFlags = mFlags;
+ mFlags = (mFlags & ~HIDDEN) | (shown ? 0 : HIDDEN);
+ return oldFlags != mFlags;
+ }
+
+ public MenuItem setVisible(boolean shown) {
+ // Try to set the shown state to the given state. If the shown state was changed
+ // (i.e. the previous state isn't the same as given state), notify the parent menu that
+ // the shown state has changed for this item
+ //if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this);
+
+ return this;
+ }
+
+ public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener clickListener) {
+ mClickListener = clickListener;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return mTitle.toString();
+ }
+
+ void setMenuInfo(ContextMenuInfo menuInfo) {
+ mMenuInfo = menuInfo;
+ }
+
+ public ContextMenuInfo getMenuInfo() {
+ return mMenuInfo;
+ }
+
+ public void actionFormatChanged() {
+ //mMenu.onItemActionRequestChanged(this);
+ }
+
+ /**
+ * @return Whether the menu should show icons for menu items.
+ */
+ public boolean shouldShowIcon() {
+ return mMenu.getOptionalIconsVisible();
+ }
+
+ public boolean isActionButton() {
+ return (mFlags & IS_ACTION) == IS_ACTION;
+ }
+
+ public boolean requestsActionButton() {
+ return (mShowAsAction & SHOW_AS_ACTION_IF_ROOM) == SHOW_AS_ACTION_IF_ROOM;
+ }
+
+ public boolean requiresActionButton() {
+ return (mShowAsAction & SHOW_AS_ACTION_ALWAYS) == SHOW_AS_ACTION_ALWAYS;
+ }
+
+ public void setIsActionButton(boolean isActionButton) {
+ if (isActionButton) {
+ mFlags |= IS_ACTION;
+ } else {
+ mFlags &= ~IS_ACTION;
+ }
+ }
+
+ public boolean showsTextAsAction() {
+ return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT;
+ }
+
+ public void setShowAsAction(int actionEnum) {
+ switch (actionEnum & SHOW_AS_ACTION_MASK) {
+ case SHOW_AS_ACTION_ALWAYS:
+ case SHOW_AS_ACTION_IF_ROOM:
+ case SHOW_AS_ACTION_NEVER:
+ // Looks good!
+ break;
+
+ default:
+ // Mutually exclusive options selected!
+ throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM,"
+ + " and SHOW_AS_ACTION_NEVER are mutually exclusive.");
+ }
+ mShowAsAction = actionEnum;
+ //mMenu.onItemActionRequestChanged(this);
+ }
+
+ public MenuItem setActionView(View view) {
+ mActionView = view;
+ mActionProvider = null;
+ if (view != null && view.getId() == View.NO_ID && mId > 0) {
+ view.setId(mId);
+ }
+ //mMenu.onItemActionRequestChanged(this);
+ return this;
+ }
+
+ public MenuItem setActionView(int resId) {
+ //final Context context = mMenu.getContext();
+ //final LayoutInflater inflater = LayoutInflater.from(context);
+ //setActionView(inflater.inflate(resId, new LinearLayout(context), false));
+ return this;
+ }
+
+ public View getActionView() {
+ if (mActionView != null) {
+ return mActionView;
+ } else if (mActionProvider != null) {
+ mActionView = mActionProvider.onCreateActionView();
+ return mActionView;
+ } else {
+ return null;
+ }
+ }
+
+ public ActionProvider getActionProvider() {
+ return mActionProvider;
+ }
+
+ public MenuItem setActionProvider(ActionProvider actionProvider) {
+ mActionView = null;
+ mActionProvider = actionProvider;
+ //mMenu.onItemsChanged(true); // Measurement can be changed
+ return this;
+ }
+
+ @Override
+ public MenuItem setShowAsActionFlags(int actionEnum) {
+ setShowAsAction(actionEnum);
+ return this;
+ }
+
+ @Override
+ public boolean expandActionView() {
+ if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0 || mActionView == null) {
+ return false;
+ }
+
+ if (mOnActionExpandListener == null ||
+ mOnActionExpandListener.onMenuItemActionExpand(this)) {
+ //return mMenu.expandItemActionView(this);
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean collapseActionView() {
+ if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) {
+ return false;
+ }
+ if (mActionView == null) {
+ // We're already collapsed if we have no action view.
+ return true;
+ }
+
+ if (mOnActionExpandListener == null ||
+ mOnActionExpandListener.onMenuItemActionCollapse(this)) {
+ return mMenu.collapseItemActionView(this);
+ }
+
+ return false;
+ }
+
+ @Override
+ public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
+ mOnActionExpandListener = listener;
+ return this;
+ }
+
+ public boolean hasCollapsibleActionView() {
+ return (mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) != 0 && mActionView != null;
+ }
+
+ public void setActionViewExpanded(boolean isExpanded) {
+ mIsActionViewExpanded = isExpanded;
+ //mMenu.onItemsChanged(false);
+ }
+
+ public boolean isActionViewExpanded() {
+ return mIsActionViewExpanded;
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuPopupHelper.java b/appcompat/eclair/android/support/appcompat/view/menu/MenuPopupHelper.java
new file mode 100644
index 0000000..9e5e130
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/MenuPopupHelper.java
@@ -0,0 +1,374 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.view.MenuItem;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.database.DataSetObserver;
+import android.os.Parcelable;
+import android.support.appcompat.R;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.MeasureSpec;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.FrameLayout;
+import android.widget.ListAdapter;
+import android.widget.ListPopupWindow;
+import android.widget.PopupWindow;
+
+import java.util.ArrayList;
+
+/**
+ * Presents a menu as a small, simple popup anchored to another view.
+ * @hide
+ */
+public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.OnKeyListener,
+ ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener,
+ View.OnAttachStateChangeListener, MenuPresenter {
+ private static final String TAG = "MenuPopupHelper";
+
+ static final int ITEM_LAYOUT = R.layout.popup_menu_item_layout;
+
+ private Context mContext;
+ private LayoutInflater mInflater;
+ private ListPopupWindow mPopup;
+ private MenuBuilder mMenu;
+ private int mPopupMaxWidth;
+ private View mAnchorView;
+ private boolean mOverflowOnly;
+ private ViewTreeObserver mTreeObserver;
+
+ private MenuAdapter mAdapter;
+
+ private Callback mPresenterCallback;
+
+ boolean mForceShowIcon;
+
+ private ViewGroup mMeasureParent;
+
+ public MenuPopupHelper(Context context, MenuBuilder menu) {
+ this(context, menu, null, false);
+ }
+
+ public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) {
+ this(context, menu, anchorView, false);
+ }
+
+ public MenuPopupHelper(Context context, MenuBuilder menu,
+ View anchorView, boolean overflowOnly) {
+ mContext = context;
+ mInflater = LayoutInflater.from(context);
+ mMenu = menu;
+ mOverflowOnly = overflowOnly;
+
+ final Resources res = context.getResources();
+ mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2,
+ res.getDimensionPixelSize(R.dimen.config_prefDialogWidth));
+
+ mAnchorView = anchorView;
+
+ menu.addMenuPresenter(this);
+ }
+
+ public void setAnchorView(View anchor) {
+ mAnchorView = anchor;
+ }
+
+ public void setForceShowIcon(boolean forceShow) {
+ mForceShowIcon = forceShow;
+ }
+
+ public void show() {
+ if (!tryShow()) {
+ throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
+ }
+ }
+
+ public boolean tryShow() {
+ mPopup = new ListPopupWindow(mContext, null, R.attr.popupMenuStyle);
+ mPopup.setOnDismissListener(this);
+ mPopup.setOnItemClickListener(this);
+
+ mAdapter = new MenuAdapter(mMenu);
+ mPopup.setAdapter(mAdapter);
+ mPopup.setModal(true);
+
+ View anchor = mAnchorView;
+ if (anchor != null) {
+ final boolean addGlobalListener = mTreeObserver == null;
+ mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest
+ if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this);
+ anchor.addOnAttachStateChangeListener(this);
+ mPopup.setAnchorView(anchor);
+ } else {
+ return false;
+ }
+
+ mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
+ mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
+ mPopup.show();
+ mPopup.getListView().setOnKeyListener(this);
+ return true;
+ }
+
+ public void dismiss() {
+ if (isShowing()) {
+ mPopup.dismiss();
+ }
+ }
+
+ public void onDismiss() {
+ mPopup = null;
+ mMenu.close();
+ if (mTreeObserver != null) {
+ if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver();
+ mTreeObserver.removeGlobalOnLayoutListener(this);
+ mTreeObserver = null;
+ }
+ mAnchorView.removeOnAttachStateChangeListener(this);
+ }
+
+ public boolean isShowing() {
+ return mPopup != null && mPopup.isShowing();
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ MenuAdapter adapter = mAdapter;
+ adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0);
+ }
+
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_MENU) {
+ dismiss();
+ return true;
+ }
+ return false;
+ }
+
+ private int measureContentWidth(ListAdapter adapter) {
+ // Menus don't tend to be long, so this is more sane than it looks.
+ int width = 0;
+ View itemView = null;
+ int itemType = 0;
+ final int widthMeasureSpec =
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ final int heightMeasureSpec =
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ final int count = adapter.getCount();
+ for (int i = 0; i < count; i++) {
+ final int positionType = adapter.getItemViewType(i);
+ if (positionType != itemType) {
+ itemType = positionType;
+ itemView = null;
+ }
+ if (mMeasureParent == null) {
+ mMeasureParent = new FrameLayout(mContext);
+ }
+ itemView = adapter.getView(i, itemView, mMeasureParent);
+ itemView.measure(widthMeasureSpec, heightMeasureSpec);
+ width = Math.max(width, itemView.getMeasuredWidth());
+ }
+ return width;
+ }
+
+ @Override
+ public void onGlobalLayout() {
+ if (isShowing()) {
+ final View anchor = mAnchorView;
+ if (anchor == null || !anchor.isShown()) {
+ dismiss();
+ } else if (isShowing()) {
+ // Recompute window size and position
+ mPopup.show();
+ }
+ }
+ }
+
+ @Override
+ public void onViewAttachedToWindow(View v) {
+ }
+
+ @Override
+ public void onViewDetachedFromWindow(View v) {
+ if (mTreeObserver != null) {
+ if (!mTreeObserver.isAlive()) mTreeObserver = v.getViewTreeObserver();
+ mTreeObserver.removeGlobalOnLayoutListener(this);
+ }
+ v.removeOnAttachStateChangeListener(this);
+ }
+
+ @Override
+ public void initForMenu(Context context, MenuBuilder menu) {
+ // Don't need to do anything; we added as a presenter in the constructor.
+ }
+
+ @Override
+ public MenuView getMenuView(ViewGroup root) {
+ throw new UnsupportedOperationException("MenuPopupHelpers manage their own views");
+ }
+
+ @Override
+ public void updateMenuView(boolean cleared) {
+ if (mAdapter != null) mAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void setCallback(Callback cb) {
+ mPresenterCallback = cb;
+ }
+
+ @Override
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
+ if (subMenu.hasVisibleItems()) {
+ MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false);
+ subPopup.setCallback(mPresenterCallback);
+
+ boolean preserveIconSpacing = false;
+ final int count = subMenu.size();
+ for (int i = 0; i < count; i++) {
+ MenuItem childItem = subMenu.getItem(i);
+ if (childItem.isVisible() && childItem.getIcon() != null) {
+ preserveIconSpacing = true;
+ break;
+ }
+ }
+ subPopup.setForceShowIcon(preserveIconSpacing);
+
+ if (subPopup.tryShow()) {
+ if (mPresenterCallback != null) {
+ mPresenterCallback.onOpenSubMenu(subMenu);
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ // Only care about the (sub)menu we're presenting.
+ if (menu != mMenu) return;
+
+ dismiss();
+ if (mPresenterCallback != null) {
+ mPresenterCallback.onCloseMenu(menu, allMenusAreClosing);
+ }
+ }
+
+ @Override
+ public boolean flagActionItems() {
+ return false;
+ }
+
+ public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ return false;
+ }
+
+ public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ return false;
+ }
+
+ @Override
+ public int getId() {
+ return 0;
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ return null;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ }
+
+ private class MenuAdapter extends BaseAdapter {
+ private MenuBuilder mAdapterMenu;
+ private int mExpandedIndex = -1;
+
+ public MenuAdapter(MenuBuilder menu) {
+ mAdapterMenu = menu;
+ findExpandedIndex();
+ }
+
+ public int getCount() {
+ ArrayList<MenuItemImpl> items = mOverflowOnly ?
+ mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems();
+ if (mExpandedIndex < 0) {
+ return items.size();
+ }
+ return items.size() - 1;
+ }
+
+ public MenuItemImpl getItem(int position) {
+ ArrayList<MenuItemImpl> items = mOverflowOnly ?
+ mAdapterMenu.getNonActionItems() : mAdapterMenu.getVisibleItems();
+ if (mExpandedIndex >= 0 && position >= mExpandedIndex) {
+ position++;
+ }
+ return items.get(position);
+ }
+
+ public long getItemId(int position) {
+ // Since a menu item's ID is optional, we'll use the position as an
+ // ID for the item in the AdapterView
+ return position;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = mInflater.inflate(ITEM_LAYOUT, parent, false);
+ }
+
+ MenuView.ItemView itemView = (MenuView.ItemView) convertView;
+ if (mForceShowIcon) {
+ ((ListMenuItemView) convertView).setForceShowIcon(true);
+ }
+ itemView.initialize(getItem(position), 0);
+ return convertView;
+ }
+
+ void findExpandedIndex() {
+ final MenuItemImpl expandedItem = mMenu.getExpandedItem();
+ if (expandedItem != null) {
+ final ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
+ final int count = items.size();
+ for (int i = 0; i < count; i++) {
+ final MenuItemImpl item = items.get(i);
+ if (item == expandedItem) {
+ mExpandedIndex = i;
+ return;
+ }
+ }
+ }
+ mExpandedIndex = -1;
+ }
+
+ @Override
+ public void notifyDataSetChanged() {
+ findExpandedIndex();
+ super.notifyDataSetChanged();
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuPresenter.java b/appcompat/eclair/android/support/appcompat/view/menu/MenuPresenter.java
new file mode 100644
index 0000000..dd2e126
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/MenuPresenter.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.view.Menu;
+
+import android.content.Context;
+import android.os.Parcelable;
+import android.view.ViewGroup;
+
+/**
+ * A MenuPresenter is responsible for building views for a Menu object.
+ * It takes over some responsibility from the old style monolithic MenuBuilder class.
+ */
+public interface MenuPresenter {
+ /**
+ * Called by menu implementation to notify another component of open/close events.
+ */
+ public interface Callback {
+ /**
+ * Called when a menu is closing.
+ * @param menu
+ * @param allMenusAreClosing
+ */
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing);
+
+ /**
+ * Called when a submenu opens. Useful for notifying the application
+ * of menu state so that it does not attempt to hide the action bar
+ * while a submenu is open or similar.
+ *
+ * @param subMenu Submenu currently being opened
+ * @return true if the Callback will handle presenting the submenu, false if
+ * the presenter should attempt to do so.
+ */
+ public boolean onOpenSubMenu(MenuBuilder subMenu);
+ }
+
+ /**
+ * Initialize this presenter for the given context and menu.
+ * This method is called by MenuBuilder when a presenter is
+ * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)}
+ *
+ * @param context Context for this presenter; used for view creation and resource management
+ * @param menu Menu to host
+ */
+ public void initForMenu(Context context, MenuBuilder menu);
+
+ /**
+ * Retrieve a MenuView to display the menu specified in
+ * {@link #initForMenu(Context, Menu)}.
+ *
+ * @param root Intended parent of the MenuView.
+ * @return A freshly created MenuView.
+ */
+ public MenuView getMenuView(ViewGroup root);
+
+ /**
+ * Update the menu UI in response to a change. Called by
+ * MenuBuilder during the normal course of operation.
+ *
+ * @param cleared true if the menu was entirely cleared
+ */
+ public void updateMenuView(boolean cleared);
+
+ /**
+ * Set a callback object that will be notified of menu events
+ * related to this specific presentation.
+ * @param cb Callback that will be notified of future events
+ */
+ public void setCallback(Callback cb);
+
+ /**
+ * Called by Menu implementations to indicate that a submenu item
+ * has been selected. An active Callback should be notified, and
+ * if applicable the presenter should present the submenu.
+ *
+ * @param subMenu SubMenu being opened
+ * @return true if the the event was handled, false otherwise.
+ */
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu);
+
+ /**
+ * Called by Menu implementations to indicate that a menu or submenu is
+ * closing. Presenter implementations should close the representation
+ * of the menu indicated as necessary and notify a registered callback.
+ *
+ * @param menu Menu or submenu that is closing.
+ * @param allMenusAreClosing True if all associated menus are closing.
+ */
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing);
+
+ /**
+ * Called by Menu implementations to flag items that will be shown as actions.
+ * @return true if this presenter changed the action status of any items.
+ */
+ public boolean flagActionItems();
+
+ /**
+ * Called when a menu item with a collapsable action view should expand its action view.
+ *
+ * @param menu Menu containing the item to be expanded
+ * @param item Item to be expanded
+ * @return true if this presenter expanded the action view, false otherwise.
+ */
+ public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item);
+
+ /**
+ * Called when a menu item with a collapsable action view should collapse its action view.
+ *
+ * @param menu Menu containing the item to be collapsed
+ * @param item Item to be collapsed
+ * @return true if this presenter collapsed the action view, false otherwise.
+ */
+ public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item);
+
+ /**
+ * Returns an ID for determining how to save/restore instance state.
+ * @return a valid ID value.
+ */
+ public int getId();
+
+ /**
+ * Returns a Parcelable describing the current state of the presenter.
+ * It will be passed to the {@link #onRestoreInstanceState(Parcelable)}
+ * method of the presenter sharing the same ID later.
+ * @return The saved instance state
+ */
+ public Parcelable onSaveInstanceState();
+
+ /**
+ * Supplies the previously saved instance state to be restored.
+ * @param state The previously saved instance state
+ */
+ public void onRestoreInstanceState(Parcelable state);
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuView.java b/appcompat/eclair/android/support/appcompat/view/menu/MenuView.java
new file mode 100644
index 0000000..09d48e6
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/MenuView.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.view.menu.MenuBuilder;
+import android.support.appcompat.view.menu.MenuItemImpl;
+
+import android.graphics.drawable.Drawable;
+
+/**
+ * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the
+ * menu to be functional.
+ *
+ * @hide
+ */
+public interface MenuView {
+ /**
+ * Initializes the menu to the given menu. This should be called after the
+ * view is inflated.
+ *
+ * @param menu The menu that this MenuView should display.
+ */
+ public void initialize(MenuBuilder menu);
+
+ /**
+ * Returns the default animations to be used for this menu when entering/exiting.
+ * @return A resource ID for the default animations to be used for this menu.
+ */
+ public int getWindowAnimations();
+
+ /**
+ * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be called
+ * for the item to be functional.
+ */
+ public interface ItemView {
+ /**
+ * Initializes with the provided MenuItemData. This should be called after the view is
+ * inflated.
+ * @param itemData The item that this ItemView should display.
+ * @param menuType The type of this menu, one of
+ * {@link MenuBuilder#TYPE_ICON}, {@link MenuBuilder#TYPE_EXPANDED},
+ * {@link MenuBuilder#TYPE_DIALOG}).
+ */
+ public void initialize(MenuItemImpl itemData, int menuType);
+
+ /**
+ * Gets the item data that this view is displaying.
+ * @return the item data, or null if there is not one
+ */
+ public MenuItemImpl getItemData();
+
+ /**
+ * Sets the title of the item view.
+ * @param title The title to set.
+ */
+ public void setTitle(CharSequence title);
+
+ /**
+ * Sets the enabled state of the item view.
+ * @param enabled Whether the item view should be enabled.
+ */
+ public void setEnabled(boolean enabled);
+
+ /**
+ * Displays the checkbox for the item view. This does not ensure the item view will be
+ * checked, for that use {@link #setChecked}.
+ * @param checkable Whether to display the checkbox or to hide it
+ */
+ public void setCheckable(boolean checkable);
+
+ /**
+ * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be
+ * made visible, call {@link #setCheckable(boolean)} for that.
+ * @param checked Whether the checkbox should be checked
+ */
+ public void setChecked(boolean checked);
+
+ /**
+ * Sets the shortcut for the item.
+ * @param showShortcut Whether a shortcut should be shown(if false, the value of
+ * shortcutKey should be ignored).
+ * @param shortcutKey The shortcut key that should be shown on the ItemView.
+ */
+ public void setShortcut(boolean showShortcut, char shortcutKey);
+
+ /**
+ * Set the icon of this item view.
+ * @param icon The icon of this item. null to hide the icon.
+ */
+ public void setIcon(Drawable icon);
+
+ /**
+ * Whether this item view prefers displaying the condensed title rather
+ * than the normal title. If a condensed title is not available, the
+ * normal title will be used.
+ *
+ * @return Whether this item view prefers displaying the condensed
+ * title.
+ */
+ public boolean prefersCondensedTitle();
+
+ /**
+ * Whether this item view shows an icon.
+ *
+ * @return Whether this item view shows an icon.
+ */
+ public boolean showsIcon();
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/SubMenuBuilder.java b/appcompat/eclair/android/support/appcompat/view/menu/SubMenuBuilder.java
new file mode 100644
index 0000000..1639450
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/view/menu/SubMenuBuilder.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.view.menu;
+
+import android.support.appcompat.view.Menu;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.view.MenuItem;
+import android.support.appcompat.view.SubMenu;
+import android.view.View;
+
+/**
+ * The model for a sub menu, which is an extension of the menu. Most methods are proxied to
+ * the parent menu.
+ */
+public class SubMenuBuilder extends MenuBuilder implements SubMenu {
+ private MenuBuilder mParentMenu;
+ private MenuItemImpl mItem;
+
+ public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) {
+ super(context);
+
+ mParentMenu = parentMenu;
+ mItem = item;
+ }
+
+ @Override
+ public void setQwertyMode(boolean isQwerty) {
+ mParentMenu.setQwertyMode(isQwerty);
+ }
+
+ @Override
+ public boolean isQwertyMode() {
+ return mParentMenu.isQwertyMode();
+ }
+
+ @Override
+ public void setShortcutsVisible(boolean shortcutsVisible) {
+ mParentMenu.setShortcutsVisible(shortcutsVisible);
+ }
+
+ @Override
+ public boolean isShortcutsVisible() {
+ return mParentMenu.isShortcutsVisible();
+ }
+
+ public Menu getParentMenu() {
+ return mParentMenu;
+ }
+
+ public MenuItem getItem() {
+ return mItem;
+ }
+
+ @Override
+ public void setCallback(MenuPresenter.Callback callback) {
+ mParentMenu.setCallback(callback);
+ }
+
+ public MenuBuilder getRootMenu() {
+ return mParentMenu;
+ }
+
+ @Override
+ public boolean dispatchMenuItemSelected(MenuBuilder menu, MenuItem item) {
+ return super.dispatchMenuItemSelected(menu, item) ||
+ mParentMenu.dispatchMenuItemSelected(menu, item);
+ }
+
+ public SubMenu setIcon(Drawable icon) {
+ mItem.setIcon(icon);
+ return this;
+ }
+
+ public SubMenu setIcon(int iconRes) {
+ mItem.setIcon(iconRes);
+ return this;
+ }
+
+ public SubMenu setHeaderIcon(Drawable icon) {
+ super.setHeaderIconInt(icon);
+ return this;
+ }
+
+ public SubMenu setHeaderIcon(int iconRes) {
+ super.setHeaderIconInt(getContext().getResources().getDrawable(iconRes));
+ return this;
+ }
+
+ public SubMenu setHeaderTitle(CharSequence title) {
+ super.setHeaderTitleInt(title);
+ return this;
+ }
+
+ public SubMenu setHeaderTitle(int titleRes) {
+ super.setHeaderTitleInt(getContext().getResources().getString(titleRes));
+ return this;
+ }
+
+ public SubMenu setHeaderView(View view) {
+ super.setHeaderViewInt(view);
+ return this;
+ }
+
+ @Override
+ public void clearHeader() {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean expandItemActionView(MenuItemImpl item) {
+ return mParentMenu.expandItemActionView(item);
+ }
+
+ @Override
+ public boolean collapseItemActionView(MenuItemImpl item) {
+ return mParentMenu.collapseItemActionView(item);
+ }
+
+ @Override
+ public String getActionViewStatesKey() {
+ final int itemId = mItem != null ? mItem.getItemId() : 0;
+ if (itemId == 0) {
+ return null;
+ }
+ return super.getActionViewStatesKey() + ":" + itemId;
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/AbsActionBarView.java b/appcompat/eclair/android/support/appcompat/widget/AbsActionBarView.java
new file mode 100644
index 0000000..5920d2a
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/widget/AbsActionBarView.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.support.appcompat.widget;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.support.appcompat.R;
+import android.support.appcompat.view.menu.ActionMenuPresenter;
+import android.support.appcompat.view.menu.ActionMenuView;
+import android.text.AndroidCharacter;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+public abstract class AbsActionBarView extends ViewGroup {
+ protected ActionMenuView mMenuView;
+ protected ActionMenuPresenter mActionMenuPresenter;
+ protected ActionBarContainer mSplitView;
+ protected boolean mSplitActionBar;
+ protected boolean mSplitWhenNarrow;
+ protected int mContentHeight;
+
+ private static final int FADE_DURATION = 200;
+
+ public AbsActionBarView(Context context) {
+ super(context);
+ }
+
+ public AbsActionBarView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public AbsActionBarView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ if (Build.VERSION.SDK_INT >= 8) {
+ super.onConfigurationChanged(newConfig);
+ }
+
+ // Action bar can change size on configuration changes.
+ // Reread the desired height from the theme-specified style.
+ TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
+ R.attr.actionBarStyle, 0);
+ setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
+ a.recycle();
+ if (mSplitWhenNarrow) {
+ setSplitActionBar(getContext().getResources().getBoolean(
+ R.bool.split_action_bar_is_narrow));
+ }
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.onConfigurationChanged(newConfig);
+ }
+ }
+
+ /**
+ * Sets whether the bar should be split right now, no questions asked.
+ * @param split true if the bar should split
+ */
+ public void setSplitActionBar(boolean split) {
+ mSplitActionBar = split;
+ }
+
+ /**
+ * Sets whether the bar should split if we enter a narrow screen configuration.
+ * @param splitWhenNarrow true if the bar should check to split after a config change
+ */
+ public void setSplitWhenNarrow(boolean splitWhenNarrow) {
+ mSplitWhenNarrow = splitWhenNarrow;
+ }
+
+ public void setContentHeight(int height) {
+ mContentHeight = height;
+ requestLayout();
+ }
+
+ public int getContentHeight() {
+ return mContentHeight;
+ }
+
+ public void setSplitView(ActionBarContainer splitView) {
+ mSplitView = splitView;
+ }
+
+ /**
+ * @return Current visibility or if animating, the visibility being animated to.
+ */
+ public int getAnimatedVisibility() {
+ return getVisibility();
+ }
+
+ public void animateToVisibility(int visibility) {
+ setVisibility(visibility);
+ }
+
+ @Override
+ public void setVisibility(int visibility) {
+ if (visibility != getVisibility()) {
+ super.setVisibility(visibility);
+ }
+ }
+
+ public boolean showOverflowMenu() {
+ if (mActionMenuPresenter != null) {
+ return mActionMenuPresenter.showOverflowMenu();
+ }
+ return false;
+ }
+
+ public void postShowOverflowMenu() {
+ post(new Runnable() {
+ public void run() {
+ showOverflowMenu();
+ }
+ });
+ }
+
+ public boolean hideOverflowMenu() {
+ if (mActionMenuPresenter != null) {
+ return mActionMenuPresenter.hideOverflowMenu();
+ }
+ return false;
+ }
+
+ public boolean isOverflowMenuShowing() {
+ if (mActionMenuPresenter != null) {
+ return mActionMenuPresenter.isOverflowMenuShowing();
+ }
+ return false;
+ }
+
+ public boolean isOverflowReserved() {
+ return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved();
+ }
+
+ public void dismissPopupMenus() {
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.dismissPopupMenus();
+ }
+ }
+
+ protected int measureChildView(View child, int availableWidth, int childSpecHeight,
+ int spacing) {
+ child.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
+ childSpecHeight);
+
+ availableWidth -= child.getMeasuredWidth();
+ availableWidth -= spacing;
+
+ return Math.max(0, availableWidth);
+ }
+
+ protected int positionChild(View child, int x, int y, int contentHeight) {
+ int childWidth = child.getMeasuredWidth();
+ int childHeight = child.getMeasuredHeight();
+ int childTop = y + (contentHeight - childHeight) / 2;
+
+ child.layout(x, childTop, x + childWidth, childTop + childHeight);
+
+ return childWidth;
+ }
+
+ protected int positionChildInverse(View child, int x, int y, int contentHeight) {
+ int childWidth = child.getMeasuredWidth();
+ int childHeight = child.getMeasuredHeight();
+ int childTop = y + (contentHeight - childHeight) / 2;
+
+ child.layout(x - childWidth, childTop, x, childTop + childHeight);
+
+ return childWidth;
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarContainer.java b/appcompat/eclair/android/support/appcompat/widget/ActionBarContainer.java
new file mode 100644
index 0000000..1d9f09c
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/widget/ActionBarContainer.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.R;
+import android.support.appcompat.app.ActionBar;
+import android.support.appcompat.view.ActionMode;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
+/**
+ * This class acts as a container for the action bar view and action mode context views.
+ * It applies special styles as needed to help handle animated transitions between them.
+ * @hide
+ */
+public class ActionBarContainer extends FrameLayout {
+ private boolean mIsTransitioning;
+ private View mTabContainer;
+ private ActionBarView mActionBarView;
+
+ private Drawable mBackground;
+ private Drawable mStackedBackground;
+ private Drawable mSplitBackground;
+ private boolean mIsSplit;
+ private boolean mIsStacked;
+
+ public ActionBarContainer(Context context) {
+ this(context, null);
+ }
+
+ public ActionBarContainer(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ setBackgroundDrawable(null);
+
+ TypedArray a = context.obtainStyledAttributes(attrs,
+ R.styleable.ActionBar);
+ mBackground = a.getDrawable(R.styleable.ActionBar_background);
+ mStackedBackground = a.getDrawable(
+ R.styleable.ActionBar_backgroundStacked);
+
+ if (getId() == R.id.split_action_bar) {
+ mIsSplit = true;
+ mSplitBackground = a.getDrawable(
+ R.styleable.ActionBar_backgroundSplit);
+ }
+ a.recycle();
+
+ setWillNotDraw(mIsSplit ? mSplitBackground == null :
+ mBackground == null && mStackedBackground == null);
+ }
+
+ @Override
+ public void onFinishInflate() {
+ super.onFinishInflate();
+ mActionBarView = (ActionBarView) findViewById(R.id.action_bar);
+ }
+
+ public void setPrimaryBackground(Drawable bg) {
+ mBackground = bg;
+ invalidate();
+ }
+
+ public void setStackedBackground(Drawable bg) {
+ mStackedBackground = bg;
+ invalidate();
+ }
+
+ public void setSplitBackground(Drawable bg) {
+ mSplitBackground = bg;
+ invalidate();
+ }
+
+ /**
+ * Set the action bar into a "transitioning" state. While transitioning
+ * the bar will block focus and touch from all of its descendants. This
+ * prevents the user from interacting with the bar while it is animating
+ * in or out.
+ *
+ * @param isTransitioning true if the bar is currently transitioning, false otherwise.
+ */
+ public void setTransitioning(boolean isTransitioning) {
+ mIsTransitioning = isTransitioning;
+ setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS
+ : FOCUS_AFTER_DESCENDANTS);
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ return mIsTransitioning || super.onInterceptTouchEvent(ev);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ super.onTouchEvent(ev);
+
+ // An action bar always eats touch events.
+ return true;
+ }
+
+ //@Override
+ public boolean onHoverEvent(MotionEvent ev) {
+ //super.onHoverEvent(ev);
+
+ // An action bar always eats hover events.
+ return true;
+ }
+
+ public void setTabContainer(ScrollingTabContainerView tabView) {
+ if (mTabContainer != null) {
+ removeView(mTabContainer);
+ }
+ mTabContainer = tabView;
+ if (tabView != null) {
+ addView(tabView);
+ final ViewGroup.LayoutParams lp = tabView.getLayoutParams();
+ lp.width = LayoutParams.FILL_PARENT;
+ lp.height = LayoutParams.WRAP_CONTENT;
+ tabView.setAllowCollapse(false);
+ }
+ }
+
+ public View getTabContainer() {
+ return mTabContainer;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ if (getWidth() == 0 || getHeight() == 0) {
+ return;
+ }
+
+ if (mIsSplit) {
+ if (mSplitBackground != null) mSplitBackground.draw(canvas);
+ } else {
+ if (mBackground != null) {
+ mBackground.draw(canvas);
+ }
+ if (mStackedBackground != null && mIsStacked) {
+ mStackedBackground.draw(canvas);
+ }
+ }
+ }
+
+ //@Override
+ public ActionMode startActionModeForChild(View child, ActionMode.Callback callback) {
+ // No starting an action mode for an action bar child! (Where would it go?)
+ return null;
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ if (mActionBarView == null) return;
+
+ final LayoutParams lp = (LayoutParams) mActionBarView.getLayoutParams();
+ final int actionBarViewHeight = mActionBarView.isCollapsed() ? 0 :
+ mActionBarView.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
+
+ if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
+ final int mode = MeasureSpec.getMode(heightMeasureSpec);
+ if (mode == MeasureSpec.AT_MOST) {
+ final int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
+ setMeasuredDimension(getMeasuredWidth(),
+ Math.min(actionBarViewHeight + mTabContainer.getMeasuredHeight(),
+ maxHeight));
+ }
+ }
+ }
+
+ @Override
+ public void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+
+ final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE;
+
+ if (mTabContainer != null && mTabContainer.getVisibility() != GONE) {
+ final int containerHeight = getMeasuredHeight();
+ final int tabHeight = mTabContainer.getMeasuredHeight();
+
+ if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) {
+ // Not showing home, put tabs on top.
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+
+ if (child == mTabContainer) continue;
+
+ if (!mActionBarView.isCollapsed()) {
+ child.offsetTopAndBottom(tabHeight);
+ }
+ }
+ mTabContainer.layout(l, 0, r, tabHeight);
+ } else {
+ mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight);
+ }
+ }
+
+ boolean needsInvalidate = false;
+ if (mIsSplit) {
+ if (mSplitBackground != null) {
+ mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
+ needsInvalidate = true;
+ }
+ } else {
+ if (mBackground != null) {
+ mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(),
+ mActionBarView.getRight(), mActionBarView.getBottom());
+ needsInvalidate = true;
+ }
+ if ((mIsStacked = hasTabs && mStackedBackground != null)) {
+ mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(),
+ mTabContainer.getRight(), mTabContainer.getBottom());
+ needsInvalidate = true;
+ }
+ }
+
+ if (needsInvalidate) {
+ invalidate();
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarContextView.java b/appcompat/eclair/android/support/appcompat/widget/ActionBarContextView.java
new file mode 100644
index 0000000..eb13d6c
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/widget/ActionBarContextView.java
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.support.appcompat.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.R;
+import android.support.appcompat.view.menu.ActionMenuPresenter;
+import android.support.appcompat.view.menu.ActionMenuView;
+import android.support.appcompat.view.menu.MenuBuilder;
+import android.support.appcompat.view.ActionMode;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.animation.DecelerateInterpolator;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+/**
+ * @hide
+ */
+public class ActionBarContextView extends AbsActionBarView {
+ private static final String TAG = "ActionBarContextView";
+
+ private CharSequence mTitle;
+ private CharSequence mSubtitle;
+
+ private View mClose;
+ private View mCustomView;
+ private LinearLayout mTitleLayout;
+ private TextView mTitleView;
+ private TextView mSubtitleView;
+ private int mTitleStyleRes;
+ private int mSubtitleStyleRes;
+ private Drawable mSplitBackground;
+ private boolean mTitleOptional;
+
+ public ActionBarContextView(Context context) {
+ this(context, null);
+ }
+
+ public ActionBarContextView(Context context, AttributeSet attrs) {
+ this(context, attrs, R.attr.actionModeStyle);
+ }
+
+ public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionMode, defStyle, 0);
+ setBackgroundDrawable(a.getDrawable(
+ R.styleable.ActionMode_background));
+ mTitleStyleRes = a.getResourceId(
+ R.styleable.ActionMode_titleTextStyle, 0);
+ mSubtitleStyleRes = a.getResourceId(
+ R.styleable.ActionMode_subtitleTextStyle, 0);
+
+ mContentHeight = a.getLayoutDimension(
+ R.styleable.ActionMode_height, 0);
+
+ mSplitBackground = a.getDrawable(
+ R.styleable.ActionMode_backgroundSplit);
+
+ a.recycle();
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.hideOverflowMenu();
+ mActionMenuPresenter.hideSubMenus();
+ }
+ }
+
+ @Override
+ public void setSplitActionBar(boolean split) {
+ if (mSplitActionBar != split) {
+ if (mActionMenuPresenter != null) {
+ // Mode is already active; move everything over and adjust the menu itself.
+ final ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.FILL_PARENT);
+ if (!split) {
+ mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
+ mMenuView.setBackgroundDrawable(null);
+ final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
+ if (oldParent != null) oldParent.removeView(mMenuView);
+ addView(mMenuView, layoutParams);
+ } else {
+ // Allow full screen width in split mode.
+ mActionMenuPresenter.setWidthLimit(
+ getContext().getResources().getDisplayMetrics().widthPixels, true);
+ // No limit to the item count; use whatever will fit.
+ mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
+ // Span the whole width
+ layoutParams.width = ViewGroup.LayoutParams.FILL_PARENT;
+ layoutParams.height = mContentHeight;
+ mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
+ mMenuView.setBackgroundDrawable(mSplitBackground);
+ final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
+ if (oldParent != null) oldParent.removeView(mMenuView);
+ mSplitView.addView(mMenuView, layoutParams);
+ }
+ }
+ super.setSplitActionBar(split);
+ }
+ }
+
+ public void setContentHeight(int height) {
+ mContentHeight = height;
+ }
+
+ public void setCustomView(View view) {
+ if (mCustomView != null) {
+ removeView(mCustomView);
+ }
+ mCustomView = view;
+ if (mTitleLayout != null) {
+ removeView(mTitleLayout);
+ mTitleLayout = null;
+ }
+ if (view != null) {
+ addView(view);
+ }
+ requestLayout();
+ }
+
+ public void setTitle(CharSequence title) {
+ mTitle = title;
+ initTitle();
+ }
+
+ public void setSubtitle(CharSequence subtitle) {
+ mSubtitle = subtitle;
+ initTitle();
+ }
+
+ public CharSequence getTitle() {
+ return mTitle;
+ }
+
+ public CharSequence getSubtitle() {
+ return mSubtitle;
+ }
+
+ private void initTitle() {
+ if (mTitleLayout == null) {
+ LayoutInflater inflater = LayoutInflater.from(getContext());
+ inflater.inflate(R.layout.action_bar_title_item, this);
+ mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
+ mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
+ mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
+ if (mTitleStyleRes != 0) {
+ mTitleView.setTextAppearance(getContext(), mTitleStyleRes);
+ }
+ if (mSubtitleStyleRes != 0) {
+ mSubtitleView.setTextAppearance(getContext(), mSubtitleStyleRes);
+ }
+ }
+
+ mTitleView.setText(mTitle);
+ mSubtitleView.setText(mSubtitle);
+
+ final boolean hasTitle = !TextUtils.isEmpty(mTitle);
+ final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle);
+ mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE);
+ mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE);
+ if (mTitleLayout.getParent() == null) {
+ addView(mTitleLayout);
+ }
+ }
+
+ public void initForMode(final ActionMode mode) {
+ if (mClose == null) {
+ LayoutInflater inflater = LayoutInflater.from(getContext());
+ mClose = inflater.inflate(R.layout.action_mode_close_item, this, false);
+ addView(mClose);
+ } else if (mClose.getParent() == null) {
+ addView(mClose);
+ }
+
+ View closeButton = mClose.findViewById(R.id.action_mode_close_button);
+ closeButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ mode.finish();
+ }
+ });
+
+ final MenuBuilder menu = (MenuBuilder) mode.getMenu();
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.dismissPopupMenus();
+ }
+ mActionMenuPresenter = new ActionMenuPresenter(getContext());
+ mActionMenuPresenter.setReserveOverflow(true);
+
+ final ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.FILL_PARENT);
+ if (!mSplitActionBar) {
+ menu.addMenuPresenter(mActionMenuPresenter);
+ mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
+ mMenuView.setBackgroundDrawable(null);
+ addView(mMenuView, layoutParams);
+ } else {
+ // Allow full screen width in split mode.
+ mActionMenuPresenter.setWidthLimit(
+ getContext().getResources().getDisplayMetrics().widthPixels, true);
+ // No limit to the item count; use whatever will fit.
+ mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
+ // Span the whole width
+ layoutParams.width = ViewGroup.LayoutParams.FILL_PARENT;
+ layoutParams.height = mContentHeight;
+ menu.addMenuPresenter(mActionMenuPresenter);
+ mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
+ mMenuView.setBackgroundDrawable(mSplitBackground);
+ mSplitView.addView(mMenuView, layoutParams);
+ }
+ }
+
+ public void closeMode() {
+ if (mClose == null) {
+ killMode();
+ return;
+ }
+ }
+
+ public void killMode() {
+ removeAllViews();
+ if (mSplitView != null) {
+ mSplitView.removeView(mMenuView);
+ }
+ mCustomView = null;
+ mMenuView = null;
+ }
+
+ @Override
+ public boolean showOverflowMenu() {
+ if (mActionMenuPresenter != null) {
+ return mActionMenuPresenter.showOverflowMenu();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean hideOverflowMenu() {
+ if (mActionMenuPresenter != null) {
+ return mActionMenuPresenter.hideOverflowMenu();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isOverflowMenuShowing() {
+ if (mActionMenuPresenter != null) {
+ return mActionMenuPresenter.isOverflowMenuShowing();
+ }
+ return false;
+ }
+
+ @Override
+ protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
+ // Used by custom views if they don't supply layout params. Everything else
+ // added to an ActionBarContextView should have them already.
+ return new ViewGroup.MarginLayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ }
+
+ @Override
+ public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
+ return new ViewGroup.MarginLayoutParams(getContext(), attrs);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
+ if (widthMode != View.MeasureSpec.EXACTLY) {
+ throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
+ "with android:layout_width=\"match_parent\" (or fill_parent)");
+ }
+
+ final int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
+ if (heightMode == View.MeasureSpec.UNSPECIFIED) {
+ throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
+ "with android:layout_height=\"wrap_content\"");
+ }
+
+ final int contentWidth = View.MeasureSpec.getSize(widthMeasureSpec);
+
+ int maxHeight = mContentHeight > 0 ?
+ mContentHeight : View.MeasureSpec.getSize(heightMeasureSpec);
+
+ final int verticalPadding = getPaddingTop() + getPaddingBottom();
+ int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight();
+ final int height = maxHeight - verticalPadding;
+ final int childSpecHeight = View.MeasureSpec
+ .makeMeasureSpec(height, View.MeasureSpec.AT_MOST);
+
+ if (mClose != null) {
+ availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0);
+ ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mClose.getLayoutParams();
+ availableWidth -= lp.leftMargin + lp.rightMargin;
+ }
+
+ if (mMenuView != null && mMenuView.getParent() == this) {
+ availableWidth = measureChildView(mMenuView, availableWidth,
+ childSpecHeight, 0);
+ }
+
+ if (mTitleLayout != null && mCustomView == null) {
+ if (mTitleOptional) {
+ final int titleWidthSpec = View.MeasureSpec
+ .makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
+ mTitleLayout.measure(titleWidthSpec, childSpecHeight);
+ final int titleWidth = mTitleLayout.getMeasuredWidth();
+ final boolean titleFits = titleWidth <= availableWidth;
+ if (titleFits) {
+ availableWidth -= titleWidth;
+ }
+ mTitleLayout.setVisibility(titleFits ? VISIBLE : GONE);
+ } else {
+ availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0);
+ }
+ }
+
+ if (mCustomView != null) {
+ ViewGroup.LayoutParams lp = mCustomView.getLayoutParams();
+ final int customWidthMode = lp.width != ViewGroup.LayoutParams.WRAP_CONTENT ?
+ View.MeasureSpec.EXACTLY : View.MeasureSpec.AT_MOST;
+ final int customWidth = lp.width >= 0 ?
+ Math.min(lp.width, availableWidth) : availableWidth;
+ final int customHeightMode = lp.height != ViewGroup.LayoutParams.WRAP_CONTENT ?
+ View.MeasureSpec.EXACTLY : View.MeasureSpec.AT_MOST;
+ final int customHeight = lp.height >= 0 ?
+ Math.min(lp.height, height) : height;
+ mCustomView.measure(View.MeasureSpec.makeMeasureSpec(customWidth, customWidthMode),
+ View.MeasureSpec.makeMeasureSpec(customHeight, customHeightMode));
+ }
+
+ if (mContentHeight <= 0) {
+ int measuredHeight = 0;
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View v = getChildAt(i);
+ int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
+ if (paddedViewHeight > measuredHeight) {
+ measuredHeight = paddedViewHeight;
+ }
+ }
+ setMeasuredDimension(contentWidth, measuredHeight);
+ } else {
+ setMeasuredDimension(contentWidth, maxHeight);
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ int x = getPaddingLeft();
+ final int y = getPaddingTop();
+ final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();
+
+ if (mClose != null && mClose.getVisibility() != GONE) {
+ ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mClose.getLayoutParams();
+ x += lp.leftMargin;
+ x += positionChild(mClose, x, y, contentHeight);
+ x += lp.rightMargin;
+
+ }
+
+ if (mTitleLayout != null && mCustomView == null && mTitleLayout.getVisibility() != GONE) {
+ x += positionChild(mTitleLayout, x, y, contentHeight);
+ }
+
+ if (mCustomView != null) {
+ x += positionChild(mCustomView, x, y, contentHeight);
+ }
+
+ x = r - l - getPaddingRight();
+
+ if (mMenuView != null) {
+ x -= positionChildInverse(mMenuView, x, y, contentHeight);
+ }
+ }
+
+ public void setTitleOptional(boolean titleOptional) {
+ if (titleOptional != mTitleOptional) {
+ requestLayout();
+ }
+ mTitleOptional = titleOptional;
+ }
+
+ public boolean isTitleOptional() {
+ return mTitleOptional;
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarOverlayLayout.java b/appcompat/eclair/android/support/appcompat/widget/ActionBarOverlayLayout.java
new file mode 100644
index 0000000..d79c8ca
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/widget/ActionBarOverlayLayout.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.support.appcompat.R;
+import android.support.appcompat.app.ActionBar;
+import android.support.appcompat.app.ActionBarImplCompat;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+/**
+ * Special layout for the containing of an overlay action bar (and its
+ * content) to correctly handle fitting system windows when the content
+ * has request that its layout ignore them.
+ */
+public class ActionBarOverlayLayout extends FrameLayout {
+ private int mActionBarHeight;
+ private ActionBar mActionBar;
+ // TODO(trevorjohns): Should this be ActionBarImplCompat?
+ private int mWindowVisibility = View.VISIBLE;
+ private View mContent;
+ private View mActionBarTop;
+ private ActionBarContainer mContainerView;
+ private ActionBarView mActionView;
+ private View mActionBarBottom;
+ private int mLastSystemUiVisibility;
+ private final Rect mZeroRect = new Rect(0, 0, 0, 0);
+
+ static final int[] mActionBarSizeAttr = new int [] {
+ android.support.appcompat.R.attr.actionBarSize
+ };
+
+ public ActionBarOverlayLayout(Context context) {
+ super(context);
+ init(context);
+ }
+
+ public ActionBarOverlayLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context);
+ }
+
+ private void init(Context context) {
+ TypedArray ta = getContext().getTheme().obtainStyledAttributes(mActionBarSizeAttr);
+ mActionBarHeight = ta.getDimensionPixelSize(0, 0);
+ ta.recycle();
+ }
+
+ public void setActionBar(ActionBarImplCompat impl) {
+ mActionBar = impl;
+ if (getWindowToken() != null) {
+ // This is being initialized after being added to a window;
+ // make sure to update all state now.
+ // TODO(trevorjohns): Non-public method. Probably okay, but test. (Also below.)
+ // TOOD(trevorjohns): Might make sense to strip out visibility handling in general.
+ // mActionBar.setWindowVisibility(mWindowVisibility);
+ if (mLastSystemUiVisibility != 0) {
+ int newVis = mLastSystemUiVisibility;
+ // Removed: Not relevant on older devices
+ // onWindowSystemUiVisibilityChanged(newVis);
+ // requestFitSystemWindows();
+ }
+ }
+ }
+
+ // Removed: Not relevant for older devices
+ /*public void setShowingForActionMode(boolean showing) {
+ if (showing) {
+ // Here's a fun hack: if the status bar is currently being hidden,
+ // and the application has asked for stable content insets, then
+ // we will end up with the action mode action bar being shown
+ // without the status bar, but moved below where the status bar
+ // would be. Not nice. Trying to have this be positioned
+ // correctly is not easy (basically we need yet *another* content
+ // inset from the window manager to know where to put it), so
+ // instead we will just temporarily force the status bar to be shown.
+ if ((getWindowSystemUiVisibility() & (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | SYSTEM_UI_FLAG_LAYOUT_STABLE))
+ == (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_STABLE)) {
+ setDisabledSystemUiVisibility(SYSTEM_UI_FLAG_FULLSCREEN);
+ }
+ } else {
+ setDisabledSystemUiVisibility(0);
+ }
+ }*/
+
+ // Removed: Not relevant for older devices
+ /*@Override
+ public void onWindowSystemUiVisibilityChanged(int visible) {
+ super.onWindowSystemUiVisibilityChanged(visible);
+ pullChildren();
+ final int diff = mLastSystemUiVisibility ^ visible;
+ mLastSystemUiVisibility = visible;
+ final boolean barVisible = (visible&SYSTEM_UI_FLAG_FULLSCREEN) == 0;
+ final boolean wasVisible = mActionBar != null ? mActionBar.isSystemShowing() : true;
+ if (mActionBar != null) {
+ if (barVisible) mActionBar.showForSystem();
+ else mActionBar.hideForSystem();
+ }
+ if ((diff&SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
+ if (mActionBar != null) {
+ requestFitSystemWindows();
+ }
+ }
+ }*/
+
+ @Override
+ protected void onWindowVisibilityChanged(int visibility) {
+ super.onWindowVisibilityChanged(visibility);
+ mWindowVisibility = visibility;
+ // See above.
+ //if (mActionBar != null) {
+ // mActionBar.setWindowVisibility(visibility);
+ //}
+ }
+
+ private boolean applyInsets(View view, Rect insets, boolean left, boolean top,
+ boolean bottom, boolean right) {
+ boolean changed = false;
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)view.getLayoutParams();
+ if (left && lp.leftMargin != insets.left) {
+ changed = true;
+ lp.leftMargin = insets.left;
+ }
+ if (top && lp.topMargin != insets.top) {
+ changed = true;
+ lp.topMargin = insets.top;
+ }
+ if (right && lp.rightMargin != insets.right) {
+ changed = true;
+ lp.rightMargin = insets.right;
+ }
+ if (bottom && lp.bottomMargin != insets.bottom) {
+ changed = true;
+ lp.bottomMargin = insets.bottom;
+ }
+ return changed;
+ }
+
+ // Removed:
+ /*@Override
+ protected boolean fitSystemWindows(Rect insets) {
+ pullChildren();
+
+ final int vis = getWindowSystemUiVisibility();
+ final boolean stable = (vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
+
+ // The top and bottom action bars are always within the content area.
+ boolean changed = applyInsets(mActionBarTop, insets, true, true, false, true);
+ if (mActionBarBottom != null) {
+ changed |= applyInsets(mActionBarBottom, insets, true, false, true, true);
+ }
+
+ // If the window has not requested system UI layout flags, we need to
+ // make sure its content is not being covered by system UI... though it
+ // will still be covered by the action bar since they have requested it to
+ // overlay.
+ if ((vis & SYSTEM_UI_LAYOUT_FLAGS) == 0) {
+ changed |= applyInsets(mContent, insets, true, true, true, true);
+ // The insets are now consumed.
+ insets.set(0, 0, 0, 0);
+ } else {
+ changed |= applyInsets(mContent, mZeroRect, true, true, true, true);
+ }
+
+
+ if (stable || mActionBarTop.getVisibility() == VISIBLE) {
+ // The action bar creates additional insets for its content to use.
+ insets.top += mActionBarHeight;
+ }
+
+ if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) {
+ View tabs = mContainerView.getTabContainer();
+ if (stable || (tabs != null && tabs.getVisibility() == VISIBLE)) {
+ // If tabs are not embedded, adjust insets to account for them.
+ insets.top += mActionBarHeight;
+ }
+ }
+
+ if (mActionView.isSplitActionBar()) {
+ if (stable || (mActionBarBottom != null
+ && mActionBarBottom.getVisibility() == VISIBLE)) {
+ // If action bar is split, adjust buttom insets for it.
+ insets.bottom += mActionBarHeight;
+ }
+ }
+
+ if (changed) {
+ requestLayout();
+ }
+
+ return super.fitSystemWindows(insets);
+ }*/
+
+ void pullChildren() {
+ if (mContent == null) {
+ mContent = findViewById(R.id.content);
+ mActionBarTop = findViewById(R.id.top_action_bar);
+ mContainerView = (ActionBarContainer)findViewById(
+ R.id.action_bar_container);
+ mActionView = (ActionBarView) findViewById(R.id.action_bar);
+ mActionBarBottom = findViewById(R.id.split_action_bar);
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarView.java b/appcompat/eclair/android/support/appcompat/widget/ActionBarView.java
new file mode 100644
index 0000000..1006ab9
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/widget/ActionBarView.java
@@ -0,0 +1,1480 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.widget;
+
+import android.support.appcompat.R;
+import android.support.appcompat.view.menu.ActionMenuItem;
+import android.support.appcompat.view.menu.ActionMenuPresenter;
+import android.support.appcompat.view.menu.ActionMenuView;
+import android.support.appcompat.view.menu.MenuBuilder;
+import android.support.appcompat.view.menu.MenuItemImpl;
+import android.support.appcompat.view.menu.MenuPresenter;
+import android.support.appcompat.view.menu.MenuView;
+import android.support.appcompat.view.menu.SubMenuBuilder;
+
+import android.support.appcompat.app.ActionBar;
+import android.support.appcompat.app.ActionBar.OnNavigationListener;
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.CollapsibleActionView;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.view.Window;
+import android.view.accessibility.AccessibilityEvent;
+import android.widget.AdapterView;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+import android.widget.TextView;
+
+/**
+ * @hide
+ */
+public class ActionBarView extends AbsActionBarView {
+ private static final String TAG = "ActionBarView";
+
+ /**
+ * Display options applied by default
+ */
+ public static final int DISPLAY_DEFAULT = 0;
+
+ /**
+ * Display options that require re-layout as opposed to a simple invalidate
+ */
+ private static final int DISPLAY_RELAYOUT_MASK =
+ ActionBar.DISPLAY_SHOW_HOME |
+ ActionBar.DISPLAY_USE_LOGO |
+ ActionBar.DISPLAY_HOME_AS_UP |
+ ActionBar.DISPLAY_SHOW_CUSTOM |
+ ActionBar.DISPLAY_SHOW_TITLE;
+
+ private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.LEFT | Gravity.CENTER_VERTICAL;
+
+ private int mNavigationMode;
+ private int mDisplayOptions = -1;
+ private CharSequence mTitle;
+ private CharSequence mSubtitle;
+ private Drawable mIcon;
+ private Drawable mLogo;
+
+ private Context mContext;
+ private HomeView mHomeLayout;
+ private HomeView mExpandedHomeLayout;
+ private LinearLayout mTitleLayout;
+ private TextView mTitleView;
+ private TextView mSubtitleView;
+ private View mTitleUpView;
+
+ private Spinner mSpinner;
+ private LinearLayout mListNavLayout;
+ private ScrollingTabContainerView mTabScrollView;
+ private View mCustomNavView;
+ private ProgressBar mProgressView;
+ private ProgressBar mIndeterminateProgressView;
+
+ private int mProgressBarPadding;
+ private int mItemPadding;
+
+ private int mTitleStyleRes;
+ private int mSubtitleStyleRes;
+ private int mProgressStyle;
+ private int mIndeterminateProgressStyle;
+
+ private boolean mUserTitle;
+ private boolean mIncludeTabs;
+ private boolean mIsCollapsable;
+ private boolean mIsCollapsed;
+
+ // TODO(trevorjohns): Uncomment to enable options menu
+ // private MenuBuilder mOptionsMenu;
+
+ private ActionBarContextView mContextView;
+
+ private ActionMenuItem mLogoNavItem;
+
+ private SpinnerAdapter mSpinnerAdapter;
+ private OnNavigationListener mCallback;
+
+ private Runnable mTabSelector;
+
+ private ExpandedActionViewMenuPresenter mExpandedMenuPresenter;
+ View mExpandedActionView;
+
+ Window.Callback mWindowCallback;
+
+ private final AdapterView.OnItemSelectedListener mNavItemSelectedListener =
+ new AdapterView.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView parent, View view, int position, long id) {
+ if (mCallback != null) {
+ mCallback.onNavigationItemSelected(position, id);
+ }
+ }
+ public void onNothingSelected(AdapterView parent) {
+ // Do nothing
+ }
+ };
+
+ private final OnClickListener mExpandedActionViewUpListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final MenuItemImpl item = mExpandedMenuPresenter.mCurrentExpandedItem;
+ if (item != null) {
+ item.collapseActionView();
+ }
+ }
+ };
+
+ private final OnClickListener mUpClickListener = new OnClickListener() {
+ public void onClick(View v) {
+ mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
+ }
+ };
+
+ public ActionBarView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+
+ // Background is always provided by the container.
+ setBackgroundResource(0);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar,
+ R.attr.actionBarStyle, 0);
+
+ ApplicationInfo appInfo = context.getApplicationInfo();
+ PackageManager pm = context.getPackageManager();
+ mNavigationMode = a.getInt(R.styleable.ActionBar_navigationMode,
+ ActionBar.NAVIGATION_MODE_STANDARD);
+ mTitle = a.getText(R.styleable.ActionBar_title);
+ mSubtitle = a.getText(R.styleable.ActionBar_subtitle);
+
+ mLogo = a.getDrawable(R.styleable.ActionBar_logo);
+ if (mLogo == null) {
+ if (context instanceof Activity) {
+ try {
+ mLogo = pm.getActivityLogo(((Activity) context).getComponentName());
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Activity component name not found!", e);
+ }
+ }
+ if (mLogo == null) {
+ mLogo = appInfo.loadLogo(pm);
+ }
+ }
+
+ mIcon = a.getDrawable(R.styleable.ActionBar_icon); // TODO(trevorjohns): Should these use the android namespace
+ if (mIcon == null) {
+ if (context instanceof Activity) {
+ try {
+ mIcon = pm.getActivityIcon(((Activity) context).getComponentName());
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Activity component name not found!", e);
+ }
+ }
+ if (mIcon == null) {
+ mIcon = appInfo.loadIcon(pm);
+ }
+ }
+
+ final LayoutInflater inflater = LayoutInflater.from(context);
+
+ final int homeResId = a.getResourceId(
+ R.styleable.ActionBar_homeLayout,
+ R.layout.action_bar_home);
+
+ mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
+
+ mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
+ mExpandedHomeLayout.setUp(true);
+ mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
+ mExpandedHomeLayout.setContentDescription(getResources().getText(
+ R.string.action_bar_up_description));
+
+ mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
+ mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
+ mProgressStyle = a.getResourceId(R.styleable.ActionBar_progressBarStyle, 0);
+ mIndeterminateProgressStyle = a.getResourceId(
+ R.styleable.ActionBar_indeterminateProgressStyle, 0);
+
+ mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_progressBarPadding, 0);
+ mItemPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_itemPadding, 0);
+
+ setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, DISPLAY_DEFAULT));
+
+ final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
+ if (customNavId != 0) {
+ mCustomNavView = (View) inflater.inflate(customNavId, this, false);
+ mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
+ setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM);
+ }
+
+ mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
+
+ a.recycle();
+
+ mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
+ mHomeLayout.setOnClickListener(mUpClickListener);
+ mHomeLayout.setClickable(true);
+ mHomeLayout.setFocusable(true);
+
+ // These methods were not introduced until API 16
+ /*
+ if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
+ setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
+ }
+ */
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ mTitleView = null;
+ mSubtitleView = null;
+ mTitleUpView = null;
+ if (mTitleLayout != null && mTitleLayout.getParent() == this) {
+ removeView(mTitleLayout);
+ }
+ mTitleLayout = null;
+ if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
+ initTitle();
+ }
+
+ if (mTabScrollView != null && mIncludeTabs) {
+ ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
+ if (lp != null) {
+ lp.width = LayoutParams.WRAP_CONTENT;
+ lp.height = LayoutParams.MATCH_PARENT;
+ }
+ mTabScrollView.setAllowCollapse(true);
+ }
+ }
+
+ /**
+ * Set the window callback used to invoke menu items; used for dispatching home button presses.
+ * @param cb Window callback to dispatch to
+ */
+ public void setWindowCallback(Window.Callback cb) {
+ mWindowCallback = cb;
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ removeCallbacks(mTabSelector);
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.hideOverflowMenu();
+ mActionMenuPresenter.hideSubMenus();
+ }
+ }
+
+ @Override
+ public boolean shouldDelayChildPressedState() {
+ return false;
+ }
+
+ public void initProgress() {
+ mProgressView = new ProgressBar(mContext, null, mProgressStyle);
+ mProgressView.setId(R.id.progress_horizontal);
+ mProgressView.setMax(10000);
+ mProgressView.setVisibility(GONE);
+ addView(mProgressView);
+ }
+
+ public void initIndeterminateProgress() {
+ mIndeterminateProgressView = new ProgressBar(mContext, null, mIndeterminateProgressStyle);
+ mIndeterminateProgressView.setId(R.id.progress_circular);
+ mIndeterminateProgressView.setVisibility(GONE);
+ addView(mIndeterminateProgressView);
+ }
+
+ @Override
+ public void setSplitActionBar(boolean splitActionBar) {
+ if (mSplitActionBar != splitActionBar) {
+ if (mMenuView != null) {
+ final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
+ if (oldParent != null) {
+ oldParent.removeView(mMenuView);
+ }
+ if (splitActionBar) {
+ if (mSplitView != null) {
+ mSplitView.addView(mMenuView);
+ }
+ mMenuView.getLayoutParams().width = LayoutParams.MATCH_PARENT;
+ } else {
+ addView(mMenuView);
+ mMenuView.getLayoutParams().width = LayoutParams.WRAP_CONTENT;
+ }
+ mMenuView.requestLayout();
+ }
+ if (mSplitView != null) {
+ mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE);
+ }
+
+ if (mActionMenuPresenter != null) {
+ if (!splitActionBar) {
+ mActionMenuPresenter.setExpandedActionViewsExclusive(
+ getResources().getBoolean(
+ R.bool.action_bar_expanded_action_views_exclusive));
+ } else {
+ mActionMenuPresenter.setExpandedActionViewsExclusive(false);
+ // Allow full screen width in split mode.
+ mActionMenuPresenter.setWidthLimit(
+ getContext().getResources().getDisplayMetrics().widthPixels, true);
+ // No limit to the item count; use whatever will fit.
+ mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
+ }
+ }
+ super.setSplitActionBar(splitActionBar);
+ }
+ }
+
+ public boolean isSplitActionBar() {
+ return mSplitActionBar;
+ }
+
+ public boolean hasEmbeddedTabs() {
+ return mIncludeTabs;
+ }
+
+ public void setEmbeddedTabView(ScrollingTabContainerView tabs) {
+ if (mTabScrollView != null) {
+ removeView(mTabScrollView);
+ }
+ mTabScrollView = tabs;
+ mIncludeTabs = tabs != null;
+ if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
+ addView(mTabScrollView);
+ ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
+ lp.width = LayoutParams.WRAP_CONTENT;
+ lp.height = LayoutParams.MATCH_PARENT;
+ tabs.setAllowCollapse(true);
+ }
+ }
+
+ public void setCallback(OnNavigationListener callback) {
+ mCallback = callback;
+ }
+
+ public void setMenu(Menu menu, MenuPresenter.Callback cb) {
+ if (menu == mOptionsMenu) return;
+
+ if (mOptionsMenu != null) {
+ mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
+ mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
+ }
+
+ MenuBuilder builder = (MenuBuilder) menu;
+ mOptionsMenu = builder;
+ if (mMenuView != null) {
+ final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
+ if (oldParent != null) {
+ oldParent.removeView(mMenuView);
+ }
+ }
+ if (mActionMenuPresenter == null) {
+ mActionMenuPresenter = new ActionMenuPresenter(mContext);
+ mActionMenuPresenter.setCallback(cb);
+ mActionMenuPresenter.setId(R.id.action_menu_presenter);
+ mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
+ }
+
+ ActionMenuView menuView;
+ final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.MATCH_PARENT);
+ if (!mSplitActionBar) {
+ mActionMenuPresenter.setExpandedActionViewsExclusive(
+ getResources().getBoolean(
+ R.bool.action_bar_expanded_action_views_exclusive));
+ configPresenters(builder);
+ menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
+ final ViewGroup oldParent = (ViewGroup) menuView.getParent();
+ if (oldParent != null && oldParent != this) {
+ oldParent.removeView(menuView);
+ }
+ addView(menuView, layoutParams);
+ } else {
+ mActionMenuPresenter.setExpandedActionViewsExclusive(false);
+ // Allow full screen width in split mode.
+ mActionMenuPresenter.setWidthLimit(
+ getContext().getResources().getDisplayMetrics().widthPixels, true);
+ // No limit to the item count; use whatever will fit.
+ mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
+ // Span the whole width
+ layoutParams.width = LayoutParams.MATCH_PARENT;
+ configPresenters(builder);
+ menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
+ if (mSplitView != null) {
+ final ViewGroup oldParent = (ViewGroup) menuView.getParent();
+ if (oldParent != null && oldParent != mSplitView) {
+ oldParent.removeView(menuView);
+ }
+ menuView.setVisibility(getAnimatedVisibility());
+ mSplitView.addView(menuView, layoutParams);
+ } else {
+ // We'll add this later if we missed it this time.
+ menuView.setLayoutParams(layoutParams);
+ }
+ }
+ mMenuView = menuView;
+ }
+
+ private void configPresenters(MenuBuilder builder) {
+ if (builder != null) {
+ builder.addMenuPresenter(mActionMenuPresenter);
+ builder.addMenuPresenter(mExpandedMenuPresenter);
+ } else {
+ mActionMenuPresenter.initForMenu(mContext, null);
+ mExpandedMenuPresenter.initForMenu(mContext, null);
+ mActionMenuPresenter.updateMenuView(true);
+ mExpandedMenuPresenter.updateMenuView(true);
+ }
+ }
+
+ public boolean hasExpandedActionView() {
+ return mExpandedMenuPresenter != null &&
+ mExpandedMenuPresenter.mCurrentExpandedItem != null;
+ }
+
+ public void collapseActionView() {
+ final MenuItemImpl item = mExpandedMenuPresenter == null ? null :
+ mExpandedMenuPresenter.mCurrentExpandedItem;
+ if (item != null) {
+ item.collapseActionView();
+ }
+ }
+
+ public void setCustomNavigationView(View view) {
+ final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0;
+ if (mCustomNavView != null && showCustom) {
+ removeView(mCustomNavView);
+ }
+ mCustomNavView = view;
+ if (mCustomNavView != null && showCustom) {
+ addView(mCustomNavView);
+ }
+ }
+
+ public CharSequence getTitle() {
+ return mTitle;
+ }
+
+ /**
+ * Set the action bar title. This will always replace or override window titles.
+ * @param title Title to set
+ *
+ * @see #setWindowTitle(CharSequence)
+ */
+ public void setTitle(CharSequence title) {
+ mUserTitle = true;
+ setTitleImpl(title);
+ }
+
+ /**
+ * Set the window title. A window title will always be replaced or overridden by a user title.
+ * @param title Title to set
+ *
+ * @see #setTitle(CharSequence)
+ */
+ public void setWindowTitle(CharSequence title) {
+ if (!mUserTitle) {
+ setTitleImpl(title);
+ }
+ }
+
+ private void setTitleImpl(CharSequence title) {
+ mTitle = title;
+ if (mTitleView != null) {
+ mTitleView.setText(title);
+ final boolean visible = mExpandedActionView == null &&
+ (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 &&
+ (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle));
+ mTitleLayout.setVisibility(visible ? VISIBLE : GONE);
+ }
+ if (mLogoNavItem != null) {
+ mLogoNavItem.setTitle(title);
+ }
+ }
+
+ public CharSequence getSubtitle() {
+ return mSubtitle;
+ }
+
+ public void setSubtitle(CharSequence subtitle) {
+ mSubtitle = subtitle;
+ if (mSubtitleView != null) {
+ mSubtitleView.setText(subtitle);
+ mSubtitleView.setVisibility(subtitle != null ? VISIBLE : GONE);
+ final boolean visible = mExpandedActionView == null &&
+ (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 &&
+ (!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle));
+ mTitleLayout.setVisibility(visible ? VISIBLE : GONE);
+ }
+ }
+
+ public void setHomeButtonEnabled(boolean enable) {
+ mHomeLayout.setEnabled(enable);
+ mHomeLayout.setFocusable(enable);
+ // Make sure the home button has an accurate content description for accessibility.
+ if (!enable) {
+ mHomeLayout.setContentDescription(null);
+ } else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
+ mHomeLayout.setContentDescription(mContext.getResources().getText(
+ R.string.action_bar_up_description));
+ } else {
+ mHomeLayout.setContentDescription(mContext.getResources().getText(
+ R.string.action_bar_home_description));
+ }
+ }
+
+ public void setDisplayOptions(int options) {
+ final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
+ mDisplayOptions = options;
+
+ if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
+ final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
+ final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE;
+ mHomeLayout.setVisibility(vis);
+
+ if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
+ final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
+ mHomeLayout.setUp(setUp);
+
+ // Showing home as up implicitly enables interaction with it.
+ // In honeycomb it was always enabled, so make this transition
+ // a bit easier for developers in the common case.
+ // (It would be silly to show it as up without responding to it.)
+ if (setUp) {
+ setHomeButtonEnabled(true);
+ }
+ }
+
+ if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) {
+ final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0;
+ mHomeLayout.setIcon(logoVis ? mLogo : mIcon);
+ }
+
+ if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
+ if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
+ initTitle();
+ } else {
+ removeView(mTitleLayout);
+ }
+ }
+
+ if (mTitleLayout != null && (flagsChanged &
+ (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
+ final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
+ mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
+ mTitleLayout.setEnabled(!showHome && homeAsUp);
+ }
+
+ if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
+ if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
+ addView(mCustomNavView);
+ } else {
+ removeView(mCustomNavView);
+ }
+ }
+
+ requestLayout();
+ } else {
+ invalidate();
+ }
+
+ // Make sure the home button has an accurate content description for accessibility.
+ if (!mHomeLayout.isEnabled()) {
+ mHomeLayout.setContentDescription(null);
+ } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
+ mHomeLayout.setContentDescription(mContext.getResources().getText(
+ R.string.action_bar_up_description));
+ } else {
+ mHomeLayout.setContentDescription(mContext.getResources().getText(
+ R.string.action_bar_home_description));
+ }
+ }
+
+ public void setIcon(Drawable icon) {
+ mIcon = icon;
+ if (icon != null &&
+ ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) {
+ mHomeLayout.setIcon(icon);
+ }
+ if (mExpandedActionView != null) {
+ mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(getResources()));
+ }
+ }
+
+ public void setIcon(int resId) {
+ setIcon(mContext.getResources().getDrawable(resId));
+ }
+
+ public void setLogo(Drawable logo) {
+ mLogo = logo;
+ if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) {
+ mHomeLayout.setIcon(logo);
+ }
+ }
+
+ public void setLogo(int resId) {
+ setLogo(mContext.getResources().getDrawable(resId));
+ }
+
+ public void setNavigationMode(int mode) {
+ final int oldMode = mNavigationMode;
+ if (mode != oldMode) {
+ switch (oldMode) {
+ case ActionBar.NAVIGATION_MODE_LIST:
+ if (mListNavLayout != null) {
+ removeView(mListNavLayout);
+ }
+ break;
+ case ActionBar.NAVIGATION_MODE_TABS:
+ if (mTabScrollView != null && mIncludeTabs) {
+ removeView(mTabScrollView);
+ }
+ }
+
+ switch (mode) {
+ case ActionBar.NAVIGATION_MODE_LIST:
+ if (mSpinner == null) {
+ mSpinner = new Spinner(mContext, null,
+ R.attr.actionDropDownStyle);
+ mListNavLayout = new LinearLayout(mContext, null,
+ R.attr.actionBarTabBarStyle);
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+ LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
+ params.gravity = Gravity.CENTER;
+ mListNavLayout.addView(mSpinner, params);
+ }
+ if (mSpinner.getAdapter() != mSpinnerAdapter) {
+ mSpinner.setAdapter(mSpinnerAdapter);
+ }
+ mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
+ addView(mListNavLayout);
+ break;
+ case ActionBar.NAVIGATION_MODE_TABS:
+ if (mTabScrollView != null && mIncludeTabs) {
+ addView(mTabScrollView);
+ }
+ break;
+ }
+ mNavigationMode = mode;
+ requestLayout();
+ }
+ }
+
+ public void setDropdownAdapter(SpinnerAdapter adapter) {
+ mSpinnerAdapter = adapter;
+ if (mSpinner != null) {
+ mSpinner.setAdapter(adapter);
+ }
+ }
+
+ public SpinnerAdapter getDropdownAdapter() {
+ return mSpinnerAdapter;
+ }
+
+ public void setDropdownSelectedPosition(int position) {
+ mSpinner.setSelection(position);
+ }
+
+ public int getDropdownSelectedPosition() {
+ return mSpinner.getSelectedItemPosition();
+ }
+
+ public View getCustomNavigationView() {
+ return mCustomNavView;
+ }
+
+ public int getNavigationMode() {
+ return mNavigationMode;
+ }
+
+ public int getDisplayOptions() {
+ return mDisplayOptions;
+ }
+
+ @Override
+ protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
+ // Used by custom nav views if they don't supply layout params. Everything else
+ // added to an ActionBarView should have them already.
+ return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ addView(mHomeLayout);
+
+ if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
+ final ViewParent parent = mCustomNavView.getParent();
+ if (parent != this) {
+ if (parent instanceof ViewGroup) {
+ ((ViewGroup) parent).removeView(mCustomNavView);
+ }
+ addView(mCustomNavView);
+ }
+ }
+ }
+
+ private void initTitle() {
+ if (mTitleLayout == null) {
+ LayoutInflater inflater = LayoutInflater.from(getContext());
+ mTitleLayout = (LinearLayout) inflater.inflate(R.layout.action_bar_title_item,
+ this, false);
+ mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
+ mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
+ mTitleUpView = (View) mTitleLayout.findViewById(R.id.up);
+
+ mTitleLayout.setOnClickListener(mUpClickListener);
+
+ if (mTitleStyleRes != 0) {
+ mTitleView.setTextAppearance(mContext, mTitleStyleRes);
+ }
+ if (mTitle != null) {
+ mTitleView.setText(mTitle);
+ }
+
+ if (mSubtitleStyleRes != 0) {
+ mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
+ }
+ if (mSubtitle != null) {
+ mSubtitleView.setText(mSubtitle);
+ mSubtitleView.setVisibility(VISIBLE);
+ }
+
+ final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
+ final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0;
+ mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
+ mTitleLayout.setEnabled(homeAsUp && !showHome);
+ }
+
+ addView(mTitleLayout);
+ if (mExpandedActionView != null ||
+ (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
+ // Don't show while in expanded mode or with empty text
+ mTitleLayout.setVisibility(GONE);
+ }
+ }
+
+ public void setContextView(ActionBarContextView view) {
+ mContextView = view;
+ }
+
+ public void setCollapsable(boolean collapsable) {
+ mIsCollapsable = collapsable;
+ }
+
+ public boolean isCollapsed() {
+ return mIsCollapsed;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int childCount = getChildCount();
+ if (mIsCollapsable) {
+ int visibleChildren = 0;
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ if (child.getVisibility() != GONE &&
+ !(child == mMenuView && mMenuView.getChildCount() == 0)) {
+ visibleChildren++;
+ }
+ }
+
+ if (visibleChildren == 0) {
+ // No size for an empty action bar when collapsable.
+ setMeasuredDimension(0, 0);
+ mIsCollapsed = true;
+ return;
+ }
+ }
+ mIsCollapsed = false;
+
+ int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ if (widthMode != MeasureSpec.EXACTLY) {
+ throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
+ "with android:layout_width=\"match_parent\" (or fill_parent)");
+ }
+
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ if (heightMode != MeasureSpec.AT_MOST) {
+ throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
+ "with android:layout_height=\"wrap_content\"");
+ }
+
+ int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
+
+ int maxHeight = mContentHeight > 0 ?
+ mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
+
+ final int verticalPadding = getPaddingTop() + getPaddingBottom();
+ final int paddingLeft = getPaddingLeft();
+ final int paddingRight = getPaddingRight();
+ final int height = maxHeight - verticalPadding;
+ final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
+
+ int availableWidth = contentWidth - paddingLeft - paddingRight;
+ int leftOfCenter = availableWidth / 2;
+ int rightOfCenter = leftOfCenter;
+
+ HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
+
+ if (homeLayout.getVisibility() != GONE) {
+ final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams();
+ int homeWidthSpec;
+ if (lp.width < 0) {
+ homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
+ } else {
+ homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
+ }
+ homeLayout.measure(homeWidthSpec,
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
+ final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getLeftOffset();
+ availableWidth = Math.max(0, availableWidth - homeWidth);
+ leftOfCenter = Math.max(0, availableWidth - homeWidth);
+ }
+
+ if (mMenuView != null && mMenuView.getParent() == this) {
+ availableWidth = measureChildView(mMenuView, availableWidth,
+ childSpecHeight, 0);
+ rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth());
+ }
+
+ if (mIndeterminateProgressView != null &&
+ mIndeterminateProgressView.getVisibility() != GONE) {
+ availableWidth = measureChildView(mIndeterminateProgressView, availableWidth,
+ childSpecHeight, 0);
+ rightOfCenter = Math.max(0,
+ rightOfCenter - mIndeterminateProgressView.getMeasuredWidth());
+ }
+
+ final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
+ (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
+
+ if (mExpandedActionView == null) {
+ switch (mNavigationMode) {
+ case ActionBar.NAVIGATION_MODE_LIST:
+ if (mListNavLayout != null) {
+ final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
+ availableWidth = Math.max(0, availableWidth - itemPaddingSize);
+ leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize);
+ mListNavLayout.measure(
+ MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
+ final int listNavWidth = mListNavLayout.getMeasuredWidth();
+ availableWidth = Math.max(0, availableWidth - listNavWidth);
+ leftOfCenter = Math.max(0, leftOfCenter - listNavWidth);
+ }
+ break;
+ case ActionBar.NAVIGATION_MODE_TABS:
+ if (mTabScrollView != null) {
+ final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
+ availableWidth = Math.max(0, availableWidth - itemPaddingSize);
+ leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize);
+ mTabScrollView.measure(
+ MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
+ final int tabWidth = mTabScrollView.getMeasuredWidth();
+ availableWidth = Math.max(0, availableWidth - tabWidth);
+ leftOfCenter = Math.max(0, leftOfCenter - tabWidth);
+ }
+ break;
+ }
+ }
+
+ View customView = null;
+ if (mExpandedActionView != null) {
+ customView = mExpandedActionView;
+ } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 &&
+ mCustomNavView != null) {
+ customView = mCustomNavView;
+ }
+
+ if (customView != null) {
+ final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams());
+ final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
+ (ActionBar.LayoutParams) lp : null;
+
+ int horizontalMargin = 0;
+ int verticalMargin = 0;
+ if (ablp != null) {
+ horizontalMargin = ablp.leftMargin + ablp.rightMargin;
+ verticalMargin = ablp.topMargin + ablp.bottomMargin;
+ }
+
+ // If the action bar is wrapping to its content height, don't allow a custom
+ // view to MATCH_PARENT.
+ int customNavHeightMode;
+ if (mContentHeight <= 0) {
+ customNavHeightMode = MeasureSpec.AT_MOST;
+ } else {
+ customNavHeightMode = lp.height != LayoutParams.WRAP_CONTENT ?
+ MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
+ }
+ final int customNavHeight = Math.max(0,
+ (lp.height >= 0 ? Math.min(lp.height, height) : height) - verticalMargin);
+
+ final int customNavWidthMode = lp.width != LayoutParams.WRAP_CONTENT ?
+ MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
+ int customNavWidth = Math.max(0,
+ (lp.width >= 0 ? Math.min(lp.width, availableWidth) : availableWidth)
+ - horizontalMargin);
+ final int hgrav = (ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY) &
+ Gravity.HORIZONTAL_GRAVITY_MASK;
+
+ // Centering a custom view is treated specially; we try to center within the whole
+ // action bar rather than in the available space.
+ if (hgrav == Gravity.CENTER_HORIZONTAL && lp.width == LayoutParams.MATCH_PARENT) {
+ customNavWidth = Math.min(leftOfCenter, rightOfCenter) * 2;
+ }
+
+ customView.measure(
+ MeasureSpec.makeMeasureSpec(customNavWidth, customNavWidthMode),
+ MeasureSpec.makeMeasureSpec(customNavHeight, customNavHeightMode));
+ availableWidth -= horizontalMargin + customView.getMeasuredWidth();
+ }
+
+ if (mExpandedActionView == null && showTitle) {
+ availableWidth = measureChildView(mTitleLayout, availableWidth,
+ MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0);
+ leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth());
+ }
+
+ if (mContentHeight <= 0) {
+ int measuredHeight = 0;
+ for (int i = 0; i < childCount; i++) {
+ View v = getChildAt(i);
+ int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
+ if (paddedViewHeight > measuredHeight) {
+ measuredHeight = paddedViewHeight;
+ }
+ }
+ setMeasuredDimension(contentWidth, measuredHeight);
+ } else {
+ setMeasuredDimension(contentWidth, maxHeight);
+ }
+
+ if (mContextView != null) {
+ mContextView.setContentHeight(getMeasuredHeight());
+ }
+
+ if (mProgressView != null && mProgressView.getVisibility() != GONE) {
+ mProgressView.measure(MeasureSpec.makeMeasureSpec(
+ contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST));
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ int x = getPaddingLeft();
+ final int y = getPaddingTop();
+ final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();
+
+ if (contentHeight <= 0) {
+ // Nothing to do if we can't see anything.
+ return;
+ }
+
+ HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
+ if (homeLayout.getVisibility() != GONE) {
+ final int leftOffset = homeLayout.getLeftOffset();
+ x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset;
+ }
+
+ if (mExpandedActionView == null) {
+ final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
+ (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
+ if (showTitle) {
+ x += positionChild(mTitleLayout, x, y, contentHeight);
+ }
+
+ switch (mNavigationMode) {
+ case ActionBar.NAVIGATION_MODE_STANDARD:
+ break;
+ case ActionBar.NAVIGATION_MODE_LIST:
+ if (mListNavLayout != null) {
+ if (showTitle) x += mItemPadding;
+ x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding;
+ }
+ break;
+ case ActionBar.NAVIGATION_MODE_TABS:
+ if (mTabScrollView != null) {
+ if (showTitle) x += mItemPadding;
+ x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding;
+ }
+ break;
+ }
+ }
+
+ int menuLeft = r - l - getPaddingRight();
+ if (mMenuView != null && mMenuView.getParent() == this) {
+ positionChildInverse(mMenuView, menuLeft, y, contentHeight);
+ menuLeft -= mMenuView.getMeasuredWidth();
+ }
+
+ if (mIndeterminateProgressView != null &&
+ mIndeterminateProgressView.getVisibility() != GONE) {
+ positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight);
+ menuLeft -= mIndeterminateProgressView.getMeasuredWidth();
+ }
+
+ View customView = null;
+ if (mExpandedActionView != null) {
+ customView = mExpandedActionView;
+ } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 &&
+ mCustomNavView != null) {
+ customView = mCustomNavView;
+ }
+ if (customView != null) {
+ ViewGroup.LayoutParams lp = customView.getLayoutParams();
+ final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
+ (ActionBar.LayoutParams) lp : null;
+
+ final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY;
+ final int navWidth = customView.getMeasuredWidth();
+
+ int topMargin = 0;
+ int bottomMargin = 0;
+ if (ablp != null) {
+ x += ablp.leftMargin;
+ menuLeft -= ablp.rightMargin;
+ topMargin = ablp.topMargin;
+ bottomMargin = ablp.bottomMargin;
+ }
+
+ int hgravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
+ // See if we actually have room to truly center; if not push against left or right.
+ if (hgravity == Gravity.CENTER_HORIZONTAL) {
+ final int centeredLeft = (getWidth() - navWidth) / 2;
+ if (centeredLeft < x) {
+ hgravity = Gravity.LEFT;
+ } else if (centeredLeft + navWidth > menuLeft) {
+ hgravity = Gravity.RIGHT;
+ }
+ } else if (gravity == -1) {
+ hgravity = Gravity.LEFT;
+ }
+
+ int xpos = 0;
+ switch (hgravity) {
+ case Gravity.CENTER_HORIZONTAL:
+ xpos = (getWidth() - navWidth) / 2;
+ break;
+ case Gravity.LEFT:
+ xpos = x;
+ break;
+ case Gravity.RIGHT:
+ xpos = menuLeft - navWidth;
+ break;
+ }
+
+ int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
+
+ if (gravity == -1) {
+ vgravity = Gravity.CENTER_VERTICAL;
+ }
+
+ int ypos = 0;
+ switch (vgravity) {
+ case Gravity.CENTER_VERTICAL:
+ final int paddedTop = getPaddingTop();
+ final int paddedBottom = getHeight() - getPaddingBottom();
+ ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2;
+ break;
+ case Gravity.TOP:
+ ypos = getPaddingTop() + topMargin;
+ break;
+ case Gravity.BOTTOM:
+ ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight()
+ - bottomMargin;
+ break;
+ }
+ final int customWidth = customView.getMeasuredWidth();
+ customView.layout(xpos, ypos, xpos + customWidth,
+ ypos + customView.getMeasuredHeight());
+ x += customWidth;
+ }
+
+ if (mProgressView != null) {
+ mProgressView.bringToFront();
+ final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2;
+ mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
+ mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight);
+ }
+ }
+
+ @Override
+ public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
+ return new ActionBar.LayoutParams(getContext(), attrs);
+ }
+
+ @Override
+ public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
+ if (lp == null) {
+ lp = generateDefaultLayoutParams();
+ }
+ return lp;
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ SavedState state = new SavedState(superState);
+
+ if (mExpandedMenuPresenter != null && mExpandedMenuPresenter.mCurrentExpandedItem != null) {
+ state.expandedMenuItemId = mExpandedMenuPresenter.mCurrentExpandedItem.getItemId();
+ }
+
+ state.isOverflowOpen = isOverflowMenuShowing();
+
+ return state;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable p) {
+ SavedState state = (SavedState) p;
+
+ super.onRestoreInstanceState(state.getSuperState());
+
+ if (state.expandedMenuItemId != 0 &&
+ mExpandedMenuPresenter != null && mOptionsMenu != null) {
+ final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId);
+ if (item != null) {
+ item.expandActionView();
+ }
+ }
+
+ if (state.isOverflowOpen) {
+ postShowOverflowMenu();
+ }
+ }
+
+ static class SavedState extends BaseSavedState {
+ int expandedMenuItemId;
+ boolean isOverflowOpen;
+
+ SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ private SavedState(Parcel in) {
+ super(in);
+ expandedMenuItemId = in.readInt();
+ isOverflowOpen = in.readInt() != 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeInt(expandedMenuItemId);
+ out.writeInt(isOverflowOpen ? 1 : 0);
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR =
+ new Parcelable.Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+
+ private static class HomeView extends FrameLayout {
+ private View mUpView;
+ private ImageView mIconView;
+ private int mUpWidth;
+
+ public HomeView(Context context) {
+ this(context, null);
+ }
+
+ public HomeView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setUp(boolean isUp) {
+ mUpView.setVisibility(isUp ? VISIBLE : GONE);
+ }
+
+ public void setIcon(Drawable icon) {
+ mIconView.setImageDrawable(icon);
+ }
+
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ onPopulateAccessibilityEvent(event);
+ return true;
+ }
+
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ super.onPopulateAccessibilityEvent(event);
+ final CharSequence cdesc = getContentDescription();
+ if (!TextUtils.isEmpty(cdesc)) {
+ event.getText().add(cdesc);
+ }
+ }
+
+ @Override
+ public boolean dispatchHoverEvent(MotionEvent event) {
+ // Don't allow children to hover; we want this to be treated as a single component.
+ return onHoverEvent(event);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ mUpView = findViewById(R.id.up);
+ mIconView = (ImageView) findViewById(R.id.home);
+ }
+
+ public int getLeftOffset() {
+ return mUpView.getVisibility() == GONE ? mUpWidth : 0;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0);
+ final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams();
+ mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin;
+ int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth;
+ int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin;
+ measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0);
+ final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
+ width += iconLp.leftMargin + mIconView.getMeasuredWidth() + iconLp.rightMargin;
+ height = Math.max(height,
+ iconLp.topMargin + mIconView.getMeasuredHeight() + iconLp.bottomMargin);
+
+ final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+
+ switch (widthMode) {
+ case MeasureSpec.AT_MOST:
+ width = Math.min(width, widthSize);
+ break;
+ case MeasureSpec.EXACTLY:
+ width = widthSize;
+ break;
+ case MeasureSpec.UNSPECIFIED:
+ default:
+ break;
+ }
+ switch (heightMode) {
+ case MeasureSpec.AT_MOST:
+ height = Math.min(height, heightSize);
+ break;
+ case MeasureSpec.EXACTLY:
+ height = heightSize;
+ break;
+ case MeasureSpec.UNSPECIFIED:
+ default:
+ break;
+ }
+ setMeasuredDimension(width, height);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ final int vCenter = (b - t) / 2;
+ int width = r - l;
+ int upOffset = 0;
+ if (mUpView.getVisibility() != GONE) {
+ final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams();
+ final int upHeight = mUpView.getMeasuredHeight();
+ final int upWidth = mUpView.getMeasuredWidth();
+ final int upTop = vCenter - upHeight / 2;
+ mUpView.layout(0, upTop, upWidth, upTop + upHeight);
+ upOffset = upLp.leftMargin + upWidth + upLp.rightMargin;
+ width -= upOffset;
+ l += upOffset;
+ }
+ final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
+ final int iconHeight = mIconView.getMeasuredHeight();
+ final int iconWidth = mIconView.getMeasuredWidth();
+ final int hCenter = (r - l) / 2;
+ final int iconLeft = upOffset + Math.max(iconLp.leftMargin, hCenter - iconWidth / 2);
+ final int iconTop = Math.max(iconLp.topMargin, vCenter - iconHeight / 2);
+ mIconView.layout(iconLeft, iconTop, iconLeft + iconWidth, iconTop + iconHeight);
+ }
+ }
+
+ private class ExpandedActionViewMenuPresenter implements MenuPresenter {
+ MenuBuilder mMenu;
+ MenuItemImpl mCurrentExpandedItem;
+
+ @Override
+ public void initForMenu(Context context, MenuBuilder menu) {
+ // Clear the expanded action view when menus change.
+ if (mMenu != null && mCurrentExpandedItem != null) {
+ mMenu.collapseItemActionView(mCurrentExpandedItem);
+ }
+ mMenu = menu;
+ }
+
+ @Override
+ public MenuView getMenuView(ViewGroup root) {
+ return null;
+ }
+
+ @Override
+ public void updateMenuView(boolean cleared) {
+ // Make sure the expanded item we have is still there.
+ if (mCurrentExpandedItem != null) {
+ boolean found = false;
+
+ if (mMenu != null) {
+ final int count = mMenu.size();
+ for (int i = 0; i < count; i++) {
+ final MenuItem item = mMenu.getItem(i);
+ if (item == mCurrentExpandedItem) {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ if (!found) {
+ // The item we had expanded disappeared. Collapse.
+ collapseItemActionView(mMenu, mCurrentExpandedItem);
+ }
+ }
+ }
+
+ @Override
+ public void setCallback(Callback cb) {
+ }
+
+ @Override
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
+ return false;
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ }
+
+ @Override
+ public boolean flagActionItems() {
+ return false;
+ }
+
+ @Override
+ public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ mExpandedActionView = item.getActionView();
+ mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(getResources()));
+ mCurrentExpandedItem = item;
+ if (mExpandedActionView.getParent() != ActionBarView.this) {
+ addView(mExpandedActionView);
+ }
+ if (mExpandedHomeLayout.getParent() != ActionBarView.this) {
+ addView(mExpandedHomeLayout);
+ }
+ mHomeLayout.setVisibility(GONE);
+ if (mTitleLayout != null) mTitleLayout.setVisibility(GONE);
+ if (mTabScrollView != null) mTabScrollView.setVisibility(GONE);
+ if (mSpinner != null) mSpinner.setVisibility(GONE);
+ if (mCustomNavView != null) mCustomNavView.setVisibility(GONE);
+ requestLayout();
+ item.setActionViewExpanded(true);
+
+ if (mExpandedActionView instanceof CollapsibleActionView) {
+ ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded();
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ // Do this before detaching the actionview from the hierarchy, in case
+ // it needs to dismiss the soft keyboard, etc.
+ if (mExpandedActionView instanceof CollapsibleActionView) {
+ ((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed();
+ }
+
+ removeView(mExpandedActionView);
+ removeView(mExpandedHomeLayout);
+ mExpandedActionView = null;
+ if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
+ mHomeLayout.setVisibility(VISIBLE);
+ }
+ if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
+ if (mTitleLayout == null) {
+ initTitle();
+ } else {
+ mTitleLayout.setVisibility(VISIBLE);
+ }
+ }
+ if (mTabScrollView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
+ mTabScrollView.setVisibility(VISIBLE);
+ }
+ if (mSpinner != null && mNavigationMode == ActionBar.NAVIGATION_MODE_LIST) {
+ mSpinner.setVisibility(VISIBLE);
+ }
+ if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
+ mCustomNavView.setVisibility(VISIBLE);
+ }
+ mExpandedHomeLayout.setIcon(null);
+ mCurrentExpandedItem = null;
+ requestLayout();
+ item.setActionViewExpanded(false);
+
+ return true;
+ }
+
+ @Override
+ public int getId() {
+ return 0;
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ return null;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ScrollingTabContainerView.java b/appcompat/eclair/android/support/appcompat/widget/ScrollingTabContainerView.java
new file mode 100644
index 0000000..aeb9904
--- /dev/null
+++ b/appcompat/eclair/android/support/appcompat/widget/ScrollingTabContainerView.java
@@ -0,0 +1,464 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.support.appcompat.widget;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.R;
+import android.support.appcompat.app.ActionBar;
+import android.support.appcompat.view.ActionBarPolicy;
+import android.text.TextUtils.TruncateAt;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.view.animation.DecelerateInterpolator;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.HorizontalScrollView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+/**
+ * This widget implements the dynamic action bar tab behavior that can change
+ * across different configurations or circumstances.
+ */
+public class ScrollingTabContainerView extends HorizontalScrollView
+ implements AdapterView.OnItemClickListener {
+ private static final String TAG = "ScrollingTabContainerView";
+ Runnable mTabSelector;
+ private TabClickListener mTabClickListener;
+
+ private LinearLayout mTabLayout;
+ private Spinner mTabSpinner;
+ private boolean mAllowCollapse;
+
+ int mMaxTabWidth;
+ int mStackedTabMaxWidth;
+ private int mContentHeight;
+ private int mSelectedTabIndex;
+
+ public ScrollingTabContainerView(Context context) {
+ super(context);
+ setHorizontalScrollBarEnabled(false);
+
+ ActionBarPolicy abp = ActionBarPolicy.get(context);
+ setContentHeight(abp.getTabContainerHeight());
+ mStackedTabMaxWidth = abp.getStackedTabMaxWidth();
+
+ mTabLayout = createTabLayout();
+ addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.FILL_PARENT));
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
+ setFillViewport(lockedExpanded);
+
+ final int childCount = mTabLayout.getChildCount();
+ if (childCount > 1 &&
+ (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
+ if (childCount > 2) {
+ mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
+ } else {
+ mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
+ }
+ mMaxTabWidth = Math.min(mMaxTabWidth, mStackedTabMaxWidth);
+ } else {
+ mMaxTabWidth = -1;
+ }
+
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY);
+
+ final boolean canCollapse = !lockedExpanded && mAllowCollapse;
+
+ if (canCollapse) {
+ // See if we should expand
+ mTabLayout.measure(MeasureSpec.UNSPECIFIED, heightMeasureSpec);
+ if (mTabLayout.getMeasuredWidth() > MeasureSpec.getSize(widthMeasureSpec)) {
+ performCollapse();
+ } else {
+ performExpand();
+ }
+ } else {
+ performExpand();
+ }
+
+ final int oldWidth = getMeasuredWidth();
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ final int newWidth = getMeasuredWidth();
+
+ if (lockedExpanded && oldWidth != newWidth) {
+ // Recenter the tab display if we're at a new (scrollable) size.
+ setTabSelected(mSelectedTabIndex);
+ }
+ }
+
+ /**
+ * Indicates whether this view is collapsed into a dropdown menu instead
+ * of traditional tabs.
+ * @return true if showing as a spinner
+ */
+ private boolean isCollapsed() {
+ return mTabSpinner != null && mTabSpinner.getParent() == this;
+ }
+
+ public void setAllowCollapse(boolean allowCollapse) {
+ mAllowCollapse = allowCollapse;
+ }
+
+ private void performCollapse() {
+ if (isCollapsed()) return;
+
+ if (mTabSpinner == null) {
+ mTabSpinner = createSpinner();
+ }
+ removeView(mTabLayout);
+ addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.FILL_PARENT));
+ if (mTabSpinner.getAdapter() == null) {
+ mTabSpinner.setAdapter(new TabAdapter());
+ }
+ if (mTabSelector != null) {
+ removeCallbacks(mTabSelector);
+ mTabSelector = null;
+ }
+ mTabSpinner.setSelection(mSelectedTabIndex);
+ }
+
+ private boolean performExpand() {
+ if (!isCollapsed()) return false;
+
+ removeView(mTabSpinner);
+ addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.FILL_PARENT));
+ setTabSelected(mTabSpinner.getSelectedItemPosition());
+ return false;
+ }
+
+ public void setTabSelected(int position) {
+ mSelectedTabIndex = position;
+ final int tabCount = mTabLayout.getChildCount();
+ for (int i = 0; i < tabCount; i++) {
+ final View child = mTabLayout.getChildAt(i);
+ final boolean isSelected = i == position;
+ child.setSelected(isSelected);
+ if (isSelected) {
+ animateToTab(position);
+ }
+ }
+ }
+
+ public void setContentHeight(int contentHeight) {
+ mContentHeight = contentHeight;
+ requestLayout();
+ }
+
+ private LinearLayout createTabLayout() {
+ //final LinearLayout tabLayout = new LinearLayout( getContext(), null, R.attr.actionBarTabBarStyle);
+ final LinearLayout tabLayout = new LinearLayout(getContext(), null);
+
+ //tabLayout.setMeasureWithLargestChildEnabled(true);
+ tabLayout.setGravity(Gravity.CENTER);
+ tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT));
+ return tabLayout;
+ }
+
+ private Spinner createSpinner() {
+ final Spinner spinner = new Spinner(getContext(), null,
+ R.attr.actionDropDownStyle);
+ spinner.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT));
+ spinner.setOnItemClickListener(this);
+ return spinner;
+ }
+
+ protected void onConfigurationChanged(Configuration newConfig) {
+ ActionBarPolicy abp = ActionBarPolicy.get(getContext());
+ // Action bar can change size on configuration changes.
+ // Reread the desired height from the theme-specified style.
+ setContentHeight(abp.getTabContainerHeight());
+ mStackedTabMaxWidth = abp.getStackedTabMaxWidth();
+ }
+
+ public void animateToTab(final int position) {
+ final View tabView = mTabLayout.getChildAt(position);
+ if (mTabSelector != null) {
+ removeCallbacks(mTabSelector);
+ }
+ mTabSelector = new Runnable() {
+ public void run() {
+ final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
+ smoothScrollTo(scrollPos, 0);
+ mTabSelector = null;
+ }
+ };
+ post(mTabSelector);
+ }
+
+ @Override
+ public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (mTabSelector != null) {
+ // Re-post the selector we saved
+ post(mTabSelector);
+ }
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (mTabSelector != null) {
+ removeCallbacks(mTabSelector);
+ }
+ }
+
+ private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) {
+ final TabView tabView = new TabView(getContext(), tab, forAdapter);
+ if (forAdapter) {
+ tabView.setBackgroundDrawable(null);
+ tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT,
+ mContentHeight));
+ } else {
+ tabView.setFocusable(true);
+
+ if (mTabClickListener == null) {
+ mTabClickListener = new TabClickListener();
+ }
+ tabView.setOnClickListener(mTabClickListener);
+ }
+ return tabView;
+ }
+
+ public void addTab(ActionBar.Tab tab, boolean setSelected) {
+ TabView tabView = createTabView(tab, false);
+ mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0,
+ LayoutParams.FILL_PARENT, 1));
+ if (mTabSpinner != null) {
+ ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+ }
+ if (setSelected) {
+ tabView.setSelected(true);
+ }
+ if (mAllowCollapse) {
+ requestLayout();
+ }
+ }
+
+ public void addTab(ActionBar.Tab tab, int position, boolean setSelected) {
+ final TabView tabView = createTabView(tab, false);
+ mTabLayout.addView(tabView, position, new LinearLayout.LayoutParams(
+ 0, LayoutParams.FILL_PARENT, 1));
+ if (mTabSpinner != null) {
+ ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+ }
+ if (setSelected) {
+ tabView.setSelected(true);
+ }
+ if (mAllowCollapse) {
+ requestLayout();
+ }
+ }
+
+ public void updateTab(int position) {
+ ((TabView) mTabLayout.getChildAt(position)).update();
+ if (mTabSpinner != null) {
+ ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+ }
+ if (mAllowCollapse) {
+ requestLayout();
+ }
+ }
+
+ public void removeTabAt(int position) {
+ mTabLayout.removeViewAt(position);
+ if (mTabSpinner != null) {
+ ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+ }
+ if (mAllowCollapse) {
+ requestLayout();
+ }
+ }
+
+ public void removeAllTabs() {
+ mTabLayout.removeAllViews();
+ if (mTabSpinner != null) {
+ ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+ }
+ if (mAllowCollapse) {
+ requestLayout();
+ }
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ TabView tabView = (TabView) view;
+ tabView.getTab().select();
+ }
+
+ private class TabView extends LinearLayout {
+ private ActionBar.Tab mTab;
+ private TextView mTextView;
+ private ImageView mIconView;
+ private View mCustomView;
+
+ public TabView(Context context, ActionBar.Tab tab, boolean forList) {
+ //super(context, null, R.attr.actionBarTabStyle);
+ super(context, null);
+
+ mTab = tab;
+
+ if (forList) {
+ setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
+ }
+
+ update();
+ }
+
+ public void bindTab(ActionBar.Tab tab) {
+ mTab = tab;
+ update();
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ // Re-measure if we went beyond our maximum size.
+ if (mMaxTabWidth > 0 && getMeasuredWidth() > mMaxTabWidth) {
+ super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxTabWidth, MeasureSpec.EXACTLY),
+ heightMeasureSpec);
+ }
+ }
+
+ public void update() {
+ final ActionBar.Tab tab = mTab;
+ final View custom = tab.getCustomView();
+ if (custom != null) {
+ final ViewParent customParent = custom.getParent();
+ if (customParent != this) {
+ if (customParent != null) ((ViewGroup) customParent).removeView(custom);
+ addView(custom);
+ }
+ mCustomView = custom;
+ if (mTextView != null) mTextView.setVisibility(GONE);
+ if (mIconView != null) {
+ mIconView.setVisibility(GONE);
+ mIconView.setImageDrawable(null);
+ }
+ } else {
+ if (mCustomView != null) {
+ removeView(mCustomView);
+ mCustomView = null;
+ }
+
+ final Drawable icon = tab.getIcon();
+ final CharSequence text = tab.getText();
+
+ if (icon != null) {
+ if (mIconView == null) {
+ ImageView iconView = new ImageView(getContext());
+ LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT);
+ lp.gravity = Gravity.CENTER_VERTICAL;
+ iconView.setLayoutParams(lp);
+ addView(iconView, 0);
+ mIconView = iconView;
+ }
+ mIconView.setImageDrawable(icon);
+ mIconView.setVisibility(VISIBLE);
+ } else if (mIconView != null) {
+ mIconView.setVisibility(GONE);
+ mIconView.setImageDrawable(null);
+ }
+
+ if (text != null) {
+ if (mTextView == null) {
+ TextView textView = new TextView(getContext(), null,
+ R.attr.actionBarTabTextStyle);
+ textView.setEllipsize(TruncateAt.END);
+ LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT);
+ lp.gravity = Gravity.CENTER_VERTICAL;
+ textView.setLayoutParams(lp);
+ addView(textView);
+ mTextView = textView;
+ }
+ mTextView.setText(text);
+ mTextView.setVisibility(VISIBLE);
+ } else if (mTextView != null) {
+ mTextView.setVisibility(GONE);
+ mTextView.setText(null);
+ }
+
+ if (mIconView != null) {
+ mIconView.setContentDescription(tab.getContentDescription());
+ }
+ }
+ }
+
+ public ActionBar.Tab getTab() {
+ return mTab;
+ }
+ }
+
+ private class TabAdapter extends BaseAdapter {
+ @Override
+ public int getCount() {
+ return mTabLayout.getChildCount();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return ((TabView) mTabLayout.getChildAt(position)).getTab();
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = createTabView((ActionBar.Tab) getItem(position), true);
+ } else {
+ ((TabView) convertView).bindTab((ActionBar.Tab) getItem(position));
+ }
+ return convertView;
+ }
+ }
+
+ private class TabClickListener implements OnClickListener {
+ public void onClick(View view) {
+ TabView tabView = (TabView) view;
+ tabView.getTab().select();
+ final int tabCount = mTabLayout.getChildCount();
+ for (int i = 0; i < tabCount; i++) {
+ final View child = mTabLayout.getChildAt(i);
+ child.setSelected(child == view);
+ }
+ }
+ }
+
+}
diff --git a/appcompat/gen/android/support/appcompat/BuildConfig.java b/appcompat/gen/android/support/appcompat/BuildConfig.java
new file mode 100644
index 0000000..7ef36b0
--- /dev/null
+++ b/appcompat/gen/android/support/appcompat/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package android.support.appcompat;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
\ No newline at end of file
diff --git a/appcompat/gen/android/support/appcompat/R.java b/appcompat/gen/android/support/appcompat/R.java
new file mode 100644
index 0000000..e5b6f97
--- /dev/null
+++ b/appcompat/gen/android/support/appcompat/R.java
@@ -0,0 +1,1489 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package android.support.appcompat;
+
+public final class R {
+ public static final class attr {
+ /** Custom divider drawable to use for elements in the action bar.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarDivider=0x7f01000a;
+ /** Custom item state list drawable background for action bar items.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarItemBackground=0x7f01000b;
+ /** Size of the Action Bar, including the contextual
+ bar used to present Action Modes.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int actionBarSize=0x7f010009;
+ /** Reference to a theme that should be used to inflate widgets
+ and layouts destined for the action bar. Most of the time
+ this will be a reference to the current theme, but when
+ the action bar has a significantly different contrast
+ profile than the rest of the activity the difference
+ can become important. If this is set to @null the current
+ theme will be used.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarSplitStyle=0x7f010007;
+ /** Reference to a style for the Action Bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarStyle=0x7f010006;
+ /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarTabBarStyle=0x7f010003;
+ /** Default style for tabs within an action bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarTabStyle=0x7f010002;
+ /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarTabTextStyle=0x7f010004;
+ /** Reference to a theme that should be used to inflate widgets
+ and layouts destined for the action bar. Most of the time
+ this will be a reference to the current theme, but when
+ the action bar has a significantly different contrast
+ profile than the rest of the activity the difference
+ can become important. If this is set to @null the current
+ theme will be used.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionBarWidgetTheme=0x7f010008;
+ /** Default action button style.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionButtonStyle=0x7f010011;
+ /** TODO(trevorjohns): Add other attributes!
+ Default ActionBar dropdown style.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionDropDownStylFe=0x7f01003e;
+ /** Default ActionBar dropdown style.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionDropDownStyle=0x7f010041;
+ /** TextAppearance style that will be applied to text that
+ appears within action menu items.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionMenuTextAppearance=0x7f01000c;
+ /** Color for text that appears within action menu items.
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ */
+ public static final int actionMenuTextColor=0x7f01000d;
+ /** Background drawable to use for action mode UI
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeBackground=0x7f010033;
+ /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeCloseButtonStyle=0x7f010032;
+ /** Drawable to use for the close action mode button
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeCloseDrawable=0x7f010035;
+ /** Drawable to use for the Copy action button in Contextual Action Bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeCopyDrawable=0x7f010037;
+ /** Drawable to use for the Cut action button in Contextual Action Bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeCutDrawable=0x7f010036;
+ /** Drawable to use for the Find action button in WebView selection action modes
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeFindDrawable=0x7f01003b;
+ /** Drawable to use for the Paste action button in Contextual Action Bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModePasteDrawable=0x7f010038;
+ /** PopupWindow style to use for action modes when showing as a window overlay.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModePopupWindowStyle=0x7f01003d;
+ /** Drawable to use for the Select all action button in Contextual Action Bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeSelectAllDrawable=0x7f010039;
+ /** Drawable to use for the Share action button in WebView selection action modes
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeShareDrawable=0x7f01003a;
+ /** Background drawable to use for action mode UI in the lower split bar
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeSplitBackground=0x7f010034;
+ /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeStyle=0x7f010031;
+ /** Drawable to use for the Web Search action button in WebView selection action modes
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionModeWebSearchDrawable=0x7f01003c;
+ /** <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int actionOverflowButtonStyle=0x7f010005;
+ /** Specifies a background drawable for the action bar.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int background=0x7f010028;
+ /** Specifies a background drawable for the bottom component of a split action bar.
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ */
+ public static final int backgroundSplit=0x7f01002a;
+ /** Specifies a background drawable for a second stacked row of the action bar.
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ */
+ public static final int backgroundStacked=0x7f010029;
+ /** A style that may be applied to Buttons placed within a
+ LinearLayout with the style buttonBarStyle to form a button bar.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int buttonBarButtonStyle=0x7f010013;
+ /** A style that may be applied to horizontal LinearLayouts
+ to form a button bar.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int buttonBarStyle=0x7f010012;
+ /** Specifies a layout for custom navigation. Overrides navigationMode.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int customNavigationLayout=0x7f01002b;
+ /** Options affecting how the action bar is displayed.
+ <p>Must be one or more (separated by '|') of the following constant values.</p>
+<table>
+<colgroup align="left" />
+<colgroup align="left" />
+<colgroup align="left" />
+<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
+<tr><td><code>useLogo</code></td><td>0x1</td><td></td></tr>
+<tr><td><code>showHome</code></td><td>0x2</td><td></td></tr>
+<tr><td><code>homeAsUp</code></td><td>0x4</td><td></td></tr>
+<tr><td><code>showTitle</code></td><td>0x8</td><td></td></tr>
+<tr><td><code>showCustom</code></td><td>0x10</td><td></td></tr>
+<tr><td><code>disableHome</code></td><td>0x20</td><td></td></tr>
+</table>
+ */
+ public static final int displayOptions=0x7f010021;
+ /** Specifies the drawable used for item dividers.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int divider=0x7f010027;
+ /** A drawable that may be used as a horizontal divider between visual elements.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int dividerHorizontal=0x7f010016;
+ /** <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int dividerPadding=0x7f01004a;
+ /** A drawable that may be used as a vertical divider between visual elements.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int dividerVertical=0x7f010015;
+ /** The preferred item height for dropdown lists.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int dropdownListPreferredItemHeight=0x7f01003f;
+ /** Default background for the menu header.
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ */
+ public static final int headerBackground=0x7f010045;
+ /** <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int height=0x7f01001f;
+ /** Specifies a drawable to use for the 'home as up' indicator.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int homeAsUpIndicator=0x7f01000e;
+ /** Specifies a layout to use for the "home" section of the action bar.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int homeLayout=0x7f01002c;
+ /** Default horizontal divider between rows of menu items.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int horizontalDivider=0x7f010043;
+ /** Specifies the drawable used for the application icon.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int icon=0x7f010025;
+ /** Specifies a style resource to use for an indeterminate progress spinner.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int indeterminateProgressStyle=0x7f01002e;
+ /** Default background for each menu item.
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ */
+ public static final int itemBackground=0x7f010046;
+ /** Default disabled icon alpha for each menu item that shows an icon.
+ <p>Must be a floating point value, such as "<code>1.2</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int itemIconDisabledAlpha=0x7f010048;
+ /** Specifies padding that should be applied to the left and right sides of
+ system-provided items in the bar.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int itemPadding=0x7f010030;
+ /** Default appearance of menu item text.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int itemTextAppearance=0x7f010042;
+ /** The preferred list item height.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int listPreferredItemHeight=0x7f010017;
+ /** A larger, more robust list item height.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int listPreferredItemHeightLarge=0x7f010019;
+ /** A smaller, sleeker list item height.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int listPreferredItemHeightSmall=0x7f010018;
+ /** The preferred padding along the left edge of list items.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int listPreferredItemPaddingLeft=0x7f01001a;
+ /** The preferred padding along the right edge of list items.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int listPreferredItemPaddingRight=0x7f01001b;
+ /** Specifies the drawable used for the application logo.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int logo=0x7f010026;
+ /** The type of navigation to use.
+ <p>Must be one of the following constant values.</p>
+<table>
+<colgroup align="left" />
+<colgroup align="left" />
+<colgroup align="left" />
+<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
+<tr><td><code>normal</code></td><td>0</td><td> Normal static title text </td></tr>
+<tr><td><code>listMode</code></td><td>1</td><td> The action bar will use a selection list for navigation. </td></tr>
+<tr><td><code>tabMode</code></td><td>2</td><td> The action bar will use a series of horizontal tabs for navigation. </td></tr>
+</table>
+ */
+ public static final int navigationMode=0x7f010020;
+ /** Default PopupMenu style.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int popupMenuStyle=0x7f010040;
+ /** Whether space should be reserved in layout when an icon is missing.
+ <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int preserveIconSpacing=0x7f010049;
+ /** Specifies the horizontal padding on either end for an embedded progress bar.
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int progressBarPadding=0x7f01002f;
+ /** Specifies a style resource to use for an embedded progress bar.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int progressBarStyle=0x7f01002d;
+ /** A style that may be applied to buttons or other selectable items
+ that should react to pressed and focus states, but that do not
+ have a clear visual border along the edges.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int selectableItemBackground=0x7f010014;
+ /** Specifies subtitle text used for navigationMode="normal"
+ <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int subtitle=0x7f010022;
+ /** Specifies a style to use for subtitle text.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int subtitleTextStyle=0x7f010024;
+ /** Text color, typeface, size, and style for the text inside of a popup menu.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int textAppearanceLargePopupMenu=0x7f01000f;
+ /** The preferred TextAppearance for the primary text of list items.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int textAppearanceListItem=0x7f01001c;
+ /** The preferred TextAppearance for the primary text of small list items.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int textAppearanceListItemSmall=0x7f01001d;
+ /** Text color, typeface, size, and style for small text inside of a popup menu.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int textAppearanceSmallPopupMenu=0x7f010010;
+ /** <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int title=0x7f01001e;
+ /** Specifies a style to use for title text.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int titleTextStyle=0x7f010023;
+ /** Default vertical divider between menu items.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int verticalDivider=0x7f010044;
+ /** <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int windowActionBar=0x7f010000;
+ /** <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ */
+ public static final int windowActionBarOverlay=0x7f010001;
+ /** Default animations for the menu.
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ */
+ public static final int windowAnimationStyle=0x7f010047;
+ }
+ public static final class bool {
+ public static final int action_bar_embed_tabs=0x7f050000;
+ public static final int action_bar_embed_tabs_pre_jb=0x7f050001;
+ public static final int action_bar_expanded_action_views_exclusive=0x7f050002;
+ /** Whether action menu items should obey the "withText" showAsAction
+ flag. This may be set to false for situations where space is
+ extremely limited.
+ */
+ public static final int config_allowActionMenuItemTextWithIcon=0x7f050004;
+ public static final int split_action_bar_is_narrow=0x7f050003;
+ }
+ public static final class dimen {
+ /** Default height of an action bar.
+ Default height of an action bar.
+ Default height of an action bar.
+ */
+ public static final int action_bar_default_height=0x7f060004;
+ /** Vertical padding around action bar icons.
+ Vertical padding around action bar icons.
+ Vertical padding around action bar icons.
+ */
+ public static final int action_bar_icon_vertical_padding=0x7f060005;
+ public static final int action_bar_size=0x7f060001;
+ /** Maximum height for a stacked tab bar as part of an action bar
+ */
+ public static final int action_bar_stacked_max_height=0x7f060002;
+ /** Maximum width for a stacked action bar tab. This prevents
+ action bar tabs from becoming too wide on a wide screen when only
+ a few are present.
+ */
+ public static final int action_bar_stacked_tab_max_width=0x7f060003;
+ /** Bottom margin for action bar subtitles
+ Bottom margin for action bar subtitles
+ Bottom margin for action bar subtitles
+ */
+ public static final int action_bar_subtitle_bottom_margin=0x7f060009;
+ /** Text size for action bar subtitles
+ Text size for action bar subtitles
+ Text size for action bar subtitles
+ */
+ public static final int action_bar_subtitle_text_size=0x7f060007;
+ /** Top margin for action bar subtitles
+ Top margin for action bar subtitles
+ Top margin for action bar subtitles
+ */
+ public static final int action_bar_subtitle_top_margin=0x7f060008;
+ /** Text size for action bar titles
+ Text size for action bar titles
+ Text size for action bar titles
+ */
+ public static final int action_bar_title_text_size=0x7f060006;
+ /** The maximum width we would prefer dialogs to be. 0 if there is no
+ maximum (let them grow as large as the screen). Actual values are
+ specified for -large and -xlarge configurations.
+ see comment in values/config.xml
+ see comment in values/config.xml
+ */
+ public static final int config_prefDialogWidth=0x7f060000;
+ }
+ public static final class drawable {
+ public static final int appcompat_divider_dark=0x7f020000;
+ public static final int appcompat_divider_light=0x7f020001;
+ }
+ public static final class id {
+ public static final int action_bar=0x7f04000e;
+ public static final int action_bar_activity_content=0x7f04000a;
+ public static final int action_bar_container=0x7f04000d;
+ public static final int action_bar_overlay_layout=0x7f040012;
+ public static final int action_bar_subtitle=0x7f040016;
+ public static final int action_bar_title=0x7f040015;
+ public static final int action_context_bar=0x7f04000f;
+ public static final int action_menu_divider=0x7f04000b;
+ public static final int action_menu_presenter=0x7f04000c;
+ public static final int action_mode_bar=0x7f04001e;
+ public static final int action_mode_bar_stub=0x7f04001d;
+ public static final int action_mode_close_button=0x7f040017;
+ public static final int checkbox=0x7f040018;
+ public static final int content=0x7f040010;
+ public static final int disableHome=0x7f040008;
+ public static final int home=0x7f040009;
+ public static final int homeAsUp=0x7f040005;
+ public static final int icon=0x7f040019;
+ public static final int left_icon=0x7f040020;
+ public static final int listMode=0x7f040001;
+ public static final int normal=0x7f040000;
+ public static final int progress_circular=0x7f040023;
+ public static final int progress_horizontal=0x7f040024;
+ public static final int radio=0x7f04001a;
+ public static final int right_container=0x7f040021;
+ public static final int right_icon=0x7f040022;
+ public static final int shortcut=0x7f04001c;
+ public static final int showCustom=0x7f040007;
+ public static final int showHome=0x7f040004;
+ public static final int showTitle=0x7f040006;
+ public static final int split_action_bar=0x7f040011;
+ public static final int tabMode=0x7f040002;
+ public static final int title=0x7f04001b;
+ public static final int title_container=0x7f04001f;
+ public static final int top_action_bar=0x7f040013;
+ public static final int up=0x7f040014;
+ public static final int useLogo=0x7f040003;
+ }
+ public static final class integer {
+ /** The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this.
+ The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this.
+ The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this.
+ The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this.
+ The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this.
+ */
+ public static final int max_action_buttons=0x7f070000;
+ }
+ public static final class layout {
+ public static final int action_bar_decor=0x7f030000;
+ public static final int action_bar_decor_overlay=0x7f030001;
+ public static final int action_bar_home=0x7f030002;
+ public static final int action_bar_title_item=0x7f030003;
+ public static final int action_menu_item_layout=0x7f030004;
+ public static final int action_menu_layout=0x7f030005;
+ public static final int action_mode_bar=0x7f030006;
+ public static final int action_mode_close_item=0x7f030007;
+ public static final int list_menu_item_checkbox=0x7f030008;
+ public static final int list_menu_item_icon=0x7f030009;
+ public static final int list_menu_item_radio=0x7f03000a;
+ public static final int popup_menu_item_layout=0x7f03000b;
+ public static final int screen=0x7f03000c;
+ }
+ public static final class string {
+ /** Content description for the action bar "home" affordance. [CHAR LIMIT=NONE]
+ */
+ public static final int action_bar_home_description=0x7f080001;
+ /** Content description for the action bar "up" affordance. [CHAR LIMIT=NONE]
+ */
+ public static final int action_bar_up_description=0x7f080002;
+ /** Content description for the action menu overflow button. [CHAR LIMIT=NONE]
+ */
+ public static final int action_menu_overflow_description=0x7f080003;
+ /** Label for the "Done" button on the far left of action mode toolbars.
+ */
+ public static final int action_mode_done=0x7f080000;
+ }
+ public static final class style {
+ public static final int TextAppearance_AppCompat_Base_Widget_ActionBar_Menu=0x7f090007;
+ public static final int TextAppearance_AppCompat_Widget_ActionBar_Menu=0x7f09000e;
+ public static final int TextAppearance_Widget_ActionMode_Subtitle=0x7f090011;
+ public static final int TextAppearance_Widget_ActionMode_Title=0x7f090010;
+ /** Themes in the "Theme.AppCompat" family will contain an action bar by default.
+ If Holo themes are available on the current platform version they will be used.
+ A limited Holo-styled action bar will be provided on platform versions older
+ than 3.0. (API 11)
+
+ These theme declarations contain any version-independent specification. Items
+ that need to vary based on platform version should be defined in the corresponding
+ "Theme.Base" theme.
+ Platform-independent theme providing an action bar in a dark-themed activity.
+ */
+ public static final int Theme_AppCompat=0x7f090018;
+ /** Platform-independent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available.
+ */
+ public static final int Theme_AppCompat_DeviceDefault=0x7f09001b;
+ /** Platform-independent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available.
+ */
+ public static final int Theme_AppCompat_DeviceDefault_Light=0x7f09001c;
+ /** Platform-independent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available.
+ */
+ public static final int Theme_AppCompat_DeviceDefault_Light_DarkActionBar=0x7f09001d;
+ /** Platform-independent theme providing an action bar in a dark-themed activity.
+ */
+ public static final int Theme_AppCompat_Light=0x7f090019;
+ /** Platform-independent theme providing an action bar in a dark-themed activity.
+ */
+ public static final int Theme_AppCompat_Light_DarkActionBar=0x7f09001a;
+ /** Base platform-dependent theme providing an action bar in a dark-themed activity.
+ TODO(trevorjohns): The item below doesn't work.
+ <item name="popupMenuStyle">@android:style/Widget.PopupMenu</item>
+ Base platform-dependent theme providing an action bar in a dark-themed activity.
+ Base platform-dependent theme providing an action bar in a dark-themed activity.
+ */
+ public static final int Theme_Base_AppCompat=0x7f090012;
+ /** Base platform-dependent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available.
+ Base platform-dependent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available.
+ */
+ public static final int Theme_Base_AppCompat_DeviceDefault=0x7f090015;
+ /** Base platform-dependent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available.
+ Base platform-dependent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available.
+ */
+ public static final int Theme_Base_AppCompat_DeviceDefault_Light=0x7f090016;
+ /** Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available.
+ Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available.
+ */
+ public static final int Theme_Base_AppCompat_DeviceDefault_Light_DarkActionBar=0x7f090017;
+ /** Base platform-dependent theme providing an action bar in a light-themed activity.
+ Base platform-dependent theme providing an action bar in a light-themed activity.
+ Base platform-dependent theme providing an action bar in a light-themed activity.
+ */
+ public static final int Theme_Base_AppCompat_Light=0x7f090013;
+ /** Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ Base platform-dependent theme providing a dark action bar in a light-themed activity.
+<style name="Theme.Base.AppCompat.Light.DarkActionBar"
+ parent="@android:style/Theme.Holo.Light.DarkActionBar">
+ */
+ public static final int Theme_Base_AppCompat_Light_DarkActionBar=0x7f090014;
+ /** Default action bar style. Remember that if you are overriding
+ any attributes here in a derived style, you should declare each
+ item twice - both with and without the "android:" namespace prefix.
+ TODO(trevorjohns): Missing styles here, including padding. Note that padding was commented out in ActionBarOverlayLayout
+ */
+ public static final int Widget_AppCompat_ActionBar=0x7f090008;
+ public static final int Widget_AppCompat_ActionBar_TabBar=0x7f09000b;
+ public static final int Widget_AppCompat_ActionBar_TabText=0x7f09000d;
+ public static final int Widget_AppCompat_ActionBar_TabView=0x7f09000c;
+ public static final int Widget_AppCompat_ActionButton=0x7f090009;
+ public static final int Widget_AppCompat_ActionButton_Overflow=0x7f09000a;
+ public static final int Widget_AppCompat_ActionMode=0x7f09000f;
+ public static final int Widget_AppCompat_Base_ActionBar=0x7f090000;
+ public static final int Widget_AppCompat_Base_ActionBar_TabBar=0x7f090003;
+ public static final int Widget_AppCompat_Base_ActionBar_TabText=0x7f090005;
+ public static final int Widget_AppCompat_Base_ActionBar_TabView=0x7f090004;
+ public static final int Widget_AppCompat_Base_ActionButton=0x7f090001;
+ public static final int Widget_AppCompat_Base_ActionButton_Overflow=0x7f090002;
+ public static final int Widget_AppCompat_Base_ActionMode=0x7f090006;
+ }
+ public static final class styleable {
+ /** ============================================
+ Attributes used to style the Action Bar.
+ These should be set on your theme; the default actionBarStyle will
+ propagate them to the correct elements as needed.
+
+ Please Note: when overriding attributes for an ActionBar style
+ you must specify each attribute twice: once with the "android:"
+ namespace prefix and once without.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #ActionBar_background android.support.appcompat:background}</code></td><td> Specifies a background drawable for the action bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_backgroundSplit android.support.appcompat:backgroundSplit}</code></td><td> Specifies a background drawable for the bottom component of a split action bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_backgroundStacked android.support.appcompat:backgroundStacked}</code></td><td> Specifies a background drawable for a second stacked row of the action bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_customNavigationLayout android.support.appcompat:customNavigationLayout}</code></td><td> Specifies a layout for custom navigation.</td></tr>
+ <tr><td><code>{@link #ActionBar_displayOptions android.support.appcompat:displayOptions}</code></td><td> Options affecting how the action bar is displayed.</td></tr>
+ <tr><td><code>{@link #ActionBar_divider android.support.appcompat:divider}</code></td><td> Specifies the drawable used for item dividers.</td></tr>
+ <tr><td><code>{@link #ActionBar_height android.support.appcompat:height}</code></td><td> Specifies a fixed height.</td></tr>
+ <tr><td><code>{@link #ActionBar_homeLayout android.support.appcompat:homeLayout}</code></td><td> Specifies a layout to use for the "home" section of the action bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_icon android.support.appcompat:icon}</code></td><td> Specifies the drawable used for the application icon.</td></tr>
+ <tr><td><code>{@link #ActionBar_indeterminateProgressStyle android.support.appcompat:indeterminateProgressStyle}</code></td><td> Specifies a style resource to use for an indeterminate progress spinner.</td></tr>
+ <tr><td><code>{@link #ActionBar_itemPadding android.support.appcompat:itemPadding}</code></td><td> Specifies padding that should be applied to the left and right sides of
+ system-provided items in the bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_logo android.support.appcompat:logo}</code></td><td> Specifies the drawable used for the application logo.</td></tr>
+ <tr><td><code>{@link #ActionBar_navigationMode android.support.appcompat:navigationMode}</code></td><td> The type of navigation to use.</td></tr>
+ <tr><td><code>{@link #ActionBar_progressBarPadding android.support.appcompat:progressBarPadding}</code></td><td> Specifies the horizontal padding on either end for an embedded progress bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_progressBarStyle android.support.appcompat:progressBarStyle}</code></td><td> Specifies a style resource to use for an embedded progress bar.</td></tr>
+ <tr><td><code>{@link #ActionBar_subtitle android.support.appcompat:subtitle}</code></td><td> Specifies subtitle text used for navigationMode="normal" </td></tr>
+ <tr><td><code>{@link #ActionBar_subtitleTextStyle android.support.appcompat:subtitleTextStyle}</code></td><td> Specifies a style to use for subtitle text.</td></tr>
+ <tr><td><code>{@link #ActionBar_title android.support.appcompat:title}</code></td><td> Specifies title text used for navigationMode="normal" </td></tr>
+ <tr><td><code>{@link #ActionBar_titleTextStyle android.support.appcompat:titleTextStyle}</code></td><td> Specifies a style to use for title text.</td></tr>
+ </table>
+ @see #ActionBar_background
+ @see #ActionBar_backgroundSplit
+ @see #ActionBar_backgroundStacked
+ @see #ActionBar_customNavigationLayout
+ @see #ActionBar_displayOptions
+ @see #ActionBar_divider
+ @see #ActionBar_height
+ @see #ActionBar_homeLayout
+ @see #ActionBar_icon
+ @see #ActionBar_indeterminateProgressStyle
+ @see #ActionBar_itemPadding
+ @see #ActionBar_logo
+ @see #ActionBar_navigationMode
+ @see #ActionBar_progressBarPadding
+ @see #ActionBar_progressBarStyle
+ @see #ActionBar_subtitle
+ @see #ActionBar_subtitleTextStyle
+ @see #ActionBar_title
+ @see #ActionBar_titleTextStyle
+ */
+ public static final int[] ActionBar = {
+ 0x7f01001e, 0x7f01001f, 0x7f010020, 0x7f010021,
+ 0x7f010022, 0x7f010023, 0x7f010024, 0x7f010025,
+ 0x7f010026, 0x7f010027, 0x7f010028, 0x7f010029,
+ 0x7f01002a, 0x7f01002b, 0x7f01002c, 0x7f01002d,
+ 0x7f01002e, 0x7f01002f, 0x7f010030
+ };
+ /**
+ <p>
+ @attr description
+ Specifies a background drawable for the action bar.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:background
+ */
+ public static final int ActionBar_background = 10;
+ /**
+ <p>
+ @attr description
+ Specifies a background drawable for the bottom component of a split action bar.
+
+
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ <p>This is a private symbol.
+ @attr name android:backgroundSplit
+ */
+ public static final int ActionBar_backgroundSplit = 12;
+ /**
+ <p>
+ @attr description
+ Specifies a background drawable for a second stacked row of the action bar.
+
+
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ <p>This is a private symbol.
+ @attr name android:backgroundStacked
+ */
+ public static final int ActionBar_backgroundStacked = 11;
+ /**
+ <p>
+ @attr description
+ Specifies a layout for custom navigation. Overrides navigationMode.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:customNavigationLayout
+ */
+ public static final int ActionBar_customNavigationLayout = 13;
+ /**
+ <p>
+ @attr description
+ Options affecting how the action bar is displayed.
+
+
+ <p>Must be one or more (separated by '|') of the following constant values.</p>
+<table>
+<colgroup align="left" />
+<colgroup align="left" />
+<colgroup align="left" />
+<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
+<tr><td><code>useLogo</code></td><td>0x1</td><td></td></tr>
+<tr><td><code>showHome</code></td><td>0x2</td><td></td></tr>
+<tr><td><code>homeAsUp</code></td><td>0x4</td><td></td></tr>
+<tr><td><code>showTitle</code></td><td>0x8</td><td></td></tr>
+<tr><td><code>showCustom</code></td><td>0x10</td><td></td></tr>
+<tr><td><code>disableHome</code></td><td>0x20</td><td></td></tr>
+</table>
+ <p>This is a private symbol.
+ @attr name android:displayOptions
+ */
+ public static final int ActionBar_displayOptions = 3;
+ /**
+ <p>
+ @attr description
+ Specifies the drawable used for item dividers.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:divider
+ */
+ public static final int ActionBar_divider = 9;
+ /**
+ <p>
+ @attr description
+ Specifies a fixed height.
+
+
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:height
+ */
+ public static final int ActionBar_height = 1;
+ /**
+ <p>
+ @attr description
+ Specifies a layout to use for the "home" section of the action bar.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:homeLayout
+ */
+ public static final int ActionBar_homeLayout = 14;
+ /**
+ <p>
+ @attr description
+ Specifies the drawable used for the application icon.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:icon
+ */
+ public static final int ActionBar_icon = 7;
+ /**
+ <p>
+ @attr description
+ Specifies a style resource to use for an indeterminate progress spinner.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:indeterminateProgressStyle
+ */
+ public static final int ActionBar_indeterminateProgressStyle = 16;
+ /**
+ <p>
+ @attr description
+ Specifies padding that should be applied to the left and right sides of
+ system-provided items in the bar.
+
+
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:itemPadding
+ */
+ public static final int ActionBar_itemPadding = 18;
+ /**
+ <p>
+ @attr description
+ Specifies the drawable used for the application logo.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:logo
+ */
+ public static final int ActionBar_logo = 8;
+ /**
+ <p>
+ @attr description
+ The type of navigation to use.
+
+
+ <p>Must be one of the following constant values.</p>
+<table>
+<colgroup align="left" />
+<colgroup align="left" />
+<colgroup align="left" />
+<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
+<tr><td><code>normal</code></td><td>0</td><td> Normal static title text </td></tr>
+<tr><td><code>listMode</code></td><td>1</td><td> The action bar will use a selection list for navigation. </td></tr>
+<tr><td><code>tabMode</code></td><td>2</td><td> The action bar will use a series of horizontal tabs for navigation. </td></tr>
+</table>
+ <p>This is a private symbol.
+ @attr name android:navigationMode
+ */
+ public static final int ActionBar_navigationMode = 2;
+ /**
+ <p>
+ @attr description
+ Specifies the horizontal padding on either end for an embedded progress bar.
+
+
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:progressBarPadding
+ */
+ public static final int ActionBar_progressBarPadding = 17;
+ /**
+ <p>
+ @attr description
+ Specifies a style resource to use for an embedded progress bar.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:progressBarStyle
+ */
+ public static final int ActionBar_progressBarStyle = 15;
+ /**
+ <p>
+ @attr description
+ Specifies subtitle text used for navigationMode="normal"
+
+
+ <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:subtitle
+ */
+ public static final int ActionBar_subtitle = 4;
+ /**
+ <p>
+ @attr description
+ Specifies a style to use for subtitle text.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:subtitleTextStyle
+ */
+ public static final int ActionBar_subtitleTextStyle = 6;
+ /**
+ <p>
+ @attr description
+ Specifies title text used for navigationMode="normal"
+
+
+ <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:title
+ */
+ public static final int ActionBar_title = 0;
+ /**
+ <p>
+ @attr description
+ Specifies a style to use for title text.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:titleTextStyle
+ */
+ public static final int ActionBar_titleTextStyle = 5;
+ /** Valid LayoutParams for views placed in the action bar as custom views.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #ActionBarLayout_android_layout_gravity android.support.appcompat:android_layout_gravity}</code></td><td></td></tr>
+ </table>
+ @see #ActionBarLayout_android_layout_gravity
+ */
+ public static final int[] ActionBarLayout = {
+ 0x010100b3
+ };
+ /**
+ <p>This symbol is the offset where the {@link android.support.appcompat.R.attr#android_layout_gravity}
+ attribute's value can be found in the {@link #ActionBarLayout} array.
+ @attr name android:android_layout_gravity
+ */
+ public static final int ActionBarLayout_android_layout_gravity = 0;
+ /** These attributes are meant to be specified and customized by the app.
+ The system will read and apply them as needed. These attributes control
+ properties of the activity window, such as whether an action bar should
+ be present and whether it should overlay content.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #ActionBarWindow_windowActionBar android.support.appcompat:windowActionBar}</code></td><td></td></tr>
+ <tr><td><code>{@link #ActionBarWindow_windowActionBarOverlay android.support.appcompat:windowActionBarOverlay}</code></td><td></td></tr>
+ </table>
+ @see #ActionBarWindow_windowActionBar
+ @see #ActionBarWindow_windowActionBarOverlay
+ */
+ public static final int[] ActionBarWindow = {
+ 0x7f010000, 0x7f010001
+ };
+ /**
+ <p>This symbol is the offset where the {@link android.support.appcompat.R.attr#windowActionBar}
+ attribute's value can be found in the {@link #ActionBarWindow} array.
+
+
+ <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ @attr name android:windowActionBar
+ */
+ public static final int ActionBarWindow_windowActionBar = 0;
+ /**
+ <p>This symbol is the offset where the {@link android.support.appcompat.R.attr#windowActionBarOverlay}
+ attribute's value can be found in the {@link #ActionBarWindow} array.
+
+
+ <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ @attr name android:windowActionBarOverlay
+ */
+ public static final int ActionBarWindow_windowActionBarOverlay = 1;
+ /** TODO(trevorjohns): Write docs for this.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #ActionMenuItemView_android_minWidth android.support.appcompat:android_minWidth}</code></td><td></td></tr>
+ </table>
+ @see #ActionMenuItemView_android_minWidth
+ */
+ public static final int[] ActionMenuItemView = {
+ 0x0101013f
+ };
+ /**
+ <p>This symbol is the offset where the {@link android.support.appcompat.R.attr#android_minWidth}
+ attribute's value can be found in the {@link #ActionMenuItemView} array.
+ @attr name android:android_minWidth
+ */
+ public static final int ActionMenuItemView_android_minWidth = 0;
+ /** Size of padding on either end of a divider.
+ */
+ public static final int[] ActionMenuView = {
+
+ };
+ /** Attributes that can be used with a ActionMode.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #ActionMode_background android.support.appcompat:background}</code></td><td> Specifies a background for the action mode bar.</td></tr>
+ <tr><td><code>{@link #ActionMode_backgroundSplit android.support.appcompat:backgroundSplit}</code></td><td> Specifies a background for the split action mode bar.</td></tr>
+ <tr><td><code>{@link #ActionMode_height android.support.appcompat:height}</code></td><td> Specifies a fixed height for the action mode bar.</td></tr>
+ <tr><td><code>{@link #ActionMode_subtitleTextStyle android.support.appcompat:subtitleTextStyle}</code></td><td> Specifies a style to use for subtitle text.</td></tr>
+ <tr><td><code>{@link #ActionMode_titleTextStyle android.support.appcompat:titleTextStyle}</code></td><td> Specifies a style to use for title text.</td></tr>
+ </table>
+ @see #ActionMode_background
+ @see #ActionMode_backgroundSplit
+ @see #ActionMode_height
+ @see #ActionMode_subtitleTextStyle
+ @see #ActionMode_titleTextStyle
+ */
+ public static final int[] ActionMode = {
+ 0x7f01001f, 0x7f010023, 0x7f010024, 0x7f010028,
+ 0x7f01002a
+ };
+ /**
+ <p>
+ @attr description
+ Specifies a background for the action mode bar.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:background
+ */
+ public static final int ActionMode_background = 3;
+ /**
+ <p>
+ @attr description
+ Specifies a background for the split action mode bar.
+
+
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ <p>This is a private symbol.
+ @attr name android:backgroundSplit
+ */
+ public static final int ActionMode_backgroundSplit = 4;
+ /**
+ <p>
+ @attr description
+ Specifies a fixed height for the action mode bar.
+
+
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:height
+ */
+ public static final int ActionMode_height = 0;
+ /**
+ <p>
+ @attr description
+ Specifies a style to use for subtitle text.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:subtitleTextStyle
+ */
+ public static final int ActionMode_subtitleTextStyle = 2;
+ /**
+ <p>
+ @attr description
+ Specifies a style to use for title text.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:titleTextStyle
+ */
+ public static final int ActionMode_titleTextStyle = 1;
+ /** Attributes that can be used with a MenuView.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #MenuView_headerBackground android.support.appcompat:headerBackground}</code></td><td> Default background for the menu header.</td></tr>
+ <tr><td><code>{@link #MenuView_horizontalDivider android.support.appcompat:horizontalDivider}</code></td><td> Default horizontal divider between rows of menu items.</td></tr>
+ <tr><td><code>{@link #MenuView_itemBackground android.support.appcompat:itemBackground}</code></td><td> Default background for each menu item.</td></tr>
+ <tr><td><code>{@link #MenuView_itemIconDisabledAlpha android.support.appcompat:itemIconDisabledAlpha}</code></td><td> Default disabled icon alpha for each menu item that shows an icon.</td></tr>
+ <tr><td><code>{@link #MenuView_itemTextAppearance android.support.appcompat:itemTextAppearance}</code></td><td> Default appearance of menu item text.</td></tr>
+ <tr><td><code>{@link #MenuView_preserveIconSpacing android.support.appcompat:preserveIconSpacing}</code></td><td> Whether space should be reserved in layout when an icon is missing.</td></tr>
+ <tr><td><code>{@link #MenuView_verticalDivider android.support.appcompat:verticalDivider}</code></td><td> Default vertical divider between menu items.</td></tr>
+ <tr><td><code>{@link #MenuView_windowAnimationStyle android.support.appcompat:windowAnimationStyle}</code></td><td> Default animations for the menu.</td></tr>
+ </table>
+ @see #MenuView_headerBackground
+ @see #MenuView_horizontalDivider
+ @see #MenuView_itemBackground
+ @see #MenuView_itemIconDisabledAlpha
+ @see #MenuView_itemTextAppearance
+ @see #MenuView_preserveIconSpacing
+ @see #MenuView_verticalDivider
+ @see #MenuView_windowAnimationStyle
+ */
+ public static final int[] MenuView = {
+ 0x7f010042, 0x7f010043, 0x7f010044, 0x7f010045,
+ 0x7f010046, 0x7f010047, 0x7f010048, 0x7f010049
+ };
+ /**
+ <p>
+ @attr description
+ Default background for the menu header.
+
+
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ <p>This is a private symbol.
+ @attr name android:headerBackground
+ */
+ public static final int MenuView_headerBackground = 3;
+ /**
+ <p>
+ @attr description
+ Default horizontal divider between rows of menu items.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:horizontalDivider
+ */
+ public static final int MenuView_horizontalDivider = 1;
+ /**
+ <p>
+ @attr description
+ Default background for each menu item.
+
+
+ <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+ <p>This is a private symbol.
+ @attr name android:itemBackground
+ */
+ public static final int MenuView_itemBackground = 4;
+ /**
+ <p>
+ @attr description
+ Default disabled icon alpha for each menu item that shows an icon.
+
+
+ <p>Must be a floating point value, such as "<code>1.2</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:itemIconDisabledAlpha
+ */
+ public static final int MenuView_itemIconDisabledAlpha = 6;
+ /**
+ <p>
+ @attr description
+ Default appearance of menu item text.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:itemTextAppearance
+ */
+ public static final int MenuView_itemTextAppearance = 0;
+ /**
+ <p>
+ @attr description
+ Whether space should be reserved in layout when an icon is missing.
+
+
+ <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:preserveIconSpacing
+ */
+ public static final int MenuView_preserveIconSpacing = 7;
+ /**
+ <p>
+ @attr description
+ Default vertical divider between menu items.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:verticalDivider
+ */
+ public static final int MenuView_verticalDivider = 2;
+ /**
+ <p>
+ @attr description
+ Default animations for the menu.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:windowAnimationStyle
+ */
+ public static final int MenuView_windowAnimationStyle = 5;
+ /** These are the standard attributes that make up a complete theme.
+ <p>Includes the following attributes:</p>
+ <table>
+ <colgroup align="left" />
+ <colgroup align="left" />
+ <tr><th>Attribute</th><th>Description</th></tr>
+ <tr><td><code>{@link #Theme_actionDropDownStylFe android.support.appcompat:actionDropDownStylFe}</code></td><td> TODO(trevorjohns): Add other attributes!
+ Default ActionBar dropdown style.</td></tr>
+ <tr><td><code>{@link #Theme_actionDropDownStyle android.support.appcompat:actionDropDownStyle}</code></td><td> Default ActionBar dropdown style.</td></tr>
+ <tr><td><code>{@link #Theme_dropdownListPreferredItemHeight android.support.appcompat:dropdownListPreferredItemHeight}</code></td><td> The preferred item height for dropdown lists.</td></tr>
+ <tr><td><code>{@link #Theme_popupMenuStyle android.support.appcompat:popupMenuStyle}</code></td><td> Default PopupMenu style.</td></tr>
+ </table>
+ @see #Theme_actionDropDownStylFe
+ @see #Theme_actionDropDownStyle
+ @see #Theme_dropdownListPreferredItemHeight
+ @see #Theme_popupMenuStyle
+ */
+ public static final int[] Theme = {
+ 0x7f01003e, 0x7f01003f, 0x7f010040, 0x7f010041
+ };
+ /**
+ <p>
+ @attr description
+ TODO(trevorjohns): Add other attributes!
+ Default ActionBar dropdown style.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:actionDropDownStylFe
+ */
+ public static final int Theme_actionDropDownStylFe = 0;
+ /**
+ <p>
+ @attr description
+ Default ActionBar dropdown style.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:actionDropDownStyle
+ */
+ public static final int Theme_actionDropDownStyle = 3;
+ /**
+ <p>
+ @attr description
+ The preferred item height for dropdown lists.
+
+
+ <p>Must be a dimension value, which is a floating point number appended with a unit such as "<code>14.5sp</code>".
+Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
+in (inches), mm (millimeters).
+<p>This may also be a reference to a resource (in the form
+"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
+theme attribute (in the form
+"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
+containing a value of this type.
+ <p>This is a private symbol.
+ @attr name android:dropdownListPreferredItemHeight
+ */
+ public static final int Theme_dropdownListPreferredItemHeight = 1;
+ /**
+ <p>
+ @attr description
+ Default PopupMenu style.
+
+
+ <p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+ <p>This is a private symbol.
+ @attr name android:popupMenuStyle
+ */
+ public static final int Theme_popupMenuStyle = 2;
+ };
+}
diff --git a/appcompat/honeycomb/android/support/appcompat/app/ActionBarImplHC.java b/appcompat/honeycomb/android/support/appcompat/app/ActionBarImplHC.java
new file mode 100644
index 0000000..d641f50
--- /dev/null
+++ b/appcompat/honeycomb/android/support/appcompat/app/ActionBarImplHC.java
@@ -0,0 +1,475 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.app;
+
+import android.app.Activity;
+import android.graphics.drawable.Drawable;
+import android.support.appcompat.app.ActionBar;
+import android.support.v4.app.FragmentTransaction;
+import android.view.View;
+import android.widget.SpinnerAdapter;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+
+class ActionBarImplHC extends ActionBar {
+ Activity mActivity;
+ Callback mCallback;
+ android.app.ActionBar mActionBar;
+
+ private ArrayList<WeakReference<OnMenuVisibilityListenerWrapper>> mAddedMenuVisWrappers =
+ new ArrayList<WeakReference<OnMenuVisibilityListenerWrapper>>();
+
+ public ActionBarImplHC(Activity activity, Callback callback) {
+ mActivity = activity;
+ mCallback = callback;
+ mActionBar = activity.getActionBar();
+ }
+
+ private OnMenuVisibilityListenerWrapper findAndRemoveMenuVisWrapper(
+ OnMenuVisibilityListener compatListener) {
+ for (int i = 0; i < mAddedMenuVisWrappers.size(); i++) {
+ OnMenuVisibilityListenerWrapper wrapper = mAddedMenuVisWrappers.get(i).get();
+ if (wrapper == null) {
+ mAddedMenuVisWrappers.remove(i--);
+ } else if (wrapper.mWrappedListener == compatListener) {
+ mAddedMenuVisWrappers.remove(i);
+ return wrapper;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void setCustomView(View view) {
+ mActionBar.setCustomView(view);
+ }
+
+ @Override
+ public void setCustomView(View view, LayoutParams layoutParams) {
+ android.app.ActionBar.LayoutParams lp =
+ new android.app.ActionBar.LayoutParams(layoutParams);
+ lp.gravity = layoutParams.gravity;
+
+ mActionBar.setCustomView(view, lp);
+ }
+
+ @Override
+ public void setCustomView(int resId) {
+ // TODO: do layoutparams translation
+ mActionBar.setCustomView(resId);
+ }
+
+ @Override
+ public void setIcon(int resId) {
+ // TODO compatibility impl?
+ //mActionBar.setIcon(resId);
+ }
+
+ @Override
+ public void setIcon(Drawable icon) {
+ // TODO compatibility impl?
+ //mActionBar.setIcon(icon);
+ }
+
+ @Override
+ public void setLogo(int resId) {
+ // TODO compatibility impl?
+ //mActionBar.setLogo(resId);
+ }
+
+ @Override
+ public void setLogo(Drawable logo) {
+ // TODO compatibility impl?
+ //mActionBar.setLogo(logo);
+ }
+
+ @Override
+ public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
+ mActionBar.setListNavigationCallbacks(adapter, new OnNavigationListenerWrapper(callback));
+ }
+
+ @Override
+ public void setSelectedNavigationItem(int position) {
+ mActionBar.setSelectedNavigationItem(position);
+ }
+
+ @Override
+ public int getSelectedNavigationIndex() {
+ return mActionBar.getSelectedNavigationIndex();
+ }
+
+ @Override
+ public int getNavigationItemCount() {
+ return mActionBar.getNavigationItemCount();
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mActionBar.setTitle(title);
+ }
+
+ @Override
+ public void setTitle(int resId) {
+ mActionBar.setTitle(resId);
+ }
+
+ @Override
+ public void setSubtitle(CharSequence subtitle) {
+ mActionBar.setSubtitle(subtitle);
+ }
+
+ @Override
+ public void setSubtitle(int resId) {
+ mActionBar.setSubtitle(resId);
+ }
+
+ @Override
+ public void setDisplayOptions(int options) {
+ mActionBar.setDisplayOptions(options);
+ }
+
+ @Override
+ public void setDisplayOptions(int options, int mask) {
+ mActionBar.setDisplayOptions(options, mask);
+ }
+
+ @Override
+ public void setDisplayUseLogoEnabled(boolean useLogo) {
+ mActionBar.setDisplayUseLogoEnabled(useLogo);
+ }
+
+ @Override
+ public void setDisplayShowHomeEnabled(boolean showHome) {
+ mActionBar.setDisplayShowHomeEnabled(showHome);
+ }
+
+ @Override
+ public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
+ mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp);
+ }
+
+ @Override
+ public void setDisplayShowTitleEnabled(boolean showTitle) {
+ mActionBar.setDisplayShowTitleEnabled(showTitle);
+ }
+
+ @Override
+ public void setDisplayShowCustomEnabled(boolean showCustom) {
+ mActionBar.setDisplayShowCustomEnabled(showCustom);
+ }
+
+ @Override
+ public void setBackgroundDrawable(Drawable d) {
+ mActionBar.setBackgroundDrawable(d);
+ }
+
+ @Override
+ public View getCustomView() {
+ return mActionBar.getCustomView();
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mActionBar.getTitle();
+ }
+
+ @Override
+ public CharSequence getSubtitle() {
+ return mActionBar.getSubtitle();
+ }
+
+ @Override
+ public int getNavigationMode() {
+ return mActionBar.getNavigationMode();
+ }
+
+ @Override
+ public void setNavigationMode(int mode) {
+ mActionBar.setNavigationMode(mode);
+ }
+
+ @Override
+ public int getDisplayOptions() {
+ return mActionBar.getDisplayOptions();
+ }
+
+ @Override
+ public Tab newTab() {
+ final android.app.ActionBar.Tab realTab = mActionBar.newTab();
+ final TabWrapper result = new TabWrapper(realTab);
+ result.setTag(realTab);
+ return result;
+ }
+
+ @Override
+ public void addTab(Tab tab) {
+ mActionBar.addTab(((TabWrapper) tab).mWrappedTab);
+ }
+
+ @Override
+ public void addTab(Tab tab, boolean setSelected) {
+ mActionBar.addTab(((TabWrapper) tab).mWrappedTab);
+ }
+
+ @Override
+ public void addTab(Tab tab, int position) {
+ mActionBar.addTab(((TabWrapper) tab).mWrappedTab, position);
+ }
+
+ @Override
+ public void addTab(Tab tab, int position, boolean setSelected) {
+ mActionBar.addTab(((TabWrapper) tab).mWrappedTab, position, setSelected);
+ }
+
+ @Override
+ public void removeTab(Tab tab) {
+ mActionBar.removeTab(((TabWrapper) tab).mWrappedTab);
+ }
+
+ @Override
+ public void removeTabAt(int position) {
+ mActionBar.removeTabAt(position);
+ }
+
+ @Override
+ public void removeAllTabs() {
+ mActionBar.removeAllTabs();
+ }
+
+ @Override
+ public void selectTab(Tab tab) {
+ mActionBar.selectTab(((TabWrapper) tab).mWrappedTab);
+ }
+
+ @Override
+ public Tab getSelectedTab() {
+ return (Tab) mActionBar.getSelectedTab().getTag();
+ }
+
+ @Override
+ public Tab getTabAt(int index) {
+ return (Tab) mActionBar.getTabAt(index).getTag();
+ }
+
+ @Override
+ public int getTabCount() {
+ return mActionBar.getTabCount();
+ }
+
+ @Override
+ public int getHeight() {
+ return mActionBar.getHeight();
+ }
+
+ @Override
+ public void show() {
+ mActionBar.show();
+ }
+
+ @Override
+ public void hide() {
+ mActionBar.hide();
+ }
+
+ @Override
+ public boolean isShowing() {
+ return mActionBar.isShowing();
+ }
+
+ @Override
+ public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
+ OnMenuVisibilityListenerWrapper w = new OnMenuVisibilityListenerWrapper(listener);
+ mAddedMenuVisWrappers.add(new WeakReference<OnMenuVisibilityListenerWrapper>(w));
+ mActionBar.addOnMenuVisibilityListener(w);
+ }
+
+ @Override
+ public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
+ OnMenuVisibilityListenerWrapper l = findAndRemoveMenuVisWrapper(listener);
+ mActionBar.removeOnMenuVisibilityListener(l);
+ }
+
+ static class OnNavigationListenerWrapper implements android.app.ActionBar.OnNavigationListener {
+ private final OnNavigationListener mWrappedListener;
+
+ public OnNavigationListenerWrapper(OnNavigationListener l) {
+ mWrappedListener = l;
+ }
+
+ @Override
+ public boolean onNavigationItemSelected(int itemPosition, long itemId) {
+ return mWrappedListener.onNavigationItemSelected(itemPosition, itemId);
+ }
+
+ }
+
+ static class OnMenuVisibilityListenerWrapper implements
+ android.app.ActionBar.OnMenuVisibilityListener {
+ final OnMenuVisibilityListener mWrappedListener;
+
+ public OnMenuVisibilityListenerWrapper(OnMenuVisibilityListener l) {
+ mWrappedListener = l;
+ }
+
+ @Override
+ public void onMenuVisibilityChanged(boolean isVisible) {
+ mWrappedListener.onMenuVisibilityChanged(isVisible);
+ }
+
+ }
+
+ class TabWrapper extends ActionBar.Tab {
+ final android.app.ActionBar.Tab mWrappedTab;
+ private Object mTag;
+ private FragmentTransaction mActiveTransaction;
+ private CharSequence mContentDescription;
+
+ public TabWrapper(android.app.ActionBar.Tab tab) {
+ mWrappedTab = tab;
+ }
+
+ @Override
+ public int getPosition() {
+ return mWrappedTab.getPosition();
+ }
+
+ @Override
+ public Drawable getIcon() {
+ return mWrappedTab.getIcon();
+ }
+
+ @Override
+ public CharSequence getText() {
+ return mWrappedTab.getText();
+ }
+
+ @Override
+ public Tab setIcon(Drawable icon) {
+ mWrappedTab.setIcon(icon);
+ return this;
+ }
+
+ @Override
+ public Tab setIcon(int resId) {
+ mWrappedTab.setIcon(resId);
+ return this;
+ }
+
+ @Override
+ public Tab setText(CharSequence text) {
+ mWrappedTab.setText(text);
+ return this;
+ }
+
+ @Override
+ public Tab setText(int resId) {
+ mWrappedTab.setText(resId);
+ return this;
+ }
+
+ @Override
+ public Tab setCustomView(View view) {
+ mWrappedTab.setCustomView(view);
+ return this;
+ }
+
+ @Override
+ public Tab setCustomView(int layoutResId) {
+ mWrappedTab.setCustomView(layoutResId);
+ return this;
+ }
+
+ @Override
+ public View getCustomView() {
+ return mWrappedTab.getCustomView();
+ }
+
+ @Override
+ public Tab setTag(Object obj) {
+ mTag = obj;
+ return this;
+ }
+
+ @Override
+ public Object getTag() {
+ return mTag;
+ }
+
+ @Override
+ public Tab setTabListener(TabListener listener) {
+ mWrappedTab.setTabListener(new TabListenerWrapper(listener));
+ return this;
+ }
+
+ @Override
+ public void select() {
+ mActiveTransaction = mCallback.getSupportFragmentManager().beginTransaction();
+ mWrappedTab.select();
+ mActiveTransaction.commit();
+ mActiveTransaction = null;
+ }
+
+ @Override
+ public Tab setContentDescription(int resId) {
+ mContentDescription = mActivity.getText(resId);
+ return this;
+ }
+
+ @Override
+ public Tab setContentDescription(CharSequence contentDesc) {
+ mContentDescription = contentDesc;
+ return this;
+ }
+
+ @Override
+ public CharSequence getContentDescription() {
+ return mContentDescription;
+ }
+
+ }
+
+ class TabListenerWrapper implements android.app.ActionBar.TabListener {
+ private final TabListener mWrappedListener;
+
+ public TabListenerWrapper(TabListener l) {
+ mWrappedListener = l;
+ }
+
+ @Override
+ public void onTabSelected(android.app.ActionBar.Tab tab,
+ android.app.FragmentTransaction ft) {
+ final TabWrapper wrappedTab = (TabWrapper) tab.getTag();
+ mWrappedListener.onTabSelected(wrappedTab, wrappedTab.mActiveTransaction);
+ }
+
+ @Override
+ public void onTabUnselected(android.app.ActionBar.Tab tab,
+ android.app.FragmentTransaction ft) {
+ final TabWrapper wrappedTab = (TabWrapper) tab.getTag();
+ mWrappedListener.onTabUnselected(wrappedTab, wrappedTab.mActiveTransaction);
+ }
+
+ @Override
+ public void onTabReselected(android.app.ActionBar.Tab tab,
+ android.app.FragmentTransaction ft) {
+ final TabWrapper wrappedTab = (TabWrapper) tab.getTag();
+ mWrappedListener.onTabReselected(wrappedTab, wrappedTab.mActiveTransaction);
+ }
+
+ }
+}
diff --git a/appcompat/ics/android/support/appcompat/app/ActionBarImplICS.java b/appcompat/ics/android/support/appcompat/app/ActionBarImplICS.java
new file mode 100644
index 0000000..cb94431
--- /dev/null
+++ b/appcompat/ics/android/support/appcompat/app/ActionBarImplICS.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.app;
+
+import android.app.Activity;
+import android.support.appcompat.app.ActionBarImplHC;
+
+class ActionBarImplICS extends ActionBarImplHC {
+
+ public ActionBarImplICS(Activity activity, Callback callback) {
+ super(activity, callback);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/appcompat/java/android/support/appcompat/app/ActionBarActivity.java b/appcompat/java/android/support/appcompat/app/ActionBarActivity.java
new file mode 100644
index 0000000..5a7ad0a
--- /dev/null
+++ b/appcompat/java/android/support/appcompat/app/ActionBarActivity.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.app;
+
+import android.content.res.TypedArray;
+import android.os.Bundle;
+import android.support.appcompat.R;
+import android.support.v4.app.FragmentActivity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class ActionBarActivity extends FragmentActivity implements ActionBar.Callback {
+
+ private static final int FEATURE_ACTION_BAR = 8;
+ private static final int FEATURE_ACTION_BAR_OVERLAY = 9;
+
+ interface ActionBarActivityImpl {
+ void onCreate(ActionBarActivity activity, Bundle savedInstanceState);
+ void setContentView(ActionBarActivity activity, View v);
+ void setContentView(ActionBarActivity activity, int resId);
+ void setContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp);
+ void addContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp);
+ ActionBar createActionBar(ActionBarActivity activity);
+ void requestWindowFeature(ActionBarActivity activity, int feature);
+ }
+
+ static class ActionBarActivityImplBase implements ActionBarActivityImpl {
+
+ @Override
+ public void onCreate(ActionBarActivity activity, Bundle savedInstanceState) {
+ TypedArray a = activity.obtainStyledAttributes(R.styleable.ActionBarWindow);
+ activity.mHasActionBar = a.getBoolean(
+ R.styleable.ActionBarWindow_windowActionBar, false);
+ activity.mOverlayActionBar = a.getBoolean(
+ R.styleable.ActionBarWindow_windowActionBarOverlay, false);
+ a.recycle();
+ }
+
+ private void ensureSubDecor(ActionBarActivity activity) {
+ if (activity.mHasActionBar && !activity.mSubDecorInstalled) {
+ if (activity.mOverlayActionBar) {
+ activity.setContentView(R.layout.action_bar_decor_overlay);
+ } else {
+ activity.setContentView(R.layout.action_bar_decor);
+ }
+ }
+ }
+
+ @Override
+ public void setContentView(ActionBarActivity activity, View v) {
+ ensureSubDecor(activity);
+ if (activity.mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
+ contentParent.removeAllViews();
+ contentParent.addView(v);
+ } else {
+ activity.setContentView(v);
+ }
+ }
+
+ @Override
+ public void setContentView(ActionBarActivity activity, int resId) {
+ ensureSubDecor(activity);
+ if (activity.mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
+ contentParent.removeAllViews();
+ final LayoutInflater inflater = activity.getLayoutInflater();
+ inflater.inflate(resId, contentParent);
+ } else {
+ activity.setContentView(resId);
+ }
+ }
+
+ @Override
+ public void setContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
+ ensureSubDecor(activity);
+ if (activity.mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
+ contentParent.removeAllViews();
+ contentParent.addView(v, lp);
+ } else {
+ activity.setContentView(v, lp);
+ }
+ }
+
+ @Override
+ public void addContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
+ ensureSubDecor(activity);
+ if (activity.mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
+ contentParent.addView(v, lp);
+ } else {
+ activity.setContentView(v, lp);
+ }
+ }
+
+ @Override
+ public ActionBar createActionBar(ActionBarActivity activity) {
+ return new ActionBarImplCompat(activity, activity);
+ }
+
+ @Override
+ public void requestWindowFeature(ActionBarActivity activity, int feature) {
+ if (feature == FEATURE_ACTION_BAR) {
+ activity.mHasActionBar = true;
+ } else if (feature == FEATURE_ACTION_BAR_OVERLAY) {
+ activity.mOverlayActionBar = true;
+ }
+ }
+
+ }
+
+ static class ActionBarActivityImplHC implements ActionBarActivityImpl {
+
+ @Override
+ public void onCreate(ActionBarActivity activity, Bundle savedInstanceState) {
+ // Not needed; the native action bar will take care of things.
+ }
+
+ @Override
+ public void setContentView(ActionBarActivity activity, View v) {
+ activity.setContentView(v);
+ }
+
+ @Override
+ public void setContentView(ActionBarActivity activity, int resId) {
+ activity.setContentView(resId);
+ }
+
+ @Override
+ public void setContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
+ activity.setContentView(v, lp);
+ }
+
+ @Override
+ public void addContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
+ activity.addContentView(v, lp);
+ }
+
+ @Override
+ public ActionBar createActionBar(ActionBarActivity activity) {
+ return new ActionBarImplHC(activity, activity);
+ }
+
+ @Override
+ public void requestWindowFeature(ActionBarActivity activity, int feature) {
+ activity.requestWindowFeature(feature);
+ }
+
+ }
+
+ static class ActionBarActivityImplICS extends ActionBarActivityImplHC {
+ @Override
+ public ActionBar createActionBar(ActionBarActivity activity) {
+ return new ActionBarImplICS(activity, activity);
+ }
+ }
+
+ static final ActionBarActivityImpl IMPL;
+ static {
+ final int version = android.os.Build.VERSION.SDK_INT;
+ if (version >= 14) {
+ IMPL = new ActionBarActivityImplICS();
+ } else if (version >= 11) {
+ IMPL = new ActionBarActivityImplHC();
+ } else {
+ IMPL = new ActionBarActivityImplBase();
+ }
+ }
+
+ private ActionBar mActionBar;
+
+ // true if the compatibility implementation has installed a window sub-decor layout.
+ boolean mSubDecorInstalled;
+
+ // true if this activity has an action bar.
+ boolean mHasActionBar;
+
+ // true if this activity's action bar overlays other activity content.
+ boolean mOverlayActionBar;
+
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ IMPL.onCreate(this, savedInstanceState);
+ }
+
+ public ActionBar getSupportActionBar() {
+ initActionBar();
+ return mActionBar;
+ }
+
+ private void initActionBar() {
+ if (mActionBar == null && mHasActionBar) {
+ mActionBar = IMPL.createActionBar(this);
+ }
+ }
+}
diff --git a/appcompat/proguard-project.txt b/appcompat/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/appcompat/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/appcompat/res-stub/android/support/appcompat/dummy/Dummy.java b/appcompat/res-stub/android/support/appcompat/dummy/Dummy.java
new file mode 100644
index 0000000..2115289
--- /dev/null
+++ b/appcompat/res-stub/android/support/appcompat/dummy/Dummy.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.appcompat.dummy;
+
+/**
+ * TODO Find out why the build system is rejecting the res-only
+ * sublibrary without any source files.
+ */
+class Dummy {
+}
diff --git a/appcompat/res/drawable-hdpi/appcompat_divider_dark.9.png b/appcompat/res/drawable-hdpi/appcompat_divider_dark.9.png
new file mode 100644
index 0000000..986ab0b
--- /dev/null
+++ b/appcompat/res/drawable-hdpi/appcompat_divider_dark.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/appcompat_divider_light.9.png b/appcompat/res/drawable-hdpi/appcompat_divider_light.9.png
new file mode 100644
index 0000000..0279e17
--- /dev/null
+++ b/appcompat/res/drawable-hdpi/appcompat_divider_light.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/appcompat_divider_dark.9.png b/appcompat/res/drawable-mdpi/appcompat_divider_dark.9.png
new file mode 100644
index 0000000..986ab0b
--- /dev/null
+++ b/appcompat/res/drawable-mdpi/appcompat_divider_dark.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/appcompat_divider_light.9.png b/appcompat/res/drawable-mdpi/appcompat_divider_light.9.png
new file mode 100644
index 0000000..0279e17
--- /dev/null
+++ b/appcompat/res/drawable-mdpi/appcompat_divider_light.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/appcompat_divider_dark.9.png b/appcompat/res/drawable-xhdpi/appcompat_divider_dark.9.png
new file mode 100644
index 0000000..e62f011
--- /dev/null
+++ b/appcompat/res/drawable-xhdpi/appcompat_divider_dark.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/appcompat_divider_light.9.png b/appcompat/res/drawable-xhdpi/appcompat_divider_light.9.png
new file mode 100644
index 0000000..65061c0
--- /dev/null
+++ b/appcompat/res/drawable-xhdpi/appcompat_divider_light.9.png
Binary files differ
diff --git a/appcompat/res/layout/action_bar_decor.xml b/appcompat/res/layout/action_bar_decor.xml
new file mode 100644
index 0000000..86e985f
--- /dev/null
+++ b/appcompat/res/layout/action_bar_decor.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:fitsSystemWindows="true">
+ <android.support.appcompat.widget.ActionBarContainer android:id="@+id/action_bar_container"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ style="?attr/actionBarStyle">
+ <android.support.appcompat.widget.ActionBarView
+ android:id="@+id/action_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ style="?attr/actionBarStyle" />
+ <android.support.appcompat.widget.ActionBarContextView
+ android:id="@+id/action_context_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ style="?attr/actionModeStyle" />
+ </android.support.appcompat.widget.ActionBarContainer>
+ <FrameLayout android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:foregroundGravity="fill_horizontal|top"
+ android:foreground="?android:attr/windowContentOverlay" />
+ <android.support.appcompat.widget.ActionBarContainer android:id="@+id/split_action_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ style="?attr/actionBarSplitStyle"
+ android:visibility="gone"
+ android:gravity="center"/>
+</LinearLayout>
diff --git a/appcompat/res/layout/action_bar_decor_overlay.xml b/appcompat/res/layout/action_bar_decor_overlay.xml
new file mode 100644
index 0000000..3a24cf8
--- /dev/null
+++ b/appcompat/res/layout/action_bar_decor_overlay.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<android.support.appcompat.widget.ActionBarOverlayLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/action_bar_overlay_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <FrameLayout android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" />
+ <LinearLayout android:id="@+id/top_action_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top">
+ <android.support.appcompat.widget.ActionBarContainer android:id="@+id/action_bar_container"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ style="?attr/actionBarStyle"
+ android:gravity="top">
+ <android.support.appcompat.widget.ActionBarView
+ android:id="@+id/action_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ style="?attr/actionBarStyle" />
+ <android.support.appcompat.widget.ActionBarContextView
+ android:id="@+id/action_context_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ style="?attr/actionModeStyle" />
+ </android.support.appcompat.widget.ActionBarContainer>
+ <ImageView android:src="?android:attr/windowContentOverlay"
+ android:scaleType="fitXY"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
+ <android.support.appcompat.widget.ActionBarContainer android:id="@+id/split_action_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ style="?attr/actionBarSplitStyle"
+ android:visibility="gone"
+ android:gravity="center"/>
+</android.support.appcompat.widget.ActionBarOverlayLayout>
diff --git a/appcompat/res/layout/action_bar_home.xml b/appcompat/res/layout/action_bar_home.xml
new file mode 100644
index 0000000..24b1332
--- /dev/null
+++ b/appcompat/res/layout/action_bar_home.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ />
diff --git a/appcompat/res/layout/action_bar_title_item.xml b/appcompat/res/layout/action_bar_title_item.xml
new file mode 100644
index 0000000..3f70b4b
--- /dev/null
+++ b/appcompat/res/layout/action_bar_title_item.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingRight="8dip"
+ android:background="?attr/actionBarItemBackground"
+ android:enabled="false">
+
+ <ImageView android:id="@+id/up"
+ android:src="?attr/homeAsUpIndicator"
+ android:layout_gravity="center_vertical|left"
+ android:visibility="gone"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|left"
+ android:orientation="vertical">
+ <TextView android:id="@+id/action_bar_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end" />
+ <TextView android:id="@+id/action_bar_subtitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/action_bar_subtitle_top_margin"
+ android:layout_marginBottom="@dimen/action_bar_subtitle_bottom_margin"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:visibility="gone" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/appcompat/res/layout/action_menu_item_layout.xml b/appcompat/res/layout/action_menu_item_layout.xml
new file mode 100644
index 0000000..c20e086
--- /dev/null
+++ b/appcompat/res/layout/action_menu_item_layout.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ dd
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<com.android.internal.view.menu.ActionMenuItemView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:focusable="true"
+ android:paddingTop="4dip"
+ android:paddingBottom="4dip"
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip"
+ android:textAppearance="?attr/actionMenuTextAppearance"
+ android:textColor="?attr/actionMenuTextColor"
+ style="?attr/actionButtonStyle" />
diff --git a/appcompat/res/layout/action_menu_layout.xml b/appcompat/res/layout/action_menu_layout.xml
new file mode 100644
index 0000000..3236be4
--- /dev/null
+++ b/appcompat/res/layout/action_menu_layout.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<android.support.appcompat.view.menu.ActionMenuView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:divider="?attr/actionBarDivider"
+ app:dividerPadding="12dip"
+ android:gravity="center_vertical" />
diff --git a/appcompat/res/layout/action_mode_bar.xml b/appcompat/res/layout/action_mode_bar.xml
new file mode 100644
index 0000000..1e9e948
--- /dev/null
+++ b/appcompat/res/layout/action_mode_bar.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<com.android.internal.widget.ActionBarContextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ style="?attr/actionModeStyle" />
diff --git a/appcompat/res/layout/action_mode_close_item.xml b/appcompat/res/layout/action_mode_close_item.xml
new file mode 100644
index 0000000..1bb237f
--- /dev/null
+++ b/appcompat/res/layout/action_mode_close_item.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/action_mode_close_button"
+ android:focusable="true"
+ android:clickable="true"
+ android:paddingLeft="8dip"
+ android:contentDescription="@string/action_mode_done"
+ style="?attr/actionModeCloseButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_marginRight="16dip">
+ <ImageView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:scaleType="fitCenter"
+ android:src="?attr/actionModeCloseDrawable" />
+</LinearLayout>
diff --git a/appcompat/res/layout/list_menu_item_checkbox.xml b/appcompat/res/layout/list_menu_item_checkbox.xml
new file mode 100644
index 0000000..a2465d0
--- /dev/null
+++ b/appcompat/res/layout/list_menu_item_checkbox.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/checkbox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:focusable="false"
+ android:clickable="false"
+ android:duplicateParentState="true" />
+
+
diff --git a/appcompat/res/layout/list_menu_item_icon.xml b/appcompat/res/layout/list_menu_item_icon.xml
new file mode 100644
index 0000000..8e4ab99
--- /dev/null
+++ b/appcompat/res/layout/list_menu_item_icon.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="8dip"
+ android:layout_marginRight="-8dip"
+ android:layout_marginTop="8dip"
+ android:layout_marginBottom="8dip"
+ android:scaleType="centerInside"
+ android:duplicateParentState="true" />
+
diff --git a/appcompat/res/layout/list_menu_item_radio.xml b/appcompat/res/layout/list_menu_item_radio.xml
new file mode 100644
index 0000000..bebcbbc
--- /dev/null
+++ b/appcompat/res/layout/list_menu_item_radio.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/radio"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:focusable="false"
+ android:clickable="false"
+ android:duplicateParentState="true" />
diff --git a/appcompat/res/layout/popup_menu_item_layout.xml b/appcompat/res/layout/popup_menu_item_layout.xml
new file mode 100644
index 0000000..810e98d
--- /dev/null
+++ b/appcompat/res/layout/popup_menu_item_layout.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- TODO(trevorjohns): This will need to be renamed once ListMenuItemView is copied over. -->
+<com.android.internal.view.menu.ListMenuItemView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="?attr/dropdownListPreferredItemHeight"
+ android:minWidth="196dip"
+ android:paddingRight="16dip">
+
+ <!-- Icon will be inserted here. -->
+
+ <!-- The title and summary have some gap between them, and this 'group' should be centered vertically. -->
+ <RelativeLayout
+ android:layout_width="0dip"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="16dip"
+ android:duplicateParentState="true">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:textAppearance="?attr/textAppearanceLargePopupMenu"
+ android:singleLine="true"
+ android:duplicateParentState="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <TextView
+ android:id="@+id/shortcut"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/title"
+ android:layout_alignParentLeft="true"
+ android:textAppearance="?attr/textAppearanceSmallPopupMenu"
+ android:singleLine="true"
+ android:duplicateParentState="true" />
+
+ </RelativeLayout>
+
+ <!-- Checkbox, and/or radio button will be inserted here. -->
+
+</com.android.internal.view.menu.ListMenuItemView>
diff --git a/appcompat/res/layout/screen.xml b/appcompat/res/layout/screen.xml
new file mode 100644
index 0000000..11182d3
--- /dev/null
+++ b/appcompat/res/layout/screen.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2006 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+This is the basic layout for a screen, with all of its features enabled.
+-->
+
+<!-- Title bar and content -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fitsSystemWindows="true"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+ <!-- Popout bar for action modes -->
+ <ViewStub android:id="@+id/action_mode_bar_stub"
+ android:inflatedId="@+id/action_mode_bar"
+ android:layout="@layout/action_mode_bar"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <!-- Title bar -->
+ <RelativeLayout android:id="@+id/title_container"
+ style="?android:attr/windowTitleBackgroundStyle"
+ android:layout_width="fill_parent"
+ android:layout_height="?android:attr/windowTitleSize"
+ >
+ <ImageView android:id="@+id/left_icon"
+ android:layout_width="16dip"
+ android:layout_height="16dip"
+ android:layout_marginRight="5dip"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true"
+ android:visibility="gone"
+ android:scaleType="fitCenter"
+ />
+ <LinearLayout android:id="@+id/right_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ >
+ <ImageView android:id="@+id/right_icon"
+ android:layout_width="16dip"
+ android:layout_height="16dip"
+ android:layout_marginLeft="5dip"
+ android:layout_gravity="center_vertical"
+ android:visibility="gone"
+ android:scaleType="fitCenter"
+ />
+ <ProgressBar android:id="@+id/progress_circular"
+ style="?android:attr/progressBarStyleSmallTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="5dip"
+ android:layout_gravity="center_vertical"
+ android:visibility="gone"
+ android:max="10000"
+ />
+ </LinearLayout>
+ <ProgressBar android:id="@+id/progress_horizontal"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="2dip"
+ android:layout_toLeftOf="@id/right_container"
+ android:layout_toRightOf="@id/left_icon"
+ android:layout_centerVertical="true"
+ android:visibility="gone"
+ android:max="10000"
+ />
+ <TextView android:id="@+id/title"
+ style="?android:attr/windowTitleStyle"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@null"
+ android:fadingEdge="horizontal"
+ android:scrollHorizontally="true"
+ android:gravity="center_vertical"
+ android:layout_toLeftOf="@id/right_container"
+ android:layout_toRightOf="@id/left_icon"
+ />
+ </RelativeLayout>
+
+ <!-- Content -->
+ <FrameLayout android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:foregroundGravity="fill_horizontal|top"
+ android:foreground="?android:attr/windowContentOverlay"
+ />
+</LinearLayout>
diff --git a/appcompat/res/values-land/dimens.xml b/appcompat/res/values-land/dimens.xml
new file mode 100644
index 0000000..6f21638
--- /dev/null
+++ b/appcompat/res/values-land/dimens.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Default height of an action bar. -->
+ <dimen name="action_bar_default_height">40dip</dimen>
+ <!-- Vertical padding around action bar icons. -->
+ <dimen name="action_bar_icon_vertical_padding">4dip</dimen>
+ <!-- Text size for action bar titles -->
+ <dimen name="action_bar_title_text_size">16dp</dimen>
+ <!-- Text size for action bar subtitles -->
+ <dimen name="action_bar_subtitle_text_size">12dp</dimen>
+ <!-- Top margin for action bar subtitles -->
+ <dimen name="action_bar_subtitle_top_margin">-2dp</dimen>
+ <!-- Bottom margin for action bar subtitles -->
+ <dimen name="action_bar_subtitle_bottom_margin">4dip</dimen>
+
+
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-large/config.xml b/appcompat/res/values-large/config.xml
new file mode 100644
index 0000000..211b782
--- /dev/null
+++ b/appcompat/res/values-large/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+ <!-- see comment in values/config.xml -->
+ <dimen name="config_prefDialogWidth">440dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-port/bools.xml b/appcompat/res/values-port/bools.xml
new file mode 100644
index 0000000..fc62b69
--- /dev/null
+++ b/appcompat/res/values-port/bools.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <bool name="action_bar_embed_tabs">false</bool>
+</resources>
diff --git a/appcompat/res/values-sw600dp/config.xml b/appcompat/res/values-sw600dp/config.xml
new file mode 100644
index 0000000..bf17341
--- /dev/null
+++ b/appcompat/res/values-sw600dp/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+ <!-- see comment in values/config.xml -->
+ <dimen name="config_prefDialogWidth">580dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-sw600dp/dimens.xml b/appcompat/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..0042d76
--- /dev/null
+++ b/appcompat/res/values-sw600dp/dimens.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">5</integer>
+ <!-- Default height of an action bar. -->
+ <dimen name="action_bar_default_height">56dip</dimen>
+ <!-- Vertical padding around action bar icons. -->
+ <dimen name="action_bar_icon_vertical_padding">4dip</dimen>
+ <!-- Text size for action bar titles -->
+ <dimen name="action_bar_title_text_size">18dp</dimen>
+ <!-- Text size for action bar subtitles -->
+ <dimen name="action_bar_subtitle_text_size">14dp</dimen>
+ <!-- Top margin for action bar subtitles -->
+ <dimen name="action_bar_subtitle_top_margin">-3dp</dimen>
+ <!-- Bottom margin for action bar subtitles -->
+ <dimen name="action_bar_subtitle_bottom_margin">9dip</dimen>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-v11/themes.xml b/appcompat/res/values-v11/themes.xml
new file mode 100644
index 0000000..817b401
--- /dev/null
+++ b/appcompat/res/values-v11/themes.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Themes in the "Theme.Base" family vary based on the current platform
+ version to provide the correct basis on each device. You probably don't
+ want to use them directly in your apps.
+
+ Themes in the "Theme.AppCompat" family are meant to be extended or used
+ directly by apps.
+
+ This is the values-v11/ file that only declares the Base themes for
+ Honeycomb+. You probably want to edit values/themes.xml instead. -->
+ <eat-comment />
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.Base.AppCompat" parent="@android:style/Theme">
+
+ <item name="buttonBarStyle">?attr/buttonBarStyle</item>
+ <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
+ <item name="selectableItemBackground">?attr/selectableItemBackground</item>
+
+ <item name="dividerVertical">?attr/dividerVertical</item>
+ <item name="dividerHorizontal">?attr/dividerHorizontal</item>
+ <item name="actionBarDivider">?attr/dividerVertical</item>
+
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+
+ <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
+
+ <item name="actionBarSize">?attr/actionBarSize</item>
+
+ <!-- Redirect compatibility styles to the real ones that exist here -->
+ <item name="actionBarStyle">?attr/actionBarStyle</item>
+ <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
+ <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light" parent="@android:style/Theme.Light">
+ <item name="buttonBarStyle">?attr/buttonBarStyle</item>
+ <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
+ <item name="selectableItemBackground">?attr/selectableItemBackground</item>
+
+ <item name="dividerVertical">?attr/dividerVertical</item>
+ <item name="dividerHorizontal">?attr/dividerHorizontal</item>
+ <item name="actionBarDivider">?attr/dividerVertical</item>
+
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+
+ <item name="textAppearanceListItem">@android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">@android:attr/textAppearanceMedium</item>
+
+ <!-- Redirect compatibility styles to the real ones that exist here -->
+ <item name="actionBarStyle">?attr/actionBarStyle</item>
+ <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
+ <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light.DarkActionBar" parent="Theme.Base.AppCompat.Light">
+ <item name="actionBarDivider">@drawable/appcompat_divider_dark</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.Base.AppCompat.DeviceDefault" parent="Theme.Base.AppCompat">
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.Base.AppCompat.DeviceDefault.Light" parent="Theme.Base.AppCompat.Light">
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar"
+ parent="Theme.Base.AppCompat.Light.DarkActionBar">
+ </style>
+
+</resources>
diff --git a/appcompat/res/values-v14/themes.xml b/appcompat/res/values-v14/themes.xml
new file mode 100644
index 0000000..429c17b
--- /dev/null
+++ b/appcompat/res/values-v14/themes.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Themes in the "Theme.Base" family vary based on the current platform
+ version to provide the correct basis on each device. You probably don't
+ want to use them directly in your apps.
+
+ Themes in the "Theme.AppCompat" family are meant to be extended or used
+ directly by apps.
+
+ This is the values-v14/ file that only declares the Base themes for
+ Ice Cream Sandwich+. You probably want to edit values/themes.xml instead. -->
+ <eat-comment />
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.Base.AppCompat" parent="@android:style/Theme">
+
+ <item name="buttonBarStyle">?attr/buttonBarStyle</item>
+ <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
+ <item name="selectableItemBackground">?attr/selectableItemBackground</item>
+
+ <item name="dividerVertical">?attr/dividerVertical</item>
+ <item name="dividerHorizontal">?attr/dividerHorizontal</item>
+ <item name="actionBarDivider">?attr/actionBarDivider</item>
+
+ <item name="listPreferredItemHeight">?attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">?attr/listPreferredItemHeightSmall</item>
+ <item name="listPreferredItemHeightLarge">?attr/listPreferredItemHeightLarge</item>
+
+ <item name="listPreferredItemPaddingLeft">?attr/listPreferredItemPaddingLeft</item>
+ <item name="listPreferredItemPaddingRight">?attr/listPreferredItemPaddingRight</item>
+
+ <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
+
+ <!-- Redirect compatibility styles to the real ones that exist here -->
+ <item name="actionBarStyle">?attr/actionBarStyle</item>
+ <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
+ <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
+ <item name="actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light" parent="@android:style/Theme.Light">
+ <item name="buttonBarStyle">?attr/buttonBarStyle</item>
+ <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
+ <item name="selectableItemBackground">?attr/selectableItemBackground</item>
+
+ <item name="dividerVertical">?attr/dividerVertical</item>
+ <item name="dividerHorizontal">?attr/dividerHorizontal</item>
+ <item name="actionBarDivider">?attr/actionBarDivider</item>
+
+ <item name="listPreferredItemHeight">?attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">?attr/listPreferredItemHeightSmall</item>
+ <item name="listPreferredItemHeightLarge">?attr/listPreferredItemHeightLarge</item>
+
+ <item name="listPreferredItemPaddingLeft">?attr/listPreferredItemPaddingLeft</item>
+ <item name="listPreferredItemPaddingRight">?attr/listPreferredItemPaddingRight</item>
+
+ <item name="textAppearanceListItem">@android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">@android:attr/textAppearanceMedium</item>
+
+ <!-- Redirect compatibility styles to the real ones that exist here -->
+ <item name="actionBarStyle">?attr/actionBarStyle</item>
+ <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
+ <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
+ <item name="actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
+ <!--<style name="Theme.Base.AppCompat.Light.DarkActionBar"
+ parent="@android:style/Theme.Holo.Light.DarkActionBar">-->
+ <style name="Theme.Base.AppCompat.Light.DarkActionBar"
+ parent="@android:style/Theme.Light">
+ <!-- TODO(trevorjohns): This actually needs to make the ActionBar dark. -->
+ <item name="actionBarDivider">?attr/actionBarDivider</item>
+ <item name="actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <!-- TODO(trevorjohns): DeviceDefault is not available. What do we do? -->
+ <!--<style name="Theme.Base.AppCompat.DeviceDefault"
+ parent="@android:style/Theme.DeviceDefault">
+ </style>-->
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <!-- TODO(trevorjohns): DeviceDefault is not available. What do we do? -->
+ <!--<style name="Theme.Base.AppCompat.DeviceDefault.Light"-->
+ <!--parent="@android:style/Theme.DeviceDefault.Light">-->
+ <!--</style>-->
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <!-- TODO(trevorjohns): DeviceDefault is not available. What do we do? -->
+ <!--<style name="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar"-->
+ <!--parent="@android:style/Theme.DeviceDefault.Light.DarkActionBar">-->
+ <!--</style>-->
+
+</resources>
diff --git a/appcompat/res/values-w360dp/dimens.xml b/appcompat/res/values-w360dp/dimens.xml
new file mode 100644
index 0000000..20539f8
--- /dev/null
+++ b/appcompat/res/values-w360dp/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">3</integer>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-w480dp/bools.xml b/appcompat/res/values-w480dp/bools.xml
new file mode 100644
index 0000000..10ff76b
--- /dev/null
+++ b/appcompat/res/values-w480dp/bools.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <bool name="action_bar_embed_tabs_pre_jb">true</bool>
+ <bool name="split_action_bar_is_narrow">false</bool>
+</resources>
diff --git a/appcompat/res/values-w480dp/config.xml b/appcompat/res/values-w480dp/config.xml
new file mode 100644
index 0000000..571dce0
--- /dev/null
+++ b/appcompat/res/values-w480dp/config.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <bool name="config_allowActionMenuItemTextWithIcon">true</bool>
+</resources>
diff --git a/appcompat/res/values-w500dp/dimens.xml b/appcompat/res/values-w500dp/dimens.xml
new file mode 100644
index 0000000..972af10
--- /dev/null
+++ b/appcompat/res/values-w500dp/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">4</integer>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-w600dp/dimens.xml b/appcompat/res/values-w600dp/dimens.xml
new file mode 100644
index 0000000..93f3c51
--- /dev/null
+++ b/appcompat/res/values-w600dp/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">5</integer>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-w720dp/bools.xml b/appcompat/res/values-w720dp/bools.xml
new file mode 100644
index 0000000..a88f542
--- /dev/null
+++ b/appcompat/res/values-w720dp/bools.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <bool name="action_bar_expanded_action_views_exclusive">false</bool>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values/attrs.xml b/appcompat/res/values/attrs.xml
new file mode 100644
index 0000000..c593c3c
--- /dev/null
+++ b/appcompat/res/values/attrs.xml
@@ -0,0 +1,285 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Many app-specific attributes are declared in this file.
+ Unless otherwise specified, they are intended to be set within
+ the context of a theme declaration.
+
+ Each cluster of attributes below states whether it is meant to
+ be set by the app and read by the system, or set by the system and
+ read by the app. -->
+ <eat-comment />
+
+ <!-- These attributes are meant to be specified and customized by the app.
+ The system will read and apply them as needed. These attributes control
+ properties of the activity window, such as whether an action bar should
+ be present and whether it should overlay content. -->
+ <declare-styleable name="ActionBarWindow">
+ <attr name="windowActionBar" format="boolean" />
+ <attr name="windowActionBarOverlay" format="boolean" />
+ </declare-styleable>
+
+ <!-- ============================================ -->
+
+ <!-- Action bar appearance and styling attributes.
+ These attributes are meant to be specified and customized by the
+ app. The system will read and apply them as needed. -->
+ <eat-comment />
+
+ <!-- Default style for tabs within an action bar -->
+ <attr name="actionBarTabStyle" format="reference" />
+ <attr name="actionBarTabBarStyle" format="reference" />
+ <attr name="actionBarTabTextStyle" format="reference" />
+ <attr name="actionOverflowButtonStyle" format="reference" />
+ <!-- Reference to a style for the Action Bar -->
+ <attr name="actionBarStyle" format="reference" />
+ <!-- Reference to a theme that should be used to inflate widgets
+ and layouts destined for the action bar. Most of the time
+ this will be a reference to the current theme, but when
+ the action bar has a significantly different contrast
+ profile than the rest of the activity the difference
+ can become important. If this is set to @null the current
+ theme will be used.-->
+ <attr name="actionBarSplitStyle" format="reference" />
+ <!-- Reference to a theme that should be used to inflate widgets
+ and layouts destined for the action bar. Most of the time
+ this will be a reference to the current theme, but when
+ the action bar has a significantly different contrast
+ profile than the rest of the activity the difference
+ can become important. If this is set to @null the current
+ theme will be used.-->
+ <attr name="actionBarWidgetTheme" format="reference" />
+ <!-- Size of the Action Bar, including the contextual
+ bar used to present Action Modes. -->
+ <attr name="actionBarSize" format="dimension" />
+ <!-- Custom divider drawable to use for elements in the action bar. -->
+ <attr name="actionBarDivider" format="reference" />
+ <!-- Custom item state list drawable background for action bar items. -->
+ <attr name="actionBarItemBackground" format="reference" />
+ <!-- TextAppearance style that will be applied to text that
+ appears within action menu items. -->
+ <attr name="actionMenuTextAppearance" format="reference" />
+ <!-- Color for text that appears within action menu items. -->
+ <attr name="actionMenuTextColor" format="color|reference" />
+ <!-- Specifies a drawable to use for the 'home as up' indicator. -->
+ <attr name="homeAsUpIndicator" format="reference" />
+ <!-- Text color, typeface, size, and style for the text inside of a popup menu. -->
+ <attr name="textAppearanceLargePopupMenu" format="reference" />
+ <!-- Text color, typeface, size, and style for small text inside of a popup menu. -->
+ <attr name="textAppearanceSmallPopupMenu" format="reference" />
+ <!-- Default action button style. -->
+ <attr name="actionButtonStyle" format="reference" />
+
+ <!-- ============================================ -->
+
+ <!-- Assorted theme compatibility attributes.
+ These attributes are meant to be set by the system and read by apps
+ for use in layouts or other style declarations. -->
+ <eat-comment />
+ <!-- A style that may be applied to horizontal LinearLayouts
+ to form a button bar. -->
+ <attr name="buttonBarStyle" format="reference" />
+ <!-- A style that may be applied to Buttons placed within a
+ LinearLayout with the style buttonBarStyle to form a button bar. -->
+ <attr name="buttonBarButtonStyle" format="reference" />
+ <!-- A style that may be applied to buttons or other selectable items
+ that should react to pressed and focus states, but that do not
+ have a clear visual border along the edges. -->
+ <attr name="selectableItemBackground" format="reference" />
+ <!-- A drawable that may be used as a vertical divider between visual elements. -->
+ <attr name="dividerVertical" format="reference" />
+ <!-- A drawable that may be used as a horizontal divider between visual elements. -->
+ <attr name="dividerHorizontal" format="reference" />
+
+ <!-- The preferred list item height. -->
+ <attr name="listPreferredItemHeight" format="dimension" />
+ <!-- A smaller, sleeker list item height. -->
+ <attr name="listPreferredItemHeightSmall" format="dimension" />
+ <!-- A larger, more robust list item height. -->
+ <attr name="listPreferredItemHeightLarge" format="dimension" />
+
+ <!-- The preferred padding along the left edge of list items. -->
+ <attr name="listPreferredItemPaddingLeft" format="dimension" />
+ <!-- The preferred padding along the right edge of list items. -->
+ <attr name="listPreferredItemPaddingRight" format="dimension" />
+
+ <!-- The preferred TextAppearance for the primary text of list items. -->
+ <attr name="textAppearanceListItem" format="reference" />
+ <!-- The preferred TextAppearance for the primary text of small list items. -->
+ <attr name="textAppearanceListItemSmall" format="reference" />
+
+ <attr name="title" format="string"/>
+ <attr name="height" format="dimension"/>
+
+
+ <!-- ============================================ -->
+
+ <!-- Attributes used to style the Action Bar.
+ These should be set on your theme; the default actionBarStyle will
+ propagate them to the correct elements as needed.
+
+ Please Note: when overriding attributes for an ActionBar style
+ you must specify each attribute twice: once with the "android:"
+ namespace prefix and once without. -->
+ <declare-styleable name="ActionBar">
+ <!-- The type of navigation to use. -->
+ <attr name="navigationMode">
+ <!-- Normal static title text -->
+ <enum name="normal" value="0" />
+ <!-- The action bar will use a selection list for navigation. -->
+ <enum name="listMode" value="1" />
+ <!-- The action bar will use a series of horizontal tabs for navigation. -->
+ <enum name="tabMode" value="2" />
+ </attr>
+ <!-- Options affecting how the action bar is displayed. -->
+ <attr name="displayOptions">
+ <flag name="useLogo" value="0x1" />
+ <flag name="showHome" value="0x2" />
+ <flag name="homeAsUp" value="0x4" />
+ <flag name="showTitle" value="0x8" />
+ <flag name="showCustom" value="0x10" />
+ <flag name="disableHome" value="0x20" />
+ </attr>
+ <!-- Specifies title text used for navigationMode="normal" -->
+ <attr name="title" />
+ <!-- Specifies subtitle text used for navigationMode="normal" -->
+ <attr name="subtitle" format="string" />
+ <!-- Specifies a style to use for title text. -->
+ <attr name="titleTextStyle" format="reference" />
+ <!-- Specifies a style to use for subtitle text. -->
+ <attr name="subtitleTextStyle" format="reference" />
+ <!-- Specifies the drawable used for the application icon. -->
+ <attr name="icon" format="reference" />
+ <!-- Specifies the drawable used for the application logo. -->
+ <attr name="logo" format="reference"/>
+ <!-- Specifies the drawable used for item dividers. -->
+ <attr name="divider" format="reference" />
+ <!-- Specifies a background drawable for the action bar. -->
+ <attr name="background" format="reference"/>
+ <!-- Specifies a background drawable for a second stacked row of the action bar. -->
+ <attr name="backgroundStacked" format="reference|color" />
+ <!-- Specifies a background drawable for the bottom component of a split action bar. -->
+ <attr name="backgroundSplit" format="reference|color" />
+ <!-- Specifies a layout for custom navigation. Overrides navigationMode. -->
+ <attr name="customNavigationLayout" format="reference" />
+ <!-- Specifies a fixed height. -->
+ <attr name="height"/>
+ <!-- Specifies a layout to use for the "home" section of the action bar. -->
+ <attr name="homeLayout" format="reference" />
+ <!-- Specifies a style resource to use for an embedded progress bar. -->
+ <attr name="progressBarStyle" format="reference" />
+ <!-- Specifies a style resource to use for an indeterminate progress spinner. -->
+ <attr name="indeterminateProgressStyle" format="reference" />
+ <!-- Specifies the horizontal padding on either end for an embedded progress bar. -->
+ <attr name="progressBarPadding" format="dimension" />
+ <!-- Specifies padding that should be applied to the left and right sides of
+ system-provided items in the bar. -->
+ <attr name="itemPadding" format="dimension" />
+ </declare-styleable>
+
+ <!-- Valid LayoutParams for views placed in the action bar as custom views. -->
+ <declare-styleable name="ActionBarLayout">
+ <attr name="android:layout_gravity" />
+ </declare-styleable>
+
+ <!-- TODO(trevorjohns): Write docs for this. -->
+ <declare-styleable name="ActionMenuItemView">
+ <attr name="android:minWidth" />
+ </declare-styleable>
+
+ <declare-styleable name="ActionMode">
+ <!-- Specifies a style to use for title text. -->
+ <attr name="titleTextStyle" />
+ <!-- Specifies a style to use for subtitle text. -->
+ <attr name="subtitleTextStyle" />
+ <!-- Specifies a background for the action mode bar. -->
+ <attr name="background" />
+ <!-- Specifies a background for the split action mode bar. -->
+ <attr name="backgroundSplit" />
+ <!-- Specifies a fixed height for the action mode bar. -->
+ <attr name="height"/>
+ </declare-styleable>
+
+ <!-- =================== -->
+ <!-- Action mode styles -->
+ <!-- =================== -->
+ <eat-comment />
+ <attr name="actionModeStyle" format="reference" />
+ <attr name="actionModeCloseButtonStyle" format="reference" />
+ <!-- Background drawable to use for action mode UI -->
+ <attr name="actionModeBackground" format="reference" />
+ <!-- Background drawable to use for action mode UI in the lower split bar -->
+ <attr name="actionModeSplitBackground" format="reference" />
+ <!-- Drawable to use for the close action mode button -->
+ <attr name="actionModeCloseDrawable" format="reference" />
+
+ <!-- Drawable to use for the Cut action button in Contextual Action Bar -->
+ <attr name="actionModeCutDrawable" format="reference" />
+ <!-- Drawable to use for the Copy action button in Contextual Action Bar -->
+ <attr name="actionModeCopyDrawable" format="reference" />
+ <!-- Drawable to use for the Paste action button in Contextual Action Bar -->
+ <attr name="actionModePasteDrawable" format="reference" />
+ <!-- Drawable to use for the Select all action button in Contextual Action Bar -->
+ <attr name="actionModeSelectAllDrawable" format="reference" />
+ <!-- Drawable to use for the Share action button in WebView selection action modes -->
+ <attr name="actionModeShareDrawable" format="reference" />
+ <!-- Drawable to use for the Find action button in WebView selection action modes -->
+ <attr name="actionModeFindDrawable" format="reference" />
+ <!-- Drawable to use for the Web Search action button in WebView selection action modes -->
+ <attr name="actionModeWebSearchDrawable" format="reference" />
+
+ <!-- PopupWindow style to use for action modes when showing as a window overlay. -->
+ <attr name="actionModePopupWindowStyle" format="reference" />
+
+ <!-- These are the standard attributes that make up a complete theme. -->
+ <declare-styleable name="Theme">
+ <!-- TODO(trevorjohns): Add other attributes! -->
+ <!-- Default ActionBar dropdown style. -->
+ <attr name="actionDropDownStylFe" format="reference" />
+ <!-- The preferred item height for dropdown lists. -->
+ <attr name="dropdownListPreferredItemHeight" format="dimension" />
+ <!-- Default PopupMenu style. -->
+ <attr name="popupMenuStyle" format="reference" />
+ <!-- Default ActionBar dropdown style. -->
+ <attr name="actionDropDownStyle" format="reference" />
+ </declare-styleable>
+
+ <declare-styleable name="MenuView">
+ <!-- Default appearance of menu item text. -->
+ <attr name="itemTextAppearance" format="reference" />
+ <!-- Default horizontal divider between rows of menu items. -->
+ <attr name="horizontalDivider" format="reference" />
+ <!-- Default vertical divider between menu items. -->
+ <attr name="verticalDivider" format="reference" />
+ <!-- Default background for the menu header. -->
+ <attr name="headerBackground" format="color|reference" />
+ <!-- Default background for each menu item. -->
+ <attr name="itemBackground" format="color|reference" />
+ <!-- Default animations for the menu. -->
+ <attr name="windowAnimationStyle" format="reference" />
+ <!-- Default disabled icon alpha for each menu item that shows an icon. -->
+ <attr name="itemIconDisabledAlpha" format="float" />
+ <!-- Whether space should be reserved in layout when an icon is missing. -->
+ <attr name="preserveIconSpacing" format="boolean" />
+ </declare-styleable>
+ <declare-styleable name="ActionMenuView">
+ <!-- Size of padding on either end of a divider. -->
+ </declare-styleable>
+
+ <attr name="dividerPadding" format="dimension" />
+
+</resources>
diff --git a/appcompat/res/values/bools.xml b/appcompat/res/values/bools.xml
new file mode 100644
index 0000000..8423ff8
--- /dev/null
+++ b/appcompat/res/values/bools.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <bool name="action_bar_embed_tabs">true</bool>
+ <bool name="action_bar_embed_tabs_pre_jb">false</bool>
+ <bool name="action_bar_expanded_action_views_exclusive">true</bool>
+ <bool name="split_action_bar_is_narrow">true</bool>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values/config.xml b/appcompat/res/values/config.xml
new file mode 100644
index 0000000..02859b3
--- /dev/null
+++ b/appcompat/res/values/config.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+ <!-- Whether action menu items should obey the "withText" showAsAction
+ flag. This may be set to false for situations where space is
+ extremely limited. -->
+ <bool name="config_allowActionMenuItemTextWithIcon">false</bool>
+
+ <!-- The maximum width we would prefer dialogs to be. 0 if there is no
+ maximum (let them grow as large as the screen). Actual values are
+ specified for -large and -xlarge configurations. -->
+ <dimen name="config_prefDialogWidth">320dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values/dimens.xml b/appcompat/res/values/dimens.xml
new file mode 100644
index 0000000..066f0c7
--- /dev/null
+++ b/appcompat/res/values/dimens.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <dimen name="action_bar_size">48dp</dimen>
+
+ <!-- Maximum height for a stacked tab bar as part of an action bar -->
+ <dimen name="action_bar_stacked_max_height">48dp</dimen>
+
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">2</integer>
+
+ <!-- Maximum width for a stacked action bar tab. This prevents
+ action bar tabs from becoming too wide on a wide screen when only
+ a few are present. -->
+ <dimen name="action_bar_stacked_tab_max_width">180dp</dimen>
+
+ <!-- Default height of an action bar. -->
+ <dimen name="action_bar_default_height">48dip</dimen>
+ <!-- Vertical padding around action bar icons. -->
+ <dimen name="action_bar_icon_vertical_padding">8dip</dimen>
+ <!-- Text size for action bar titles -->
+ <dimen name="action_bar_title_text_size">18dp</dimen>
+ <!-- Text size for action bar subtitles -->
+ <dimen name="action_bar_subtitle_text_size">14dp</dimen>
+ <!-- Top margin for action bar subtitles -->
+ <dimen name="action_bar_subtitle_top_margin">-3dp</dimen>
+ <!-- Bottom margin for action bar subtitles -->
+ <dimen name="action_bar_subtitle_bottom_margin">5dip</dimen>
+
+</resources>
diff --git a/appcompat/res/values/ids.xml b/appcompat/res/values/ids.xml
new file mode 100644
index 0000000..04822b3
--- /dev/null
+++ b/appcompat/res/values/ids.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <item type="id" name="home" />
+ <item type="id" name="action_bar_activity_content" />
+ <item type="id" name="action_menu_divider" />
+ <item type="id" name="action_menu_presenter" />
+</resources>
diff --git a/appcompat/res/values/strings.xml b/appcompat/res/values/strings.xml
new file mode 100644
index 0000000..6e71d16
--- /dev/null
+++ b/appcompat/res/values/strings.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Label for the "Done" button on the far left of action mode toolbars. -->
+ <string name="action_mode_done">Done</string>
+ <!-- Content description for the action bar "home" affordance. [CHAR LIMIT=NONE] -->
+ <string name="action_bar_home_description">Navigate home</string>
+ <!-- Content description for the action bar "up" affordance. [CHAR LIMIT=NONE] -->
+ <string name="action_bar_up_description">Navigate up</string>
+ <!-- Content description for the action menu overflow button. [CHAR LIMIT=NONE] -->
+ <string name="action_menu_overflow_description">More options</string>
+</resources>
\ No newline at end of file
diff --git a/appcompat/res/values/styles.xml b/appcompat/res/values/styles.xml
new file mode 100644
index 0000000..ec3e0c4
--- /dev/null
+++ b/appcompat/res/values/styles.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Like in themes.xml, the namespace "*.AppCompat.Base" is used to
+ define base styles for the platform version. The "*.AppCompat"
+ variants are for direct use or use as parent styles by the app. -->
+ <eat-comment />
+
+ <style name="Widget.AppCompat.Base.ActionBar" parent="">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton" parent="">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton.Overflow">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabBar" parent="">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabView" parent="">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabText" parent="">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionMode" parent="">
+ </style>
+
+
+ <style name="TextAppearance.AppCompat.Base.Widget.ActionBar.Menu"
+ parent="@android:style/TextAppearance.Small">
+ </style>
+
+ <!-- Default action bar style. Remember that if you are overriding
+ any attributes here in a derived style, you should declare each
+ item twice - both with and without the "android:" namespace prefix. -->
+ <style name="Widget.AppCompat.ActionBar" parent="Widget.AppCompat.Base.ActionBar">
+ <item name="android:height">?attr/actionBarSize</item>
+ <item name="android:background">@null</item>
+ <item name="android:divider">?attr/dividerVertical</item>
+ <item name="homeLayout">@layout/action_bar_home</item>
+ <!-- TODO(trevorjohns): Missing styles here, including padding. Note that padding was commented out in ActionBarOverlayLayout -->
+ </style>
+
+ <style name="Widget.AppCompat.ActionButton" parent="Widget.AppCompat.Base.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.ActionButton.Overflow">
+ </style>
+
+ <style name="Widget.AppCompat.ActionBar.TabBar" parent="Widget.AppCompat.Base.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.ActionBar.TabView" parent="Widget.AppCompat.Base.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.ActionBar.TabText" parent="Widget.AppCompat.Base.ActionBar.TabText">
+ <item name="android:maxWidth">180dip</item>
+ <item name="android:textAppearance">@android:style/TextAppearance.Widget.TextView</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textSize">18sp</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionBar.Menu"
+ parent="TextAppearance.AppCompat.Base.Widget.ActionBar.Menu">
+ <item name="android:textSize">12sp</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textColor">?attr/actionMenuTextColor</item>
+ </style>
+
+
+ <style name="Widget.AppCompat.ActionMode" parent="Widget.AppCompat.Base.ActionMode">
+ <item name="android:background">?attr/actionModeBackground</item>
+ <item name="backgroundSplit">?attr/actionModeSplitBackground</item>
+ <item name="android:height">?attr/actionBarSize</item>
+ <item name="titleTextStyle">@style/TextAppearance.Widget.ActionMode.Title</item>
+ <item name="subtitleTextStyle">@style/TextAppearance.Widget.ActionMode.Subtitle</item>
+ </style>
+
+ <style name="TextAppearance.Widget.ActionMode.Title"
+ parent="@android:style/TextAppearance.Medium">
+ </style>
+
+ <style name="TextAppearance.Widget.ActionMode.Subtitle"
+ parent="@android:style/TextAppearance.Small">
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
+ </style>
+
+</resources>
diff --git a/appcompat/res/values/themes.xml b/appcompat/res/values/themes.xml
new file mode 100644
index 0000000..3664ff0
--- /dev/null
+++ b/appcompat/res/values/themes.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Themes in the "Theme.Base" family vary based on the current platform
+ version to provide the correct basis on each device. You probably don't
+ want to use them directly in your apps.
+
+ Themes in the "Theme.AppCompat" family are meant to be extended or used
+ directly by apps. -->
+ <eat-comment />
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.Base.AppCompat" parent="@android:style/Theme">
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+
+ <item name="buttonBarStyle">@android:style/ButtonBar</item>
+ <item name="buttonBarButtonStyle">@android:style/Widget.Button</item>
+ <item name="selectableItemBackground">?android:attr/listSelector</item>
+
+ <item name="dividerVertical">@drawable/appcompat_divider_dark</item>
+ <item name="dividerHorizontal">@drawable/appcompat_divider_dark</item>
+ <item name="actionBarDivider">?attr/dividerVertical</item>
+
+ <item name="listPreferredItemHeight">64dp</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+
+ <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
+
+ <!-- List attributes -->
+ <item name="dropdownListPreferredItemHeight">64dip</item>
+ <!-- TODO(trevorjohns): The item below doesn't work. -->
+ <!-- <item name="popupMenuStyle">@android:style/Widget.PopupMenu</item> -->
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light" parent="@android:style/Theme.Light">
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+
+ <item name="buttonBarStyle">@android:style/ButtonBar</item>
+ <item name="buttonBarButtonStyle">@android:style/Widget.Button</item>
+ <item name="selectableItemBackground">?android:attr/listSelector</item>
+
+ <item name="dividerVertical">@drawable/appcompat_divider_light</item>
+ <item name="dividerHorizontal">@drawable/appcompat_divider_light</item>
+ <item name="actionBarDivider">?attr/dividerVertical</item>
+
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+
+ <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light.DarkActionBar" parent="Theme.Base.AppCompat.Light">
+ <item name="actionBarDivider">@drawable/appcompat_divider_dark</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.Base.AppCompat.DeviceDefault" parent="Theme.Base.AppCompat">
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.Base.AppCompat.DeviceDefault.Light" parent="Theme.Base.AppCompat.Light">
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar"
+ parent="Theme.Base.AppCompat.Light.DarkActionBar">
+ </style>
+
+ <!-- Themes in the "Theme.AppCompat" family will contain an action bar by default.
+ If Holo themes are available on the current platform version they will be used.
+ A limited Holo-styled action bar will be provided on platform versions older
+ than 3.0. (API 11)
+
+ These theme declarations contain any version-independent specification. Items
+ that need to vary based on platform version should be defined in the corresponding
+ "Theme.Base" theme. -->
+
+ <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.AppCompat" parent="Theme.Base.AppCompat">
+ <item name="windowActionBar">true</item>
+
+ <item name="actionBarTabStyle">@style/Widget.AppCompat.ActionBar.TabView</item>
+ <item name="actionBarTabBarStyle">@style/Widget.AppCompat.ActionBar.TabBar</item>
+ <item name="actionBarTabTextStyle">@style/Widget.AppCompat.ActionBar.TabText</item>
+ <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow</item>
+ <item name="actionBarStyle">@style/Widget.AppCompat.ActionBar</item>
+ <item name="actionBarWidgetTheme">@null</item>
+ <item name="actionBarSize">@dimen/action_bar_size</item>
+ <item name="actionBarDivider">?attr/dividerHorizontal</item>
+ <item name="actionBarItemBackground">?attr/selectableItemBackground</item>
+ <item name="actionMenuTextAppearance">@style/TextAppearance.AppCompat.Widget.ActionBar.Menu</item>
+ <item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
+ <!-- TODO(trevorjohns): Does not exist on API < 11. -->
+ <!-- <item name="actionDropDownStyle">@android:style/Widget_Spinner_DropDown</item> -->
+ </style>
+
+ <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.AppCompat.Light" parent="Theme.Base.AppCompat.Light">
+ <item name="windowActionBar">true</item>
+ </style>
+
+ <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.AppCompat.Light.DarkActionBar"
+ parent="Theme.Base.AppCompat.Light.DarkActionBar">
+ <item name="windowActionBar">true</item>
+ </style>
+
+ <!-- Platform-independent theme providing an action bar in a dark-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.AppCompat.DeviceDefault" parent="Theme.Base.AppCompat.DeviceDefault">
+ <item name="windowActionBar">true</item>
+ </style>
+
+ <!-- Platform-independent theme providing an action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.AppCompat.DeviceDefault.Light"
+ parent="Theme.Base.AppCompat.DeviceDefault.Light">
+ <item name="windowActionBar">true</item>
+ </style>
+
+ <!-- Platform-independent theme providing a dark action bar in a light-themed activity.
+ This theme will follow the device's default styling if available. -->
+ <style name="Theme.AppCompat.DeviceDefault.Light.DarkActionBar"
+ parent="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar">
+ <item name="windowActionBar">true</item>
+ </style>
+</resources>
diff --git a/v4/java/android/support/v4/view/ViewPager.java b/v4/java/android/support/v4/view/ViewPager.java
index 62e86fd..966fcbc 100644
--- a/v4/java/android/support/v4/view/ViewPager.java
+++ b/v4/java/android/support/v4/view/ViewPager.java
@@ -464,6 +464,10 @@
mAdapterChangeListener = listener;
}
+ private int getClientWidth() {
+ return getWidth() - getPaddingLeft() - getPaddingRight();
+ }
+
/**
* Set the currently selected page. If the ViewPager has already been through its first
* layout with its current adapter there will be a smooth animated transition between
@@ -529,7 +533,7 @@
final ItemInfo curInfo = infoForPosition(item);
int destX = 0;
if (curInfo != null) {
- final int width = getWidth();
+ final int width = getClientWidth();
destX = (int) (width * Math.max(mFirstOffset,
Math.min(curInfo.offset, mLastOffset)));
}
@@ -774,7 +778,7 @@
setScrollingCacheEnabled(true);
setScrollState(SCROLL_STATE_SETTLING);
- final int width = getWidth();
+ final int width = getClientWidth();
final int halfWidth = width / 2;
final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
final float distance = halfWidth + halfWidth *
@@ -937,7 +941,8 @@
float extraWidthLeft = 0.f;
int itemIndex = curIndex - 1;
ItemInfo ii = itemIndex >= 0 ? mItems.get(itemIndex) : null;
- final float leftWidthNeeded = 2.f - curItem.widthFactor;
+ final float leftWidthNeeded = 2.f - curItem.widthFactor +
+ (float) getPaddingLeft() / (float) getClientWidth();
for (int pos = mCurItem - 1; pos >= 0; pos--) {
if (extraWidthLeft >= leftWidthNeeded && pos < startPos) {
if (ii == null) {
@@ -970,8 +975,10 @@
itemIndex = curIndex + 1;
if (extraWidthRight < 2.f) {
ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
+ final float rightWidthNeeded = (float) getPaddingRight() / (float) getClientWidth()
+ + 2.f;
for (int pos = mCurItem + 1; pos < N; pos++) {
- if (extraWidthRight >= 2.f && pos > endPos) {
+ if (extraWidthRight >= rightWidthNeeded && pos > endPos) {
if (ii == null) {
break;
}
@@ -1059,7 +1066,7 @@
private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
final int N = mAdapter.getCount();
- final int width = getWidth();
+ final int width = getClientWidth();
final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
// Fix up offsets for later layout.
if (oldCurInfo != null) {
@@ -1396,8 +1403,9 @@
private void recomputeScrollPosition(int width, int oldWidth, int margin, int oldMargin) {
if (oldWidth > 0 && !mItems.isEmpty()) {
- final int widthWithMargin = width + margin;
- final int oldWidthWithMargin = oldWidth + oldMargin;
+ final int widthWithMargin = width - getPaddingLeft() - getPaddingRight() + margin;
+ final int oldWidthWithMargin = oldWidth - getPaddingLeft() - getPaddingRight()
+ + oldMargin;
final int xpos = getScrollX();
final float pageOffset = (float) xpos / oldWidthWithMargin;
final int newOffsetPixels = (int) (pageOffset * widthWithMargin);
@@ -1413,7 +1421,8 @@
} else {
final ItemInfo ii = infoForPosition(mCurItem);
final float scrollOffset = ii != null ? Math.min(ii.offset, mLastOffset) : 0;
- final int scrollPos = (int) (scrollOffset * width);
+ final int scrollPos = (int) (scrollOffset *
+ (width - getPaddingLeft() - getPaddingRight()));
if (scrollPos != getScrollX()) {
completeScroll(false);
scrollTo(scrollPos, getScrollY());
@@ -1492,6 +1501,7 @@
}
}
+ final int childWidth = width - paddingLeft - paddingRight;
// Page views. Do this once we have the right padding offsets from above.
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
@@ -1499,7 +1509,7 @@
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
ItemInfo ii;
if (!lp.isDecor && (ii = infoForChild(child)) != null) {
- int loff = (int) (width * ii.offset);
+ int loff = (int) (childWidth * ii.offset);
int childLeft = paddingLeft + loff;
int childTop = paddingTop;
if (lp.needsMeasure) {
@@ -1507,7 +1517,7 @@
// Do it now that we know what we're working with.
lp.needsMeasure = false;
final int widthSpec = MeasureSpec.makeMeasureSpec(
- (int) ((width - paddingLeft - paddingRight) * lp.widthFactor),
+ (int) (childWidth * lp.widthFactor),
MeasureSpec.EXACTLY);
final int heightSpec = MeasureSpec.makeMeasureSpec(
(int) (height - paddingTop - paddingBottom),
@@ -1565,7 +1575,7 @@
return false;
}
final ItemInfo ii = infoForCurrentScrollPosition();
- final int width = getWidth();
+ final int width = getClientWidth();
final int widthWithMargin = width + mPageMargin;
final float marginOffset = (float) mPageMargin / width;
final int currentPage = ii.position;
@@ -1658,7 +1668,7 @@
if (lp.isDecor) continue;
- final float transformPos = (float) (child.getLeft() - scrollX) / getWidth();
+ final float transformPos = (float) (child.getLeft() - scrollX) / getClientWidth();
mPageTransformer.transformPage(child, transformPos);
}
}
@@ -1927,7 +1937,7 @@
int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
velocityTracker, mActivePointerId);
mPopulatePending = true;
- final int width = getWidth();
+ final int width = getClientWidth();
final int scrollX = getScrollX();
final ItemInfo ii = infoForCurrentScrollPosition();
final int currentPage = ii.position;
@@ -1980,7 +1990,7 @@
float oldScrollX = getScrollX();
float scrollX = oldScrollX + deltaX;
- final int width = getWidth();
+ final int width = getClientWidth();
float leftBound = width * mFirstOffset;
float rightBound = width * mLastOffset;
@@ -2024,7 +2034,7 @@
* This can be synthetic for a missing middle page; the 'object' field can be null.
*/
private ItemInfo infoForCurrentScrollPosition() {
- final int width = getWidth();
+ final int width = getClientWidth();
final float scrollOffset = width > 0 ? (float) getScrollX() / width : 0;
final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
int lastPos = -1;
@@ -2228,7 +2238,7 @@
int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
velocityTracker, mActivePointerId);
mPopulatePending = true;
- final int width = getWidth();
+ final int width = getClientWidth();
final int scrollX = getScrollX();
final ItemInfo ii = infoForCurrentScrollPosition();
final int currentPage = ii.position;
@@ -2258,7 +2268,7 @@
float oldScrollX = getScrollX();
float scrollX = oldScrollX - xOffset;
- final int width = getWidth();
+ final int width = getClientWidth();
float leftBound = width * mFirstOffset;
float rightBound = width * mLastOffset;