From 23caec047182a85869f56c9ca0ae9125227734fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Helper for implementing the action bar design pattern across all versions
- * of Android. This class will manage interaction with a custom action bar based on the
- * Android 4.0 source code. The exposed API mirrors that of its native
- * counterpart and you should refer to its documentation for instruction. Denotes an implementation of ActionBarSherlock which provides an
- * action bar-enhanced experience.
- * @Override
- * protected void onStop() {
- * mSherlock.dispatchStop();
- * super.onStop();
- * }
- *
- * @Override
- * public void openOptionsMenu() {
- * if (!mSherlock.dispatchOpenOptionsMenu()) {
- * super.openOptionsMenu();
- * }
- * }
- *
- * @Override
- * public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- * return mSherlock.dispatchPrepareOptionsMenu(menu);
- * }
- *
- * @Override
- * public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- * return mSherlock.dispatchOptionsItemSelected(item);
- * }
- *
- * @Override
- * public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- * if (mSherlock.dispatchMenuOpened(featureId, menu)) {
- * return true;
- * }
- * return super.onMenuOpened(featureId, menu);
- * }
- *
- * @Override
- * public void onPanelClosed(int featureId, android.view.Menu menu) {
- * mSherlock.dispatchPanelClosed(featureId, menu);
- * super.onPanelClosed(featureId, menu);
- * }
- *
- * @Override
- * public void onDestroy() {
- * mSherlock.dispatchDestroy();
- * super.onDestroy();
- * }
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param visible Whether to show the progress bars in the title.
- */
- public abstract void setProgressBarVisibility(boolean visible);
-
- /**
- * Sets the visibility of the indeterminate progress bar in the title.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param visible Whether to show the progress bars in the title.
- */
- public abstract void setProgressBarIndeterminateVisibility(boolean visible);
-
- /**
- * Sets whether the horizontal progress bar in the title should be indeterminate (the circular
- * is always indeterminate).
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param indeterminate Whether the horizontal progress bar should be indeterminate.
- */
- public abstract void setProgressBarIndeterminate(boolean indeterminate);
-
- /**
- * Sets the progress for the progress bars in the title.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param progress The progress for the progress bar. Valid ranges are from
- * 0 to 10000 (both inclusive). If 10000 is given, the progress
- * bar will be completely filled and will fade out.
- */
- public abstract void setProgress(int progress);
-
- /**
- * Sets the secondary progress for the progress bar in the title. This
- * progress is drawn between the primary progress (set via
- * {@link #setProgress(int)} and the background. It can be ideal for media
- * scenarios such as showing the buffering progress while the default
- * progress shows the play progress.
- *
- * In order for the progress bar to be shown, the feature must be requested
- * via {@link #requestWindowFeature(int)}.
- *
- * @param secondaryProgress The secondary progress for the progress bar. Valid ranges are from
- * 0 to 10000 (both inclusive).
- */
- public abstract void setSecondaryProgress(int secondaryProgress);
-
- /**
- * Get a menu inflater instance which supports the newer menu attributes.
- *
- * @return Menu inflater instance.
- */
- public MenuInflater getMenuInflater() {
- if (DEBUG) Log.d(TAG, "[getMenuInflater]");
-
- // Make sure that action views can get an appropriate theme.
- if (mMenuInflater == null) {
- if (getActionBar() != null) {
- mMenuInflater = new MenuInflater(getThemedContext(), mActivity);
- } else {
- mMenuInflater = new MenuInflater(mActivity);
- }
- }
- return mMenuInflater;
- }
-
- protected abstract Context getThemedContext();
-
- /**
- * Start an action mode.
- *
- * @param callback Callback that will manage lifecycle events for this
- * context mode.
- * @return The ContextMode that was started, or null if it was canceled.
- * @see ActionMode
- */
- public abstract ActionMode startActionMode(ActionMode.Callback callback);
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java
deleted file mode 100644
index 03755be2b..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
- * 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 com.actionbarsherlock.app;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.support.v4.app.FragmentTransaction;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewDebug;
-import android.view.ViewGroup;
-import android.view.ViewGroup.MarginLayoutParams;
-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.
- * 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.
- * 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. From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
- * android.app.Activity#getActionBar getActionBar()}. 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}.
- * For information about how to use the action bar, including how to add action items, navigation
- * modes and more, read the Action
- * Bar developer guide. 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 = android.app.ActionBar.DISPLAY_HOME_AS_UP;
-
- /**
- * 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 = android.app.ActionBar.DISPLAY_SHOW_TITLE;
-
- /**
- * 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 = android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
-
- /**
- * 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.
- *
- * 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. The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
- * the custom view to be displayed. 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. The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
- * the custom view to be displayed. 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- * 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:
- * Very often tabs will be used to switch between {@link Fragment}
- * objects. Here is a typical implementation of such tabs: Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}. 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.
- *
- * 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.
- *
- * 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 {
- private static final int[] ATTRS = new int[] {
- android.R.attr.layout_gravity
- };
-
- /**
- * Gravity for the view associated with these LayoutParams.
- *
- * @see android.view.Gravity
- */
- @ViewDebug.ExportedProperty(mapping = {
- @ViewDebug.IntToString(from = -1, to = "NONE"),
- @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),
- @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),
- @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),
- @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),
- @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),
- @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),
- @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),
- @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
- @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),
- @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),
- @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")
- })
- public int gravity = -1;
-
- public LayoutParams(Context c, AttributeSet attrs) {
- super(c, attrs);
-
- TypedArray a = c.obtainStyledAttributes(attrs, ATTRS);
- gravity = a.getInt(0, -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);
- }
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java
deleted file mode 100644
index 7b4543640..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java
+++ /dev/null
@@ -1,270 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.ViewGroup.LayoutParams;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockActivity extends Activity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- getSherlock().dispatchSaveInstanceState(outState);
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- getSherlock().dispatchRestoreInstanceState(savedInstanceState);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java
deleted file mode 100644
index a7c856bf0..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.support.v4.app.DialogFragment;
-import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
-
-public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
- private SherlockFragmentActivity mActivity;
-
- public SherlockFragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof SherlockFragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (SherlockFragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
- onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public final void onPrepareOptionsMenu(android.view.Menu menu) {
- onPrepareOptionsMenu(new MenuWrapper(menu));
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return onOptionsItemSelected(new MenuItemWrapper(item));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java
deleted file mode 100644
index 078f9b0ca..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.ExpandableListActivity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockExpandableListActivity extends ExpandableListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java
deleted file mode 100644
index 0f24e9c85..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.support.v4.app.Fragment;
-import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
-
-public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
- private SherlockFragmentActivity mActivity;
-
- public SherlockFragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof SherlockFragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (SherlockFragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
- onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public final void onPrepareOptionsMenu(android.view.Menu menu) {
- onPrepareOptionsMenu(new MenuWrapper(menu));
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return onOptionsItemSelected(new MenuItemWrapper(item));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
deleted file mode 100644
index 3d092f033..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
+++ /dev/null
@@ -1,303 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.support.v4.app.Watson;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-
-/** @see {@link android.support.v4.app.Watson} */
-public class SherlockFragmentActivity extends Watson implements OnActionModeStartedListener, OnActionModeFinishedListener {
- private static final boolean DEBUG = false;
- private static final String TAG = "SherlockFragmentActivity";
-
- private ActionBarSherlock mSherlock;
- private boolean mIgnoreNativeCreate = false;
- private boolean mIgnoreNativePrepare = false;
- private boolean mIgnoreNativeSelected = false;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- getSherlock().dispatchSaveInstanceState(outState);
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- getSherlock().dispatchRestoreInstanceState(savedInstanceState);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]");
-
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]");
-
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]");
-
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreatePanelMenu(int featureId, android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu);
-
- if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeCreate) {
- mIgnoreNativeCreate = true;
- boolean result = getSherlock().dispatchCreateOptionsMenu(menu);
- mIgnoreNativeCreate = false;
-
- if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result);
- return result;
- }
- return super.onCreatePanelMenu(featureId, menu);
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return true;
- }
-
- @Override
- public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
- if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu);
-
- if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) {
- mIgnoreNativePrepare = true;
- boolean result = getSherlock().dispatchPrepareOptionsMenu(menu);
- mIgnoreNativePrepare = false;
-
- if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result);
- return result;
- }
- return super.onPreparePanel(featureId, view, menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return true;
- }
-
- @Override
- public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
- if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);
-
- if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) {
- mIgnoreNativeSelected = true;
- boolean result = getSherlock().dispatchOptionsItemSelected(item);
- mIgnoreNativeSelected = false;
-
- if (DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result);
- return result;
- }
- return super.onMenuItemSelected(featureId, item);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return false;
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java
deleted file mode 100644
index aba6d85e8..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java
+++ /dev/null
@@ -1,270 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.ListActivity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.ViewGroup.LayoutParams;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockListActivity extends ListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- getSherlock().dispatchSaveInstanceState(outState);
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- getSherlock().dispatchRestoreInstanceState(savedInstanceState);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java
deleted file mode 100644
index 13ca3c49f..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.app.Activity;
-import android.support.v4.app.ListFragment;
-import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
-import com.actionbarsherlock.internal.view.menu.MenuWrapper;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
-import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
-
-public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
- private SherlockFragmentActivity mActivity;
-
- public SherlockFragmentActivity getSherlockActivity() {
- return mActivity;
- }
-
- @Override
- public void onAttach(Activity activity) {
- if (!(activity instanceof SherlockFragmentActivity)) {
- throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
- }
- mActivity = (SherlockFragmentActivity)activity;
-
- super.onAttach(activity);
- }
-
- @Override
- public void onDetach() {
- mActivity = null;
- super.onDetach();
- }
-
- @Override
- public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
- onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- //Nothing to see here.
- }
-
- @Override
- public final void onPrepareOptionsMenu(android.view.Menu menu) {
- onPrepareOptionsMenu(new MenuWrapper(menu));
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- //Nothing to see here.
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return onOptionsItemSelected(new MenuItemWrapper(item));
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- //Nothing to see here.
- return false;
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java
deleted file mode 100644
index bee72cb25..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java
+++ /dev/null
@@ -1,270 +0,0 @@
-package com.actionbarsherlock.app;
-
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
-import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
-import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-public abstract class SherlockPreferenceActivity extends PreferenceActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
- private ActionBarSherlock mSherlock;
-
- protected final ActionBarSherlock getSherlock() {
- if (mSherlock == null) {
- mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
- }
- return mSherlock;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Action bar and mode
- ///////////////////////////////////////////////////////////////////////////
-
- public ActionBar getSupportActionBar() {
- return getSherlock().getActionBar();
- }
-
- public ActionMode startActionMode(ActionMode.Callback callback) {
- return getSherlock().startActionMode(callback);
- }
-
- @Override
- public void onActionModeStarted(ActionMode mode) {}
-
- @Override
- public void onActionModeFinished(ActionMode mode) {}
-
-
- ///////////////////////////////////////////////////////////////////////////
- // General lifecycle/callback dispatching
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- getSherlock().dispatchConfigurationChanged(newConfig);
- }
-
- @Override
- protected void onPostResume() {
- super.onPostResume();
- getSherlock().dispatchPostResume();
- }
-
- @Override
- protected void onPause() {
- getSherlock().dispatchPause();
- super.onPause();
- }
-
- @Override
- protected void onStop() {
- getSherlock().dispatchStop();
- super.onStop();
- }
-
- @Override
- protected void onDestroy() {
- getSherlock().dispatchDestroy();
- super.onDestroy();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- getSherlock().dispatchPostCreate(savedInstanceState);
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- protected void onTitleChanged(CharSequence title, int color) {
- getSherlock().dispatchTitleChanged(title, color);
- super.onTitleChanged(title, color);
- }
-
- @Override
- public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
- if (getSherlock().dispatchMenuOpened(featureId, menu)) {
- return true;
- }
- return super.onMenuOpened(featureId, menu);
- }
-
- @Override
- public void onPanelClosed(int featureId, android.view.Menu menu) {
- getSherlock().dispatchPanelClosed(featureId, menu);
- super.onPanelClosed(featureId, menu);
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (getSherlock().dispatchKeyEvent(event)) {
- return true;
- }
- return super.dispatchKeyEvent(event);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- getSherlock().dispatchSaveInstanceState(outState);
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- getSherlock().dispatchRestoreInstanceState(savedInstanceState);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Native menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- public MenuInflater getSupportMenuInflater() {
- return getSherlock().getMenuInflater();
- }
-
- public void invalidateOptionsMenu() {
- getSherlock().dispatchInvalidateOptionsMenu();
- }
-
- public void supportInvalidateOptionsMenu() {
- invalidateOptionsMenu();
- }
-
- @Override
- public final boolean onCreateOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchCreateOptionsMenu(menu);
- }
-
- @Override
- public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
- return getSherlock().dispatchPrepareOptionsMenu(menu);
- }
-
- @Override
- public final boolean onOptionsItemSelected(android.view.MenuItem item) {
- return getSherlock().dispatchOptionsItemSelected(item);
- }
-
- @Override
- public void openOptionsMenu() {
- if (!getSherlock().dispatchOpenOptionsMenu()) {
- super.openOptionsMenu();
- }
- }
-
- @Override
- public void closeOptionsMenu() {
- if (!getSherlock().dispatchCloseOptionsMenu()) {
- super.closeOptionsMenu();
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Sherlock menu handling
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean onCreatePanelMenu(int featureId, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onCreateOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onPreparePanel(int featureId, View view, Menu menu) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onPrepareOptionsMenu(menu);
- }
- return false;
- }
-
- public boolean onPrepareOptionsMenu(Menu menu) {
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (featureId == Window.FEATURE_OPTIONS_PANEL) {
- return onOptionsItemSelected(item);
- }
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- return false;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Content
- ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public void addContentView(View view, LayoutParams params) {
- getSherlock().addContentView(view, params);
- }
-
- @Override
- public void setContentView(int layoutResId) {
- getSherlock().setContentView(layoutResId);
- }
-
- @Override
- public void setContentView(View view, LayoutParams params) {
- getSherlock().setContentView(view, params);
- }
-
- @Override
- public void setContentView(View view) {
- getSherlock().setContentView(view);
- }
-
- public void requestWindowFeature(long featureId) {
- getSherlock().requestFeature((int)featureId);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Progress Indication
- ///////////////////////////////////////////////////////////////////////////
-
- public void setSupportProgress(int progress) {
- getSherlock().setProgress(progress);
- }
-
- public void setSupportProgressBarIndeterminate(boolean indeterminate) {
- getSherlock().setProgressBarIndeterminate(indeterminate);
- }
-
- public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
- getSherlock().setProgressBarIndeterminateVisibility(visible);
- }
-
- public void setSupportProgressBarVisibility(boolean visible) {
- getSherlock().setProgressBarVisibility(visible);
- }
-
- public void setSupportSecondaryProgress(int secondaryProgress) {
- getSherlock().setSecondaryProgress(secondaryProgress);
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
deleted file mode 100644
index 5e69275c7..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
+++ /dev/null
@@ -1,1203 +0,0 @@
-package com.actionbarsherlock.internal;
-
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import org.xmlpull.v1.XmlPullParser;
-import android.app.Activity;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.res.AssetManager;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
-import android.os.Bundle;
-import android.util.AndroidRuntimeException;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.ContextThemeWrapper;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewStub;
-import android.view.Window;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-import com.actionbarsherlock.ActionBarSherlock;
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.internal.app.ActionBarImpl;
-import com.actionbarsherlock.internal.view.StandaloneActionMode;
-import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
-import com.actionbarsherlock.internal.view.menu.MenuBuilder;
-import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
-import com.actionbarsherlock.internal.view.menu.MenuPresenter;
-import com.actionbarsherlock.internal.widget.ActionBarContainer;
-import com.actionbarsherlock.internal.widget.ActionBarContextView;
-import com.actionbarsherlock.internal.widget.ActionBarView;
-import com.actionbarsherlock.internal.widget.IcsProgressBar;
-import com.actionbarsherlock.view.ActionMode;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-
-@ActionBarSherlock.Implementation(api = 7)
-public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener {
- /** Window features which are enabled by default. */
- protected static final int DEFAULT_FEATURES = 0;
-
- static private final String PANELS_TAG = "sherlock:Panels";
-
- public ActionBarSherlockCompat(Activity activity, int flags) {
- super(activity, flags);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- // Properties
- ///////////////////////////////////////////////////////////////////////////
-
- /** Whether or not the device has a dedicated menu key button. */
- private boolean mReserveOverflow;
- /** Lazy-load indicator for {@link #mReserveOverflow}. */
- private boolean mReserveOverflowSet = false;
-
- /** Current menu instance for managing action items. */
- private MenuBuilder mMenu;
- /** Map between native options items and sherlock items. */
- protected HashMap The animation started by calling this method will be run on the thread that called
- * this method. This thread should have a Looper on it (a runtime exception will be thrown if
- * this is not the case). Also, if the animation will animate
- * properties of objects in the view hierarchy, then the calling thread should be the UI
- * thread for that view hierarchy. This method must be called on the thread that is running the animation. This method must be called on the thread that is running the animation. An animation listener receives notifications from an animation.
- * Notifications indicate animation related events, such as the end or the
- * repetition of the animation. Notifies the start of the animation. Notifies the end of the animation. This callback is not invoked
- * for animations with repeat count set to INFINITE. Notifies the cancellation of the animation. This callback is not invoked
- * for animations with repeat count set to INFINITE. Notifies the repetition of the animation. There are two different approaches to adding animations to a It is possible to set up a Note that Note that ending a Starting this The For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to
- * play when anim2 finishes, and anim4 to play when anim3 finishes: Note in the example that both {@link Builder#before(Animator)} and {@link
- * Builder#after(Animator)} are used. These are just different ways of expressing the same
- * relationship and are provided to make it easier to say things in a way that is more natural,
- * depending on the situation. It is possible to make several calls into the same Note that it is possible to express relationships that cannot be resolved and will not
- * result in sensible results. For example, This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
- * int, exists to speed up the getValue() method when there is no custom
- * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
- * Object equivalents of these primitive types. This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
- * float, exists to speed up the getValue() method when there is no custom
- * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
- * Object equivalents of these primitive types. The Keyframe class itself is abstract. The type-specific factory methods will return
- * a subclass of Keyframe specific to the type of value being stored. This is done to improve
- * performance when dealing with the most common cases (e.g., For best performance of the mechanism that calls the setter function determined by the
- * name of the property being animated, use Note that the setter function derived from this property name
- * must take the same parameter type as the
- * If this ObjectAnimator has been set up to animate several properties together,
- * using more than one PropertyValuesHolder objects, then setting the propertyName simply
- * sets the propertyName in the first of those PropertyValuesHolder objects. Overriders of this method should call the superclass method to cause
- * internal mechanisms to be set up correctly. Overrides of this method must call the superclass to perform the calculation
- * of the animated value. If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling the property's
- * {@link android.util.Property#get(Object)} function.
- * Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction with
- * {@link ObjectAnimator}, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- * @param property The property associated with this set of values. Should not be null.
- * @param values The set of values to animate between.
- */
- //public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) {
- // KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
- // if (keyframeSet instanceof IntKeyframeSet) {
- // return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet);
- // } else if (keyframeSet instanceof FloatKeyframeSet) {
- // return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet);
- // }
- // else {
- // PropertyValuesHolder pvh = new PropertyValuesHolder(property);
- // pvh.mKeyframeSet = keyframeSet;
- // pvh.mValueType = ((Keyframe)values[0]).getType();
- // return pvh;
- // }
- //}
-
- /**
- * Set the animated values for this object to this set of ints.
- * If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from Note that the setter function derived from this property name
- * must take the same parameter type as the
- * Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property
- * must exist on the target object specified in that ObjectAnimator. There is a single timing pulse that all animations use. It runs in a
- * custom handler to ensure that property changes happen on the UI thread. By default, ValueAnimator uses non-linear time interpolation, via the
- * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates
- * out of an animation. This behavior can be changed by calling
- * {@link ValueAnimator#setInterpolator(TimeInterpolator)}. Since ValueAnimator does not know how to animate between arbitrary Objects, this
- * factory method also takes a TypeEvaluator object that the ValueAnimator will use
- * to perform that interpolation.
- *
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the ncessry interpolation between the Object values to derive the animated
- * value.
- * @param values A set of values that the animation will animate between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setObjectValues(values);
- anim.setEvaluator(evaluator);
- return anim;
- }
-
- /**
- * Sets int values that will be animated between. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- * If there are already multiple sets of values defined for this ValueAnimator via more
- * than one PropertyValuesHolder object, this method will set the values for the first
- * of those objects. If there are already multiple sets of values defined for this ValueAnimator via more
- * than one PropertyValuesHolder object, this method will set the values for the first
- * of those objects. If there are already multiple sets of values defined for this ValueAnimator via more
- * than one PropertyValuesHolder object, this method will set the values for the first
- * of those objects. There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate
- * between these value objects. ValueAnimator only knows how to interpolate between the
- * primitive types specified in the other setValues() methods. Overrides of this method should call the superclass method to ensure
- * that internal mechanisms for the animation are set up correctly. If this ValueAnimator has only one set of values being animated between, this evaluator
- * will be used for that set. If there are several sets of values being animated, which is
- * the case if PropertyValuesHOlder objects were set on the ValueAnimator, then the evaluator
- * is assigned just to the first PropertyValuesHolder object. The animation started by calling this method will be run on the thread that called
- * this method. This thread should have a Looper on it (a runtime exception will be thrown if
- * this is not the case). Also, if the animation will animate
- * properties of objects in the view hierarchy, then the calling thread should be the UI
- * thread for that view hierarchy. Overrides of this method must call the superclass to perform the calculation
- * of the animated value. Notifies the occurrence of another frame of the animation. 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);
-
- int cellsUsed = 0;
- if (cellsRemaining > 0) {
- 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++;
- }
-
- final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
- (ActionMenuItemView) child : null;
- final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.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 = 0;//getDividerWidth();
- int overflowWidth = 0;
- //UNUSED 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();
- 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;
- //UNUSED nonOverflowWidth += size;
- widthRemaining -= size;
- //if (hasDividerBeforeChildAt(i)) {
- //UNUSED 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;
- }
-
- //@Override
- protected boolean hasDividerBeforeChildAt(int childIndex) {
- if (childIndex == 0) {
- return false;
- }
- 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 {
- public boolean isOverflowButton;
- public int cellsUsed;
- public int extraPixels;
- public boolean expandable;
- 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/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java
deleted file mode 100644
index 6da26f2ae..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * 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 com.actionbarsherlock.internal.view.menu;
-
-import java.util.ArrayList;
-import android.content.Context;
-import android.os.Build;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-/**
- * 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 {
- private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
-
- 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;
- }
-
- @Override
- 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 Items are considered for inclusion in the order specified within the menu.
- * There is a limit of mMaxActionItems as a total count, optionally including the overflow
- * menu button itself. This is a soft limit; if an item shares a group ID with an item
- * previously included as an action item, the new item will stay with its group and become
- * an action item itself even if it breaks the max item count limit. This is done to
- * limit the conceptual complexity of the items presented within an action bar. Only a few
- * unrelated concepts should be presented to the user in this space, and groups are treated
- * as a single concept.
- *
- * There is also a hard limit of consumed measurable space: mActionWidthLimit. This
- * limit may be broken by a single item that exceeds the remaining space, but no further
- * items may be added. If an item that is part of a group cannot fit within the remaining
- * measured width, the entire group will be demoted to overflow. This is done to ensure room
- * for navigation and other affordances in the action bar as well as reduce general UI clutter.
- *
- * The space freed by demoting a full group cannot be consumed by future menu items.
- * Once items begin to overflow, all future items become overflow items as well. This is
- * to avoid inadvertent reordering that may break the app's intended design.
- */
- public void flagActionItems() {
- if (!mIsActionItemsStale) {
- return;
- }
-
- // Presenters flag action items as needed.
- boolean flagged = false;
- for (WeakReference
- * See {@link ListView}, {@link GridView}, {@link Spinner} and
- * {@link Gallery} for commonly used subclasses of AdapterView.
- *
- * For more information about using AdapterView, read the
- * Binding to Data with AdapterView
- * developer guide. Callback method to be invoked when an item in this view has been
- * selected. This callback is invoked only when the newly selected
- * position is different from the previously selected position or if
- * there was no selected item.
- * Visual indicator of progress in some operation. Displays a bar to the user
- * representing how far the operation has progressed; the application can
- * change the amount of progress (modifying the length of the bar) as it moves
- * forward. There is also a secondary progress displayable on a progress bar
- * which is useful for displaying intermediate progress, such as the buffer
- * level during a streaming playback progress bar.
- *
- * A progress bar can also be made indeterminate. In indeterminate mode, the
- * progress bar shows a cyclic animation without an indication of progress. This mode is used by
- * applications when the length of the task is unknown. The indeterminate progress bar can be either
- * a spinning wheel or a horizontal bar.
- * The following code example shows how a progress bar can be used from
- * a worker thread to update the user interface to notify the user of progress:
- * To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element.
- * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a
- * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal
- * Widget.ProgressBar.Horizontal} style, like so: If you will use the progress bar to show real progress, you must use the horizontal bar. You
- * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or
- * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If
- * necessary, you can adjust the maximum value (the value for a full bar) using the {@link
- * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed
- * below. Another common style to apply to the progress bar is {@link
- * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller
- * version of the spinning wheel—useful when waiting for content to load.
- * For example, you can insert this kind of progress bar into your default layout for
- * a view that will be populated by some content fetched from the Internet—the spinning wheel
- * appears immediately and when your application receives the content, it replaces the progress bar
- * with the loaded content. For example: Other progress bar styles provided by the system include: The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary
- * if your application uses a light colored theme (a white background). XML attributes
- *
- * See {@link android.R.styleable#ProgressBar ProgressBar Attributes},
- * {@link android.R.styleable#View View Attributes}
- *
- * Initialize the progress bar's default values:
- * Indicate whether this progress bar is in indeterminate mode. Change the indeterminate mode for this progress bar. In indeterminate
- * mode, the progress is ignored and the progress bar shows an infinite
- * animation instead. Get the drawable used to draw the progress bar in
- * indeterminate mode. Define the drawable used to draw the progress bar in
- * indeterminate mode. Get the drawable used to draw the progress bar in
- * progress mode. Define the drawable used to draw the progress bar in
- * progress mode. Set the current progress to the specified value. Does not do anything
- * if the progress bar is in indeterminate mode.
- * Set the current secondary progress to the specified value. Does not do
- * anything if the progress bar is in indeterminate mode.
- * Get the progress bar's current level of progress. Return 0 when the
- * progress bar is in indeterminate mode. Get the progress bar's current level of secondary progress. Return 0 when the
- * progress bar is in indeterminate mode. Return the upper limit of this progress bar's range. Set the range of the progress bar to 0...max. Increase the progress bar's progress by the specified amount. Increase the progress bar's secondary progress by the specified amount. Start the indeterminate progress animation. Stop the indeterminate progress animation. See the Spinner
- * tutorial. A spinner does not support item click events. Calling this method
- * will raise an exception. Wrapper class for an Adapter. Transforms the embedded Adapter instance
- * into a ListAdapter. Creates a new ListAdapter wrapper for the specified adapter. 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.
- *
- * 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 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.
- *
- * An action mode's lifecycle is as follows:
- *
- * 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.
- *
- * There are two ways for using an action provider for creating and handling of action views:
- *
- * 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.
- *
- * A menu item selection is processed in the following order:
- *
- * The default implementation does not perform any action and returns false.
- * 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.
- *
- * 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/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java
deleted file mode 100644
index 43281b013..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 com.actionbarsherlock.view;
-
-/**
- * When a {@link View} implements this interface it will receive callbacks
- * when expanded or collapsed as an action view alongside the optional,
- * app-specified callbacks to {@link OnActionExpandListener}.
- *
- * See {@link MenuItem} for more information about action views.
- * See {@link android.app.ActionBar} for more information about the action bar.
- */
-public interface CollapsibleActionView {
- /**
- * Called when this view is expanded as an action view.
- * See {@link MenuItem#expandActionView()}.
- */
- public void onActionViewExpanded();
-
- /**
- * Called when this view is collapsed as an action view.
- * See {@link MenuItem#collapseActionView()}.
- */
- public void onActionViewCollapsed();
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java
deleted file mode 100644
index 951f4ccef..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * 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 com.actionbarsherlock.view;
-
-import android.content.ComponentName;
-import android.content.Intent;
-import android.view.KeyEvent;
-
-/**
- * Interface for managing the items in a menu.
- *
- * 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)}.
- *
- * Different menu types support different features:
- * For more information about creating menus, read the
- * Menus developer guide.
- * 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.
- *
- *
- * See {@link android.content.pm.PackageManager#queryIntentActivityOptions}
- * for more * details on the caller, specifics, and
- * intent arguments. The list returned by that function is used
- * to populate the resulting menu items.
- *
- *
- * 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 flags 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 specifics 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/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
deleted file mode 100644
index 5a0f40859..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- * 2011 Jake Wharton
- *
- * 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 com.actionbarsherlock.view;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.TypedValue;
-import android.util.Xml;
-import android.view.InflateException;
-import android.view.View;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
-
-/**
- * This class is used to instantiate menu XML files into Menu objects.
- *
- * For performance reasons, menu inflation relies heavily on pre-processing of
- * XML files that is done at build time. Therefore, it is not currently possible
- * to use MenuInflater with an XmlPullParser over a plain XML file at runtime;
- * it only works with an XmlPullParser returned from a compiled resource (R.
- * something file.)
- */
-public class MenuInflater {
- private static final String LOG_TAG = "MenuInflater";
-
- /** Menu tag name in XML. */
- private static final String XML_MENU = "menu";
-
- /** Group tag name in XML. */
- private static final String XML_GROUP = "group";
-
- /** Item tag name in XML. */
- private static final String XML_ITEM = "item";
-
- private static final int NO_ID = 0;
-
- private static final Class>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class};
-
- private static final Class>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE;
-
- private final Object[] mActionViewConstructorArguments;
-
- private final Object[] mActionProviderConstructorArguments;
-
- private Context mContext;
- private Object mRealOwner;
-
- /**
- * Constructs a menu inflater.
- *
- * @see Activity#getMenuInflater()
- */
- public MenuInflater(Context context) {
- mContext = context;
- mRealOwner = context;
- mActionViewConstructorArguments = new Object[] {context};
- mActionProviderConstructorArguments = mActionViewConstructorArguments;
- }
-
- /**
- * Constructs a menu inflater.
- *
- * @see Activity#getMenuInflater()
- * @hide
- */
- public MenuInflater(Context context, Object realOwner) {
- mContext = context;
- mRealOwner = realOwner;
- mActionViewConstructorArguments = new Object[] {context};
- mActionProviderConstructorArguments = mActionViewConstructorArguments;
- }
-
- /**
- * Inflate a menu hierarchy from the specified XML resource. Throws
- * {@link InflateException} if there is an error.
- *
- * @param menuRes Resource ID for an XML layout resource to load (e.g.,
- *
- * Groups can not be nested unless there is another menu (which will have
- * its state class).
- */
- private class MenuState {
- private Menu menu;
-
- /*
- * Group state is set on items as they are added, allowing an item to
- * override its group state. (As opposed to set on items at the group end tag.)
- */
- private int groupId;
- private int groupCategory;
- private int groupOrder;
- private int groupCheckable;
- private boolean groupVisible;
- private boolean groupEnabled;
-
- private boolean itemAdded;
- private int itemId;
- private int itemCategoryOrder;
- private CharSequence itemTitle;
- private CharSequence itemTitleCondensed;
- private int itemIconResId;
- private char itemAlphabeticShortcut;
- private char itemNumericShortcut;
- /**
- * Sync to attrs.xml enum:
- * - 0: none
- * - 1: all
- * - 2: exclusive
- */
- private int itemCheckable;
- private boolean itemChecked;
- private boolean itemVisible;
- private boolean itemEnabled;
-
- /**
- * Sync to attrs.xml enum, values in MenuItem:
- * - 0: never
- * - 1: ifRoom
- * - 2: always
- * - -1: Safe sentinel for "no value".
- */
- private int itemShowAsAction;
-
- private int itemActionViewLayout;
- private String itemActionViewClassName;
- private String itemActionProviderClassName;
-
- private String itemListenerMethodName;
-
- private ActionProvider itemActionProvider;
-
- private static final int defaultGroupId = NO_ID;
- private static final int defaultItemId = NO_ID;
- private static final int defaultItemCategory = 0;
- private static final int defaultItemOrder = 0;
- private static final int defaultItemCheckable = 0;
- private static final boolean defaultItemChecked = false;
- private static final boolean defaultItemVisible = true;
- private static final boolean defaultItemEnabled = true;
-
- public MenuState(final Menu menu) {
- this.menu = menu;
-
- resetGroup();
- }
-
- public void resetGroup() {
- groupId = defaultGroupId;
- groupCategory = defaultItemCategory;
- groupOrder = defaultItemOrder;
- groupCheckable = defaultItemCheckable;
- groupVisible = defaultItemVisible;
- groupEnabled = defaultItemEnabled;
- }
-
- /**
- * Called when the parser is pointing to a group tag.
- */
- public void readGroup(AttributeSet attrs) {
- TypedArray a = mContext.obtainStyledAttributes(attrs,
- R.styleable.SherlockMenuGroup);
-
- groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId);
- groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory);
- groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder);
- groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable);
- groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible);
- groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled);
-
- a.recycle();
- }
-
- /**
- * Called when the parser is pointing to an item tag.
- */
- public void readItem(AttributeSet attrs) {
- TypedArray a = mContext.obtainStyledAttributes(attrs,
- R.styleable.SherlockMenuItem);
-
- // Inherit attributes from the group as default value
- itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId);
- final int category = a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory);
- final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder);
- itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
- itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title);
- itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed);
- itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0);
- itemAlphabeticShortcut =
- getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut));
- itemNumericShortcut =
- getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut));
- if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) {
- // Item has attribute checkable, use it
- itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0;
- } else {
- // Item does not have attribute, use the group's (group can have one more state
- // for checkable that represents the exclusive checkable)
- itemCheckable = groupCheckable;
- }
-
- itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked);
- itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible);
- itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled);
-
- TypedValue value = new TypedValue();
- a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value);
- itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1;
-
- itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
- itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
-
- // itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
- value = new TypedValue();
- a.getValue(R.styleable.SherlockMenuItem_android_actionViewClass, value);
- itemActionViewClassName = value.type == TypedValue.TYPE_STRING ? value.string.toString() : null;
-
- // itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);
- value = new TypedValue();
- a.getValue(R.styleable.SherlockMenuItem_android_actionProviderClass, value);
- itemActionProviderClassName = value.type == TypedValue.TYPE_STRING ? value.string.toString() : null;
-
- final boolean hasActionProvider = itemActionProviderClassName != null;
- if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
- itemActionProvider = newInstance(itemActionProviderClassName,
- ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
- mActionProviderConstructorArguments);
- } else {
- if (hasActionProvider) {
- Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'."
- + " Action view already specified.");
- }
- itemActionProvider = null;
- }
-
- a.recycle();
-
- itemAdded = false;
- }
-
- private char getShortcut(String shortcutString) {
- if (shortcutString == null) {
- return 0;
- } else {
- return shortcutString.charAt(0);
- }
- }
-
- private void setItem(MenuItem item) {
- item.setChecked(itemChecked)
- .setVisible(itemVisible)
- .setEnabled(itemEnabled)
- .setCheckable(itemCheckable >= 1)
- .setTitleCondensed(itemTitleCondensed)
- .setIcon(itemIconResId)
- .setAlphabeticShortcut(itemAlphabeticShortcut)
- .setNumericShortcut(itemNumericShortcut);
-
- if (itemShowAsAction >= 0) {
- item.setShowAsAction(itemShowAsAction);
- }
-
- if (itemListenerMethodName != null) {
- if (mContext.isRestricted()) {
- throw new IllegalStateException("The android:onClick attribute cannot "
- + "be used within a restricted context");
- }
- item.setOnMenuItemClickListener(
- new InflatedOnMenuItemClickListener(mRealOwner, itemListenerMethodName));
- }
-
- if (itemCheckable >= 2) {
- if (item instanceof MenuItemImpl) {
- MenuItemImpl impl = (MenuItemImpl) item;
- impl.setExclusiveCheckable(true);
- } else {
- menu.setGroupCheckable(groupId, true, true);
- }
- }
-
- boolean actionViewSpecified = false;
- if (itemActionViewClassName != null) {
- View actionView = (View) newInstance(itemActionViewClassName,
- ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments);
- item.setActionView(actionView);
- actionViewSpecified = true;
- }
- if (itemActionViewLayout > 0) {
- if (!actionViewSpecified) {
- item.setActionView(itemActionViewLayout);
- actionViewSpecified = true;
- } else {
- Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'."
- + " Action view already specified.");
- }
- }
- if (itemActionProvider != null) {
- item.setActionProvider(itemActionProvider);
- }
- }
-
- public void addItem() {
- itemAdded = true;
- setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle));
- }
-
- public SubMenu addSubMenuItem() {
- itemAdded = true;
- SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle);
- setItem(subMenu.getItem());
- return subMenu;
- }
-
- public boolean hasAddedItem() {
- return itemAdded;
- }
-
- @SuppressWarnings("unchecked")
- private
- * An Item is returned by calling one of the {@link android.view.Menu#add}
- * methods.
- *
- * For a feature set of specific menu types, see {@link Menu}.
- *
- * For information about creating menus, read the
- * Menus developer guide.
- * 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 Menu#CATEGORY_SYSTEM},
- * {@link Menu#CATEGORY_SECONDARY}, {@link Menu#CATEGORY_ALTERNATIVE},
- * {@link Menu#CATEGORY_CONTAINER}. See {@link 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.
- *
- * Some menu types do not sufficient space to show the full title, and
- * instead a condensed title is preferred. See {@link 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 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 Menu} for the menu types that support icons.
- *
- * 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.
- *
- * Note that setIntent() can not be used with the versions of
- * {@link 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 not 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.
- *
- * See {@link 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.
- *
- * See {@link 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.
- *
- * See {@link 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.
- *
- * See {@link 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 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 Menu#setGroupCheckable(int, boolean, boolean)},
- * the other items in the group will be unchecked.
- *
- * See {@link Menu} for the menu types that support check marks.
- *
- * @see #setCheckable
- * @see #isChecked
- * @see 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.
- *
- * 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.
- *
- * Note: Setting an action view overrides the action provider
- * set via {@link #setActionProvider(ActionProvider)}.
- *
- * Note: Setting an action view overrides the action provider
- * set via {@link #setActionProvider(ActionProvider)}.
- *
- * Note: Setting an action provider overrides the action view
- * set via {@link #setActionView(int)} or {@link #setActionView(View)}.
- *
- * Sub menus do not support item icons, or nested sub menus.
- *
- * For information about creating menus, read the
- * Menus developer guide. Abstract base class for a top-level window look and behavior policy. An
- * instance of this class should be used as the top-level view added to the
- * window manager. It provides standard UI policies such as a background, title
- * area, default key processing, etc. The only existing implementation of this abstract class is
- * android.policy.PhoneWindow, which you should instantiate when needing a
- * Window. Eventually that class will be refactored and a factory method added
- * for creating Window instances without knowing about a particular
- * implementation.
- * This class represents a data model for choosing a component for handing a
- * given {@link Intent}. The model is responsible for querying the system for
- * activities that can handle the given intent and order found activities
- * based on historical data of previous choices. The historical data is stored
- * in an application private file. If a client does not want to have persistent
- * choice history the file can be omitted, thus the activities will be ordered
- * based on historical usage for the current session.
- *
- *
- * The way clients interact with this class is as follows:
- *
- *
- * Note: This class is thread safe.
- *
- * Note: Modifying the intent is not permitted and
- * any changes to the latter will be ignored.
- *
- * Note: To use the default historical data file clients should explicitly
- * pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice
- * history is desired clients should pass
- * Always use difference historical data files for semantically different actions.
- * For example, sharing is different from importing.
- *
- * Note: Clients must set only semantically similar
- * intents for each data model.
- *
- *
- * @param intent The intent.
- */
- public void setIntent(Intent intent) {
- synchronized (mInstanceLock) {
- if (mIntent == intent) {
- return;
- }
- mIntent = intent;
- loadActivitiesLocked();
- }
- }
-
- /**
- * Gets the intent for which a activity is being chosen.
- *
- * @return The intent.
- */
- public Intent getIntent() {
- synchronized (mInstanceLock) {
- return mIntent;
- }
- }
-
- /**
- * Gets the number of activities that can handle the intent.
- *
- * @return The activity count.
- *
- * @see #setIntent(Intent)
- */
- public int getActivityCount() {
- synchronized (mInstanceLock) {
- return mActivites.size();
- }
- }
-
- /**
- * Gets an activity at a given index.
- *
- * @return The activity.
- *
- * @see ActivityResolveInfo
- * @see #setIntent(Intent)
- */
- public ResolveInfo getActivity(int index) {
- synchronized (mInstanceLock) {
- return mActivites.get(index).resolveInfo;
- }
- }
-
- /**
- * Gets the index of a the given activity.
- *
- * @param activity The activity index.
- *
- * @return The index if found, -1 otherwise.
- */
- public int getActivityIndex(ResolveInfo activity) {
- List
- * Note: By calling this method the client guarantees
- * that the returned intent will be started. This intent is returned to
- * the client solely to let additional customization before the start.
- *
- * Note: Historical data is read asynchronously and
- * as soon as the reading is completed any registered
- * {@link DataSetObserver}s will be notified. Also no historical
- * data is read until this method is invoked.
- *
- */
- private void readHistoricalData() {
- synchronized (mInstanceLock) {
- if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) {
- return;
- }
- mCanReadHistoricalData = false;
- mReadShareHistoryCalled = true;
- if (!TextUtils.isEmpty(mHistoryFileName)) {
- /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader());
- }
- }
- }
-
- private static final Executor SERIAL_EXECUTOR = Executors.newSingleThreadExecutor();
-
- /**
- * Persists the history data to the backing file if the latter
- * was provided. Calling this method before a call to {@link #readHistoricalData()}
- * throws an exception. Calling this method more than one without choosing an
- * activity has not effect.
- *
- * @throws IllegalStateException If this method is called before a call to
- * {@link #readHistoricalData()}.
- */
- private void persistHistoricalData() {
- synchronized (mInstanceLock) {
- if (!mReadShareHistoryCalled) {
- throw new IllegalStateException("No preceding call to #readHistoricalData");
- }
- if (!mHistoricalRecordsChanged) {
- return;
- }
- mHistoricalRecordsChanged = false;
- mCanReadHistoricalData = true;
- if (!TextUtils.isEmpty(mHistoryFileName)) {
- /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister());
- }
- }
- }
-
- /**
- * Sets the sorter for ordering activities based on historical data and an intent.
- *
- * @param activitySorter The sorter.
- *
- * @see ActivitySorter
- */
- public void setActivitySorter(ActivitySorter activitySorter) {
- synchronized (mInstanceLock) {
- if (mActivitySorter == activitySorter) {
- return;
- }
- mActivitySorter = activitySorter;
- sortActivities();
- }
- }
-
- /**
- * Sorts the activities based on history and an intent. If
- * a sorter is not specified this a default implementation is used.
- *
- * @see #setActivitySorter(ActivitySorter)
- */
- private void sortActivities() {
- synchronized (mInstanceLock) {
- if (mActivitySorter != null && !mActivites.isEmpty()) {
- mActivitySorter.sort(mIntent, mActivites,
- Collections.unmodifiableList(mHistoricalRecords));
- notifyChanged();
- }
- }
- }
-
- /**
- * Sets the maximal size of the historical data. Defaults to
- * {@link #DEFAULT_HISTORY_MAX_LENGTH}
- *
- * Note: Setting this property will immediately
- * enforce the specified max history size by dropping enough old
- * historical records to enforce the desired size. Thus, any
- * records that exceed the history size will be discarded and
- * irreversibly lost.
- *
- * The view is composed of two adjacent buttons:
- *
- * When the SearchView is used in an ActionBar as an action view for a collapsible menu item, it
- * needs to be set to iconified by default using {@link #setIconifiedByDefault(boolean)
- * setIconifiedByDefault(true)}. This is the default, so nothing needs to be done.
- *
- * If you want the search field to always be visible, then call setIconifiedByDefault(false).
- * For information about using {@code SearchView}, read the
- * Search developer guide. The default value is true.
- * Here is how to use the action provider with custom backing file in a {@link MenuItem}:
- *
- *
- * Note: While the sample snippet demonstrates how to use this provider
- * in the context of a menu item, the use of the provider is not limited to menu items.
- *
- * Note: Modifying the intent is not permitted and
- * any changes to the latter will be ignored.
- *
- * Note: If you choose the backing share history file
- * you will still be notified in this callback.
- *
- * Note: The history file name can be set any time, however
- * only the action views created by {@link #onCreateActionView()} after setting
- * the file name will be backed by the provided file.
- *
- *
- * @param shareHistoryFile The share history file name.
- */
- public void setShareHistoryFileName(String shareHistoryFile) {
- mShareHistoryFileName = shareHistoryFile;
- setActivityChooserPolicyIfNeeded();
- }
-
- /**
- * Sets an intent with information about the share action. Here is a
- * sample for constructing a share intent:
- *
- *
- *
- * @param newConfig The new device configuration.
- */
- public void dispatchConfigurationChanged(Configuration newConfig) {}
-
- /**
- * Notify the action bar that the activity has finished its resuming. This
- * should be dispatched after the call to the superclass implementation.
- *
- *
- * @Override
- * public void onConfigurationChanged(Configuration newConfig) {
- * super.onConfigurationChanged(newConfig);
- * mSherlock.dispatchConfigurationChanged(newConfig);
- * }
- *
- */
- public void dispatchPostResume() {}
-
- /**
- * Notify the action bar that the activity is pausing. This should be
- * dispatched before the call to the superclass implementation.
- *
- *
- * @Override
- * protected void onPostResume() {
- * super.onPostResume();
- * mSherlock.dispatchPostResume();
- * }
- *
- */
- public void dispatchPause() {}
-
- /**
- * Notify the action bar that the activity is stopping. This should be
- * called before the superclass implementation.
- *
- *
- * @Override
- * protected void onPause() {
- * mSherlock.dispatchPause();
- * super.onPause();
- * }
- *
- */
- public void dispatchStop() {}
-
- /**
- * Indicate that the menu should be recreated by calling
- * {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}.
- */
- public abstract void dispatchInvalidateOptionsMenu();
-
- /**
- * Notify the action bar that it should display its overflow menu if it is
- * appropriate for the device. The implementation should conditionally
- * call the superclass method only if this method returns {@code false}.
- *
- *
- *
- * @return {@code true} if the opening of the menu was handled internally.
- */
- public boolean dispatchOpenOptionsMenu() {
- return false;
- }
-
- /**
- * Notify the action bar that it should close its overflow menu if it is
- * appropriate for the device. This implementation should conditionally
- * call the superclass method only if this method returns {@code false}.
- *
- *
- *
- * @return {@code true} if the closing of the menu was handled internally.
- */
- public boolean dispatchCloseOptionsMenu() {
- return false;
- }
-
- /**
- * Notify the class that the activity has finished its creation. This
- * should be called after the superclass implementation.
- *
- *
- * @Override
- * public void closeOptionsMenu() {
- * if (!mSherlock.dispatchCloseOptionsMenu()) {
- * super.closeOptionsMenu();
- * }
- * }
- *
- *
- * @param savedInstanceState If the activity is being re-initialized after
- * previously being shut down then this Bundle
- * contains the data it most recently supplied in
- * {@link Activity#}onSaveInstanceState(Bundle)}.
- * Note: Otherwise it is null.
- */
- public void dispatchPostCreate(Bundle savedInstanceState) {}
-
- /**
- * Notify the action bar that the title has changed and the action bar
- * should be updated to reflect the change. This should be called before
- * the superclass implementation.
- *
- *
- * @Override
- * protected void onPostCreate(Bundle savedInstanceState) {
- * mSherlock.dispatchPostCreate(savedInstanceState);
- * super.onPostCreate(savedInstanceState);
- * }
- *
- *
- * @param title New activity title.
- * @param color New activity color.
- */
- public void dispatchTitleChanged(CharSequence title, int color) {}
-
- /**
- * Notify the action bar the user has created a key event. This is used to
- * toggle the display of the overflow action item with the menu key and to
- * close the action mode or expanded action item with the back key.
- *
- *
- * @Override
- * protected void onTitleChanged(CharSequence title, int color) {
- * mSherlock.dispatchTitleChanged(title, color);
- * super.onTitleChanged(title, color);
- * }
- *
- *
- * @param event Description of the key event.
- * @return {@code true} if the event was handled.
- */
- public boolean dispatchKeyEvent(KeyEvent event) {
- return false;
- }
-
- /**
- * Notify the action bar that the Activity has triggered a menu creation
- * which should happen on the conclusion of {@link Activity#onCreate}. This
- * will be used to gain a reference to the native menu for native and
- * overflow binding as well as to indicate when compatibility create should
- * occur for the first time.
- *
- * @param menu Activity native menu.
- * @return {@code true} since we always want to say that we have a native
- */
- public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu);
-
- /**
- * Notify the action bar that the Activity has triggered a menu preparation
- * which usually means that the user has requested the overflow menu via a
- * hardware menu key. You should return the result of this method call and
- * not call the superclass implementation.
- *
- *
- * @Override
- * public boolean dispatchKeyEvent(KeyEvent event) {
- * if (mSherlock.dispatchKeyEvent(event)) {
- * return true;
- * }
- * return super.dispatchKeyEvent(event);
- * }
- *
- *
- * @param menu Activity native menu.
- * @return {@code true} if menu display should proceed.
- */
- public abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu);
-
- /**
- * Notify the action bar that a native options menu item has been selected.
- * The implementation should return the result of this method call.
- *
- *
- *
- * @param item Options menu item.
- * @return @{code true} if the selection was handled.
- */
- public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item);
-
- /**
- * Notify the action bar that the overflow menu has been opened. The
- * implementation should conditionally return {@code true} if this method
- * returns {@code true}, otherwise return the result of the superclass
- * method.
- *
- *
- *
- * @param featureId Window feature which triggered the event.
- * @param menu Activity native menu.
- * @return {@code true} if the event was handled by this method.
- */
- public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) {
- return false;
- }
-
- /**
- * Notify the action bar that the overflow menu has been closed. This
- * method should be called before the superclass implementation.
- *
- *
- *
- * @param featureId
- * @param menu
- */
- public void dispatchPanelClosed(int featureId, android.view.Menu menu) {}
-
- /**
- * Notify the action bar that the activity has been destroyed. This method
- * should be called before the superclass implementation.
- *
- *
- */
- public void dispatchDestroy() {}
-
- public void dispatchSaveInstanceState(Bundle outState) {}
-
- public void dispatchRestoreInstanceState(Bundle savedInstanceState) {}
-
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
-
-
- /**
- * Internal method to trigger the menu creation process.
- *
- * @return {@code true} if menu creation should proceed.
- */
- protected final boolean callbackCreateOptionsMenu(Menu menu) {
- if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu);
-
- boolean result = true;
- if (mActivity instanceof OnCreatePanelMenuListener) {
- OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener)mActivity;
- result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
- } else if (mActivity instanceof OnCreateOptionsMenuListener) {
- OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener)mActivity;
- result = listener.onCreateOptionsMenu(menu);
- }
-
- if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result);
- return result;
- }
-
- /**
- * Internal method to trigger the menu preparation process.
- *
- * @return {@code true} if menu preparation should proceed.
- */
- protected final boolean callbackPrepareOptionsMenu(Menu menu) {
- if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu);
-
- boolean result = true;
- if (mActivity instanceof OnPreparePanelListener) {
- OnPreparePanelListener listener = (OnPreparePanelListener)mActivity;
- result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu);
- } else if (mActivity instanceof OnPrepareOptionsMenuListener) {
- OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener)mActivity;
- result = listener.onPrepareOptionsMenu(menu);
- }
-
- if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result);
- return result;
- }
-
- /**
- * Internal method for dispatching options menu selection to the owning
- * activity callback.
- *
- * @param item Selected options menu item.
- * @return {@code true} if the item selection was handled in the callback.
- */
- protected final boolean callbackOptionsItemSelected(MenuItem item) {
- if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed());
-
- boolean result = false;
- if (mActivity instanceof OnMenuItemSelectedListener) {
- OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener)mActivity;
- result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
- } else if (mActivity instanceof OnOptionsItemSelectedListener) {
- OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener)mActivity;
- result = listener.onOptionsItemSelected(item);
- }
-
- if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result);
- return result;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
-
-
- /**
- * Query for the availability of a certain feature.
- *
- * @param featureId The feature ID to check.
- * @return {@code true} if feature is enabled, {@code false} otherwise.
- */
- public abstract boolean hasFeature(int featureId);
-
- /**
- * Enable extended screen features. This must be called before
- * {@code setContentView()}. May be called as many times as desired as long
- * as it is before {@code setContentView()}. If not called, no extended
- * features will be available. You can not turn off a feature once it is
- * requested.
- *
- * @param featureId The desired features, defined as constants by Window.
- * @return Returns true if the requested feature is supported and now
- * enabled.
- */
- public abstract boolean requestFeature(int featureId);
-
- /**
- * Set extra options that will influence the UI for this window.
- *
- * @param uiOptions Flags specifying extra options for this window.
- */
- public abstract void setUiOptions(int uiOptions);
-
- /**
- * Set extra options that will influence the UI for this window. Only the
- * bits filtered by mask will be modified.
- *
- * @param uiOptions Flags specifying extra options for this window.
- * @param mask Flags specifying which options should be modified. Others
- * will remain unchanged.
- */
- public abstract void setUiOptions(int uiOptions, int mask);
-
- /**
- * Set the content of the activity inside the action bar.
- *
- * @param layoutResId Layout resource ID.
- */
- public abstract void setContentView(int layoutResId);
-
- /**
- * Set the content of the activity inside the action bar.
- *
- * @param view The desired content to display.
- */
- public void setContentView(View view) {
- if (DEBUG) Log.d(TAG, "[setContentView] view: " + view);
-
- setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
- }
-
- /**
- * Set the content of the activity inside the action bar.
- *
- * @param view The desired content to display.
- * @param params Layout parameters to apply to the view.
- */
- public abstract void setContentView(View view, ViewGroup.LayoutParams params);
-
- /**
- * Variation on {@link #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)}
- * to add an additional content view to the screen. Added after any
- * existing ones on the screen -- existing views are NOT removed.
- *
- * @param view The desired content to display.
- * @param params Layout parameters for the view.
- */
- public abstract void addContentView(View view, ViewGroup.LayoutParams params);
-
- /**
- * Change the title associated with this activity.
- */
- public abstract void setTitle(CharSequence title);
-
- /**
- * Change the title associated with this activity.
- */
- public void setTitle(int resId) {
- if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId);
-
- setTitle(mActivity.getString(resId));
- }
-
- /**
- * Sets the visibility of the progress bar in the title.
- * Developer Guides
- *
- *
- *
- * @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.
- *
- * position
. 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
- * position
.
- *
- * @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.
- *
- * true
if the ActionBar is showing, false
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.)
- *
- * AnimatorListeners
added to them.
- */
-public abstract class Animator implements Cloneable {
-
-
- /**
- * The set of listeners to be sent events through the life of an animation.
- */
- ArrayListcancel()
causes the animation to
- * stop in its tracks, sending an
- * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
- * its listeners, followed by an
- * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
- *
- * Animator
object.
- *
- * @return ArrayListgetListeners()
followed by calling clear()
on the
- * returned list of listeners.
- */
- public void removeAllListeners() {
- if (mListeners != null) {
- mListeners.clear();
- mListeners = null;
- }
- }
-
- @Override
- public Animator clone() {
- try {
- final Animator anim = (Animator) super.clone();
- if (mListeners != null) {
- ArrayListAnimatorSet
:
- * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or
- * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add
- * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be
- * used in conjunction with methods in the {@link AnimatorSet.Builder Builder}
- * class to add animations
- * one by one.AnimatorSet
with circular dependencies between
- * its animations. For example, an animation a1 could be set up to start before animation a2, a2
- * before a3, and a3 before a1. The results of this configuration are undefined, but will typically
- * result in none of the affected animations being played. Because of this (and because
- * circular dependencies do not make logical sense anyway), circular dependencies
- * should be avoided, and the dependency flow of animations should only be in one direction.
- */
-@SuppressWarnings("unchecked")
-public final class AnimatorSet extends Animator {
-
- /**
- * Internal variables
- * NOTE: This object implements the clone() method, making a deep copy of any referenced
- * objects. As other non-trivial fields are added to this class, make sure to add logic
- * to clone() to make deep copies of them.
- */
-
- /**
- * Tracks animations currently being played, so that we know what to
- * cancel or end when cancel() or end() is called on this AnimatorSet
- */
- private ArrayListBuilder
object, which is used to
- * set up playing constraints. This initial play()
method
- * tells the Builder
the animation that is the dependency for
- * the succeeding commands to the Builder
. For example,
- * calling play(a1).with(a2)
sets up the AnimatorSet to play
- * a1
and a2
at the same time,
- * play(a1).before(a2)
sets up the AnimatorSet to play
- * a1
first, followed by a2
, and
- * play(a1).after(a2)
sets up the AnimatorSet to play
- * a2
first, followed by a1
.
- *
- * play()
is the only way to tell the
- * Builder
the animation upon which the dependency is created,
- * so successive calls to the various functions in Builder
- * will all refer to the initial parameter supplied in play()
- * as the dependency of the other animations. For example, calling
- * play(a1).before(a2).before(a3)
will play both a2
- * and a3
when a1 ends; it does not set up a dependency between
- * a2
and a3
.Builder
object. A null parameter will result
- * in a null Builder
return value.
- * @return Builder The object that constructs the AnimatorSet based on the dependencies
- * outlined in the calls to play
and the other methods in the
- * Builder
Note that canceling a AnimatorSet
also cancels all of the animations that it
- * is responsible for.AnimatorSet
also ends all of the animations that it is
- * responsible for.AnimatorSet
will, in turn, start the animations for which
- * it is responsible. The details of when exactly those animations are started depends on
- * the dependency relationships that have been set up between the animations.
- */
- @Override
- public void start() {
- mTerminated = false;
- mStarted = true;
-
- // First, sort the nodes (if necessary). This will ensure that sortedNodes
- // contains the animation nodes in the correct order.
- sortNodes();
-
- int numSortedNodes = mSortedNodes.size();
- for (int i = 0; i < numSortedNodes; ++i) {
- Node node = mSortedNodes.get(i);
- // First, clear out the old listeners
- ArrayListBuilder
object is a utility class to facilitate adding animations to a
- * AnimatorSet
along with the relationships between the various animations. The
- * intention of the Builder
methods, along with the {@link
- * AnimatorSet#play(Animator) play()} method of AnimatorSet
is to make it possible
- * to express the dependency relationships of animations in a natural way. Developers can also
- * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link
- * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need,
- * but it might be easier in some situations to express the AnimatorSet of animations in pairs.
- *
- * Builder
object cannot be constructed directly, but is rather constructed
- * internally via a call to {@link AnimatorSet#play(Animator)}.
- * AnimatorSet s = new AnimatorSet();
- * s.play(anim1).with(anim2);
- * s.play(anim2).before(anim3);
- * s.play(anim4).after(anim3);
- *
- *
- * Builder
object to express
- * multiple relationships. However, note that it is only the animation passed into the initial
- * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive
- * calls to the Builder
object. For example, the following code starts both anim2
- * and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and
- * anim3:
- *
- * AnimatorSet s = new AnimatorSet();
- * s.play(anim1).before(anim2).before(anim3);
- *
- * If the desired result is to play anim1 then anim2 then anim3, this code expresses the
- * relationship correctly:
- * AnimatorSet s = new AnimatorSet();
- * s.play(anim1).before(anim2);
- * s.play(anim2).before(anim3);
- *
- *
- * play(anim1).after(anim1)
makes no
- * sense. In general, circular dependencies like this one (or more indirect ones where a depends
- * on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets
- * that can boil down to a simple, one-way relationship of animations starting with, before, and
- * after other, different, animations.Builder
object.
- *
- * @param anim The animation that will play when the animation supplied to the
- * {@link AnimatorSet#play(Animator)} method starts.
- */
- public Builder with(Animator anim) {
- Node node = mNodeMap.get(anim);
- if (node == null) {
- node = new Node(anim);
- mNodeMap.put(anim, node);
- mNodes.add(node);
- }
- Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH);
- node.addDependency(dependency);
- return this;
- }
-
- /**
- * Sets up the given animation to play when the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder
object
- * ends.
- *
- * @param anim The animation that will play when the animation supplied to the
- * {@link AnimatorSet#play(Animator)} method ends.
- */
- public Builder before(Animator anim) {
- Node node = mNodeMap.get(anim);
- if (node == null) {
- node = new Node(anim);
- mNodeMap.put(anim, node);
- mNodes.add(node);
- }
- Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER);
- node.addDependency(dependency);
- return this;
- }
-
- /**
- * Sets up the given animation to play when the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder
object
- * to start when the animation supplied in this method call ends.
- *
- * @param anim The animation whose end will cause the animation supplied to the
- * {@link AnimatorSet#play(Animator)} method to play.
- */
- public Builder after(Animator anim) {
- Node node = mNodeMap.get(anim);
- if (node == null) {
- node = new Node(anim);
- mNodeMap.put(anim, node);
- mNodes.add(node);
- }
- Dependency dependency = new Dependency(node, Dependency.AFTER);
- mCurrentNode.addDependency(dependency);
- return this;
- }
-
- /**
- * Sets up the animation supplied in the
- * {@link AnimatorSet#play(Animator)} call that created this Builder
object
- * to play when the given amount of time elapses.
- *
- * @param delay The number of milliseconds that should elapse before the
- * animation starts.
- */
- public Builder after(long delay) {
- // setup dummy ValueAnimator just to run the clock
- ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
- anim.setDuration(delay);
- after(anim);
- return this;
- }
-
- }
-
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java
deleted file mode 100644
index e41019364..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
-
-/**
- * This evaluator can be used to perform type interpolation between float
values.
- */
-public class FloatEvaluator implements TypeEvaluatorfraction
representing the proportion between the start and end values. The
- * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0)
,
- * where x0
is startValue
, x1
is endValue
,
- * and t
is fraction
.
- *
- * @param fraction The fraction from the starting to the ending values
- * @param startValue The start value; should be of type float
or
- * Float
- * @param endValue The end value; should be of type float
or Float
- * @return A linear interpolation between the start and end values, given the
- * fraction
parameter.
- */
- public Float evaluate(float fraction, Number startValue, Number endValue) {
- float startFloat = startValue.floatValue();
- return startFloat + fraction * (endValue.floatValue() - startFloat);
- }
-}
\ No newline at end of file
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java
deleted file mode 100644
index 6d9dafa7a..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe;
-
-/**
- * This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate
- * values between those keyframes for a given animation. The class internal to the animation
- * package because it is an implementation detail of how Keyframes are stored and used.
- *
- * int
values.
- */
-public class IntEvaluator implements TypeEvaluatorfraction
representing the proportion between the start and end values. The
- * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0)
,
- * where x0
is startValue
, x1
is endValue
,
- * and t
is fraction
.
- *
- * @param fraction The fraction from the starting to the ending values
- * @param startValue The start value; should be of type int
or
- * Integer
- * @param endValue The end value; should be of type int
or Integer
- * @return A linear interpolation between the start and end values, given the
- * fraction
parameter.
- */
- public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
- int startInt = startValue;
- return (int)(startInt + fraction * (endValue - startInt));
- }
-}
\ No newline at end of file
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java
deleted file mode 100644
index e9215e7f8..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe;
-
-/**
- * This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate
- * values between those keyframes for a given animation. The class internal to the animation
- * package because it is an implementation detail of how Keyframes are stored and used.
- *
- * float
and
- * int
values). Other types will fall into a more general Keyframe class that
- * treats its values as Objects. Unless your animation requires dealing with a custom type
- * or a data structure that needs to be animated directly (and evaluated using an implementation
- * of {@link TypeEvaluator}), you should stick to using float and int as animations using those
- * types have lower runtime overhead than other types.value
object passed into the constructor.
- */
- Class mValueType;
-
- /**
- * The optional time interpolator for the interval preceding this keyframe. A null interpolator
- * (the default) results in linear interpolation over the interval.
- */
- private /*Time*/Interpolator mInterpolator = null;
-
- /**
- * Flag to indicate whether this keyframe has a valid value. This flag is used when an
- * animation first starts, to populate placeholder keyframes with real values derived
- * from the target object.
- */
- boolean mHasValue = false;
-
- /**
- * Constructs a Keyframe object with the given time and value. The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- * @param value The value that the object will animate to as the animation time approaches
- * the time in this keyframe, and the the value animated from as the time passes the time in
- * this keyframe.
- */
- public static Keyframe ofInt(float fraction, int value) {
- return new IntKeyframe(fraction, value);
- }
-
- /**
- * Constructs a Keyframe object with the given time. The value at this time will be derived
- * from the target object when the animation first starts (note that this implies that keyframes
- * with no initial value must be used as part of an {@link ObjectAnimator}).
- * The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- */
- public static Keyframe ofInt(float fraction) {
- return new IntKeyframe(fraction);
- }
-
- /**
- * Constructs a Keyframe object with the given time and value. The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- * @param value The value that the object will animate to as the animation time approaches
- * the time in this keyframe, and the the value animated from as the time passes the time in
- * this keyframe.
- */
- public static Keyframe ofFloat(float fraction, float value) {
- return new FloatKeyframe(fraction, value);
- }
-
- /**
- * Constructs a Keyframe object with the given time. The value at this time will be derived
- * from the target object when the animation first starts (note that this implies that keyframes
- * with no initial value must be used as part of an {@link ObjectAnimator}).
- * The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- */
- public static Keyframe ofFloat(float fraction) {
- return new FloatKeyframe(fraction);
- }
-
- /**
- * Constructs a Keyframe object with the given time and value. The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- * @param value The value that the object will animate to as the animation time approaches
- * the time in this keyframe, and the the value animated from as the time passes the time in
- * this keyframe.
- */
- public static Keyframe ofObject(float fraction, Object value) {
- return new ObjectKeyframe(fraction, value);
- }
-
- /**
- * Constructs a Keyframe object with the given time. The value at this time will be derived
- * from the target object when the animation first starts (note that this implies that keyframes
- * with no initial value must be used as part of an {@link ObjectAnimator}).
- * The time defines the
- * time, as a proportion of an overall animation's duration, at which the value will hold true
- * for the animation. The value for the animation between keyframes will be calculated as
- * an interpolation between the values at those keyframes.
- *
- * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
- * of time elapsed of the overall animation duration.
- */
- public static Keyframe ofObject(float fraction) {
- return new ObjectKeyframe(fraction, null);
- }
-
- /**
- * Indicates whether this keyframe has a valid value. This method is called internally when
- * an {@link ObjectAnimator} first starts; keyframes without values are assigned values at
- * that time by deriving the value for the property from the target object.
- *
- * @return boolean Whether this object has a value assigned.
- */
- public boolean hasValue() {
- return mHasValue;
- }
-
- /**
- * Gets the value for this Keyframe.
- *
- * @return The value for this Keyframe.
- */
- public abstract Object getValue();
-
- /**
- * Sets the value for this Keyframe.
- *
- * @param value value for this Keyframe.
- */
- public abstract void setValue(Object value);
-
- /**
- * Gets the time for this keyframe, as a fraction of the overall animation duration.
- *
- * @return The time associated with this keyframe, as a fraction of the overall animation
- * duration. This should be a value between 0 and 1.
- */
- public float getFraction() {
- return mFraction;
- }
-
- /**
- * Sets the time for this keyframe, as a fraction of the overall animation duration.
- *
- * @param fraction time associated with this keyframe, as a fraction of the overall animation
- * duration. This should be a value between 0 and 1.
- */
- public void setFraction(float fraction) {
- mFraction = fraction;
- }
-
- /**
- * Gets the optional interpolator for this Keyframe. A value of null
indicates
- * that there is no interpolation, which is the same as linear interpolation.
- *
- * @return The optional interpolator for this Keyframe.
- */
- public /*Time*/Interpolator getInterpolator() {
- return mInterpolator;
- }
-
- /**
- * Sets the optional interpolator for this Keyframe. A value of null
indicates
- * that there is no interpolation, which is the same as linear interpolation.
- *
- * @return The optional interpolator for this Keyframe.
- */
- public void setInterpolator(/*Time*/Interpolator interpolator) {
- mInterpolator = interpolator;
- }
-
- /**
- * Gets the type of keyframe. This information is used by ValueAnimator to determine the type of
- * {@link TypeEvaluator} to use when calculating values between keyframes. The type is based
- * on the type of Keyframe created.
- *
- * @return The type of the value stored in the Keyframe.
- */
- public Class getType() {
- return mValueType;
- }
-
- @Override
- public abstract Keyframe clone();
-
- /**
- * This internal subclass is used for all types which are not int or float.
- */
- static class ObjectKeyframe extends Keyframe {
-
- /**
- * The value of the animation at the time mFraction.
- */
- Object mValue;
-
- ObjectKeyframe(float fraction, Object value) {
- mFraction = fraction;
- mValue = value;
- mHasValue = (value != null);
- mValueType = mHasValue ? value.getClass() : Object.class;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setValue(Object value) {
- mValue = value;
- mHasValue = (value != null);
- }
-
- @Override
- public ObjectKeyframe clone() {
- ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue);
- kfClone.setInterpolator(getInterpolator());
- return kfClone;
- }
- }
-
- /**
- * Internal subclass used when the keyframe value is of type int.
- */
- static class IntKeyframe extends Keyframe {
-
- /**
- * The value of the animation at the time mFraction.
- */
- int mValue;
-
- IntKeyframe(float fraction, int value) {
- mFraction = fraction;
- mValue = value;
- mValueType = int.class;
- mHasValue = true;
- }
-
- IntKeyframe(float fraction) {
- mFraction = fraction;
- mValueType = int.class;
- }
-
- public int getIntValue() {
- return mValue;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setValue(Object value) {
- if (value != null && value.getClass() == Integer.class) {
- mValue = ((Integer)value).intValue();
- mHasValue = true;
- }
- }
-
- @Override
- public IntKeyframe clone() {
- IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue);
- kfClone.setInterpolator(getInterpolator());
- return kfClone;
- }
- }
-
- /**
- * Internal subclass used when the keyframe value is of type float.
- */
- static class FloatKeyframe extends Keyframe {
- /**
- * The value of the animation at the time mFraction.
- */
- float mValue;
-
- FloatKeyframe(float fraction, float value) {
- mFraction = fraction;
- mValue = value;
- mValueType = float.class;
- mHasValue = true;
- }
-
- FloatKeyframe(float fraction) {
- mFraction = fraction;
- mValueType = float.class;
- }
-
- public float getFloatValue() {
- return mValue;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setValue(Object value) {
- if (value != null && value.getClass() == Float.class) {
- mValue = ((Float)value).floatValue();
- mHasValue = true;
- }
- }
-
- @Override
- public FloatKeyframe clone() {
- FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue);
- kfClone.setInterpolator(getInterpolator());
- return kfClone;
- }
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java
deleted file mode 100644
index a71e1ad3c..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import android.view.animation.Interpolator;
-
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe;
-import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe;
-
-/**
- * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate
- * values between those keyframes for a given animation. The class internal to the animation
- * package because it is an implementation detail of how Keyframes are stored and used.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-class KeyframeSet {
-
- int mNumKeyframes;
-
- Keyframe mFirstKeyframe;
- Keyframe mLastKeyframe;
- /*Time*/Interpolator mInterpolator; // only used in the 2-keyframe case
- ArrayListfoo
will result
- * in a call to the function setFoo()
on the target object. If either
- * valueFrom
or valueTo
is null, then a getter function will
- * also be derived and called.
- *
- * float
or int
typed values,
- * and make the setter function for those properties have a void
return value. This
- * will cause the code to take an optimized path for these constrained circumstances. Other
- * property types and return types will work, but will have more overhead in processing
- * the requests due to normal reflection mechanisms.valueFrom
and valueTo
properties, otherwise the call to
- * the setter function will fail.foo
will result
- * in a call to the function setFoo()
on the target object. If either
- * valueFrom
or valueTo
is null, then a getter function will
- * also be derived and called.
- */
- public String getPropertyName() {
- return mPropertyName;
- }
-
- /**
- * Creates a new ObjectAnimator object. This default constructor is primarily for
- * use internally; the other constructors which take parameters are more generally
- * useful.
- */
- public ObjectAnimator() {
- }
-
- /**
- * Private utility constructor that initializes the target object and name of the
- * property being animated.
- *
- * @param target The object whose property is to be animated. This object should
- * have a public method on it called setName()
, where name
is
- * the value of the propertyName
parameter.
- * @param propertyName The name of the property being animated.
- */
- private ObjectAnimator(Object target, String propertyName) {
- mTarget = target;
- setPropertyName(propertyName);
- }
-
- /**
- * Private utility constructor that initializes the target object and property being animated.
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- */
- //private setName()
, where name
is
- * the value of the propertyName
parameter.
- * @param propertyName The name of the property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofInt(Object target, String propertyName, int... values) {
- ObjectAnimator anim = new ObjectAnimator(target, propertyName);
- anim.setIntValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns an ObjectAnimator that animates between int values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- //public static setName()
, where name
is
- * the value of the propertyName
parameter.
- * @param propertyName The name of the property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
- ObjectAnimator anim = new ObjectAnimator(target, propertyName);
- anim.setFloatValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns an ObjectAnimator that animates between float values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- //public static setName()
, where name
is
- * the value of the propertyName
parameter.
- * @param propertyName The name of the property being animated.
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the necessary interpolation between the Object values to derive the animated
- * value.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofObject(Object target, String propertyName,
- TypeEvaluator evaluator, Object... values) {
- ObjectAnimator anim = new ObjectAnimator(target, propertyName);
- anim.setObjectValues(values);
- anim.setEvaluator(evaluator);
- return anim;
- }
-
- /**
- * Constructs and returns an ObjectAnimator that animates between Object values. A single
- * value implies that that value is the one being animated to. Two values imply a starting
- * and ending values. More than two values imply a starting value, values to animate through
- * along the way, and an ending value (these values will be distributed evenly across
- * the duration of the animation).
- *
- * @param target The object whose property is to be animated.
- * @param property The property being animated.
- * @param evaluator A TypeEvaluator that will be called on each animation frame to
- * provide the necessary interpolation between the Object values to derive the animated
- * value.
- * @param values A set of values that the animation will animate between over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- //public static PropertyValueHolder
objects. This variant should be used when animating
- * several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows
- * you to associate a set of animation values with a property name.
- *
- * @param target The object whose property is to be animated. Depending on how the
- * PropertyValuesObjects were constructed, the target object should either have the {@link
- * android.util.Property} objects used to construct the PropertyValuesHolder objects or (if the
- * PropertyValuesHOlder objects were created with property names) the target object should have
- * public methods on it called setName()
, where name
is the name of
- * the property passed in as the propertyName
parameter for each of the
- * PropertyValuesHolder objects.
- * @param values A set of PropertyValuesHolder objects whose values will be animated between
- * over time.
- * @return An ObjectAnimator object that is set up to animate between the given values.
- */
- public static ObjectAnimator ofPropertyValuesHolder(Object target,
- PropertyValuesHolder... values) {
- ObjectAnimator anim = new ObjectAnimator();
- anim.mTarget = target;
- anim.setValues(values);
- return anim;
- }
-
- @Override
- public void setIntValues(int... values) {
- if (mValues == null || mValues.length == 0) {
- // No values yet - this animator is being constructed piecemeal. Init the values with
- // whatever the current propertyName is
- //if (mProperty != null) {
- // setValues(PropertyValuesHolder.ofInt(mProperty, values));
- //} else {
- setValues(PropertyValuesHolder.ofInt(mPropertyName, values));
- //}
- } else {
- super.setIntValues(values);
- }
- }
-
- @Override
- public void setFloatValues(float... values) {
- if (mValues == null || mValues.length == 0) {
- // No values yet - this animator is being constructed piecemeal. Init the values with
- // whatever the current propertyName is
- //if (mProperty != null) {
- // setValues(PropertyValuesHolder.ofFloat(mProperty, values));
- //} else {
- setValues(PropertyValuesHolder.ofFloat(mPropertyName, values));
- //}
- } else {
- super.setFloatValues(values);
- }
- }
-
- @Override
- public void setObjectValues(Object... values) {
- if (mValues == null || mValues.length == 0) {
- // No values yet - this animator is being constructed piecemeal. Init the values with
- // whatever the current propertyName is
- //if (mProperty != null) {
- // setValues(PropertyValuesHolder.ofObject(mProperty, (TypeEvaluator)null, values));
- //} else {
- setValues(PropertyValuesHolder.ofObject(mPropertyName, (TypeEvaluator)null, values));
- //}
- } else {
- super.setObjectValues(values);
- }
- }
-
- @Override
- public void start() {
- if (DBG) {
- Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration());
- for (int i = 0; i < mValues.length; ++i) {
- PropertyValuesHolder pvh = mValues[i];
- ArrayListstartDelay
, the
- * function is called after that delay ends.
- * It takes care of the final initialization steps for the
- * animation. This includes setting mEvaluator, if the user has not yet
- * set it up, and the setter/getter methods, if the user did not supply
- * them.
- *
- * ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start()
.
- */
- @Override
- public ObjectAnimator setDuration(long duration) {
- super.setDuration(duration);
- return this;
- }
-
-
- /**
- * The target object whose property will be animated by this animation
- *
- * @return The object being animated
- */
- public Object getTarget() {
- return mTarget;
- }
-
- /**
- * Sets the target object whose property will be animated by this animation
- *
- * @param target The object being animated
- */
- @Override
- public void setTarget(Object target) {
- if (mTarget != target) {
- final Object oldTarget = mTarget;
- mTarget = target;
- if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) {
- return;
- }
- // New target type should cause re-initialization prior to starting
- mInitialized = false;
- }
- }
-
- @Override
- public void setupStartValues() {
- initAnimation();
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].setupStartValue(mTarget);
- }
- }
-
- @Override
- public void setupEndValues() {
- initAnimation();
- int numValues = mValues.length;
- for (int i = 0; i < numValues; ++i) {
- mValues[i].setupEndValue(mTarget);
- }
- }
-
- /**
- * This method is called with the elapsed fraction of the animation during every
- * animation frame. This function turns the elapsed fraction into an interpolated fraction
- * and then into an animated value (from the evaluator. The function is called mostly during
- * animation updates, but it is also called when the end()
- * function is called, to set the final value on the property.
- *
- * propertyName
, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- * @param propertyName The name of the property associated with this set of values. This
- * can be the actual property name to be used when using a ObjectAnimator object, or
- * just a name used to get animated values, such as if this object is used with an
- * ValueAnimator object.
- * @param values The set of values to animate between.
- */
- public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) {
- KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
- if (keyframeSet instanceof IntKeyframeSet) {
- return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet);
- } else if (keyframeSet instanceof FloatKeyframeSet) {
- return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet);
- }
- else {
- PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
- pvh.mKeyframeSet = keyframeSet;
- pvh.mValueType = values[0].getType();
- return pvh;
- }
- }
-
- /**
- * Constructs and returns a PropertyValuesHolder object with the specified property and set
- * of values. These values can be of any type, but the type should be consistent so that
- * an appropriate {@link android.animation.TypeEvaluator} can be found that matches
- * the common type.
- * propertyName
, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setIntValues(int... values) {
- mValueType = int.class;
- mKeyframeSet = KeyframeSet.ofInt(values);
- }
-
- /**
- * Set the animated values for this object to this set of floats.
- * If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from propertyName
, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setFloatValues(float... values) {
- mValueType = float.class;
- mKeyframeSet = KeyframeSet.ofFloat(values);
- }
-
- /**
- * Set the animated values for this object to this set of Keyframes.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setKeyframes(Keyframe... values) {
- int numKeyframes = values.length;
- Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)];
- mValueType = values[0].getType();
- for (int i = 0; i < numKeyframes; ++i) {
- keyframes[i] = values[i];
- }
- mKeyframeSet = new KeyframeSet(keyframes);
- }
-
- /**
- * Set the animated values for this object to this set of Objects.
- * If there is only one value, it is assumed to be the end value of an animation,
- * and an initial value will be derived, if possible, by calling a getter function
- * on the object. Also, if any value is null, the value will be filled in when the animation
- * starts in the same way. This mechanism of automatically getting null values only works
- * if the PropertyValuesHolder object is used in conjunction
- * {@link ObjectAnimator}, and with a getter function
- * derived automatically from propertyName
, since otherwise PropertyValuesHolder has
- * no way of determining what the value should be.
- *
- * @param values One or more values that the animation will animate between.
- */
- public void setObjectValues(Object... values) {
- mValueType = values[0].getClass();
- mKeyframeSet = KeyframeSet.ofObject(values);
- }
-
- /**
- * Determine the setter or getter function using the JavaBeans convention of setFoo or
- * getFoo for a property named 'foo'. This function figures out what the name of the
- * function should be and uses reflection to find the Method with that name on the
- * target object.
- *
- * @param targetClass The class to search for the method
- * @param prefix "set" or "get", depending on whether we need a setter or getter.
- * @param valueType The type of the parameter (in the case of a setter). This type
- * is derived from the values set on this PropertyValuesHolder. This type is used as
- * a first guess at the parameter type, but we check for methods with several different
- * types to avoid problems with slight mis-matches between supplied values and actual
- * value types used on the setter.
- * @return Method the method associated with mPropertyName.
- */
- private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) {
- // TODO: faster implementation...
- Method returnVal = null;
- String methodName = getMethodName(prefix, mPropertyName);
- Class args[] = null;
- if (valueType == null) {
- try {
- returnVal = targetClass.getMethod(methodName, args);
- } catch (NoSuchMethodException e) {
- Log.e("PropertyValuesHolder", targetClass.getSimpleName() + " - " +
- "Couldn't find no-arg method for property " + mPropertyName + ": " + e);
- }
- } else {
- args = new Class[1];
- Class typeVariants[];
- if (mValueType.equals(Float.class)) {
- typeVariants = FLOAT_VARIANTS;
- } else if (mValueType.equals(Integer.class)) {
- typeVariants = INTEGER_VARIANTS;
- } else if (mValueType.equals(Double.class)) {
- typeVariants = DOUBLE_VARIANTS;
- } else {
- typeVariants = new Class[1];
- typeVariants[0] = mValueType;
- }
- for (Class typeVariant : typeVariants) {
- args[0] = typeVariant;
- try {
- returnVal = targetClass.getMethod(methodName, args);
- // change the value type to suit
- mValueType = typeVariant;
- return returnVal;
- } catch (NoSuchMethodException e) {
- // Swallow the error and keep trying other variants
- }
- }
- // If we got here, then no appropriate function was found
- Log.e("PropertyValuesHolder",
- "Couldn't find " + prefix + "ter property " + mPropertyName +
- " for " + targetClass.getSimpleName() +
- " with value type "+ mValueType);
- }
-
- return returnVal;
- }
-
-
- /**
- * Returns the setter or getter requested. This utility function checks whether the
- * requested method exists in the propertyMapMap cache. If not, it calls another
- * utility function to request the Method from the targetClass directly.
- * @param targetClass The Class on which the requested method should exist.
- * @param propertyMapMap The cache of setters/getters derived so far.
- * @param prefix "set" or "get", for the setter or getter.
- * @param valueType The type of parameter passed into the method (null for getter).
- * @return Method the method associated with mPropertyName.
- */
- private Method setupSetterOrGetter(Class targetClass,
- HashMapfoo
will result
- * in a call to the function setFoo()
on the target object. If either
- * valueFrom
or valueTo
is null, then a getter function will
- * also be derived and called.
- *
- * valueFrom
and valueTo
properties, otherwise the call to
- * the setter function will fail.foo
will result
- * in a call to the function setFoo()
on the target object. If either
- * valueFrom
or valueTo
is null, then a getter function will
- * also be derived and called.
- */
- public String getPropertyName() {
- return mPropertyName;
- }
-
- /**
- * Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value
- * most recently calculated in calculateValue().
- * @return
- */
- Object getAnimatedValue() {
- return mAnimatedValue;
- }
-
- @Override
- public String toString() {
- return mPropertyName + ": " + mKeyframeSet.toString();
- }
-
- /**
- * Utility method to derive a setter/getter method name from a property name, where the
- * prefix is typically "set" or "get" and the first letter of the property name is
- * capitalized.
- *
- * @param prefix The precursor to the method name, before the property name begins, typically
- * "set" or "get".
- * @param propertyName The name of the property that represents the bulk of the method name
- * after the prefix. The first letter of this word will be capitalized in the resulting
- * method name.
- * @return String the property name converted to a method name according to the conventions
- * specified above.
- */
- static String getMethodName(String prefix, String propertyName) {
- if (propertyName == null || propertyName.length() == 0) {
- // shouldn't get here
- return prefix;
- }
- char firstLetter = Character.toUpperCase(propertyName.charAt(0));
- String theRest = propertyName.substring(1);
- return prefix + firstLetter + theRest;
- }
-
- static class IntPropertyValuesHolder extends PropertyValuesHolder {
-
- // Cache JNI functions to avoid looking them up twice
- //private static final HashMapfraction
representing the proportion between the start and end values. The
- * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0)
,
- * where x0
is startValue
, x1
is endValue
,
- * and t
is fraction
.
- *
- * @param fraction The fraction from the starting to the ending values
- * @param startValue The start value.
- * @param endValue The end value.
- * @return A linear interpolation between the start and end values, given the
- * fraction
parameter.
- */
- public T evaluate(float fraction, T startValue, T endValue);
-
-}
\ No newline at end of file
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
deleted file mode 100644
index d8a12c688..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
+++ /dev/null
@@ -1,1265 +0,0 @@
-/*
- * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
-
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.util.AndroidRuntimeException;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
-import android.view.animation.LinearInterpolator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * This class provides a simple timing engine for running animations
- * which calculate animated values and set them on target objects.
- *
- * repeatCount
is INFINITE
- * or a positive value, the animation restarts from the beginning.
- */
- public static final int RESTART = 1;
- /**
- * When the animation reaches the end and repeatCount
is INFINITE
- * or a positive value, the animation reverses direction on every iteration.
- */
- public static final int REVERSE = 2;
- /**
- * This value used used with the {@link #setRepeatCount(int)} property to repeat
- * the animation indefinitely.
- */
- public static final int INFINITE = -1;
-
- /**
- * Creates a new ValueAnimator object. This default constructor is primarily for
- * use internally; the factory methods which take parameters are more generally
- * useful.
- */
- public ValueAnimator() {
- }
-
- /**
- * Constructs and returns a ValueAnimator that animates between int values. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- * @param values A set of values that the animation will animate between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofInt(int... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setIntValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns a ValueAnimator that animates between float values. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- * @param values A set of values that the animation will animate between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofFloat(float... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setFloatValues(values);
- return anim;
- }
-
- /**
- * Constructs and returns a ValueAnimator that animates between the values
- * specified in the PropertyValuesHolder objects.
- *
- * @param values A set of PropertyValuesHolder objects whose values will be animated
- * between over time.
- * @return A ValueAnimator object that is set up to animate between the given values.
- */
- public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) {
- ValueAnimator anim = new ValueAnimator();
- anim.setValues(values);
- return anim;
- }
- /**
- * Constructs and returns a ValueAnimator that animates between Object values. A single
- * value implies that that value is the one being animated to. However, this is not typically
- * useful in a ValueAnimator object because there is no way for the object to determine the
- * starting value for the animation (unlike ObjectAnimator, which can derive that value
- * from the target object and property being animated). Therefore, there should typically
- * be two or more values.
- *
- * startDelay
, the
- * function is called after that delay ends.
- * It takes care of the final initialization steps for the
- * animation.
- *
- * ValueAnimator.ofInt(0, 10).setDuration(500).start()
.
- */
- public ValueAnimator setDuration(long duration) {
- if (duration < 0) {
- throw new IllegalArgumentException("Animators cannot have negative duration: " +
- duration);
- }
- mDuration = duration;
- return this;
- }
-
- /**
- * Gets the length of the animation. The default duration is 300 milliseconds.
- *
- * @return The length of the animation, in milliseconds.
- */
- public long getDuration() {
- return mDuration;
- }
-
- /**
- * Sets the position of the animation to the specified point in time. This time should
- * be between 0 and the total duration of the animation, including any repetition. If
- * the animation has not yet been started, then it will not advance forward after it is
- * set to this time; it will simply set the time to this value and perform any appropriate
- * actions based on that time. If the animation is already running, then setCurrentPlayTime()
- * will set the current playing time to this value and continue playing from that point.
- *
- * @param playTime The time, in milliseconds, to which the animation is advanced or rewound.
- */
- public void setCurrentPlayTime(long playTime) {
- initAnimation();
- long currentTime = AnimationUtils.currentAnimationTimeMillis();
- if (mPlayingState != RUNNING) {
- mSeekTime = playTime;
- mPlayingState = SEEKED;
- }
- mStartTime = currentTime - playTime;
- animationFrame(currentTime);
- }
-
- /**
- * Gets the current position of the animation in time, which is equal to the current
- * time minus the time that the animation started. An animation that is not yet started will
- * return a value of zero.
- *
- * @return The current position in time of the animation.
- */
- public long getCurrentPlayTime() {
- if (!mInitialized || mPlayingState == STOPPED) {
- return 0;
- }
- return AnimationUtils.currentAnimationTimeMillis() - mStartTime;
- }
-
- /**
- * This custom, static handler handles the timing pulse that is shared by
- * all active animations. This approach ensures that the setting of animation
- * values will happen on the UI thread and that all animations will share
- * the same times for calculating their values, which makes synchronizing
- * animations possible.
- *
- */
- private static class AnimationHandler extends Handler {
- /**
- * There are only two messages that we care about: ANIMATION_START and
- * ANIMATION_FRAME. The START message is sent when an animation's start()
- * method is called. It cannot start synchronously when start() is called
- * because the call may be on the wrong thread, and it would also not be
- * synchronized with other animations because it would not start on a common
- * timing pulse. So each animation sends a START message to the handler, which
- * causes the handler to place the animation on the active animations queue and
- * start processing frames for that animation.
- * The FRAME message is the one that is sent over and over while there are any
- * active animations to process.
- */
- @Override
- public void handleMessage(Message msg) {
- boolean callAgain = true;
- ArrayListValueAnimator
when there is just one
- * property being animated. This value is only sensible while the animation is running. The main
- * purpose for this read-only property is to retrieve the value from the ValueAnimator
- * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
- * is called during each animation frame, immediately after the value is calculated.
- *
- * @return animatedValue The value most recently calculated by this ValueAnimator
for
- * the single property being animated. If there are several properties being animated
- * (specified by several PropertyValuesHolder objects in the constructor), this function
- * returns the animated value for the first of those objects.
- */
- public Object getAnimatedValue() {
- if (mValues != null && mValues.length > 0) {
- return mValues[0].getAnimatedValue();
- }
- // Shouldn't get here; should always have values unless ValueAnimator was set up wrong
- return null;
- }
-
- /**
- * The most recent value calculated by this ValueAnimator
for propertyName
.
- * The main purpose for this read-only property is to retrieve the value from the
- * ValueAnimator
during a call to
- * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
- * is called during each animation frame, immediately after the value is calculated.
- *
- * @return animatedValue The value most recently calculated for the named property
- * by this ValueAnimator
.
- */
- public Object getAnimatedValue(String propertyName) {
- PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName);
- if (valuesHolder != null) {
- return valuesHolder.getAnimatedValue();
- } else {
- // At least avoid crashing if called with bogus propertyName
- return null;
- }
- }
-
- /**
- * Sets how many times the animation should be repeated. If the repeat
- * count is 0, the animation is never repeated. If the repeat count is
- * greater than 0 or {@link #INFINITE}, the repeat mode will be taken
- * into account. The repeat count is 0 by default.
- *
- * @param value the number of times the animation should be repeated
- */
- public void setRepeatCount(int value) {
- mRepeatCount = value;
- }
- /**
- * Defines how many times the animation should repeat. The default value
- * is 0.
- *
- * @return the number of times the animation should repeat, or {@link #INFINITE}
- */
- public int getRepeatCount() {
- return mRepeatCount;
- }
-
- /**
- * Defines what this animation should do when it reaches the end. This
- * setting is applied only when the repeat count is either greater than
- * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}.
- *
- * @param value {@link #RESTART} or {@link #REVERSE}
- */
- public void setRepeatMode(int value) {
- mRepeatMode = value;
- }
-
- /**
- * Defines what this animation should do when it reaches the end.
- *
- * @return either one of {@link #REVERSE} or {@link #RESTART}
- */
- public int getRepeatMode() {
- return mRepeatMode;
- }
-
- /**
- * Adds a listener to the set of listeners that are sent update events through the life of
- * an animation. This method is called on all listeners for every frame of the animation,
- * after the values for the animation have been calculated.
- *
- * @param listener the listener to be added to the current set of listeners for this animation.
- */
- public void addUpdateListener(AnimatorUpdateListener listener) {
- if (mUpdateListeners == null) {
- mUpdateListeners = new ArrayListnull
- * will result in linear interpolation.
- */
- @Override
- public void setInterpolator(/*Time*/Interpolator value) {
- if (value != null) {
- mInterpolator = value;
- } else {
- mInterpolator = new LinearInterpolator();
- }
- }
-
- /**
- * Returns the timing interpolator that this ValueAnimator uses.
- *
- * @return The timing interpolator for this ValueAnimator.
- */
- public /*Time*/Interpolator getInterpolator() {
- return mInterpolator;
- }
-
- /**
- * The type evaluator to be used when calculating the animated values of this animation.
- * The system will automatically assign a float or int evaluator based on the type
- * of startValue
and endValue
in the constructor. But if these values
- * are not one of these primitive types, or if different evaluation is desired (such as is
- * necessary with int values that represent colors), a custom evaluator needs to be assigned.
- * For example, when running an animation on color values, the {@link ArgbEvaluator}
- * should be used to get correct RGB color interpolation.
- *
- * startDelay
phase. The return value indicates whether it
- * should be woken up and put on the active animations queue.
- *
- * @param currentTime The current animation time, used to calculate whether the animation
- * has exceeded its startDelay
and should be started.
- * @return True if the animation's startDelay
has been exceeded and the animation
- * should be added to the set of active animations.
- */
- private boolean delayedAnimationFrame(long currentTime) {
- if (!mStartedDelay) {
- mStartedDelay = true;
- mDelayStartTime = currentTime;
- } else {
- long deltaTime = currentTime - mDelayStartTime;
- if (deltaTime > mStartDelay) {
- // startDelay ended - start the anim and record the
- // mStartTime appropriately
- mStartTime = currentTime - (deltaTime - mStartDelay);
- mPlayingState = RUNNING;
- return true;
- }
- }
- return false;
- }
-
- /**
- * This internal function processes a single animation frame for a given animation. The
- * currentTime parameter is the timing pulse sent by the handler, used to calculate the
- * elapsed duration, and therefore
- * the elapsed fraction, of the animation. The return value indicates whether the animation
- * should be ended (which happens when the elapsed time of the animation exceeds the
- * animation's duration, including the repeatCount).
- *
- * @param currentTime The current time, as tracked by the static timing handler
- * @return true if the animation's duration, including any repetitions due to
- * repeatCount
has been exceeded and the animation should be ended.
- */
- boolean animationFrame(long currentTime) {
- boolean done = false;
-
- if (mPlayingState == STOPPED) {
- mPlayingState = RUNNING;
- if (mSeekTime < 0) {
- mStartTime = currentTime;
- } else {
- mStartTime = currentTime - mSeekTime;
- // Now that we're playing, reset the seek time
- mSeekTime = -1;
- }
- }
- switch (mPlayingState) {
- case RUNNING:
- case SEEKED:
- float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f;
- if (fraction >= 1f) {
- if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) {
- // Time to repeat
- if (mListeners != null) {
- int numListeners = mListeners.size();
- for (int i = 0; i < numListeners; ++i) {
- mListeners.get(i).onAnimationRepeat(this);
- }
- }
- if (mRepeatMode == REVERSE) {
- mPlayingBackwards = mPlayingBackwards ? false : true;
- }
- mCurrentIteration += (int)fraction;
- fraction = fraction % 1f;
- mStartTime += mDuration;
- } else {
- done = true;
- fraction = Math.min(fraction, 1.0f);
- }
- }
- if (mPlayingBackwards) {
- fraction = 1f - fraction;
- }
- animateValue(fraction);
- break;
- }
-
- return done;
- }
-
- /**
- * Returns the current animation fraction, which is the elapsed/interpolated fraction used in
- * the most recent frame update on the animation.
- *
- * @return Elapsed/interpolated fraction of the animation.
- */
- public float getAnimatedFraction() {
- return mCurrentFraction;
- }
-
- /**
- * This method is called with the elapsed fraction of the animation during every
- * animation frame. This function turns the elapsed fraction into an interpolated fraction
- * and then into an animated value (from the evaluator. The function is called mostly during
- * animation updates, but it is also called when the end()
- * function is called, to set the final value on the property.
- *
- * ValueAnimator
instance to receive callbacks on every animation
- * frame, after the current frame's values have been calculated for that
- * ValueAnimator
.
- */
- public static interface AnimatorUpdateListener {
- /**
- * Developer Guides
- *
- * public class MyActivity extends Activity {
- * private static final int PROGRESS = 0x1;
- *
- * private ProgressBar mProgress;
- * private int mProgressStatus = 0;
- *
- * private Handler mHandler = new Handler();
- *
- * protected void onCreate(Bundle icicle) {
- * super.onCreate(icicle);
- *
- * setContentView(R.layout.progressbar_activity);
- *
- * mProgress = (ProgressBar) findViewById(R.id.progress_bar);
- *
- * // Start lengthy operation in a background thread
- * new Thread(new Runnable() {
- * public void run() {
- * while (mProgressStatus < 100) {
- * mProgressStatus = doWork();
- *
- * // Update the progress bar
- * mHandler.post(new Runnable() {
- * public void run() {
- * mProgress.setProgress(mProgressStatus);
- * }
- * });
- * }
- * }
- * }).start();
- * }
- * }
- *
- *
- * <ProgressBar
- * style="@android:style/Widget.ProgressBar.Horizontal"
- * ... />
- *
- *
- * <LinearLayout
- * android:orientation="horizontal"
- * ... >
- * <ProgressBar
- * android:layout_width="wrap_content"
- * android:layout_height="wrap_content"
- * style="@android:style/Widget.ProgressBar.Small"
- * android:layout_marginRight="5dp" />
- * <TextView
- * android:layout_width="wrap_content"
- * android:layout_height="wrap_content"
- * android:text="@string/loading" />
- * </LinearLayout>
- *
- *
- *
- *
- *
- */
- private void initProgressBar() {
- mMax = 100;
- mProgress = 0;
- mSecondaryProgress = 0;
- mIndeterminate = false;
- mOnlyIndeterminate = false;
- mDuration = 4000;
- mBehavior = AlphaAnimation.RESTART;
- mMinWidth = 24;
- mMaxWidth = 48;
- mMinHeight = 24;
- mMaxHeight = 48;
- }
-
- /**
- *
- *
- */
- 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/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java
deleted file mode 100644
index ae7cb1fe0..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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 com.actionbarsherlock.view;
-
-import android.content.Context;
-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.
- *
- *
- *
- *
- *
- * <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" />
- *
- *
- *
- *
- *
- *
- * Developer Guides
- * R.menu.main_activity
)
- * @param menu The Menu to inflate into. The items and submenus will be
- * added to this Menu.
- */
- public void inflate(int menuRes, Menu menu) {
- XmlResourceParser parser = null;
- try {
- parser = mContext.getResources().getLayout(menuRes);
- AttributeSet attrs = Xml.asAttributeSet(parser);
-
- parseMenu(parser, attrs, menu);
- } catch (XmlPullParserException e) {
- throw new InflateException("Error inflating menu XML", e);
- } catch (IOException e) {
- throw new InflateException("Error inflating menu XML", e);
- } finally {
- if (parser != null) parser.close();
- }
- }
-
- /**
- * Called internally to fill the given menu. If a sub menu is seen, it will
- * call this recursively.
- */
- private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu)
- throws XmlPullParserException, IOException {
- MenuState menuState = new MenuState(menu);
-
- int eventType = parser.getEventType();
- String tagName;
- boolean lookingForEndOfUnknownTag = false;
- String unknownTagName = null;
-
- // This loop will skip to the menu start tag
- do {
- if (eventType == XmlPullParser.START_TAG) {
- tagName = parser.getName();
- if (tagName.equals(XML_MENU)) {
- // Go to next tag
- eventType = parser.next();
- break;
- }
-
- throw new RuntimeException("Expecting menu, got " + tagName);
- }
- eventType = parser.next();
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- boolean reachedEndOfMenu = false;
- while (!reachedEndOfMenu) {
- switch (eventType) {
- case XmlPullParser.START_TAG:
- if (lookingForEndOfUnknownTag) {
- break;
- }
-
- tagName = parser.getName();
- if (tagName.equals(XML_GROUP)) {
- menuState.readGroup(attrs);
- } else if (tagName.equals(XML_ITEM)) {
- menuState.readItem(attrs);
- } else if (tagName.equals(XML_MENU)) {
- // A menu start tag denotes a submenu for an item
- SubMenu subMenu = menuState.addSubMenuItem();
-
- // Parse the submenu into returned SubMenu
- parseMenu(parser, attrs, subMenu);
- } else {
- lookingForEndOfUnknownTag = true;
- unknownTagName = tagName;
- }
- break;
-
- case XmlPullParser.END_TAG:
- tagName = parser.getName();
- if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) {
- lookingForEndOfUnknownTag = false;
- unknownTagName = null;
- } else if (tagName.equals(XML_GROUP)) {
- menuState.resetGroup();
- } else if (tagName.equals(XML_ITEM)) {
- // Add the item if it hasn't been added (if the item was
- // a submenu, it would have been added already)
- if (!menuState.hasAddedItem()) {
- if (menuState.itemActionProvider != null &&
- menuState.itemActionProvider.hasSubMenu()) {
- menuState.addSubMenuItem();
- } else {
- menuState.addItem();
- }
- }
- } else if (tagName.equals(XML_MENU)) {
- reachedEndOfMenu = true;
- }
- break;
-
- case XmlPullParser.END_DOCUMENT:
- throw new RuntimeException("Unexpected end of document");
- }
-
- eventType = parser.next();
- }
- }
-
- private static class InflatedOnMenuItemClickListener
- implements MenuItem.OnMenuItemClickListener {
- private static final Class>[] PARAM_TYPES = new Class[] { MenuItem.class };
-
- private Object mRealOwner;
- private Method mMethod;
-
- public InflatedOnMenuItemClickListener(Object realOwner, String methodName) {
- mRealOwner = realOwner;
- Class> c = realOwner.getClass();
- try {
- mMethod = c.getMethod(methodName, PARAM_TYPES);
- } catch (Exception e) {
- InflateException ex = new InflateException(
- "Couldn't resolve menu item onClick handler " + methodName +
- " in class " + c.getName());
- ex.initCause(e);
- throw ex;
- }
- }
-
- public boolean onMenuItemClick(MenuItem item) {
- try {
- if (mMethod.getReturnType() == Boolean.TYPE) {
- return (Boolean) mMethod.invoke(mRealOwner, item);
- } else {
- mMethod.invoke(mRealOwner, item);
- return true;
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- /**
- * State for the current menu.
- * Developer Guides
- * Developer Guides
- *
- *
- * // Get a model and set it to a couple of clients with semantically similar function.
- * ActivityChooserModel dataModel =
- * ActivityChooserModel.get(context, "task_specific_history_file_name.xml");
- *
- * ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1();
- * modelClient1.setActivityChooserModel(dataModel);
- *
- * ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2();
- * modelClient2.setActivityChooserModel(dataModel);
- *
- * // Set an intent to choose a an activity for.
- * dataModel.setIntent(intent);
- *
- *
- *
activities
in descending order of relevance
- * based on previous history and an intent.
- *
- * @param intent The {@link Intent}.
- * @param activities Activities to be sorted.
- * @param historicalRecords Historical records.
- */
- // This cannot be done by a simple comparator since an Activity weight
- // is computed from history. Note that Activity implements Comparable.
- public void sort(Intent intent, Listnull
for the file name. In such
- * case a new model is returned for each invocation.
- * null
- * if the model should not be backed by a file. In this case the activities
- * will be ordered only by data from the current session.
- *
- * @return The model.
- */
- public static ActivityChooserModel get(Context context, String historyFileName) {
- synchronized (sRegistryLock) {
- ActivityChooserModel dataModel = sDataModelRegistry.get(historyFileName);
- if (dataModel == null) {
- dataModel = new ActivityChooserModel(context, historyFileName);
- sDataModelRegistry.put(historyFileName, dataModel);
- }
- dataModel.readHistoricalData();
- return dataModel;
- }
- }
-
- /**
- * Creates a new instance.
- *
- * @param context Context for loading resources.
- * @param historyFileName The history XML file.
- */
- private ActivityChooserModel(Context context, String historyFileName) {
- mContext = context.getApplicationContext();
- if (!TextUtils.isEmpty(historyFileName)
- && !historyFileName.endsWith(HISTORY_FILE_EXTENSION)) {
- mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION;
- } else {
- mHistoryFileName = historyFileName;
- }
- }
-
- /**
- * Sets an intent for which to choose a activity.
- * null
id not activities.
- *
- * @see #getActivity(int)
- */
- public ResolveInfo getDefaultActivity() {
- synchronized (mInstanceLock) {
- if (!mActivites.isEmpty()) {
- return mActivites.get(0).resolveInfo;
- }
- }
- return null;
- }
-
- /**
- * Sets the default activity. The default activity is set by adding a
- * historical record with weight high enough that this activity will
- * become the highest ranked. Such a strategy guarantees that the default
- * will eventually change if not used. Also the weight of the record for
- * setting a default is inflated with a constant amount to guarantee that
- * it will stay as default for awhile.
- *
- * @param index The index of the activity to set as default.
- */
- public void setDefaultActivity(int index) {
- ActivityResolveInfo newDefaultActivity = mActivites.get(index);
- ActivityResolveInfo oldDefaultActivity = mActivites.get(0);
-
- final float weight;
- if (oldDefaultActivity != null) {
- // Add a record with weight enough to boost the chosen at the top.
- weight = oldDefaultActivity.weight - newDefaultActivity.weight
- + DEFAULT_ACTIVITY_INFLATION;
- } else {
- weight = DEFAULT_HISTORICAL_RECORD_WEIGHT;
- }
-
- ComponentName defaultName = new ComponentName(
- newDefaultActivity.resolveInfo.activityInfo.packageName,
- newDefaultActivity.resolveInfo.activityInfo.name);
- HistoricalRecord historicalRecord = new HistoricalRecord(defaultName,
- System.currentTimeMillis(), weight);
- addHisoricalRecord(historicalRecord);
- }
-
- /**
- * Reads the history data from the backing file if the latter
- * was provided. Calling this method more than once before a call
- * to {@link #persistHistoricalData()} has been made has no effect.
- *
- *
- * Developer Guides
- * null
if none.
- * @return true if a successful launch, false if could not (e.g. bad position).
- */
- private boolean launchSuggestion(int position, int actionKey, String actionMsg) {
- Cursor c = mSuggestionsAdapter.getCursor();
- if ((c != null) && c.moveToPosition(position)) {
-
- Intent intent = createIntentFromSuggestion(c, actionKey, actionMsg);
-
- // launch the intent
- launchIntent(intent);
-
- return true;
- }
- return false;
- }
-
- /**
- * Launches an intent, including any special intent handling.
- */
- private void launchIntent(Intent intent) {
- if (intent == null) {
- return;
- }
- try {
- // If the intent was created from a suggestion, it will always have an explicit
- // component here.
- getContext().startActivity(intent);
- } catch (RuntimeException ex) {
- Log.e(LOG_TAG, "Failed launch activity: " + intent, ex);
- }
- }
-
- /**
- * Sets the text in the query box, without updating the suggestions.
- */
- private void setQuery(CharSequence query) {
- setText(mQueryTextView, query, true);
- // Move the cursor to the end
- mQueryTextView.setSelection(TextUtils.isEmpty(query) ? 0 : query.length());
- }
-
- private void launchQuerySearch(int actionKey, String actionMsg, String query) {
- String action = Intent.ACTION_SEARCH;
- Intent intent = createIntent(action, null, null, query, actionKey, actionMsg);
- getContext().startActivity(intent);
- }
-
- /**
- * Constructs an intent from the given information and the search dialog state.
- *
- * @param action Intent action.
- * @param data Intent data, or null
.
- * @param extraData Data for {@link SearchManager#EXTRA_DATA_KEY} or null
.
- * @param query Intent query, or null
.
- * @param actionKey The key code of the action key that was pressed,
- * or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
- * @param actionMsg The message for the action key that was pressed,
- * or null
if none.
- * @return The intent.
- */
- private Intent createIntent(String action, Uri data, String extraData, String query,
- int actionKey, String actionMsg) {
- // Now build the Intent
- Intent intent = new Intent(action);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // We need CLEAR_TOP to avoid reusing an old task that has other activities
- // on top of the one we want. We don't want to do this in in-app search though,
- // as it can be destructive to the activity stack.
- if (data != null) {
- intent.setData(data);
- }
- intent.putExtra(SearchManager.USER_QUERY, mUserQuery);
- if (query != null) {
- intent.putExtra(SearchManager.QUERY, query);
- }
- if (extraData != null) {
- intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
- }
- if (mAppSearchData != null) {
- intent.putExtra(SearchManager.APP_DATA, mAppSearchData);
- }
- if (actionKey != KeyEvent.KEYCODE_UNKNOWN) {
- intent.putExtra(SearchManager.ACTION_KEY, actionKey);
- intent.putExtra(SearchManager.ACTION_MSG, actionMsg);
- }
- intent.setComponent(mSearchable.getSearchActivity());
- return intent;
- }
-
- /**
- * Create and return an Intent that can launch the voice search activity for web search.
- */
- private Intent createVoiceWebSearchIntent(Intent baseIntent, SearchableInfo searchable) {
- Intent voiceIntent = new Intent(baseIntent);
- ComponentName searchActivity = searchable.getSearchActivity();
- voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
- : searchActivity.flattenToShortString());
- return voiceIntent;
- }
-
- /**
- * Create and return an Intent that can launch the voice search activity, perform a specific
- * voice transcription, and forward the results to the searchable activity.
- *
- * @param baseIntent The voice app search intent to start from
- * @return A completely-configured intent ready to send to the voice search activity
- */
- private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
- ComponentName searchActivity = searchable.getSearchActivity();
-
- // create the necessary intent to set up a search-and-forward operation
- // in the voice search system. We have to keep the bundle separate,
- // because it becomes immutable once it enters the PendingIntent
- Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
- queryIntent.setComponent(searchActivity);
- PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent,
- PendingIntent.FLAG_ONE_SHOT);
-
- // Now set up the bundle that will be inserted into the pending intent
- // when it's time to do the search. We always build it here (even if empty)
- // because the voice search activity will always need to insert "QUERY" into
- // it anyway.
- Bundle queryExtras = new Bundle();
-
- // Now build the intent to launch the voice search. Add all necessary
- // extras to launch the voice recognizer, and then all the necessary extras
- // to forward the results to the searchable activity
- Intent voiceIntent = new Intent(baseIntent);
-
- // Add all of the configuration options supplied by the searchable's metadata
- String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
- String prompt = null;
- String language = null;
- int maxResults = 1;
-
- Resources resources = getResources();
- if (searchable.getVoiceLanguageModeId() != 0) {
- languageModel = resources.getString(searchable.getVoiceLanguageModeId());
- }
- if (searchable.getVoicePromptTextId() != 0) {
- prompt = resources.getString(searchable.getVoicePromptTextId());
- }
- if (searchable.getVoiceLanguageId() != 0) {
- language = resources.getString(searchable.getVoiceLanguageId());
- }
- if (searchable.getVoiceMaxResults() != 0) {
- maxResults = searchable.getVoiceMaxResults();
- }
- voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
- voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
- voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
- voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
- voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
- : searchActivity.flattenToShortString());
-
- // Add the values that configure forwarding the results
- voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
- voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
-
- return voiceIntent;
- }
-
- /**
- * When a particular suggestion has been selected, perform the various lookups required
- * to use the suggestion. This includes checking the cursor for suggestion-specific data,
- * and/or falling back to the XML for defaults; It also creates REST style Uri data when
- * the suggestion includes a data id.
- *
- * @param c The suggestions cursor, moved to the row of the user's selection
- * @param actionKey The key code of the action key that was pressed,
- * or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
- * @param actionMsg The message for the action key that was pressed,
- * or null
if none.
- * @return An intent for the suggestion at the cursor's position.
- */
- private Intent createIntentFromSuggestion(Cursor c, int actionKey, String actionMsg) {
- try {
- // use specific action if supplied, or default action if supplied, or fixed default
- String action = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_ACTION);
-
- if (action == null) {
- action = mSearchable.getSuggestIntentAction();
- }
- if (action == null) {
- action = Intent.ACTION_SEARCH;
- }
-
- // use specific data if supplied, or default data if supplied
- String data = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_DATA);
- if (data == null) {
- data = mSearchable.getSuggestIntentData();
- }
- // then, if an ID was provided, append it.
- if (data != null) {
- String id = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID);
- if (id != null) {
- data = data + "/" + Uri.encode(id);
- }
- }
- Uri dataUri = (data == null) ? null : Uri.parse(data);
-
- String query = getColumnString(c, SearchManager.SUGGEST_COLUMN_QUERY);
- String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
-
- return createIntent(action, dataUri, extraData, query, actionKey, actionMsg);
- } catch (RuntimeException e ) {
- int rowNum;
- try { // be really paranoid now
- rowNum = c.getPosition();
- } catch (RuntimeException e2 ) {
- rowNum = -1;
- }
- Log.w(LOG_TAG, "Search suggestions cursor at row " + rowNum +
- " returned exception.", e);
- return null;
- }
- }
-
- private void forceSuggestionQuery() {
- try {
- Method before = SearchAutoComplete.class.getMethod("doBeforeTextChanged");
- Method after = SearchAutoComplete.class.getMethod("doAfterTextChanged");
- before.setAccessible(true);
- after.setAccessible(true);
- before.invoke(mQueryTextView);
- after.invoke(mQueryTextView);
- } catch (Exception e) {
- // Oh well...
- }
- }
-
- static boolean isLandscapeMode(Context context) {
- return context.getResources().getConfiguration().orientation
- == Configuration.ORIENTATION_LANDSCAPE;
- }
-
- /**
- * Callback to watch the text field for empty/non-empty
- */
- private TextWatcher mTextWatcher = new TextWatcher() {
-
- public void beforeTextChanged(CharSequence s, int start, int before, int after) { }
-
- public void onTextChanged(CharSequence s, int start,
- int before, int after) {
- SearchView.this.onTextChanged(s);
- }
-
- public void afterTextChanged(Editable s) {
- }
- };
-
- /**
- * Local subclass for AutoCompleteTextView.
- * @hide
- */
- public static class SearchAutoComplete extends AutoCompleteTextView {
-
- private int mThreshold;
- private SearchView mSearchView;
-
- public SearchAutoComplete(Context context) {
- super(context);
- mThreshold = getThreshold();
- }
-
- public SearchAutoComplete(Context context, AttributeSet attrs) {
- super(context, attrs);
- mThreshold = getThreshold();
- }
-
- public SearchAutoComplete(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mThreshold = getThreshold();
- }
-
- void setSearchView(SearchView searchView) {
- mSearchView = searchView;
- }
-
- @Override
- public void setThreshold(int threshold) {
- super.setThreshold(threshold);
- mThreshold = threshold;
- }
-
- /**
- * Returns true if the text field is empty, or contains only whitespace.
- */
- private boolean isEmpty() {
- return TextUtils.getTrimmedLength(getText()) == 0;
- }
-
- /**
- * We override this method to avoid replacing the query box text when a
- * suggestion is clicked.
- */
- @Override
- protected void replaceText(CharSequence text) {
- }
-
- /**
- * We override this method to avoid an extra onItemClick being called on
- * the drop-down's OnItemClickListener by
- * {@link AutoCompleteTextView#onKeyUp(int, KeyEvent)} when an item is
- * clicked with the trackball.
- */
- @Override
- public void performCompletion() {
- }
-
- /**
- * We override this method to be sure and show the soft keyboard if
- * appropriate when the TextView has focus.
- */
- @Override
- public void onWindowFocusChanged(boolean hasWindowFocus) {
- super.onWindowFocusChanged(hasWindowFocus);
-
- if (hasWindowFocus && mSearchView.hasFocus() && getVisibility() == VISIBLE) {
- InputMethodManager inputManager = (InputMethodManager) getContext()
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- inputManager.showSoftInput(this, 0);
- // If in landscape mode, then make sure that
- // the ime is in front of the dropdown.
- if (isLandscapeMode(getContext())) {
- ensureImeVisible(this, true);
- }
- }
- }
-
- @Override
- protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
- super.onFocusChanged(focused, direction, previouslyFocusedRect);
- mSearchView.onTextFocusChanged();
- }
-
- /**
- * We override this method so that we can allow a threshold of zero,
- * which ACTV does not.
- */
- @Override
- public boolean enoughToFilter() {
- return mThreshold <= 0 || super.enoughToFilter();
- }
-
- @Override
- public boolean onKeyPreIme(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- // special case for the back key, we do not even try to send it
- // to the drop down list but instead, consume it immediately
- if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
- KeyEvent.DispatcherState state = getKeyDispatcherState();
- if (state != null) {
- state.startTracking(event, this);
- }
- return true;
- } else if (event.getAction() == KeyEvent.ACTION_UP) {
- KeyEvent.DispatcherState state = getKeyDispatcherState();
- if (state != null) {
- state.handleUpEvent(event);
- }
- if (event.isTracking() && !event.isCanceled()) {
- mSearchView.clearFocus();
- mSearchView.setImeVisibility(false);
- return true;
- }
- }
- }
- return super.onKeyPreIme(keyCode, event);
- }
-
- }
-
- private static void ensureImeVisible(AutoCompleteTextView view, boolean visible) {
- try {
- Method method = AutoCompleteTextView.class.getMethod("ensureImeVisible", boolean.class);
- method.setAccessible(true);
- method.invoke(view, visible);
- } catch (Exception e) {
- //Oh well...
- }
- }
-
- private static void showSoftInputUnchecked(View view, InputMethodManager imm, int flags) {
- try {
- Method method = imm.getClass().getMethod("showSoftInputUnchecked", int.class, ResultReceiver.class);
- method.setAccessible(true);
- method.invoke(imm, flags, null);
- } catch (Exception e) {
- //Fallback to public API which hopefully does mostly the same thing
- imm.showSoftInput(view, flags);
- }
- }
-
- private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
- try {
- Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
- method.setAccessible(true);
- method.invoke(view, text, filter);
- } catch (Exception e) {
- //Fallback to public API which hopefully does mostly the same thing
- view.setText(text);
- }
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java
deleted file mode 100644
index 83e9f0ca9..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * 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 com.actionbarsherlock.widget;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
-import android.util.TypedValue;
-import android.view.View;
-
-import com.actionbarsherlock.R;
-import com.actionbarsherlock.view.ActionProvider;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
-import com.actionbarsherlock.view.SubMenu;
-import com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener;
-
-/**
- * This is a provider for a share action. It is responsible for creating views
- * that enable data sharing and also to show a sub menu with sharing activities
- * if the hosting item is placed on the overflow menu.
- *
- *
- *
- *
- * // In Activity#onCreateOptionsMenu
- * public boolean onCreateOptionsMenu(Menu menu) {
- * // Get the menu item.
- * MenuItem menuItem = menu.findItem(R.id.my_menu_item);
- * // Get the provider and hold onto it to set/change the share intent.
- * mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
- * // Set history different from the default before getting the action
- * // view since a call to {@link MenuItem#getActionView() MenuItem.getActionView()} calls
- * // {@link ActionProvider#onCreateActionView()} which uses the backing file name. Omit this
- * // line if using the default share history file is desired.
- * mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
- * . . .
- * }
- *
- * // Somewhere in the application.
- * public void doShare(Intent shareIntent) {
- * // When you want to share set the share intent.
- * mShareActionProvider.setShareIntent(shareIntent);
- * }
- *
null
- * if share history should not be persisted between sessions.
- *
- *
- *
- *
- * Intent shareIntent = new Intent(Intent.ACTION_SEND);
- * shareIntent.setType("image/*");
- * Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
- * shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
- *
- *
- * @param refineWhat which queries to refine. Possible values are {@link #REFINE_NONE},
- * {@link #REFINE_BY_ENTRY}, and {@link #REFINE_ALL}.
- */
- public void setQueryRefinement(int refineWhat) {
- mQueryRefinement = refineWhat;
- }
-
- /**
- * Returns the current query refinement preference.
- * @return value of query refinement preference
- */
- public int getQueryRefinement() {
- return mQueryRefinement;
- }
-
- /**
- * Overridden to always return Helper for implementing the action bar design pattern across all versions
+ * of Android. This class will manage interaction with a custom action bar based on the
+ * Android 4.0 source code. The exposed API mirrors that of its native
+ * counterpart and you should refer to its documentation for instruction. Denotes an implementation of ActionBarSherlock which provides an
+ * action bar-enhanced experience.
+ * @Override
+ * protected void onStop() {
+ * mSherlock.dispatchStop();
+ * super.onStop();
+ * }
+ *
+ * @Override
+ * public void openOptionsMenu() {
+ * if (!mSherlock.dispatchOpenOptionsMenu()) {
+ * super.openOptionsMenu();
+ * }
+ * }
+ *
+ * @Override
+ * public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ * return mSherlock.dispatchPrepareOptionsMenu(menu);
+ * }
+ *
+ * @Override
+ * public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ * return mSherlock.dispatchOptionsItemSelected(item);
+ * }
+ *
+ * @Override
+ * public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
+ * if (mSherlock.dispatchMenuOpened(featureId, menu)) {
+ * return true;
+ * }
+ * return super.onMenuOpened(featureId, menu);
+ * }
+ *
+ * @Override
+ * public void onPanelClosed(int featureId, android.view.Menu menu) {
+ * mSherlock.dispatchPanelClosed(featureId, menu);
+ * super.onPanelClosed(featureId, menu);
+ * }
+ *
+ * @Override
+ * public void onDestroy() {
+ * mSherlock.dispatchDestroy();
+ * super.onDestroy();
+ * }
+ *
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #requestWindowFeature(int)}.
+ *
+ * @param visible Whether to show the progress bars in the title.
+ */
+ public abstract void setProgressBarVisibility(boolean visible);
+
+ /**
+ * Sets the visibility of the indeterminate progress bar in the title.
+ *
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #requestWindowFeature(int)}.
+ *
+ * @param visible Whether to show the progress bars in the title.
+ */
+ public abstract void setProgressBarIndeterminateVisibility(boolean visible);
+
+ /**
+ * Sets whether the horizontal progress bar in the title should be indeterminate (the circular
+ * is always indeterminate).
+ *
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #requestWindowFeature(int)}.
+ *
+ * @param indeterminate Whether the horizontal progress bar should be indeterminate.
+ */
+ public abstract void setProgressBarIndeterminate(boolean indeterminate);
+
+ /**
+ * Sets the progress for the progress bars in the title.
+ *
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #requestWindowFeature(int)}.
+ *
+ * @param progress The progress for the progress bar. Valid ranges are from
+ * 0 to 10000 (both inclusive). If 10000 is given, the progress
+ * bar will be completely filled and will fade out.
+ */
+ public abstract void setProgress(int progress);
+
+ /**
+ * Sets the secondary progress for the progress bar in the title. This
+ * progress is drawn between the primary progress (set via
+ * {@link #setProgress(int)} and the background. It can be ideal for media
+ * scenarios such as showing the buffering progress while the default
+ * progress shows the play progress.
+ *
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #requestWindowFeature(int)}.
+ *
+ * @param secondaryProgress The secondary progress for the progress bar. Valid ranges are from
+ * 0 to 10000 (both inclusive).
+ */
+ public abstract void setSecondaryProgress(int secondaryProgress);
+
+ /**
+ * Get a menu inflater instance which supports the newer menu attributes.
+ *
+ * @return Menu inflater instance.
+ */
+ public MenuInflater getMenuInflater() {
+ if (DEBUG) Log.d(TAG, "[getMenuInflater]");
+
+ // Make sure that action views can get an appropriate theme.
+ if (mMenuInflater == null) {
+ if (getActionBar() != null) {
+ mMenuInflater = new MenuInflater(getThemedContext(), mActivity);
+ } else {
+ mMenuInflater = new MenuInflater(mActivity);
+ }
+ }
+ return mMenuInflater;
+ }
+
+ protected abstract Context getThemedContext();
+
+ /**
+ * Start an action mode.
+ *
+ * @param callback Callback that will manage lifecycle events for this
+ * context mode.
+ * @return The ContextMode that was started, or null if it was canceled.
+ * @see ActionMode
+ */
+ public abstract ActionMode startActionMode(ActionMode.Callback callback);
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java
new file mode 100644
index 000000000..03755be2b
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/ActionBar.java
@@ -0,0 +1,956 @@
+/*
+ * 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 com.actionbarsherlock.app;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.support.v4.app.FragmentTransaction;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewDebug;
+import android.view.ViewGroup;
+import android.view.ViewGroup.MarginLayoutParams;
+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.
+ * 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.
+ * 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. From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
+ * android.app.Activity#getActionBar getActionBar()}. 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}.
+ * For information about how to use the action bar, including how to add action items, navigation
+ * modes and more, read the Action
+ * Bar developer guide. 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 = android.app.ActionBar.DISPLAY_HOME_AS_UP;
+
+ /**
+ * 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 = android.app.ActionBar.DISPLAY_SHOW_TITLE;
+
+ /**
+ * 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 = android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
+
+ /**
+ * 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.
+ *
+ * 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. The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
+ * the custom view to be displayed. 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. The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
+ * the custom view to be displayed. 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ * 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:
+ * Very often tabs will be used to switch between {@link Fragment}
+ * objects. Here is a typical implementation of such tabs: Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}. 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.
+ *
+ * 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.
+ *
+ * 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 {
+ private static final int[] ATTRS = new int[] {
+ android.R.attr.layout_gravity
+ };
+
+ /**
+ * Gravity for the view associated with these LayoutParams.
+ *
+ * @see android.view.Gravity
+ */
+ @ViewDebug.ExportedProperty(mapping = {
+ @ViewDebug.IntToString(from = -1, to = "NONE"),
+ @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),
+ @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),
+ @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),
+ @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),
+ @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),
+ @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),
+ @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),
+ @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),
+ @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),
+ @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),
+ @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")
+ })
+ public int gravity = -1;
+
+ public LayoutParams(Context c, AttributeSet attrs) {
+ super(c, attrs);
+
+ TypedArray a = c.obtainStyledAttributes(attrs, ATTRS);
+ gravity = a.getInt(0, -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);
+ }
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java
new file mode 100644
index 000000000..7b4543640
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockActivity.java
@@ -0,0 +1,270 @@
+package com.actionbarsherlock.app;
+
+import android.app.Activity;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.ViewGroup.LayoutParams;
+import com.actionbarsherlock.ActionBarSherlock;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
+import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+public abstract class SherlockActivity extends Activity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
+ private ActionBarSherlock mSherlock;
+
+ protected final ActionBarSherlock getSherlock() {
+ if (mSherlock == null) {
+ mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
+ }
+ return mSherlock;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Action bar and mode
+ ///////////////////////////////////////////////////////////////////////////
+
+ public ActionBar getSupportActionBar() {
+ return getSherlock().getActionBar();
+ }
+
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ return getSherlock().startActionMode(callback);
+ }
+
+ @Override
+ public void onActionModeStarted(ActionMode mode) {}
+
+ @Override
+ public void onActionModeFinished(ActionMode mode) {}
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // General lifecycle/callback dispatching
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ getSherlock().dispatchConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ getSherlock().dispatchPostResume();
+ }
+
+ @Override
+ protected void onPause() {
+ getSherlock().dispatchPause();
+ super.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ getSherlock().dispatchStop();
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ getSherlock().dispatchDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ getSherlock().dispatchPostCreate(savedInstanceState);
+ super.onPostCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color) {
+ getSherlock().dispatchTitleChanged(title, color);
+ super.onTitleChanged(title, color);
+ }
+
+ @Override
+ public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
+ if (getSherlock().dispatchMenuOpened(featureId, menu)) {
+ return true;
+ }
+ return super.onMenuOpened(featureId, menu);
+ }
+
+ @Override
+ public void onPanelClosed(int featureId, android.view.Menu menu) {
+ getSherlock().dispatchPanelClosed(featureId, menu);
+ super.onPanelClosed(featureId, menu);
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (getSherlock().dispatchKeyEvent(event)) {
+ return true;
+ }
+ return super.dispatchKeyEvent(event);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ getSherlock().dispatchSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ getSherlock().dispatchRestoreInstanceState(savedInstanceState);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Native menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ public MenuInflater getSupportMenuInflater() {
+ return getSherlock().getMenuInflater();
+ }
+
+ public void invalidateOptionsMenu() {
+ getSherlock().dispatchInvalidateOptionsMenu();
+ }
+
+ public void supportInvalidateOptionsMenu() {
+ invalidateOptionsMenu();
+ }
+
+ @Override
+ public final boolean onCreateOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return getSherlock().dispatchOptionsItemSelected(item);
+ }
+
+ @Override
+ public void openOptionsMenu() {
+ if (!getSherlock().dispatchOpenOptionsMenu()) {
+ super.openOptionsMenu();
+ }
+ }
+
+ @Override
+ public void closeOptionsMenu() {
+ if (!getSherlock().dispatchCloseOptionsMenu()) {
+ super.closeOptionsMenu();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Sherlock menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onCreateOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onPrepareOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onOptionsItemSelected(item);
+ }
+ return false;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return false;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Content
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void addContentView(View view, LayoutParams params) {
+ getSherlock().addContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(int layoutResId) {
+ getSherlock().setContentView(layoutResId);
+ }
+
+ @Override
+ public void setContentView(View view, LayoutParams params) {
+ getSherlock().setContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(View view) {
+ getSherlock().setContentView(view);
+ }
+
+ public void requestWindowFeature(long featureId) {
+ getSherlock().requestFeature((int)featureId);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Progress Indication
+ ///////////////////////////////////////////////////////////////////////////
+
+ public void setSupportProgress(int progress) {
+ getSherlock().setProgress(progress);
+ }
+
+ public void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ getSherlock().setProgressBarIndeterminate(indeterminate);
+ }
+
+ public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ getSherlock().setProgressBarIndeterminateVisibility(visible);
+ }
+
+ public void setSupportProgressBarVisibility(boolean visible) {
+ getSherlock().setProgressBarVisibility(visible);
+ }
+
+ public void setSupportSecondaryProgress(int secondaryProgress) {
+ getSherlock().setSecondaryProgress(secondaryProgress);
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java
new file mode 100644
index 000000000..a7c856bf0
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockDialogFragment.java
@@ -0,0 +1,68 @@
+package com.actionbarsherlock.app;
+
+import android.app.Activity;
+import android.support.v4.app.DialogFragment;
+import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
+import com.actionbarsherlock.internal.view.menu.MenuWrapper;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
+
+public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
+ private SherlockFragmentActivity mActivity;
+
+ public SherlockFragmentActivity getSherlockActivity() {
+ return mActivity;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ if (!(activity instanceof SherlockFragmentActivity)) {
+ throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
+ }
+ mActivity = (SherlockFragmentActivity)activity;
+
+ super.onAttach(activity);
+ }
+
+ @Override
+ public void onDetach() {
+ mActivity = null;
+ super.onDetach();
+ }
+
+ @Override
+ public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
+ onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ //Nothing to see here.
+ }
+
+ @Override
+ public final void onPrepareOptionsMenu(android.view.Menu menu) {
+ onPrepareOptionsMenu(new MenuWrapper(menu));
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ //Nothing to see here.
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return onOptionsItemSelected(new MenuItemWrapper(item));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ //Nothing to see here.
+ return false;
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java
new file mode 100644
index 000000000..078f9b0ca
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java
@@ -0,0 +1,259 @@
+package com.actionbarsherlock.app;
+
+import android.app.ExpandableListActivity;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
+import com.actionbarsherlock.ActionBarSherlock;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
+import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+public abstract class SherlockExpandableListActivity extends ExpandableListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
+ private ActionBarSherlock mSherlock;
+
+ protected final ActionBarSherlock getSherlock() {
+ if (mSherlock == null) {
+ mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
+ }
+ return mSherlock;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Action bar and mode
+ ///////////////////////////////////////////////////////////////////////////
+
+ public ActionBar getSupportActionBar() {
+ return getSherlock().getActionBar();
+ }
+
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ return getSherlock().startActionMode(callback);
+ }
+
+ @Override
+ public void onActionModeStarted(ActionMode mode) {}
+
+ @Override
+ public void onActionModeFinished(ActionMode mode) {}
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // General lifecycle/callback dispatching
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ getSherlock().dispatchConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ getSherlock().dispatchPostResume();
+ }
+
+ @Override
+ protected void onPause() {
+ getSherlock().dispatchPause();
+ super.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ getSherlock().dispatchStop();
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ getSherlock().dispatchDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ getSherlock().dispatchPostCreate(savedInstanceState);
+ super.onPostCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color) {
+ getSherlock().dispatchTitleChanged(title, color);
+ super.onTitleChanged(title, color);
+ }
+
+ @Override
+ public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
+ if (getSherlock().dispatchMenuOpened(featureId, menu)) {
+ return true;
+ }
+ return super.onMenuOpened(featureId, menu);
+ }
+
+ @Override
+ public void onPanelClosed(int featureId, android.view.Menu menu) {
+ getSherlock().dispatchPanelClosed(featureId, menu);
+ super.onPanelClosed(featureId, menu);
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (getSherlock().dispatchKeyEvent(event)) {
+ return true;
+ }
+ return super.dispatchKeyEvent(event);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Native menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ public MenuInflater getSupportMenuInflater() {
+ return getSherlock().getMenuInflater();
+ }
+
+ public void invalidateOptionsMenu() {
+ getSherlock().dispatchInvalidateOptionsMenu();
+ }
+
+ public void supportInvalidateOptionsMenu() {
+ invalidateOptionsMenu();
+ }
+
+ @Override
+ public final boolean onCreateOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return getSherlock().dispatchOptionsItemSelected(item);
+ }
+
+ @Override
+ public void openOptionsMenu() {
+ if (!getSherlock().dispatchOpenOptionsMenu()) {
+ super.openOptionsMenu();
+ }
+ }
+
+ @Override
+ public void closeOptionsMenu() {
+ if (!getSherlock().dispatchCloseOptionsMenu()) {
+ super.closeOptionsMenu();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Sherlock menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onCreateOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onPrepareOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onOptionsItemSelected(item);
+ }
+ return false;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return false;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Content
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void addContentView(View view, LayoutParams params) {
+ getSherlock().addContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(int layoutResId) {
+ getSherlock().setContentView(layoutResId);
+ }
+
+ @Override
+ public void setContentView(View view, LayoutParams params) {
+ getSherlock().setContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(View view) {
+ getSherlock().setContentView(view);
+ }
+
+ public void requestWindowFeature(long featureId) {
+ getSherlock().requestFeature((int)featureId);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Progress Indication
+ ///////////////////////////////////////////////////////////////////////////
+
+ public void setSupportProgress(int progress) {
+ getSherlock().setProgress(progress);
+ }
+
+ public void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ getSherlock().setProgressBarIndeterminate(indeterminate);
+ }
+
+ public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ getSherlock().setProgressBarIndeterminateVisibility(visible);
+ }
+
+ public void setSupportProgressBarVisibility(boolean visible) {
+ getSherlock().setProgressBarVisibility(visible);
+ }
+
+ public void setSupportSecondaryProgress(int secondaryProgress) {
+ getSherlock().setSecondaryProgress(secondaryProgress);
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java
new file mode 100644
index 000000000..0f24e9c85
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java
@@ -0,0 +1,68 @@
+package com.actionbarsherlock.app;
+
+import android.app.Activity;
+import android.support.v4.app.Fragment;
+import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
+import com.actionbarsherlock.internal.view.menu.MenuWrapper;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
+
+public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
+ private SherlockFragmentActivity mActivity;
+
+ public SherlockFragmentActivity getSherlockActivity() {
+ return mActivity;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ if (!(activity instanceof SherlockFragmentActivity)) {
+ throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
+ }
+ mActivity = (SherlockFragmentActivity)activity;
+
+ super.onAttach(activity);
+ }
+
+ @Override
+ public void onDetach() {
+ mActivity = null;
+ super.onDetach();
+ }
+
+ @Override
+ public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
+ onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ //Nothing to see here.
+ }
+
+ @Override
+ public final void onPrepareOptionsMenu(android.view.Menu menu) {
+ onPrepareOptionsMenu(new MenuWrapper(menu));
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ //Nothing to see here.
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return onOptionsItemSelected(new MenuItemWrapper(item));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ //Nothing to see here.
+ return false;
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
new file mode 100644
index 000000000..3d092f033
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragmentActivity.java
@@ -0,0 +1,303 @@
+package com.actionbarsherlock.app;
+
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.Watson;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
+import com.actionbarsherlock.ActionBarSherlock;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+import static com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
+import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
+
+/** @see {@link android.support.v4.app.Watson} */
+public class SherlockFragmentActivity extends Watson implements OnActionModeStartedListener, OnActionModeFinishedListener {
+ private static final boolean DEBUG = false;
+ private static final String TAG = "SherlockFragmentActivity";
+
+ private ActionBarSherlock mSherlock;
+ private boolean mIgnoreNativeCreate = false;
+ private boolean mIgnoreNativePrepare = false;
+ private boolean mIgnoreNativeSelected = false;
+
+ protected final ActionBarSherlock getSherlock() {
+ if (mSherlock == null) {
+ mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
+ }
+ return mSherlock;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Action bar and mode
+ ///////////////////////////////////////////////////////////////////////////
+
+ public ActionBar getSupportActionBar() {
+ return getSherlock().getActionBar();
+ }
+
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ return getSherlock().startActionMode(callback);
+ }
+
+ @Override
+ public void onActionModeStarted(ActionMode mode) {}
+
+ @Override
+ public void onActionModeFinished(ActionMode mode) {}
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // General lifecycle/callback dispatching
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ getSherlock().dispatchConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ getSherlock().dispatchPostResume();
+ }
+
+ @Override
+ protected void onPause() {
+ getSherlock().dispatchPause();
+ super.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ getSherlock().dispatchStop();
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ getSherlock().dispatchDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ getSherlock().dispatchPostCreate(savedInstanceState);
+ super.onPostCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color) {
+ getSherlock().dispatchTitleChanged(title, color);
+ super.onTitleChanged(title, color);
+ }
+
+ @Override
+ public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
+ if (getSherlock().dispatchMenuOpened(featureId, menu)) {
+ return true;
+ }
+ return super.onMenuOpened(featureId, menu);
+ }
+
+ @Override
+ public void onPanelClosed(int featureId, android.view.Menu menu) {
+ getSherlock().dispatchPanelClosed(featureId, menu);
+ super.onPanelClosed(featureId, menu);
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (getSherlock().dispatchKeyEvent(event)) {
+ return true;
+ }
+ return super.dispatchKeyEvent(event);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ getSherlock().dispatchSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ getSherlock().dispatchRestoreInstanceState(savedInstanceState);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Native menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ public MenuInflater getSupportMenuInflater() {
+ if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]");
+
+ return getSherlock().getMenuInflater();
+ }
+
+ public void invalidateOptionsMenu() {
+ if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]");
+
+ getSherlock().dispatchInvalidateOptionsMenu();
+ }
+
+ public void supportInvalidateOptionsMenu() {
+ if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]");
+
+ invalidateOptionsMenu();
+ }
+
+ @Override
+ public final boolean onCreatePanelMenu(int featureId, android.view.Menu menu) {
+ if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu);
+
+ if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeCreate) {
+ mIgnoreNativeCreate = true;
+ boolean result = getSherlock().dispatchCreateOptionsMenu(menu);
+ mIgnoreNativeCreate = false;
+
+ if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result);
+ return result;
+ }
+ return super.onCreatePanelMenu(featureId, menu);
+ }
+
+ @Override
+ public final boolean onCreateOptionsMenu(android.view.Menu menu) {
+ return true;
+ }
+
+ @Override
+ public final boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
+ if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + ", menu: " + menu);
+
+ if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativePrepare) {
+ mIgnoreNativePrepare = true;
+ boolean result = getSherlock().dispatchPrepareOptionsMenu(menu);
+ mIgnoreNativePrepare = false;
+
+ if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result);
+ return result;
+ }
+ return super.onPreparePanel(featureId, view, menu);
+ }
+
+ @Override
+ public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ return true;
+ }
+
+ @Override
+ public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
+ if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);
+
+ if (featureId == Window.FEATURE_OPTIONS_PANEL && !mIgnoreNativeSelected) {
+ mIgnoreNativeSelected = true;
+ boolean result = getSherlock().dispatchOptionsItemSelected(item);
+ mIgnoreNativeSelected = false;
+
+ if (DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result);
+ return result;
+ }
+ return super.onMenuItemSelected(featureId, item);
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return false;
+ }
+
+ @Override
+ public void openOptionsMenu() {
+ if (!getSherlock().dispatchOpenOptionsMenu()) {
+ super.openOptionsMenu();
+ }
+ }
+
+ @Override
+ public void closeOptionsMenu() {
+ if (!getSherlock().dispatchCloseOptionsMenu()) {
+ super.closeOptionsMenu();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Sherlock menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return false;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Content
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void addContentView(View view, LayoutParams params) {
+ getSherlock().addContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(int layoutResId) {
+ getSherlock().setContentView(layoutResId);
+ }
+
+ @Override
+ public void setContentView(View view, LayoutParams params) {
+ getSherlock().setContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(View view) {
+ getSherlock().setContentView(view);
+ }
+
+ public void requestWindowFeature(long featureId) {
+ getSherlock().requestFeature((int)featureId);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Progress Indication
+ ///////////////////////////////////////////////////////////////////////////
+
+ public void setSupportProgress(int progress) {
+ getSherlock().setProgress(progress);
+ }
+
+ public void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ getSherlock().setProgressBarIndeterminate(indeterminate);
+ }
+
+ public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ getSherlock().setProgressBarIndeterminateVisibility(visible);
+ }
+
+ public void setSupportProgressBarVisibility(boolean visible) {
+ getSherlock().setProgressBarVisibility(visible);
+ }
+
+ public void setSupportSecondaryProgress(int secondaryProgress) {
+ getSherlock().setSecondaryProgress(secondaryProgress);
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java
new file mode 100644
index 000000000..aba6d85e8
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListActivity.java
@@ -0,0 +1,270 @@
+package com.actionbarsherlock.app;
+
+import android.app.ListActivity;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.ViewGroup.LayoutParams;
+import com.actionbarsherlock.ActionBarSherlock;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
+import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+public abstract class SherlockListActivity extends ListActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
+ private ActionBarSherlock mSherlock;
+
+ protected final ActionBarSherlock getSherlock() {
+ if (mSherlock == null) {
+ mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
+ }
+ return mSherlock;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Action bar and mode
+ ///////////////////////////////////////////////////////////////////////////
+
+ public ActionBar getSupportActionBar() {
+ return getSherlock().getActionBar();
+ }
+
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ return getSherlock().startActionMode(callback);
+ }
+
+ @Override
+ public void onActionModeStarted(ActionMode mode) {}
+
+ @Override
+ public void onActionModeFinished(ActionMode mode) {}
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // General lifecycle/callback dispatching
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ getSherlock().dispatchConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ getSherlock().dispatchPostResume();
+ }
+
+ @Override
+ protected void onPause() {
+ getSherlock().dispatchPause();
+ super.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ getSherlock().dispatchStop();
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ getSherlock().dispatchDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ getSherlock().dispatchPostCreate(savedInstanceState);
+ super.onPostCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color) {
+ getSherlock().dispatchTitleChanged(title, color);
+ super.onTitleChanged(title, color);
+ }
+
+ @Override
+ public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
+ if (getSherlock().dispatchMenuOpened(featureId, menu)) {
+ return true;
+ }
+ return super.onMenuOpened(featureId, menu);
+ }
+
+ @Override
+ public void onPanelClosed(int featureId, android.view.Menu menu) {
+ getSherlock().dispatchPanelClosed(featureId, menu);
+ super.onPanelClosed(featureId, menu);
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (getSherlock().dispatchKeyEvent(event)) {
+ return true;
+ }
+ return super.dispatchKeyEvent(event);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ getSherlock().dispatchSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ getSherlock().dispatchRestoreInstanceState(savedInstanceState);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Native menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ public MenuInflater getSupportMenuInflater() {
+ return getSherlock().getMenuInflater();
+ }
+
+ public void invalidateOptionsMenu() {
+ getSherlock().dispatchInvalidateOptionsMenu();
+ }
+
+ public void supportInvalidateOptionsMenu() {
+ invalidateOptionsMenu();
+ }
+
+ @Override
+ public final boolean onCreateOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return getSherlock().dispatchOptionsItemSelected(item);
+ }
+
+ @Override
+ public void openOptionsMenu() {
+ if (!getSherlock().dispatchOpenOptionsMenu()) {
+ super.openOptionsMenu();
+ }
+ }
+
+ @Override
+ public void closeOptionsMenu() {
+ if (!getSherlock().dispatchCloseOptionsMenu()) {
+ super.closeOptionsMenu();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Sherlock menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onCreateOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onPrepareOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onOptionsItemSelected(item);
+ }
+ return false;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return false;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Content
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void addContentView(View view, LayoutParams params) {
+ getSherlock().addContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(int layoutResId) {
+ getSherlock().setContentView(layoutResId);
+ }
+
+ @Override
+ public void setContentView(View view, LayoutParams params) {
+ getSherlock().setContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(View view) {
+ getSherlock().setContentView(view);
+ }
+
+ public void requestWindowFeature(long featureId) {
+ getSherlock().requestFeature((int)featureId);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Progress Indication
+ ///////////////////////////////////////////////////////////////////////////
+
+ public void setSupportProgress(int progress) {
+ getSherlock().setProgress(progress);
+ }
+
+ public void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ getSherlock().setProgressBarIndeterminate(indeterminate);
+ }
+
+ public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ getSherlock().setProgressBarIndeterminateVisibility(visible);
+ }
+
+ public void setSupportProgressBarVisibility(boolean visible) {
+ getSherlock().setProgressBarVisibility(visible);
+ }
+
+ public void setSupportSecondaryProgress(int secondaryProgress) {
+ getSherlock().setSecondaryProgress(secondaryProgress);
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java
new file mode 100644
index 000000000..13ca3c49f
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockListFragment.java
@@ -0,0 +1,68 @@
+package com.actionbarsherlock.app;
+
+import android.app.Activity;
+import android.support.v4.app.ListFragment;
+import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
+import com.actionbarsherlock.internal.view.menu.MenuWrapper;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnCreateOptionsMenuListener;
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnOptionsItemSelectedListener;
+import static com.actionbarsherlock.app.SherlockFragmentActivity.OnPrepareOptionsMenuListener;
+
+public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
+ private SherlockFragmentActivity mActivity;
+
+ public SherlockFragmentActivity getSherlockActivity() {
+ return mActivity;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ if (!(activity instanceof SherlockFragmentActivity)) {
+ throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
+ }
+ mActivity = (SherlockFragmentActivity)activity;
+
+ super.onAttach(activity);
+ }
+
+ @Override
+ public void onDetach() {
+ mActivity = null;
+ super.onDetach();
+ }
+
+ @Override
+ public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
+ onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ //Nothing to see here.
+ }
+
+ @Override
+ public final void onPrepareOptionsMenu(android.view.Menu menu) {
+ onPrepareOptionsMenu(new MenuWrapper(menu));
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ //Nothing to see here.
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return onOptionsItemSelected(new MenuItemWrapper(item));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ //Nothing to see here.
+ return false;
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java
new file mode 100644
index 000000000..bee72cb25
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java
@@ -0,0 +1,270 @@
+package com.actionbarsherlock.app;
+
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
+import com.actionbarsherlock.ActionBarSherlock;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
+import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
+import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+public abstract class SherlockPreferenceActivity extends PreferenceActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener, OnActionModeStartedListener, OnActionModeFinishedListener {
+ private ActionBarSherlock mSherlock;
+
+ protected final ActionBarSherlock getSherlock() {
+ if (mSherlock == null) {
+ mSherlock = ActionBarSherlock.wrap(this, ActionBarSherlock.FLAG_DELEGATE);
+ }
+ return mSherlock;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Action bar and mode
+ ///////////////////////////////////////////////////////////////////////////
+
+ public ActionBar getSupportActionBar() {
+ return getSherlock().getActionBar();
+ }
+
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ return getSherlock().startActionMode(callback);
+ }
+
+ @Override
+ public void onActionModeStarted(ActionMode mode) {}
+
+ @Override
+ public void onActionModeFinished(ActionMode mode) {}
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // General lifecycle/callback dispatching
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ getSherlock().dispatchConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onPostResume() {
+ super.onPostResume();
+ getSherlock().dispatchPostResume();
+ }
+
+ @Override
+ protected void onPause() {
+ getSherlock().dispatchPause();
+ super.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ getSherlock().dispatchStop();
+ super.onStop();
+ }
+
+ @Override
+ protected void onDestroy() {
+ getSherlock().dispatchDestroy();
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ getSherlock().dispatchPostCreate(savedInstanceState);
+ super.onPostCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color) {
+ getSherlock().dispatchTitleChanged(title, color);
+ super.onTitleChanged(title, color);
+ }
+
+ @Override
+ public final boolean onMenuOpened(int featureId, android.view.Menu menu) {
+ if (getSherlock().dispatchMenuOpened(featureId, menu)) {
+ return true;
+ }
+ return super.onMenuOpened(featureId, menu);
+ }
+
+ @Override
+ public void onPanelClosed(int featureId, android.view.Menu menu) {
+ getSherlock().dispatchPanelClosed(featureId, menu);
+ super.onPanelClosed(featureId, menu);
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (getSherlock().dispatchKeyEvent(event)) {
+ return true;
+ }
+ return super.dispatchKeyEvent(event);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ getSherlock().dispatchSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ getSherlock().dispatchRestoreInstanceState(savedInstanceState);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Native menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ public MenuInflater getSupportMenuInflater() {
+ return getSherlock().getMenuInflater();
+ }
+
+ public void invalidateOptionsMenu() {
+ getSherlock().dispatchInvalidateOptionsMenu();
+ }
+
+ public void supportInvalidateOptionsMenu() {
+ invalidateOptionsMenu();
+ }
+
+ @Override
+ public final boolean onCreateOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ return getSherlock().dispatchPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return getSherlock().dispatchOptionsItemSelected(item);
+ }
+
+ @Override
+ public void openOptionsMenu() {
+ if (!getSherlock().dispatchOpenOptionsMenu()) {
+ super.openOptionsMenu();
+ }
+ }
+
+ @Override
+ public void closeOptionsMenu() {
+ if (!getSherlock().dispatchCloseOptionsMenu()) {
+ super.closeOptionsMenu();
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Sherlock menu handling
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onCreateOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onPrepareOptionsMenu(menu);
+ }
+ return false;
+ }
+
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return onOptionsItemSelected(item);
+ }
+ return false;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return false;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Content
+ ///////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void addContentView(View view, LayoutParams params) {
+ getSherlock().addContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(int layoutResId) {
+ getSherlock().setContentView(layoutResId);
+ }
+
+ @Override
+ public void setContentView(View view, LayoutParams params) {
+ getSherlock().setContentView(view, params);
+ }
+
+ @Override
+ public void setContentView(View view) {
+ getSherlock().setContentView(view);
+ }
+
+ public void requestWindowFeature(long featureId) {
+ getSherlock().requestFeature((int)featureId);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Progress Indication
+ ///////////////////////////////////////////////////////////////////////////
+
+ public void setSupportProgress(int progress) {
+ getSherlock().setProgress(progress);
+ }
+
+ public void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ getSherlock().setProgressBarIndeterminate(indeterminate);
+ }
+
+ public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ getSherlock().setProgressBarIndeterminateVisibility(visible);
+ }
+
+ public void setSupportProgressBarVisibility(boolean visible) {
+ getSherlock().setProgressBarVisibility(visible);
+ }
+
+ public void setSupportSecondaryProgress(int secondaryProgress) {
+ getSherlock().setSecondaryProgress(secondaryProgress);
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
new file mode 100644
index 000000000..5e69275c7
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java
@@ -0,0 +1,1203 @@
+package com.actionbarsherlock.internal;
+
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.xmlpull.v1.XmlPullParser;
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.content.res.AssetManager;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
+import android.os.Bundle;
+import android.util.AndroidRuntimeException;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.ContextThemeWrapper;
+import android.view.KeyCharacterMap;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewStub;
+import android.view.Window;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+import com.actionbarsherlock.ActionBarSherlock;
+import com.actionbarsherlock.R;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.internal.app.ActionBarImpl;
+import com.actionbarsherlock.internal.view.StandaloneActionMode;
+import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter;
+import com.actionbarsherlock.internal.view.menu.MenuBuilder;
+import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
+import com.actionbarsherlock.internal.view.menu.MenuPresenter;
+import com.actionbarsherlock.internal.widget.ActionBarContainer;
+import com.actionbarsherlock.internal.widget.ActionBarContextView;
+import com.actionbarsherlock.internal.widget.ActionBarView;
+import com.actionbarsherlock.internal.widget.IcsProgressBar;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+
+@ActionBarSherlock.Implementation(api = 7)
+public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener {
+ /** Window features which are enabled by default. */
+ protected static final int DEFAULT_FEATURES = 0;
+
+ static private final String PANELS_TAG = "sherlock:Panels";
+
+ public ActionBarSherlockCompat(Activity activity, int flags) {
+ super(activity, flags);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Properties
+ ///////////////////////////////////////////////////////////////////////////
+
+ /** Whether or not the device has a dedicated menu key button. */
+ private boolean mReserveOverflow;
+ /** Lazy-load indicator for {@link #mReserveOverflow}. */
+ private boolean mReserveOverflowSet = false;
+
+ /** Current menu instance for managing action items. */
+ private MenuBuilder mMenu;
+ /** Map between native options items and sherlock items. */
+ protected HashMap The animation started by calling this method will be run on the thread that called
+ * this method. This thread should have a Looper on it (a runtime exception will be thrown if
+ * this is not the case). Also, if the animation will animate
+ * properties of objects in the view hierarchy, then the calling thread should be the UI
+ * thread for that view hierarchy. This method must be called on the thread that is running the animation. This method must be called on the thread that is running the animation. An animation listener receives notifications from an animation.
+ * Notifications indicate animation related events, such as the end or the
+ * repetition of the animation. Notifies the start of the animation. Notifies the end of the animation. This callback is not invoked
+ * for animations with repeat count set to INFINITE. Notifies the cancellation of the animation. This callback is not invoked
+ * for animations with repeat count set to INFINITE. Notifies the repetition of the animation. There are two different approaches to adding animations to a It is possible to set up a Note that Note that ending a Starting this The For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to
+ * play when anim2 finishes, and anim4 to play when anim3 finishes: Note in the example that both {@link Builder#before(Animator)} and {@link
+ * Builder#after(Animator)} are used. These are just different ways of expressing the same
+ * relationship and are provided to make it easier to say things in a way that is more natural,
+ * depending on the situation. It is possible to make several calls into the same Note that it is possible to express relationships that cannot be resolved and will not
+ * result in sensible results. For example, This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
+ * int, exists to speed up the getValue() method when there is no custom
+ * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
+ * Object equivalents of these primitive types. This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
+ * float, exists to speed up the getValue() method when there is no custom
+ * TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
+ * Object equivalents of these primitive types. The Keyframe class itself is abstract. The type-specific factory methods will return
+ * a subclass of Keyframe specific to the type of value being stored. This is done to improve
+ * performance when dealing with the most common cases (e.g., For best performance of the mechanism that calls the setter function determined by the
+ * name of the property being animated, use Note that the setter function derived from this property name
+ * must take the same parameter type as the
+ * If this ObjectAnimator has been set up to animate several properties together,
+ * using more than one PropertyValuesHolder objects, then setting the propertyName simply
+ * sets the propertyName in the first of those PropertyValuesHolder objects. Overriders of this method should call the superclass method to cause
+ * internal mechanisms to be set up correctly. Overrides of this method must call the superclass to perform the calculation
+ * of the animated value. If there is only one value, it is assumed to be the end value of an animation,
+ * and an initial value will be derived, if possible, by calling a getter function
+ * on the object. Also, if any value is null, the value will be filled in when the animation
+ * starts in the same way. This mechanism of automatically getting null values only works
+ * if the PropertyValuesHolder object is used in conjunction
+ * {@link ObjectAnimator}, and with a getter function
+ * derived automatically from If there is only one value, it is assumed to be the end value of an animation,
+ * and an initial value will be derived, if possible, by calling the property's
+ * {@link android.util.Property#get(Object)} function.
+ * Also, if any value is null, the value will be filled in when the animation
+ * starts in the same way. This mechanism of automatically getting null values only works
+ * if the PropertyValuesHolder object is used in conjunction with
+ * {@link ObjectAnimator}, since otherwise PropertyValuesHolder has
+ * no way of determining what the value should be.
+ * @param property The property associated with this set of values. Should not be null.
+ * @param values The set of values to animate between.
+ */
+ //public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) {
+ // KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
+ // if (keyframeSet instanceof IntKeyframeSet) {
+ // return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet);
+ // } else if (keyframeSet instanceof FloatKeyframeSet) {
+ // return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet);
+ // }
+ // else {
+ // PropertyValuesHolder pvh = new PropertyValuesHolder(property);
+ // pvh.mKeyframeSet = keyframeSet;
+ // pvh.mValueType = ((Keyframe)values[0]).getType();
+ // return pvh;
+ // }
+ //}
+
+ /**
+ * Set the animated values for this object to this set of ints.
+ * If there is only one value, it is assumed to be the end value of an animation,
+ * and an initial value will be derived, if possible, by calling a getter function
+ * on the object. Also, if any value is null, the value will be filled in when the animation
+ * starts in the same way. This mechanism of automatically getting null values only works
+ * if the PropertyValuesHolder object is used in conjunction
+ * {@link ObjectAnimator}, and with a getter function
+ * derived automatically from Note that the setter function derived from this property name
+ * must take the same parameter type as the
+ * Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property
+ * must exist on the target object specified in that ObjectAnimator. There is a single timing pulse that all animations use. It runs in a
+ * custom handler to ensure that property changes happen on the UI thread. By default, ValueAnimator uses non-linear time interpolation, via the
+ * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates
+ * out of an animation. This behavior can be changed by calling
+ * {@link ValueAnimator#setInterpolator(TimeInterpolator)}. Since ValueAnimator does not know how to animate between arbitrary Objects, this
+ * factory method also takes a TypeEvaluator object that the ValueAnimator will use
+ * to perform that interpolation.
+ *
+ * @param evaluator A TypeEvaluator that will be called on each animation frame to
+ * provide the ncessry interpolation between the Object values to derive the animated
+ * value.
+ * @param values A set of values that the animation will animate between over time.
+ * @return A ValueAnimator object that is set up to animate between the given values.
+ */
+ public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) {
+ ValueAnimator anim = new ValueAnimator();
+ anim.setObjectValues(values);
+ anim.setEvaluator(evaluator);
+ return anim;
+ }
+
+ /**
+ * Sets int values that will be animated between. A single
+ * value implies that that value is the one being animated to. However, this is not typically
+ * useful in a ValueAnimator object because there is no way for the object to determine the
+ * starting value for the animation (unlike ObjectAnimator, which can derive that value
+ * from the target object and property being animated). Therefore, there should typically
+ * be two or more values.
+ *
+ * If there are already multiple sets of values defined for this ValueAnimator via more
+ * than one PropertyValuesHolder object, this method will set the values for the first
+ * of those objects. If there are already multiple sets of values defined for this ValueAnimator via more
+ * than one PropertyValuesHolder object, this method will set the values for the first
+ * of those objects. If there are already multiple sets of values defined for this ValueAnimator via more
+ * than one PropertyValuesHolder object, this method will set the values for the first
+ * of those objects. There should be a TypeEvaluator set on the ValueAnimator that knows how to interpolate
+ * between these value objects. ValueAnimator only knows how to interpolate between the
+ * primitive types specified in the other setValues() methods. Overrides of this method should call the superclass method to ensure
+ * that internal mechanisms for the animation are set up correctly. If this ValueAnimator has only one set of values being animated between, this evaluator
+ * will be used for that set. If there are several sets of values being animated, which is
+ * the case if PropertyValuesHOlder objects were set on the ValueAnimator, then the evaluator
+ * is assigned just to the first PropertyValuesHolder object. The animation started by calling this method will be run on the thread that called
+ * this method. This thread should have a Looper on it (a runtime exception will be thrown if
+ * this is not the case). Also, if the animation will animate
+ * properties of objects in the view hierarchy, then the calling thread should be the UI
+ * thread for that view hierarchy. Overrides of this method must call the superclass to perform the calculation
+ * of the animated value. Notifies the occurrence of another frame of the animation. 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);
+
+ int cellsUsed = 0;
+ if (cellsRemaining > 0) {
+ 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++;
+ }
+
+ final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
+ (ActionMenuItemView) child : null;
+ final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.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 = 0;//getDividerWidth();
+ int overflowWidth = 0;
+ //UNUSED 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();
+ 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;
+ //UNUSED nonOverflowWidth += size;
+ widthRemaining -= size;
+ //if (hasDividerBeforeChildAt(i)) {
+ //UNUSED 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;
+ }
+
+ //@Override
+ protected boolean hasDividerBeforeChildAt(int childIndex) {
+ if (childIndex == 0) {
+ return false;
+ }
+ 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 {
+ public boolean isOverflowButton;
+ public int cellsUsed;
+ public int extraPixels;
+ public boolean expandable;
+ 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/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java
new file mode 100644
index 000000000..6da26f2ae
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.java
@@ -0,0 +1,231 @@
+/*
+ * 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 com.actionbarsherlock.internal.view.menu;
+
+import java.util.ArrayList;
+import android.content.Context;
+import android.os.Build;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * 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 {
+ private static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
+
+ 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;
+ }
+
+ @Override
+ 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 Items are considered for inclusion in the order specified within the menu.
+ * There is a limit of mMaxActionItems as a total count, optionally including the overflow
+ * menu button itself. This is a soft limit; if an item shares a group ID with an item
+ * previously included as an action item, the new item will stay with its group and become
+ * an action item itself even if it breaks the max item count limit. This is done to
+ * limit the conceptual complexity of the items presented within an action bar. Only a few
+ * unrelated concepts should be presented to the user in this space, and groups are treated
+ * as a single concept.
+ *
+ * There is also a hard limit of consumed measurable space: mActionWidthLimit. This
+ * limit may be broken by a single item that exceeds the remaining space, but no further
+ * items may be added. If an item that is part of a group cannot fit within the remaining
+ * measured width, the entire group will be demoted to overflow. This is done to ensure room
+ * for navigation and other affordances in the action bar as well as reduce general UI clutter.
+ *
+ * The space freed by demoting a full group cannot be consumed by future menu items.
+ * Once items begin to overflow, all future items become overflow items as well. This is
+ * to avoid inadvertent reordering that may break the app's intended design.
+ */
+ public void flagActionItems() {
+ if (!mIsActionItemsStale) {
+ return;
+ }
+
+ // Presenters flag action items as needed.
+ boolean flagged = false;
+ for (WeakReference
+ * See {@link ListView}, {@link GridView}, {@link Spinner} and
+ * {@link Gallery} for commonly used subclasses of AdapterView.
+ *
+ * For more information about using AdapterView, read the
+ * Binding to Data with AdapterView
+ * developer guide. Callback method to be invoked when an item in this view has been
+ * selected. This callback is invoked only when the newly selected
+ * position is different from the previously selected position or if
+ * there was no selected item.
+ * Visual indicator of progress in some operation. Displays a bar to the user
+ * representing how far the operation has progressed; the application can
+ * change the amount of progress (modifying the length of the bar) as it moves
+ * forward. There is also a secondary progress displayable on a progress bar
+ * which is useful for displaying intermediate progress, such as the buffer
+ * level during a streaming playback progress bar.
+ *
+ * A progress bar can also be made indeterminate. In indeterminate mode, the
+ * progress bar shows a cyclic animation without an indication of progress. This mode is used by
+ * applications when the length of the task is unknown. The indeterminate progress bar can be either
+ * a spinning wheel or a horizontal bar.
+ * The following code example shows how a progress bar can be used from
+ * a worker thread to update the user interface to notify the user of progress:
+ * To add a progress bar to a layout file, you can use the {@code <ProgressBar>} element.
+ * By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a
+ * horizontal progress bar, apply the {@link android.R.style#Widget_ProgressBar_Horizontal
+ * Widget.ProgressBar.Horizontal} style, like so: If you will use the progress bar to show real progress, you must use the horizontal bar. You
+ * can then increment the progress with {@link #incrementProgressBy incrementProgressBy()} or
+ * {@link #setProgress setProgress()}. By default, the progress bar is full when it reaches 100. If
+ * necessary, you can adjust the maximum value (the value for a full bar) using the {@link
+ * android.R.styleable#ProgressBar_max android:max} attribute. Other attributes available are listed
+ * below. Another common style to apply to the progress bar is {@link
+ * android.R.style#Widget_ProgressBar_Small Widget.ProgressBar.Small}, which shows a smaller
+ * version of the spinning wheel—useful when waiting for content to load.
+ * For example, you can insert this kind of progress bar into your default layout for
+ * a view that will be populated by some content fetched from the Internet—the spinning wheel
+ * appears immediately and when your application receives the content, it replaces the progress bar
+ * with the loaded content. For example: Other progress bar styles provided by the system include: The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary
+ * if your application uses a light colored theme (a white background). XML attributes
+ *
+ * See {@link android.R.styleable#ProgressBar ProgressBar Attributes},
+ * {@link android.R.styleable#View View Attributes}
+ *
+ * Initialize the progress bar's default values:
+ * Indicate whether this progress bar is in indeterminate mode. Change the indeterminate mode for this progress bar. In indeterminate
+ * mode, the progress is ignored and the progress bar shows an infinite
+ * animation instead. Get the drawable used to draw the progress bar in
+ * indeterminate mode. Define the drawable used to draw the progress bar in
+ * indeterminate mode. Get the drawable used to draw the progress bar in
+ * progress mode. Define the drawable used to draw the progress bar in
+ * progress mode. Set the current progress to the specified value. Does not do anything
+ * if the progress bar is in indeterminate mode.
+ * Set the current secondary progress to the specified value. Does not do
+ * anything if the progress bar is in indeterminate mode.
+ * Get the progress bar's current level of progress. Return 0 when the
+ * progress bar is in indeterminate mode. Get the progress bar's current level of secondary progress. Return 0 when the
+ * progress bar is in indeterminate mode. Return the upper limit of this progress bar's range. Set the range of the progress bar to 0...max. Increase the progress bar's progress by the specified amount. Increase the progress bar's secondary progress by the specified amount. Start the indeterminate progress animation. Stop the indeterminate progress animation. See the Spinner
+ * tutorial. A spinner does not support item click events. Calling this method
+ * will raise an exception. Wrapper class for an Adapter. Transforms the embedded Adapter instance
+ * into a ListAdapter. Creates a new ListAdapter wrapper for the specified adapter. 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.
+ *
+ * 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 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.
+ *
+ * An action mode's lifecycle is as follows:
+ *
+ * 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.
+ *
+ * There are two ways for using an action provider for creating and handling of action views:
+ *
+ * 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.
+ *
+ * A menu item selection is processed in the following order:
+ *
+ * The default implementation does not perform any action and returns false.
+ * 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.
+ *
+ * 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/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java
new file mode 100644
index 000000000..43281b013
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/CollapsibleActionView.java
@@ -0,0 +1,39 @@
+/*
+ * 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 com.actionbarsherlock.view;
+
+/**
+ * When a {@link View} implements this interface it will receive callbacks
+ * when expanded or collapsed as an action view alongside the optional,
+ * app-specified callbacks to {@link OnActionExpandListener}.
+ *
+ * See {@link MenuItem} for more information about action views.
+ * See {@link android.app.ActionBar} for more information about the action bar.
+ */
+public interface CollapsibleActionView {
+ /**
+ * Called when this view is expanded as an action view.
+ * See {@link MenuItem#expandActionView()}.
+ */
+ public void onActionViewExpanded();
+
+ /**
+ * Called when this view is collapsed as an action view.
+ * See {@link MenuItem#collapseActionView()}.
+ */
+ public void onActionViewCollapsed();
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java
new file mode 100644
index 000000000..951f4ccef
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/Menu.java
@@ -0,0 +1,447 @@
+/*
+ * 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 com.actionbarsherlock.view;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.view.KeyEvent;
+
+/**
+ * Interface for managing the items in a menu.
+ *
+ * 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)}.
+ *
+ * Different menu types support different features:
+ * For more information about creating menus, read the
+ * Menus developer guide.
+ * 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.
+ *
+ *
+ * See {@link android.content.pm.PackageManager#queryIntentActivityOptions}
+ * for more * details on the caller, specifics, and
+ * intent arguments. The list returned by that function is used
+ * to populate the resulting menu items.
+ *
+ *
+ * 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 flags 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 specifics 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/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
new file mode 100644
index 000000000..5a0f40859
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
@@ -0,0 +1,495 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ * 2011 Jake Wharton
+ *
+ * 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 com.actionbarsherlock.view;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.TypedValue;
+import android.util.Xml;
+import android.view.InflateException;
+import android.view.View;
+
+import com.actionbarsherlock.R;
+import com.actionbarsherlock.internal.view.menu.MenuItemImpl;
+
+/**
+ * This class is used to instantiate menu XML files into Menu objects.
+ *
+ * For performance reasons, menu inflation relies heavily on pre-processing of
+ * XML files that is done at build time. Therefore, it is not currently possible
+ * to use MenuInflater with an XmlPullParser over a plain XML file at runtime;
+ * it only works with an XmlPullParser returned from a compiled resource (R.
+ * something file.)
+ */
+public class MenuInflater {
+ private static final String LOG_TAG = "MenuInflater";
+
+ /** Menu tag name in XML. */
+ private static final String XML_MENU = "menu";
+
+ /** Group tag name in XML. */
+ private static final String XML_GROUP = "group";
+
+ /** Item tag name in XML. */
+ private static final String XML_ITEM = "item";
+
+ private static final int NO_ID = 0;
+
+ private static final Class>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class};
+
+ private static final Class>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = ACTION_VIEW_CONSTRUCTOR_SIGNATURE;
+
+ private final Object[] mActionViewConstructorArguments;
+
+ private final Object[] mActionProviderConstructorArguments;
+
+ private Context mContext;
+ private Object mRealOwner;
+
+ /**
+ * Constructs a menu inflater.
+ *
+ * @see Activity#getMenuInflater()
+ */
+ public MenuInflater(Context context) {
+ mContext = context;
+ mRealOwner = context;
+ mActionViewConstructorArguments = new Object[] {context};
+ mActionProviderConstructorArguments = mActionViewConstructorArguments;
+ }
+
+ /**
+ * Constructs a menu inflater.
+ *
+ * @see Activity#getMenuInflater()
+ * @hide
+ */
+ public MenuInflater(Context context, Object realOwner) {
+ mContext = context;
+ mRealOwner = realOwner;
+ mActionViewConstructorArguments = new Object[] {context};
+ mActionProviderConstructorArguments = mActionViewConstructorArguments;
+ }
+
+ /**
+ * Inflate a menu hierarchy from the specified XML resource. Throws
+ * {@link InflateException} if there is an error.
+ *
+ * @param menuRes Resource ID for an XML layout resource to load (e.g.,
+ *
+ * Groups can not be nested unless there is another menu (which will have
+ * its state class).
+ */
+ private class MenuState {
+ private Menu menu;
+
+ /*
+ * Group state is set on items as they are added, allowing an item to
+ * override its group state. (As opposed to set on items at the group end tag.)
+ */
+ private int groupId;
+ private int groupCategory;
+ private int groupOrder;
+ private int groupCheckable;
+ private boolean groupVisible;
+ private boolean groupEnabled;
+
+ private boolean itemAdded;
+ private int itemId;
+ private int itemCategoryOrder;
+ private CharSequence itemTitle;
+ private CharSequence itemTitleCondensed;
+ private int itemIconResId;
+ private char itemAlphabeticShortcut;
+ private char itemNumericShortcut;
+ /**
+ * Sync to attrs.xml enum:
+ * - 0: none
+ * - 1: all
+ * - 2: exclusive
+ */
+ private int itemCheckable;
+ private boolean itemChecked;
+ private boolean itemVisible;
+ private boolean itemEnabled;
+
+ /**
+ * Sync to attrs.xml enum, values in MenuItem:
+ * - 0: never
+ * - 1: ifRoom
+ * - 2: always
+ * - -1: Safe sentinel for "no value".
+ */
+ private int itemShowAsAction;
+
+ private int itemActionViewLayout;
+ private String itemActionViewClassName;
+ private String itemActionProviderClassName;
+
+ private String itemListenerMethodName;
+
+ private ActionProvider itemActionProvider;
+
+ private static final int defaultGroupId = NO_ID;
+ private static final int defaultItemId = NO_ID;
+ private static final int defaultItemCategory = 0;
+ private static final int defaultItemOrder = 0;
+ private static final int defaultItemCheckable = 0;
+ private static final boolean defaultItemChecked = false;
+ private static final boolean defaultItemVisible = true;
+ private static final boolean defaultItemEnabled = true;
+
+ public MenuState(final Menu menu) {
+ this.menu = menu;
+
+ resetGroup();
+ }
+
+ public void resetGroup() {
+ groupId = defaultGroupId;
+ groupCategory = defaultItemCategory;
+ groupOrder = defaultItemOrder;
+ groupCheckable = defaultItemCheckable;
+ groupVisible = defaultItemVisible;
+ groupEnabled = defaultItemEnabled;
+ }
+
+ /**
+ * Called when the parser is pointing to a group tag.
+ */
+ public void readGroup(AttributeSet attrs) {
+ TypedArray a = mContext.obtainStyledAttributes(attrs,
+ R.styleable.SherlockMenuGroup);
+
+ groupId = a.getResourceId(R.styleable.SherlockMenuGroup_android_id, defaultGroupId);
+ groupCategory = a.getInt(R.styleable.SherlockMenuGroup_android_menuCategory, defaultItemCategory);
+ groupOrder = a.getInt(R.styleable.SherlockMenuGroup_android_orderInCategory, defaultItemOrder);
+ groupCheckable = a.getInt(R.styleable.SherlockMenuGroup_android_checkableBehavior, defaultItemCheckable);
+ groupVisible = a.getBoolean(R.styleable.SherlockMenuGroup_android_visible, defaultItemVisible);
+ groupEnabled = a.getBoolean(R.styleable.SherlockMenuGroup_android_enabled, defaultItemEnabled);
+
+ a.recycle();
+ }
+
+ /**
+ * Called when the parser is pointing to an item tag.
+ */
+ public void readItem(AttributeSet attrs) {
+ TypedArray a = mContext.obtainStyledAttributes(attrs,
+ R.styleable.SherlockMenuItem);
+
+ // Inherit attributes from the group as default value
+ itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId);
+ final int category = a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory);
+ final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder);
+ itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
+ itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title);
+ itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed);
+ itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0);
+ itemAlphabeticShortcut =
+ getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut));
+ itemNumericShortcut =
+ getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut));
+ if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) {
+ // Item has attribute checkable, use it
+ itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0;
+ } else {
+ // Item does not have attribute, use the group's (group can have one more state
+ // for checkable that represents the exclusive checkable)
+ itemCheckable = groupCheckable;
+ }
+
+ itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked);
+ itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible);
+ itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled);
+
+ TypedValue value = new TypedValue();
+ a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value);
+ itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1;
+
+ itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
+ itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
+
+ // itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
+ value = new TypedValue();
+ a.getValue(R.styleable.SherlockMenuItem_android_actionViewClass, value);
+ itemActionViewClassName = value.type == TypedValue.TYPE_STRING ? value.string.toString() : null;
+
+ // itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);
+ value = new TypedValue();
+ a.getValue(R.styleable.SherlockMenuItem_android_actionProviderClass, value);
+ itemActionProviderClassName = value.type == TypedValue.TYPE_STRING ? value.string.toString() : null;
+
+ final boolean hasActionProvider = itemActionProviderClassName != null;
+ if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
+ itemActionProvider = newInstance(itemActionProviderClassName,
+ ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
+ mActionProviderConstructorArguments);
+ } else {
+ if (hasActionProvider) {
+ Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'."
+ + " Action view already specified.");
+ }
+ itemActionProvider = null;
+ }
+
+ a.recycle();
+
+ itemAdded = false;
+ }
+
+ private char getShortcut(String shortcutString) {
+ if (shortcutString == null) {
+ return 0;
+ } else {
+ return shortcutString.charAt(0);
+ }
+ }
+
+ private void setItem(MenuItem item) {
+ item.setChecked(itemChecked)
+ .setVisible(itemVisible)
+ .setEnabled(itemEnabled)
+ .setCheckable(itemCheckable >= 1)
+ .setTitleCondensed(itemTitleCondensed)
+ .setIcon(itemIconResId)
+ .setAlphabeticShortcut(itemAlphabeticShortcut)
+ .setNumericShortcut(itemNumericShortcut);
+
+ if (itemShowAsAction >= 0) {
+ item.setShowAsAction(itemShowAsAction);
+ }
+
+ if (itemListenerMethodName != null) {
+ if (mContext.isRestricted()) {
+ throw new IllegalStateException("The android:onClick attribute cannot "
+ + "be used within a restricted context");
+ }
+ item.setOnMenuItemClickListener(
+ new InflatedOnMenuItemClickListener(mRealOwner, itemListenerMethodName));
+ }
+
+ if (itemCheckable >= 2) {
+ if (item instanceof MenuItemImpl) {
+ MenuItemImpl impl = (MenuItemImpl) item;
+ impl.setExclusiveCheckable(true);
+ } else {
+ menu.setGroupCheckable(groupId, true, true);
+ }
+ }
+
+ boolean actionViewSpecified = false;
+ if (itemActionViewClassName != null) {
+ View actionView = (View) newInstance(itemActionViewClassName,
+ ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments);
+ item.setActionView(actionView);
+ actionViewSpecified = true;
+ }
+ if (itemActionViewLayout > 0) {
+ if (!actionViewSpecified) {
+ item.setActionView(itemActionViewLayout);
+ actionViewSpecified = true;
+ } else {
+ Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'."
+ + " Action view already specified.");
+ }
+ }
+ if (itemActionProvider != null) {
+ item.setActionProvider(itemActionProvider);
+ }
+ }
+
+ public void addItem() {
+ itemAdded = true;
+ setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle));
+ }
+
+ public SubMenu addSubMenuItem() {
+ itemAdded = true;
+ SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle);
+ setItem(subMenu.getItem());
+ return subMenu;
+ }
+
+ public boolean hasAddedItem() {
+ return itemAdded;
+ }
+
+ @SuppressWarnings("unchecked")
+ private
+ * An Item is returned by calling one of the {@link android.view.Menu#add}
+ * methods.
+ *
+ * For a feature set of specific menu types, see {@link Menu}.
+ *
+ * For information about creating menus, read the
+ * Menus developer guide.
+ * 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 Menu#CATEGORY_SYSTEM},
+ * {@link Menu#CATEGORY_SECONDARY}, {@link Menu#CATEGORY_ALTERNATIVE},
+ * {@link Menu#CATEGORY_CONTAINER}. See {@link 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.
+ *
+ * Some menu types do not sufficient space to show the full title, and
+ * instead a condensed title is preferred. See {@link 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 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 Menu} for the menu types that support icons.
+ *
+ * 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.
+ *
+ * Note that setIntent() can not be used with the versions of
+ * {@link 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 not 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.
+ *
+ * See {@link 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.
+ *
+ * See {@link 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.
+ *
+ * See {@link 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.
+ *
+ * See {@link 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 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 Menu#setGroupCheckable(int, boolean, boolean)},
+ * the other items in the group will be unchecked.
+ *
+ * See {@link Menu} for the menu types that support check marks.
+ *
+ * @see #setCheckable
+ * @see #isChecked
+ * @see 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.
+ *
+ * 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.
+ *
+ * Note: Setting an action view overrides the action provider
+ * set via {@link #setActionProvider(ActionProvider)}.
+ *
+ * Note: Setting an action view overrides the action provider
+ * set via {@link #setActionProvider(ActionProvider)}.
+ *
+ * Note: Setting an action provider overrides the action view
+ * set via {@link #setActionView(int)} or {@link #setActionView(View)}.
+ *
+ * Sub menus do not support item icons, or nested sub menus.
+ *
+ * For information about creating menus, read the
+ * Menus developer guide. Abstract base class for a top-level window look and behavior policy. An
+ * instance of this class should be used as the top-level view added to the
+ * window manager. It provides standard UI policies such as a background, title
+ * area, default key processing, etc. The only existing implementation of this abstract class is
+ * android.policy.PhoneWindow, which you should instantiate when needing a
+ * Window. Eventually that class will be refactored and a factory method added
+ * for creating Window instances without knowing about a particular
+ * implementation.
+ * This class represents a data model for choosing a component for handing a
+ * given {@link Intent}. The model is responsible for querying the system for
+ * activities that can handle the given intent and order found activities
+ * based on historical data of previous choices. The historical data is stored
+ * in an application private file. If a client does not want to have persistent
+ * choice history the file can be omitted, thus the activities will be ordered
+ * based on historical usage for the current session.
+ *
+ *
+ * The way clients interact with this class is as follows:
+ *
+ *
+ * Note: This class is thread safe.
+ *
+ * Note: Modifying the intent is not permitted and
+ * any changes to the latter will be ignored.
+ *
+ * Note: To use the default historical data file clients should explicitly
+ * pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice
+ * history is desired clients should pass
+ * Always use difference historical data files for semantically different actions.
+ * For example, sharing is different from importing.
+ *
+ * Note: Clients must set only semantically similar
+ * intents for each data model.
+ *
+ *
+ * @param intent The intent.
+ */
+ public void setIntent(Intent intent) {
+ synchronized (mInstanceLock) {
+ if (mIntent == intent) {
+ return;
+ }
+ mIntent = intent;
+ loadActivitiesLocked();
+ }
+ }
+
+ /**
+ * Gets the intent for which a activity is being chosen.
+ *
+ * @return The intent.
+ */
+ public Intent getIntent() {
+ synchronized (mInstanceLock) {
+ return mIntent;
+ }
+ }
+
+ /**
+ * Gets the number of activities that can handle the intent.
+ *
+ * @return The activity count.
+ *
+ * @see #setIntent(Intent)
+ */
+ public int getActivityCount() {
+ synchronized (mInstanceLock) {
+ return mActivites.size();
+ }
+ }
+
+ /**
+ * Gets an activity at a given index.
+ *
+ * @return The activity.
+ *
+ * @see ActivityResolveInfo
+ * @see #setIntent(Intent)
+ */
+ public ResolveInfo getActivity(int index) {
+ synchronized (mInstanceLock) {
+ return mActivites.get(index).resolveInfo;
+ }
+ }
+
+ /**
+ * Gets the index of a the given activity.
+ *
+ * @param activity The activity index.
+ *
+ * @return The index if found, -1 otherwise.
+ */
+ public int getActivityIndex(ResolveInfo activity) {
+ List
+ * Note: By calling this method the client guarantees
+ * that the returned intent will be started. This intent is returned to
+ * the client solely to let additional customization before the start.
+ *
+ * Note: Historical data is read asynchronously and
+ * as soon as the reading is completed any registered
+ * {@link DataSetObserver}s will be notified. Also no historical
+ * data is read until this method is invoked.
+ *
+ */
+ private void readHistoricalData() {
+ synchronized (mInstanceLock) {
+ if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) {
+ return;
+ }
+ mCanReadHistoricalData = false;
+ mReadShareHistoryCalled = true;
+ if (!TextUtils.isEmpty(mHistoryFileName)) {
+ /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader());
+ }
+ }
+ }
+
+ private static final Executor SERIAL_EXECUTOR = Executors.newSingleThreadExecutor();
+
+ /**
+ * Persists the history data to the backing file if the latter
+ * was provided. Calling this method before a call to {@link #readHistoricalData()}
+ * throws an exception. Calling this method more than one without choosing an
+ * activity has not effect.
+ *
+ * @throws IllegalStateException If this method is called before a call to
+ * {@link #readHistoricalData()}.
+ */
+ private void persistHistoricalData() {
+ synchronized (mInstanceLock) {
+ if (!mReadShareHistoryCalled) {
+ throw new IllegalStateException("No preceding call to #readHistoricalData");
+ }
+ if (!mHistoricalRecordsChanged) {
+ return;
+ }
+ mHistoricalRecordsChanged = false;
+ mCanReadHistoricalData = true;
+ if (!TextUtils.isEmpty(mHistoryFileName)) {
+ /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister());
+ }
+ }
+ }
+
+ /**
+ * Sets the sorter for ordering activities based on historical data and an intent.
+ *
+ * @param activitySorter The sorter.
+ *
+ * @see ActivitySorter
+ */
+ public void setActivitySorter(ActivitySorter activitySorter) {
+ synchronized (mInstanceLock) {
+ if (mActivitySorter == activitySorter) {
+ return;
+ }
+ mActivitySorter = activitySorter;
+ sortActivities();
+ }
+ }
+
+ /**
+ * Sorts the activities based on history and an intent. If
+ * a sorter is not specified this a default implementation is used.
+ *
+ * @see #setActivitySorter(ActivitySorter)
+ */
+ private void sortActivities() {
+ synchronized (mInstanceLock) {
+ if (mActivitySorter != null && !mActivites.isEmpty()) {
+ mActivitySorter.sort(mIntent, mActivites,
+ Collections.unmodifiableList(mHistoricalRecords));
+ notifyChanged();
+ }
+ }
+ }
+
+ /**
+ * Sets the maximal size of the historical data. Defaults to
+ * {@link #DEFAULT_HISTORY_MAX_LENGTH}
+ *
+ * Note: Setting this property will immediately
+ * enforce the specified max history size by dropping enough old
+ * historical records to enforce the desired size. Thus, any
+ * records that exceed the history size will be discarded and
+ * irreversibly lost.
+ *
+ * The view is composed of two adjacent buttons:
+ *
+ * When the SearchView is used in an ActionBar as an action view for a collapsible menu item, it
+ * needs to be set to iconified by default using {@link #setIconifiedByDefault(boolean)
+ * setIconifiedByDefault(true)}. This is the default, so nothing needs to be done.
+ *
+ * If you want the search field to always be visible, then call setIconifiedByDefault(false).
+ * For information about using {@code SearchView}, read the
+ * Search developer guide. The default value is true.
+ * Here is how to use the action provider with custom backing file in a {@link MenuItem}:
+ *
+ * false
, since we cannot be sure that
- * suggestion sources return stable IDs.
- */
- @Override
- public boolean hasStableIds() {
- return false;
- }
-
- /**
- * Use the search suggestions provider to obtain a live cursor. This will be called
- * in a worker thread, so it's OK if the query is slow (e.g. round trip for suggestions).
- * The results will be processed in the UI thread and changeCursor() will be called.
- */
- @Override
- public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
- if (DBG) Log.d(LOG_TAG, "runQueryOnBackgroundThread(" + constraint + ")");
- String query = (constraint == null) ? "" : constraint.toString();
- /**
- * for in app search we show the progress spinner until the cursor is returned with
- * the results.
- */
- Cursor cursor = null;
- if (mSearchView.getVisibility() != View.VISIBLE
- || mSearchView.getWindowVisibility() != View.VISIBLE) {
- return null;
- }
- //mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
- try {
- cursor = getSuggestions(query, QUERY_LIMIT);
- // trigger fill window so the spinner stays up until the results are copied over and
- // closer to being ready
- if (cursor != null) {
- cursor.getCount();
- return cursor;
- }
- } catch (RuntimeException e) {
- Log.w(LOG_TAG, "Search suggestions query threw an exception.", e);
- }
- // If cursor is null or an exception was thrown, stop the spinner and return null.
- // changeCursor doesn't get called if cursor is null
- // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
- return null;
- }
-
- public Cursor getSuggestions(String query, int limit) {
- Uri.Builder uriBuilder = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel()
- .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
-
- // append standard suggestion query path
- uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
-
- // inject query, either as selection args or inline
- uriBuilder.appendPath(query);
-
- if (limit > 0) {
- uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT, String.valueOf(limit));
- }
-
- Uri uri = uriBuilder.build();
-
- // finally, make the query
- return mContext.getContentResolver().query(uri, null, null, null, null);
- }
-
- public void close() {
- if (DBG) Log.d(LOG_TAG, "close()");
- changeCursor(null);
- mClosed = true;
- }
-
- @Override
- public void notifyDataSetChanged() {
- if (DBG) Log.d(LOG_TAG, "notifyDataSetChanged");
- super.notifyDataSetChanged();
-
- // mSearchView.onDataSetChanged(); // TODO:
-
- updateSpinnerState(getCursor());
- }
-
- @Override
- public void notifyDataSetInvalidated() {
- if (DBG) Log.d(LOG_TAG, "notifyDataSetInvalidated");
- super.notifyDataSetInvalidated();
-
- updateSpinnerState(getCursor());
- }
-
- private void updateSpinnerState(Cursor cursor) {
- Bundle extras = cursor != null ? cursor.getExtras() : null;
- if (DBG) {
- Log.d(LOG_TAG, "updateSpinnerState - extra = "
- + (extras != null
- ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
- : null));
- }
- // Check if the Cursor indicates that the query is not complete and show the spinner
- if (extras != null
- && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
- // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
- return;
- }
- // If cursor is null or is done, stop the spinner
- // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
- }
-
- /**
- * Cache columns.
- */
- @Override
- public void changeCursor(Cursor c) {
- if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")");
-
- if (mClosed) {
- Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
- if (c != null) c.close();
- return;
- }
-
- try {
- super.changeCursor(c);
-
- if (c != null) {
- mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
- mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2);
- mText2UrlCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
- mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1);
- mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2);
- mFlagsCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FLAGS);
- }
- } catch (Exception e) {
- Log.e(LOG_TAG, "error changing cursor and caching columns", e);
- }
- }
-
- /**
- * Tags the view with cached child view look-ups.
- */
- @Override
- public View newView(Context context, Cursor cursor, ViewGroup parent) {
- View v = super.newView(context, cursor, parent);
- v.setTag(new ChildViewCache(v));
- return v;
- }
-
- /**
- * Cache of the child views of drop-drown list items, to avoid looking up the children
- * each time the contents of a list item are changed.
- */
- private final static class ChildViewCache {
- public final TextView mText1;
- public final TextView mText2;
- public final ImageView mIcon1;
- public final ImageView mIcon2;
- public final ImageView mIconRefine;
-
- public ChildViewCache(View v) {
- mText1 = (TextView) v.findViewById(android.R.id.text1);
- mText2 = (TextView) v.findViewById(android.R.id.text2);
- mIcon1 = (ImageView) v.findViewById(android.R.id.icon1);
- mIcon2 = (ImageView) v.findViewById(android.R.id.icon2);
- mIconRefine = (ImageView) v.findViewById(R.id.edit_query);
- }
- }
-
- @Override
- public void bindView(View view, Context context, Cursor cursor) {
- ChildViewCache views = (ChildViewCache) view.getTag();
-
- int flags = 0;
- if (mFlagsCol != INVALID_INDEX) {
- flags = cursor.getInt(mFlagsCol);
- }
- if (views.mText1 != null) {
- String text1 = getStringOrNull(cursor, mText1Col);
- setViewText(views.mText1, text1);
- }
- if (views.mText2 != null) {
- // First check TEXT_2_URL
- CharSequence text2 = getStringOrNull(cursor, mText2UrlCol);
- if (text2 != null) {
- text2 = formatUrl(text2);
- } else {
- text2 = getStringOrNull(cursor, mText2Col);
- }
-
- // If no second line of text is indicated, allow the first line of text
- // to be up to two lines if it wants to be.
- if (TextUtils.isEmpty(text2)) {
- if (views.mText1 != null) {
- views.mText1.setSingleLine(false);
- views.mText1.setMaxLines(2);
- }
- } else {
- if (views.mText1 != null) {
- views.mText1.setSingleLine(true);
- views.mText1.setMaxLines(1);
- }
- }
- setViewText(views.mText2, text2);
- }
-
- if (views.mIcon1 != null) {
- setViewDrawable(views.mIcon1, getIcon1(cursor), View.INVISIBLE);
- }
- if (views.mIcon2 != null) {
- setViewDrawable(views.mIcon2, getIcon2(cursor), View.GONE);
- }
- if (mQueryRefinement == REFINE_ALL
- || (mQueryRefinement == REFINE_BY_ENTRY
- && (flags & SearchManager.FLAG_QUERY_REFINEMENT) != 0)) {
- views.mIconRefine.setVisibility(View.VISIBLE);
- views.mIconRefine.setTag(views.mText1.getText());
- views.mIconRefine.setOnClickListener(this);
- } else {
- views.mIconRefine.setVisibility(View.GONE);
- }
- }
-
- public void onClick(View v) {
- Object tag = v.getTag();
- if (tag instanceof CharSequence) {
- mSearchView.onQueryRefine((CharSequence) tag);
- }
- }
-
- private CharSequence formatUrl(CharSequence url) {
- if (mUrlColor == null) {
- // Lazily get the URL color from the current theme.
- TypedValue colorValue = new TypedValue();
- mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true);
- mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId);
- }
-
- SpannableString text = new SpannableString(url);
- text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null),
- 0, url.length(),
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- return text;
- }
-
- private void setViewText(TextView v, CharSequence text) {
- // Set the text even if it's null, since we need to clear any previous text.
- v.setText(text);
-
- if (TextUtils.isEmpty(text)) {
- v.setVisibility(View.GONE);
- } else {
- v.setVisibility(View.VISIBLE);
- }
- }
-
- private Drawable getIcon1(Cursor cursor) {
- if (mIconName1Col == INVALID_INDEX) {
- return null;
- }
- String value = cursor.getString(mIconName1Col);
- Drawable drawable = getDrawableFromResourceValue(value);
- if (drawable != null) {
- return drawable;
- }
- return getDefaultIcon1(cursor);
- }
-
- private Drawable getIcon2(Cursor cursor) {
- if (mIconName2Col == INVALID_INDEX) {
- return null;
- }
- String value = cursor.getString(mIconName2Col);
- return getDrawableFromResourceValue(value);
- }
-
- /**
- * Sets the drawable in an image view, makes sure the view is only visible if there
- * is a drawable.
- */
- private void setViewDrawable(ImageView v, Drawable drawable, int nullVisibility) {
- // Set the icon even if the drawable is null, since we need to clear any
- // previous icon.
- v.setImageDrawable(drawable);
-
- if (drawable == null) {
- v.setVisibility(nullVisibility);
- } else {
- v.setVisibility(View.VISIBLE);
-
- // This is a hack to get any animated drawables (like a 'working' spinner)
- // to animate. You have to setVisible true on an AnimationDrawable to get
- // it to start animating, but it must first have been false or else the
- // call to setVisible will be ineffective. We need to clear up the story
- // about animated drawables in the future, see http://b/1878430.
- drawable.setVisible(false, false);
- drawable.setVisible(true, false);
- }
- }
-
- /**
- * Gets the text to show in the query field when a suggestion is selected.
- *
- * @param cursor The Cursor to read the suggestion data from. The Cursor should already
- * be moved to the suggestion that is to be read from.
- * @return The text to show, or null
if the query should not be
- * changed when selecting this suggestion.
- */
- @Override
- public CharSequence convertToString(Cursor cursor) {
- if (cursor == null) {
- return null;
- }
-
- String query = getColumnString(cursor, SearchManager.SUGGEST_COLUMN_QUERY);
- if (query != null) {
- return query;
- }
-
- return null;
- }
-
- /**
- * This method is overridden purely to provide a bit of protection against
- * flaky content providers.
- *
- * @see android.widget.ListAdapter#getView(int, View, ViewGroup)
- */
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- try {
- return super.getView(position, convertView, parent);
- } catch (RuntimeException e) {
- Log.w(LOG_TAG, "Search suggestions cursor threw exception.", e);
- // Put exception string in item title
- View v = newView(mContext, mCursor, parent);
- if (v != null) {
- ChildViewCache views = (ChildViewCache) v.getTag();
- TextView tv = views.mText1;
- tv.setText(e.toString());
- }
- return v;
- }
- }
-
- /**
- * Gets a drawable given a value provided by a suggestion provider.
- *
- * This value could be just the string value of a resource id
- * (e.g., "2130837524"), in which case we will try to retrieve a drawable from
- * the provider's resources. If the value is not an integer, it is
- * treated as a Uri and opened with
- * {@link ContentResolver#openOutputStream(android.net.Uri, String)}.
- *
- * All resources and URIs are read using the suggestion provider's context.
- *
- * If the string is not formatted as expected, or no drawable can be found for
- * the provided value, this method returns null.
- *
- * @param drawableId a string like "2130837524",
- * "android.resource://com.android.alarmclock/2130837524",
- * or "content://contacts/photos/253".
- * @return a Drawable, or null if none found
- */
- private Drawable getDrawableFromResourceValue(String drawableId) {
- if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) {
- return null;
- }
- try {
- // First, see if it's just an integer
- int resourceId = Integer.parseInt(drawableId);
- // It's an int, look for it in the cache
- String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE
- + "://" + mProviderContext.getPackageName() + "/" + resourceId;
- // Must use URI as cache key, since ints are app-specific
- Drawable drawable = checkIconCache(drawableUri);
- if (drawable != null) {
- return drawable;
- }
- // Not cached, find it by resource ID
- drawable = mProviderContext.getResources().getDrawable(resourceId);
- // Stick it in the cache, using the URI as key
- storeInIconCache(drawableUri, drawable);
- return drawable;
- } catch (NumberFormatException nfe) {
- // It's not an integer, use it as a URI
- Drawable drawable = checkIconCache(drawableId);
- if (drawable != null) {
- return drawable;
- }
- Uri uri = Uri.parse(drawableId);
- drawable = getDrawable(uri);
- storeInIconCache(drawableId, drawable);
- return drawable;
- } catch (Resources.NotFoundException nfe) {
- // It was an integer, but it couldn't be found, bail out
- Log.w(LOG_TAG, "Icon resource not found: " + drawableId);
- return null;
- }
- }
-
- /**
- * Gets a drawable by URI, without using the cache.
- *
- * @return A drawable, or {@code null} if the drawable could not be loaded.
- */
- private Drawable getDrawable(Uri uri) {
- try {
- String scheme = uri.getScheme();
- if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(scheme)) {
- // Load drawables through Resources, to get the source density information
- try {
- return getTheDrawable(uri);
- } catch (Resources.NotFoundException ex) {
- throw new FileNotFoundException("Resource does not exist: " + uri);
- }
- } else {
- // Let the ContentResolver handle content and file URIs.
- InputStream stream = mProviderContext.getContentResolver().openInputStream(uri);
- if (stream == null) {
- throw new FileNotFoundException("Failed to open " + uri);
- }
- try {
- return Drawable.createFromStream(stream, null);
- } finally {
- try {
- stream.close();
- } catch (IOException ex) {
- Log.e(LOG_TAG, "Error closing icon stream for " + uri, ex);
- }
- }
- }
- } catch (FileNotFoundException fnfe) {
- Log.w(LOG_TAG, "Icon not found: " + uri + ", " + fnfe.getMessage());
- return null;
- }
- }
-
- public Drawable getTheDrawable(Uri uri) throws FileNotFoundException {
- String authority = uri.getAuthority();
- Resources r;
- if (TextUtils.isEmpty(authority)) {
- throw new FileNotFoundException("No authority: " + uri);
- } else {
- try {
- r = mContext.getPackageManager().getResourcesForApplication(authority);
- } catch (NameNotFoundException ex) {
- throw new FileNotFoundException("No package found for authority: " + uri);
- }
- }
- Listnull
- * if the cursor does not contain the given column.
- */
- public static String getColumnString(Cursor cursor, String columnName) {
- int col = cursor.getColumnIndex(columnName);
- return getStringOrNull(cursor, col);
- }
-
- private static String getStringOrNull(Cursor cursor, int col) {
- if (col == INVALID_INDEX) {
- return null;
- }
- try {
- return cursor.getString(col);
- } catch (Exception e) {
- Log.e(LOG_TAG,
- "unexpected error retrieving valid column from cursor, "
- + "did the remote process die?", e);
- return null;
- }
- }
-}
diff --git a/OpenPGP-Keychain/android-libs/ActionBarSherlock/test/com/actionbarsherlock/internal/ManifestParsingTest.java b/OpenPGP-Keychain/android-libs/ActionBarSherlock/test/com/actionbarsherlock/internal/ManifestParsingTest.java
deleted file mode 100644
index 47475c574..000000000
--- a/OpenPGP-Keychain/android-libs/ActionBarSherlock/test/com/actionbarsherlock/internal/ManifestParsingTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.actionbarsherlock.internal;
-
-import org.junit.Test;
-
-import static com.actionbarsherlock.internal.ActionBarSherlockCompat.cleanActivityName;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class ManifestParsingTest {
- @Test
- public void testFullyQualifiedClassName() {
- String expected = "com.other.package.SomeClass";
- String actual = cleanActivityName("com.jakewharton.test", "com.other.package.SomeClass");
- assertThat(expected, equalTo(actual));
- }
-
- @Test
- public void testFullyQualifiedClassNameSamePackage() {
- String expected = "com.jakewharton.test.SomeClass";
- String actual = cleanActivityName("com.jakewharton.test", "com.jakewharton.test.SomeClass");
- assertThat(expected, equalTo(actual));
- }
-
- @Test
- public void testUnqualifiedClassName() {
- String expected = "com.jakewharton.test.SomeClass";
- String actual = cleanActivityName("com.jakewharton.test", "SomeClass");
- assertThat(expected, equalTo(actual));
- }
-
- @Test
- public void testRelativeClassName() {
- String expected = "com.jakewharton.test.ui.SomeClass";
- String actual = cleanActivityName("com.jakewharton.test", ".ui.SomeClass");
- assertThat(expected, equalTo(actual));
- }
-}
\ No newline at end of file
diff --git a/OpenPGP-Keychain/build.gradle b/OpenPGP-Keychain/build.gradle
new file mode 100644
index 000000000..b9720f405
--- /dev/null
+++ b/OpenPGP-Keychain/build.gradle
@@ -0,0 +1,63 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.4'
+ }
+}
+
+apply plugin: 'android'
+
+dependencies {
+ compile fileTree(dir: 'libs', includes: ['*.jar'], excludes: ['android-support-v4.jar'])
+ compile project(':libraries:ActionBarSherlock')
+}
+
+android {
+ compileSdkVersion 17
+ buildToolsVersion "17"
+
+ defaultConfig {
+ minSdkVersion 8
+ targetSdkVersion 17
+ }
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['src']
+ resources.srcDirs = ['src']
+ aidl.srcDirs = ['src']
+ renderscript.srcDirs = ['src']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+
+ instrumentTest.setRoot('tests')
+ }
+
+ /*
+ * To sign release build, create file gradle.properties in .gradle/ with this content:
+ *
+ * signingStoreLocation=/home/key.store
+ * signingStorePassword=xxx
+ * signingKeyAlias=alias
+ * signingKeyPassword=xxx
+ */
+ signingConfigs {
+ myConfig {
+ storeFile file(signingStoreLocation)
+ storePassword signingStorePassword
+ keyAlias signingKeyAlias
+ keyPassword signingKeyPassword
+ }
+ }
+
+ buildTypes {
+ release {
+ signingConfig signingConfigs.myConfig
+ }
+ }
+}
diff --git a/OpenPGP-Keychain/libs/android-support-v4.jar b/OpenPGP-Keychain/libs/android-support-v4.jar
new file mode 100644
index 000000000..99e063b33
Binary files /dev/null and b/OpenPGP-Keychain/libs/android-support-v4.jar differ
diff --git a/OpenPGP-Keychain/project.properties b/OpenPGP-Keychain/project.properties
index 2267fbaf8..cfb577df7 100644
--- a/OpenPGP-Keychain/project.properties
+++ b/OpenPGP-Keychain/project.properties
@@ -9,4 +9,4 @@
# Project target.
target=android-17
-android.library.reference.1=android-libs/ActionBarSherlock
+android.library.reference.1=../libraries/ActionBarSherlock
diff --git a/libraries/ActionBarSherlock/.gitignore b/libraries/ActionBarSherlock/.gitignore
new file mode 100644
index 000000000..71c11b159
--- /dev/null
+++ b/libraries/ActionBarSherlock/.gitignore
@@ -0,0 +1,30 @@
+#Android specific
+bin
+gen
+obj
+libs/armeabi
+lint.xml
+local.properties
+release.properties
+ant.properties
+*.class
+*.apk
+
+#Gradle
+.gradle
+build
+gradle.properties
+
+#Maven
+target
+pom.xml.*
+
+#Eclipse
+.project
+.classpath
+.settings
+.metadata
+
+#IntelliJ IDEA
+.idea
+*.iml
diff --git a/libraries/ActionBarSherlock/AndroidManifest.xml b/libraries/ActionBarSherlock/AndroidManifest.xml
new file mode 100644
index 000000000..7b8a84824
--- /dev/null
+++ b/libraries/ActionBarSherlock/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+ *
+ *
+ * @param newConfig The new device configuration.
+ */
+ public void dispatchConfigurationChanged(Configuration newConfig) {}
+
+ /**
+ * Notify the action bar that the activity has finished its resuming. This
+ * should be dispatched after the call to the superclass implementation.
+ *
+ *
+ * @Override
+ * public void onConfigurationChanged(Configuration newConfig) {
+ * super.onConfigurationChanged(newConfig);
+ * mSherlock.dispatchConfigurationChanged(newConfig);
+ * }
+ *
+ */
+ public void dispatchPostResume() {}
+
+ /**
+ * Notify the action bar that the activity is pausing. This should be
+ * dispatched before the call to the superclass implementation.
+ *
+ *
+ * @Override
+ * protected void onPostResume() {
+ * super.onPostResume();
+ * mSherlock.dispatchPostResume();
+ * }
+ *
+ */
+ public void dispatchPause() {}
+
+ /**
+ * Notify the action bar that the activity is stopping. This should be
+ * called before the superclass implementation.
+ *
+ *
+ * @Override
+ * protected void onPause() {
+ * mSherlock.dispatchPause();
+ * super.onPause();
+ * }
+ *
+ */
+ public void dispatchStop() {}
+
+ /**
+ * Indicate that the menu should be recreated by calling
+ * {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}.
+ */
+ public abstract void dispatchInvalidateOptionsMenu();
+
+ /**
+ * Notify the action bar that it should display its overflow menu if it is
+ * appropriate for the device. The implementation should conditionally
+ * call the superclass method only if this method returns {@code false}.
+ *
+ *
+ *
+ * @return {@code true} if the opening of the menu was handled internally.
+ */
+ public boolean dispatchOpenOptionsMenu() {
+ return false;
+ }
+
+ /**
+ * Notify the action bar that it should close its overflow menu if it is
+ * appropriate for the device. This implementation should conditionally
+ * call the superclass method only if this method returns {@code false}.
+ *
+ *
+ *
+ * @return {@code true} if the closing of the menu was handled internally.
+ */
+ public boolean dispatchCloseOptionsMenu() {
+ return false;
+ }
+
+ /**
+ * Notify the class that the activity has finished its creation. This
+ * should be called after the superclass implementation.
+ *
+ *
+ * @Override
+ * public void closeOptionsMenu() {
+ * if (!mSherlock.dispatchCloseOptionsMenu()) {
+ * super.closeOptionsMenu();
+ * }
+ * }
+ *
+ *
+ * @param savedInstanceState If the activity is being re-initialized after
+ * previously being shut down then this Bundle
+ * contains the data it most recently supplied in
+ * {@link Activity#}onSaveInstanceState(Bundle)}.
+ * Note: Otherwise it is null.
+ */
+ public void dispatchPostCreate(Bundle savedInstanceState) {}
+
+ /**
+ * Notify the action bar that the title has changed and the action bar
+ * should be updated to reflect the change. This should be called before
+ * the superclass implementation.
+ *
+ *
+ * @Override
+ * protected void onPostCreate(Bundle savedInstanceState) {
+ * mSherlock.dispatchPostCreate(savedInstanceState);
+ * super.onPostCreate(savedInstanceState);
+ * }
+ *
+ *
+ * @param title New activity title.
+ * @param color New activity color.
+ */
+ public void dispatchTitleChanged(CharSequence title, int color) {}
+
+ /**
+ * Notify the action bar the user has created a key event. This is used to
+ * toggle the display of the overflow action item with the menu key and to
+ * close the action mode or expanded action item with the back key.
+ *
+ *
+ * @Override
+ * protected void onTitleChanged(CharSequence title, int color) {
+ * mSherlock.dispatchTitleChanged(title, color);
+ * super.onTitleChanged(title, color);
+ * }
+ *
+ *
+ * @param event Description of the key event.
+ * @return {@code true} if the event was handled.
+ */
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ return false;
+ }
+
+ /**
+ * Notify the action bar that the Activity has triggered a menu creation
+ * which should happen on the conclusion of {@link Activity#onCreate}. This
+ * will be used to gain a reference to the native menu for native and
+ * overflow binding as well as to indicate when compatibility create should
+ * occur for the first time.
+ *
+ * @param menu Activity native menu.
+ * @return {@code true} since we always want to say that we have a native
+ */
+ public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu);
+
+ /**
+ * Notify the action bar that the Activity has triggered a menu preparation
+ * which usually means that the user has requested the overflow menu via a
+ * hardware menu key. You should return the result of this method call and
+ * not call the superclass implementation.
+ *
+ *
+ * @Override
+ * public boolean dispatchKeyEvent(KeyEvent event) {
+ * if (mSherlock.dispatchKeyEvent(event)) {
+ * return true;
+ * }
+ * return super.dispatchKeyEvent(event);
+ * }
+ *
+ *
+ * @param menu Activity native menu.
+ * @return {@code true} if menu display should proceed.
+ */
+ public abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu);
+
+ /**
+ * Notify the action bar that a native options menu item has been selected.
+ * The implementation should return the result of this method call.
+ *
+ *
+ *
+ * @param item Options menu item.
+ * @return @{code true} if the selection was handled.
+ */
+ public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item);
+
+ /**
+ * Notify the action bar that the overflow menu has been opened. The
+ * implementation should conditionally return {@code true} if this method
+ * returns {@code true}, otherwise return the result of the superclass
+ * method.
+ *
+ *
+ *
+ * @param featureId Window feature which triggered the event.
+ * @param menu Activity native menu.
+ * @return {@code true} if the event was handled by this method.
+ */
+ public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) {
+ return false;
+ }
+
+ /**
+ * Notify the action bar that the overflow menu has been closed. This
+ * method should be called before the superclass implementation.
+ *
+ *
+ *
+ * @param featureId
+ * @param menu
+ */
+ public void dispatchPanelClosed(int featureId, android.view.Menu menu) {}
+
+ /**
+ * Notify the action bar that the activity has been destroyed. This method
+ * should be called before the superclass implementation.
+ *
+ *
+ */
+ public void dispatchDestroy() {}
+
+ public void dispatchSaveInstanceState(Bundle outState) {}
+
+ public void dispatchRestoreInstanceState(Bundle savedInstanceState) {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Internal method to trigger the menu creation process.
+ *
+ * @return {@code true} if menu creation should proceed.
+ */
+ protected final boolean callbackCreateOptionsMenu(Menu menu) {
+ if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu);
+
+ boolean result = true;
+ if (mActivity instanceof OnCreatePanelMenuListener) {
+ OnCreatePanelMenuListener listener = (OnCreatePanelMenuListener)mActivity;
+ result = listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
+ } else if (mActivity instanceof OnCreateOptionsMenuListener) {
+ OnCreateOptionsMenuListener listener = (OnCreateOptionsMenuListener)mActivity;
+ result = listener.onCreateOptionsMenu(menu);
+ }
+
+ if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result);
+ return result;
+ }
+
+ /**
+ * Internal method to trigger the menu preparation process.
+ *
+ * @return {@code true} if menu preparation should proceed.
+ */
+ protected final boolean callbackPrepareOptionsMenu(Menu menu) {
+ if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu);
+
+ boolean result = true;
+ if (mActivity instanceof OnPreparePanelListener) {
+ OnPreparePanelListener listener = (OnPreparePanelListener)mActivity;
+ result = listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu);
+ } else if (mActivity instanceof OnPrepareOptionsMenuListener) {
+ OnPrepareOptionsMenuListener listener = (OnPrepareOptionsMenuListener)mActivity;
+ result = listener.onPrepareOptionsMenu(menu);
+ }
+
+ if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result);
+ return result;
+ }
+
+ /**
+ * Internal method for dispatching options menu selection to the owning
+ * activity callback.
+ *
+ * @param item Selected options menu item.
+ * @return {@code true} if the item selection was handled in the callback.
+ */
+ protected final boolean callbackOptionsItemSelected(MenuItem item) {
+ if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed());
+
+ boolean result = false;
+ if (mActivity instanceof OnMenuItemSelectedListener) {
+ OnMenuItemSelectedListener listener = (OnMenuItemSelectedListener)mActivity;
+ result = listener.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
+ } else if (mActivity instanceof OnOptionsItemSelectedListener) {
+ OnOptionsItemSelectedListener listener = (OnOptionsItemSelectedListener)mActivity;
+ result = listener.onOptionsItemSelected(item);
+ }
+
+ if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result);
+ return result;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Query for the availability of a certain feature.
+ *
+ * @param featureId The feature ID to check.
+ * @return {@code true} if feature is enabled, {@code false} otherwise.
+ */
+ public abstract boolean hasFeature(int featureId);
+
+ /**
+ * Enable extended screen features. This must be called before
+ * {@code setContentView()}. May be called as many times as desired as long
+ * as it is before {@code setContentView()}. If not called, no extended
+ * features will be available. You can not turn off a feature once it is
+ * requested.
+ *
+ * @param featureId The desired features, defined as constants by Window.
+ * @return Returns true if the requested feature is supported and now
+ * enabled.
+ */
+ public abstract boolean requestFeature(int featureId);
+
+ /**
+ * Set extra options that will influence the UI for this window.
+ *
+ * @param uiOptions Flags specifying extra options for this window.
+ */
+ public abstract void setUiOptions(int uiOptions);
+
+ /**
+ * Set extra options that will influence the UI for this window. Only the
+ * bits filtered by mask will be modified.
+ *
+ * @param uiOptions Flags specifying extra options for this window.
+ * @param mask Flags specifying which options should be modified. Others
+ * will remain unchanged.
+ */
+ public abstract void setUiOptions(int uiOptions, int mask);
+
+ /**
+ * Set the content of the activity inside the action bar.
+ *
+ * @param layoutResId Layout resource ID.
+ */
+ public abstract void setContentView(int layoutResId);
+
+ /**
+ * Set the content of the activity inside the action bar.
+ *
+ * @param view The desired content to display.
+ */
+ public void setContentView(View view) {
+ if (DEBUG) Log.d(TAG, "[setContentView] view: " + view);
+
+ setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ }
+
+ /**
+ * Set the content of the activity inside the action bar.
+ *
+ * @param view The desired content to display.
+ * @param params Layout parameters to apply to the view.
+ */
+ public abstract void setContentView(View view, ViewGroup.LayoutParams params);
+
+ /**
+ * Variation on {@link #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)}
+ * to add an additional content view to the screen. Added after any
+ * existing ones on the screen -- existing views are NOT removed.
+ *
+ * @param view The desired content to display.
+ * @param params Layout parameters for the view.
+ */
+ public abstract void addContentView(View view, ViewGroup.LayoutParams params);
+
+ /**
+ * Change the title associated with this activity.
+ */
+ public abstract void setTitle(CharSequence title);
+
+ /**
+ * Change the title associated with this activity.
+ */
+ public void setTitle(int resId) {
+ if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId);
+
+ setTitle(mActivity.getString(resId));
+ }
+
+ /**
+ * Sets the visibility of the progress bar in the title.
+ * Developer Guides
+ *
+ *
+ *
+ * @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.
+ *
+ * position
. 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
+ * position
.
+ *
+ * @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.
+ *
+ * true
if the ActionBar is showing, false
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.)
+ *
+ * AnimatorListeners
added to them.
+ */
+public abstract class Animator implements Cloneable {
+
+
+ /**
+ * The set of listeners to be sent events through the life of an animation.
+ */
+ ArrayListcancel()
causes the animation to
+ * stop in its tracks, sending an
+ * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
+ * its listeners, followed by an
+ * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
+ *
+ * Animator
object.
+ *
+ * @return ArrayListgetListeners()
followed by calling clear()
on the
+ * returned list of listeners.
+ */
+ public void removeAllListeners() {
+ if (mListeners != null) {
+ mListeners.clear();
+ mListeners = null;
+ }
+ }
+
+ @Override
+ public Animator clone() {
+ try {
+ final Animator anim = (Animator) super.clone();
+ if (mListeners != null) {
+ ArrayListAnimatorSet
:
+ * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or
+ * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add
+ * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be
+ * used in conjunction with methods in the {@link AnimatorSet.Builder Builder}
+ * class to add animations
+ * one by one.AnimatorSet
with circular dependencies between
+ * its animations. For example, an animation a1 could be set up to start before animation a2, a2
+ * before a3, and a3 before a1. The results of this configuration are undefined, but will typically
+ * result in none of the affected animations being played. Because of this (and because
+ * circular dependencies do not make logical sense anyway), circular dependencies
+ * should be avoided, and the dependency flow of animations should only be in one direction.
+ */
+@SuppressWarnings("unchecked")
+public final class AnimatorSet extends Animator {
+
+ /**
+ * Internal variables
+ * NOTE: This object implements the clone() method, making a deep copy of any referenced
+ * objects. As other non-trivial fields are added to this class, make sure to add logic
+ * to clone() to make deep copies of them.
+ */
+
+ /**
+ * Tracks animations currently being played, so that we know what to
+ * cancel or end when cancel() or end() is called on this AnimatorSet
+ */
+ private ArrayListBuilder
object, which is used to
+ * set up playing constraints. This initial play()
method
+ * tells the Builder
the animation that is the dependency for
+ * the succeeding commands to the Builder
. For example,
+ * calling play(a1).with(a2)
sets up the AnimatorSet to play
+ * a1
and a2
at the same time,
+ * play(a1).before(a2)
sets up the AnimatorSet to play
+ * a1
first, followed by a2
, and
+ * play(a1).after(a2)
sets up the AnimatorSet to play
+ * a2
first, followed by a1
.
+ *
+ * play()
is the only way to tell the
+ * Builder
the animation upon which the dependency is created,
+ * so successive calls to the various functions in Builder
+ * will all refer to the initial parameter supplied in play()
+ * as the dependency of the other animations. For example, calling
+ * play(a1).before(a2).before(a3)
will play both a2
+ * and a3
when a1 ends; it does not set up a dependency between
+ * a2
and a3
.Builder
object. A null parameter will result
+ * in a null Builder
return value.
+ * @return Builder The object that constructs the AnimatorSet based on the dependencies
+ * outlined in the calls to play
and the other methods in the
+ * Builder
Note that canceling a AnimatorSet
also cancels all of the animations that it
+ * is responsible for.AnimatorSet
also ends all of the animations that it is
+ * responsible for.AnimatorSet
will, in turn, start the animations for which
+ * it is responsible. The details of when exactly those animations are started depends on
+ * the dependency relationships that have been set up between the animations.
+ */
+ @Override
+ public void start() {
+ mTerminated = false;
+ mStarted = true;
+
+ // First, sort the nodes (if necessary). This will ensure that sortedNodes
+ // contains the animation nodes in the correct order.
+ sortNodes();
+
+ int numSortedNodes = mSortedNodes.size();
+ for (int i = 0; i < numSortedNodes; ++i) {
+ Node node = mSortedNodes.get(i);
+ // First, clear out the old listeners
+ ArrayListBuilder
object is a utility class to facilitate adding animations to a
+ * AnimatorSet
along with the relationships between the various animations. The
+ * intention of the Builder
methods, along with the {@link
+ * AnimatorSet#play(Animator) play()} method of AnimatorSet
is to make it possible
+ * to express the dependency relationships of animations in a natural way. Developers can also
+ * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link
+ * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need,
+ * but it might be easier in some situations to express the AnimatorSet of animations in pairs.
+ *
+ * Builder
object cannot be constructed directly, but is rather constructed
+ * internally via a call to {@link AnimatorSet#play(Animator)}.
+ * AnimatorSet s = new AnimatorSet();
+ * s.play(anim1).with(anim2);
+ * s.play(anim2).before(anim3);
+ * s.play(anim4).after(anim3);
+ *
+ *
+ * Builder
object to express
+ * multiple relationships. However, note that it is only the animation passed into the initial
+ * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive
+ * calls to the Builder
object. For example, the following code starts both anim2
+ * and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and
+ * anim3:
+ *
+ * AnimatorSet s = new AnimatorSet();
+ * s.play(anim1).before(anim2).before(anim3);
+ *
+ * If the desired result is to play anim1 then anim2 then anim3, this code expresses the
+ * relationship correctly:
+ * AnimatorSet s = new AnimatorSet();
+ * s.play(anim1).before(anim2);
+ * s.play(anim2).before(anim3);
+ *
+ *
+ * play(anim1).after(anim1)
makes no
+ * sense. In general, circular dependencies like this one (or more indirect ones where a depends
+ * on b, which depends on c, which depends on a) should be avoided. Only create AnimatorSets
+ * that can boil down to a simple, one-way relationship of animations starting with, before, and
+ * after other, different, animations.Builder
object.
+ *
+ * @param anim The animation that will play when the animation supplied to the
+ * {@link AnimatorSet#play(Animator)} method starts.
+ */
+ public Builder with(Animator anim) {
+ Node node = mNodeMap.get(anim);
+ if (node == null) {
+ node = new Node(anim);
+ mNodeMap.put(anim, node);
+ mNodes.add(node);
+ }
+ Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH);
+ node.addDependency(dependency);
+ return this;
+ }
+
+ /**
+ * Sets up the given animation to play when the animation supplied in the
+ * {@link AnimatorSet#play(Animator)} call that created this Builder
object
+ * ends.
+ *
+ * @param anim The animation that will play when the animation supplied to the
+ * {@link AnimatorSet#play(Animator)} method ends.
+ */
+ public Builder before(Animator anim) {
+ Node node = mNodeMap.get(anim);
+ if (node == null) {
+ node = new Node(anim);
+ mNodeMap.put(anim, node);
+ mNodes.add(node);
+ }
+ Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER);
+ node.addDependency(dependency);
+ return this;
+ }
+
+ /**
+ * Sets up the given animation to play when the animation supplied in the
+ * {@link AnimatorSet#play(Animator)} call that created this Builder
object
+ * to start when the animation supplied in this method call ends.
+ *
+ * @param anim The animation whose end will cause the animation supplied to the
+ * {@link AnimatorSet#play(Animator)} method to play.
+ */
+ public Builder after(Animator anim) {
+ Node node = mNodeMap.get(anim);
+ if (node == null) {
+ node = new Node(anim);
+ mNodeMap.put(anim, node);
+ mNodes.add(node);
+ }
+ Dependency dependency = new Dependency(node, Dependency.AFTER);
+ mCurrentNode.addDependency(dependency);
+ return this;
+ }
+
+ /**
+ * Sets up the animation supplied in the
+ * {@link AnimatorSet#play(Animator)} call that created this Builder
object
+ * to play when the given amount of time elapses.
+ *
+ * @param delay The number of milliseconds that should elapse before the
+ * animation starts.
+ */
+ public Builder after(long delay) {
+ // setup dummy ValueAnimator just to run the clock
+ ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
+ anim.setDuration(delay);
+ after(anim);
+ return this;
+ }
+
+ }
+
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java
new file mode 100644
index 000000000..e41019364
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatEvaluator.java
@@ -0,0 +1,42 @@
+/*
+ * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
+
+/**
+ * This evaluator can be used to perform type interpolation between float
values.
+ */
+public class FloatEvaluator implements TypeEvaluatorfraction
representing the proportion between the start and end values. The
+ * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0)
,
+ * where x0
is startValue
, x1
is endValue
,
+ * and t
is fraction
.
+ *
+ * @param fraction The fraction from the starting to the ending values
+ * @param startValue The start value; should be of type float
or
+ * Float
+ * @param endValue The end value; should be of type float
or Float
+ * @return A linear interpolation between the start and end values, given the
+ * fraction
parameter.
+ */
+ public Float evaluate(float fraction, Number startValue, Number endValue) {
+ float startFloat = startValue.floatValue();
+ return startFloat + fraction * (endValue.floatValue() - startFloat);
+ }
+}
\ No newline at end of file
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java
new file mode 100644
index 000000000..6d9dafa7a
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/FloatKeyframeSet.java
@@ -0,0 +1,136 @@
+/*
+ * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
+
+import java.util.ArrayList;
+import android.view.animation.Interpolator;
+
+import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe;
+
+/**
+ * This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate
+ * values between those keyframes for a given animation. The class internal to the animation
+ * package because it is an implementation detail of how Keyframes are stored and used.
+ *
+ * int
values.
+ */
+public class IntEvaluator implements TypeEvaluatorfraction
representing the proportion between the start and end values. The
+ * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0)
,
+ * where x0
is startValue
, x1
is endValue
,
+ * and t
is fraction
.
+ *
+ * @param fraction The fraction from the starting to the ending values
+ * @param startValue The start value; should be of type int
or
+ * Integer
+ * @param endValue The end value; should be of type int
or Integer
+ * @return A linear interpolation between the start and end values, given the
+ * fraction
parameter.
+ */
+ public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
+ int startInt = startValue;
+ return (int)(startInt + fraction * (endValue - startInt));
+ }
+}
\ No newline at end of file
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java
new file mode 100644
index 000000000..e9215e7f8
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/IntKeyframeSet.java
@@ -0,0 +1,135 @@
+/*
+ * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
+
+import java.util.ArrayList;
+import android.view.animation.Interpolator;
+
+import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe;
+
+/**
+ * This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate
+ * values between those keyframes for a given animation. The class internal to the animation
+ * package because it is an implementation detail of how Keyframes are stored and used.
+ *
+ * float
and
+ * int
values). Other types will fall into a more general Keyframe class that
+ * treats its values as Objects. Unless your animation requires dealing with a custom type
+ * or a data structure that needs to be animated directly (and evaluated using an implementation
+ * of {@link TypeEvaluator}), you should stick to using float and int as animations using those
+ * types have lower runtime overhead than other types.value
object passed into the constructor.
+ */
+ Class mValueType;
+
+ /**
+ * The optional time interpolator for the interval preceding this keyframe. A null interpolator
+ * (the default) results in linear interpolation over the interval.
+ */
+ private /*Time*/Interpolator mInterpolator = null;
+
+ /**
+ * Flag to indicate whether this keyframe has a valid value. This flag is used when an
+ * animation first starts, to populate placeholder keyframes with real values derived
+ * from the target object.
+ */
+ boolean mHasValue = false;
+
+ /**
+ * Constructs a Keyframe object with the given time and value. The time defines the
+ * time, as a proportion of an overall animation's duration, at which the value will hold true
+ * for the animation. The value for the animation between keyframes will be calculated as
+ * an interpolation between the values at those keyframes.
+ *
+ * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
+ * of time elapsed of the overall animation duration.
+ * @param value The value that the object will animate to as the animation time approaches
+ * the time in this keyframe, and the the value animated from as the time passes the time in
+ * this keyframe.
+ */
+ public static Keyframe ofInt(float fraction, int value) {
+ return new IntKeyframe(fraction, value);
+ }
+
+ /**
+ * Constructs a Keyframe object with the given time. The value at this time will be derived
+ * from the target object when the animation first starts (note that this implies that keyframes
+ * with no initial value must be used as part of an {@link ObjectAnimator}).
+ * The time defines the
+ * time, as a proportion of an overall animation's duration, at which the value will hold true
+ * for the animation. The value for the animation between keyframes will be calculated as
+ * an interpolation between the values at those keyframes.
+ *
+ * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
+ * of time elapsed of the overall animation duration.
+ */
+ public static Keyframe ofInt(float fraction) {
+ return new IntKeyframe(fraction);
+ }
+
+ /**
+ * Constructs a Keyframe object with the given time and value. The time defines the
+ * time, as a proportion of an overall animation's duration, at which the value will hold true
+ * for the animation. The value for the animation between keyframes will be calculated as
+ * an interpolation between the values at those keyframes.
+ *
+ * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
+ * of time elapsed of the overall animation duration.
+ * @param value The value that the object will animate to as the animation time approaches
+ * the time in this keyframe, and the the value animated from as the time passes the time in
+ * this keyframe.
+ */
+ public static Keyframe ofFloat(float fraction, float value) {
+ return new FloatKeyframe(fraction, value);
+ }
+
+ /**
+ * Constructs a Keyframe object with the given time. The value at this time will be derived
+ * from the target object when the animation first starts (note that this implies that keyframes
+ * with no initial value must be used as part of an {@link ObjectAnimator}).
+ * The time defines the
+ * time, as a proportion of an overall animation's duration, at which the value will hold true
+ * for the animation. The value for the animation between keyframes will be calculated as
+ * an interpolation between the values at those keyframes.
+ *
+ * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
+ * of time elapsed of the overall animation duration.
+ */
+ public static Keyframe ofFloat(float fraction) {
+ return new FloatKeyframe(fraction);
+ }
+
+ /**
+ * Constructs a Keyframe object with the given time and value. The time defines the
+ * time, as a proportion of an overall animation's duration, at which the value will hold true
+ * for the animation. The value for the animation between keyframes will be calculated as
+ * an interpolation between the values at those keyframes.
+ *
+ * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
+ * of time elapsed of the overall animation duration.
+ * @param value The value that the object will animate to as the animation time approaches
+ * the time in this keyframe, and the the value animated from as the time passes the time in
+ * this keyframe.
+ */
+ public static Keyframe ofObject(float fraction, Object value) {
+ return new ObjectKeyframe(fraction, value);
+ }
+
+ /**
+ * Constructs a Keyframe object with the given time. The value at this time will be derived
+ * from the target object when the animation first starts (note that this implies that keyframes
+ * with no initial value must be used as part of an {@link ObjectAnimator}).
+ * The time defines the
+ * time, as a proportion of an overall animation's duration, at which the value will hold true
+ * for the animation. The value for the animation between keyframes will be calculated as
+ * an interpolation between the values at those keyframes.
+ *
+ * @param fraction The time, expressed as a value between 0 and 1, representing the fraction
+ * of time elapsed of the overall animation duration.
+ */
+ public static Keyframe ofObject(float fraction) {
+ return new ObjectKeyframe(fraction, null);
+ }
+
+ /**
+ * Indicates whether this keyframe has a valid value. This method is called internally when
+ * an {@link ObjectAnimator} first starts; keyframes without values are assigned values at
+ * that time by deriving the value for the property from the target object.
+ *
+ * @return boolean Whether this object has a value assigned.
+ */
+ public boolean hasValue() {
+ return mHasValue;
+ }
+
+ /**
+ * Gets the value for this Keyframe.
+ *
+ * @return The value for this Keyframe.
+ */
+ public abstract Object getValue();
+
+ /**
+ * Sets the value for this Keyframe.
+ *
+ * @param value value for this Keyframe.
+ */
+ public abstract void setValue(Object value);
+
+ /**
+ * Gets the time for this keyframe, as a fraction of the overall animation duration.
+ *
+ * @return The time associated with this keyframe, as a fraction of the overall animation
+ * duration. This should be a value between 0 and 1.
+ */
+ public float getFraction() {
+ return mFraction;
+ }
+
+ /**
+ * Sets the time for this keyframe, as a fraction of the overall animation duration.
+ *
+ * @param fraction time associated with this keyframe, as a fraction of the overall animation
+ * duration. This should be a value between 0 and 1.
+ */
+ public void setFraction(float fraction) {
+ mFraction = fraction;
+ }
+
+ /**
+ * Gets the optional interpolator for this Keyframe. A value of null
indicates
+ * that there is no interpolation, which is the same as linear interpolation.
+ *
+ * @return The optional interpolator for this Keyframe.
+ */
+ public /*Time*/Interpolator getInterpolator() {
+ return mInterpolator;
+ }
+
+ /**
+ * Sets the optional interpolator for this Keyframe. A value of null
indicates
+ * that there is no interpolation, which is the same as linear interpolation.
+ *
+ * @return The optional interpolator for this Keyframe.
+ */
+ public void setInterpolator(/*Time*/Interpolator interpolator) {
+ mInterpolator = interpolator;
+ }
+
+ /**
+ * Gets the type of keyframe. This information is used by ValueAnimator to determine the type of
+ * {@link TypeEvaluator} to use when calculating values between keyframes. The type is based
+ * on the type of Keyframe created.
+ *
+ * @return The type of the value stored in the Keyframe.
+ */
+ public Class getType() {
+ return mValueType;
+ }
+
+ @Override
+ public abstract Keyframe clone();
+
+ /**
+ * This internal subclass is used for all types which are not int or float.
+ */
+ static class ObjectKeyframe extends Keyframe {
+
+ /**
+ * The value of the animation at the time mFraction.
+ */
+ Object mValue;
+
+ ObjectKeyframe(float fraction, Object value) {
+ mFraction = fraction;
+ mValue = value;
+ mHasValue = (value != null);
+ mValueType = mHasValue ? value.getClass() : Object.class;
+ }
+
+ public Object getValue() {
+ return mValue;
+ }
+
+ public void setValue(Object value) {
+ mValue = value;
+ mHasValue = (value != null);
+ }
+
+ @Override
+ public ObjectKeyframe clone() {
+ ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue);
+ kfClone.setInterpolator(getInterpolator());
+ return kfClone;
+ }
+ }
+
+ /**
+ * Internal subclass used when the keyframe value is of type int.
+ */
+ static class IntKeyframe extends Keyframe {
+
+ /**
+ * The value of the animation at the time mFraction.
+ */
+ int mValue;
+
+ IntKeyframe(float fraction, int value) {
+ mFraction = fraction;
+ mValue = value;
+ mValueType = int.class;
+ mHasValue = true;
+ }
+
+ IntKeyframe(float fraction) {
+ mFraction = fraction;
+ mValueType = int.class;
+ }
+
+ public int getIntValue() {
+ return mValue;
+ }
+
+ public Object getValue() {
+ return mValue;
+ }
+
+ public void setValue(Object value) {
+ if (value != null && value.getClass() == Integer.class) {
+ mValue = ((Integer)value).intValue();
+ mHasValue = true;
+ }
+ }
+
+ @Override
+ public IntKeyframe clone() {
+ IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue);
+ kfClone.setInterpolator(getInterpolator());
+ return kfClone;
+ }
+ }
+
+ /**
+ * Internal subclass used when the keyframe value is of type float.
+ */
+ static class FloatKeyframe extends Keyframe {
+ /**
+ * The value of the animation at the time mFraction.
+ */
+ float mValue;
+
+ FloatKeyframe(float fraction, float value) {
+ mFraction = fraction;
+ mValue = value;
+ mValueType = float.class;
+ mHasValue = true;
+ }
+
+ FloatKeyframe(float fraction) {
+ mFraction = fraction;
+ mValueType = float.class;
+ }
+
+ public float getFloatValue() {
+ return mValue;
+ }
+
+ public Object getValue() {
+ return mValue;
+ }
+
+ public void setValue(Object value) {
+ if (value != null && value.getClass() == Float.class) {
+ mValue = ((Float)value).floatValue();
+ mHasValue = true;
+ }
+ }
+
+ @Override
+ public FloatKeyframe clone() {
+ FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue);
+ kfClone.setInterpolator(getInterpolator());
+ return kfClone;
+ }
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java
new file mode 100644
index 000000000..a71e1ad3c
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/KeyframeSet.java
@@ -0,0 +1,227 @@
+/*
+ * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import android.view.animation.Interpolator;
+
+import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe;
+import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe;
+import com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe;
+
+/**
+ * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate
+ * values between those keyframes for a given animation. The class internal to the animation
+ * package because it is an implementation detail of how Keyframes are stored and used.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+class KeyframeSet {
+
+ int mNumKeyframes;
+
+ Keyframe mFirstKeyframe;
+ Keyframe mLastKeyframe;
+ /*Time*/Interpolator mInterpolator; // only used in the 2-keyframe case
+ ArrayListfoo
will result
+ * in a call to the function setFoo()
on the target object. If either
+ * valueFrom
or valueTo
is null, then a getter function will
+ * also be derived and called.
+ *
+ * float
or int
typed values,
+ * and make the setter function for those properties have a void
return value. This
+ * will cause the code to take an optimized path for these constrained circumstances. Other
+ * property types and return types will work, but will have more overhead in processing
+ * the requests due to normal reflection mechanisms.valueFrom
and valueTo
properties, otherwise the call to
+ * the setter function will fail.foo
will result
+ * in a call to the function setFoo()
on the target object. If either
+ * valueFrom
or valueTo
is null, then a getter function will
+ * also be derived and called.
+ */
+ public String getPropertyName() {
+ return mPropertyName;
+ }
+
+ /**
+ * Creates a new ObjectAnimator object. This default constructor is primarily for
+ * use internally; the other constructors which take parameters are more generally
+ * useful.
+ */
+ public ObjectAnimator() {
+ }
+
+ /**
+ * Private utility constructor that initializes the target object and name of the
+ * property being animated.
+ *
+ * @param target The object whose property is to be animated. This object should
+ * have a public method on it called setName()
, where name
is
+ * the value of the propertyName
parameter.
+ * @param propertyName The name of the property being animated.
+ */
+ private ObjectAnimator(Object target, String propertyName) {
+ mTarget = target;
+ setPropertyName(propertyName);
+ }
+
+ /**
+ * Private utility constructor that initializes the target object and property being animated.
+ *
+ * @param target The object whose property is to be animated.
+ * @param property The property being animated.
+ */
+ //private setName()
, where name
is
+ * the value of the propertyName
parameter.
+ * @param propertyName The name of the property being animated.
+ * @param values A set of values that the animation will animate between over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ public static ObjectAnimator ofInt(Object target, String propertyName, int... values) {
+ ObjectAnimator anim = new ObjectAnimator(target, propertyName);
+ anim.setIntValues(values);
+ return anim;
+ }
+
+ /**
+ * Constructs and returns an ObjectAnimator that animates between int values. A single
+ * value implies that that value is the one being animated to. Two values imply a starting
+ * and ending values. More than two values imply a starting value, values to animate through
+ * along the way, and an ending value (these values will be distributed evenly across
+ * the duration of the animation).
+ *
+ * @param target The object whose property is to be animated.
+ * @param property The property being animated.
+ * @param values A set of values that the animation will animate between over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ //public static setName()
, where name
is
+ * the value of the propertyName
parameter.
+ * @param propertyName The name of the property being animated.
+ * @param values A set of values that the animation will animate between over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
+ ObjectAnimator anim = new ObjectAnimator(target, propertyName);
+ anim.setFloatValues(values);
+ return anim;
+ }
+
+ /**
+ * Constructs and returns an ObjectAnimator that animates between float values. A single
+ * value implies that that value is the one being animated to. Two values imply a starting
+ * and ending values. More than two values imply a starting value, values to animate through
+ * along the way, and an ending value (these values will be distributed evenly across
+ * the duration of the animation).
+ *
+ * @param target The object whose property is to be animated.
+ * @param property The property being animated.
+ * @param values A set of values that the animation will animate between over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ //public static setName()
, where name
is
+ * the value of the propertyName
parameter.
+ * @param propertyName The name of the property being animated.
+ * @param evaluator A TypeEvaluator that will be called on each animation frame to
+ * provide the necessary interpolation between the Object values to derive the animated
+ * value.
+ * @param values A set of values that the animation will animate between over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ public static ObjectAnimator ofObject(Object target, String propertyName,
+ TypeEvaluator evaluator, Object... values) {
+ ObjectAnimator anim = new ObjectAnimator(target, propertyName);
+ anim.setObjectValues(values);
+ anim.setEvaluator(evaluator);
+ return anim;
+ }
+
+ /**
+ * Constructs and returns an ObjectAnimator that animates between Object values. A single
+ * value implies that that value is the one being animated to. Two values imply a starting
+ * and ending values. More than two values imply a starting value, values to animate through
+ * along the way, and an ending value (these values will be distributed evenly across
+ * the duration of the animation).
+ *
+ * @param target The object whose property is to be animated.
+ * @param property The property being animated.
+ * @param evaluator A TypeEvaluator that will be called on each animation frame to
+ * provide the necessary interpolation between the Object values to derive the animated
+ * value.
+ * @param values A set of values that the animation will animate between over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ //public static PropertyValueHolder
objects. This variant should be used when animating
+ * several properties at once with the same ObjectAnimator, since PropertyValuesHolder allows
+ * you to associate a set of animation values with a property name.
+ *
+ * @param target The object whose property is to be animated. Depending on how the
+ * PropertyValuesObjects were constructed, the target object should either have the {@link
+ * android.util.Property} objects used to construct the PropertyValuesHolder objects or (if the
+ * PropertyValuesHOlder objects were created with property names) the target object should have
+ * public methods on it called setName()
, where name
is the name of
+ * the property passed in as the propertyName
parameter for each of the
+ * PropertyValuesHolder objects.
+ * @param values A set of PropertyValuesHolder objects whose values will be animated between
+ * over time.
+ * @return An ObjectAnimator object that is set up to animate between the given values.
+ */
+ public static ObjectAnimator ofPropertyValuesHolder(Object target,
+ PropertyValuesHolder... values) {
+ ObjectAnimator anim = new ObjectAnimator();
+ anim.mTarget = target;
+ anim.setValues(values);
+ return anim;
+ }
+
+ @Override
+ public void setIntValues(int... values) {
+ if (mValues == null || mValues.length == 0) {
+ // No values yet - this animator is being constructed piecemeal. Init the values with
+ // whatever the current propertyName is
+ //if (mProperty != null) {
+ // setValues(PropertyValuesHolder.ofInt(mProperty, values));
+ //} else {
+ setValues(PropertyValuesHolder.ofInt(mPropertyName, values));
+ //}
+ } else {
+ super.setIntValues(values);
+ }
+ }
+
+ @Override
+ public void setFloatValues(float... values) {
+ if (mValues == null || mValues.length == 0) {
+ // No values yet - this animator is being constructed piecemeal. Init the values with
+ // whatever the current propertyName is
+ //if (mProperty != null) {
+ // setValues(PropertyValuesHolder.ofFloat(mProperty, values));
+ //} else {
+ setValues(PropertyValuesHolder.ofFloat(mPropertyName, values));
+ //}
+ } else {
+ super.setFloatValues(values);
+ }
+ }
+
+ @Override
+ public void setObjectValues(Object... values) {
+ if (mValues == null || mValues.length == 0) {
+ // No values yet - this animator is being constructed piecemeal. Init the values with
+ // whatever the current propertyName is
+ //if (mProperty != null) {
+ // setValues(PropertyValuesHolder.ofObject(mProperty, (TypeEvaluator)null, values));
+ //} else {
+ setValues(PropertyValuesHolder.ofObject(mPropertyName, (TypeEvaluator)null, values));
+ //}
+ } else {
+ super.setObjectValues(values);
+ }
+ }
+
+ @Override
+ public void start() {
+ if (DBG) {
+ Log.d("ObjectAnimator", "Anim target, duration: " + mTarget + ", " + getDuration());
+ for (int i = 0; i < mValues.length; ++i) {
+ PropertyValuesHolder pvh = mValues[i];
+ ArrayListstartDelay
, the
+ * function is called after that delay ends.
+ * It takes care of the final initialization steps for the
+ * animation. This includes setting mEvaluator, if the user has not yet
+ * set it up, and the setter/getter methods, if the user did not supply
+ * them.
+ *
+ * ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start()
.
+ */
+ @Override
+ public ObjectAnimator setDuration(long duration) {
+ super.setDuration(duration);
+ return this;
+ }
+
+
+ /**
+ * The target object whose property will be animated by this animation
+ *
+ * @return The object being animated
+ */
+ public Object getTarget() {
+ return mTarget;
+ }
+
+ /**
+ * Sets the target object whose property will be animated by this animation
+ *
+ * @param target The object being animated
+ */
+ @Override
+ public void setTarget(Object target) {
+ if (mTarget != target) {
+ final Object oldTarget = mTarget;
+ mTarget = target;
+ if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) {
+ return;
+ }
+ // New target type should cause re-initialization prior to starting
+ mInitialized = false;
+ }
+ }
+
+ @Override
+ public void setupStartValues() {
+ initAnimation();
+ int numValues = mValues.length;
+ for (int i = 0; i < numValues; ++i) {
+ mValues[i].setupStartValue(mTarget);
+ }
+ }
+
+ @Override
+ public void setupEndValues() {
+ initAnimation();
+ int numValues = mValues.length;
+ for (int i = 0; i < numValues; ++i) {
+ mValues[i].setupEndValue(mTarget);
+ }
+ }
+
+ /**
+ * This method is called with the elapsed fraction of the animation during every
+ * animation frame. This function turns the elapsed fraction into an interpolated fraction
+ * and then into an animated value (from the evaluator. The function is called mostly during
+ * animation updates, but it is also called when the end()
+ * function is called, to set the final value on the property.
+ *
+ * propertyName
, since otherwise PropertyValuesHolder has
+ * no way of determining what the value should be.
+ * @param propertyName The name of the property associated with this set of values. This
+ * can be the actual property name to be used when using a ObjectAnimator object, or
+ * just a name used to get animated values, such as if this object is used with an
+ * ValueAnimator object.
+ * @param values The set of values to animate between.
+ */
+ public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) {
+ KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
+ if (keyframeSet instanceof IntKeyframeSet) {
+ return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet);
+ } else if (keyframeSet instanceof FloatKeyframeSet) {
+ return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet);
+ }
+ else {
+ PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
+ pvh.mKeyframeSet = keyframeSet;
+ pvh.mValueType = values[0].getType();
+ return pvh;
+ }
+ }
+
+ /**
+ * Constructs and returns a PropertyValuesHolder object with the specified property and set
+ * of values. These values can be of any type, but the type should be consistent so that
+ * an appropriate {@link android.animation.TypeEvaluator} can be found that matches
+ * the common type.
+ * propertyName
, since otherwise PropertyValuesHolder has
+ * no way of determining what the value should be.
+ *
+ * @param values One or more values that the animation will animate between.
+ */
+ public void setIntValues(int... values) {
+ mValueType = int.class;
+ mKeyframeSet = KeyframeSet.ofInt(values);
+ }
+
+ /**
+ * Set the animated values for this object to this set of floats.
+ * If there is only one value, it is assumed to be the end value of an animation,
+ * and an initial value will be derived, if possible, by calling a getter function
+ * on the object. Also, if any value is null, the value will be filled in when the animation
+ * starts in the same way. This mechanism of automatically getting null values only works
+ * if the PropertyValuesHolder object is used in conjunction
+ * {@link ObjectAnimator}, and with a getter function
+ * derived automatically from propertyName
, since otherwise PropertyValuesHolder has
+ * no way of determining what the value should be.
+ *
+ * @param values One or more values that the animation will animate between.
+ */
+ public void setFloatValues(float... values) {
+ mValueType = float.class;
+ mKeyframeSet = KeyframeSet.ofFloat(values);
+ }
+
+ /**
+ * Set the animated values for this object to this set of Keyframes.
+ *
+ * @param values One or more values that the animation will animate between.
+ */
+ public void setKeyframes(Keyframe... values) {
+ int numKeyframes = values.length;
+ Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)];
+ mValueType = values[0].getType();
+ for (int i = 0; i < numKeyframes; ++i) {
+ keyframes[i] = values[i];
+ }
+ mKeyframeSet = new KeyframeSet(keyframes);
+ }
+
+ /**
+ * Set the animated values for this object to this set of Objects.
+ * If there is only one value, it is assumed to be the end value of an animation,
+ * and an initial value will be derived, if possible, by calling a getter function
+ * on the object. Also, if any value is null, the value will be filled in when the animation
+ * starts in the same way. This mechanism of automatically getting null values only works
+ * if the PropertyValuesHolder object is used in conjunction
+ * {@link ObjectAnimator}, and with a getter function
+ * derived automatically from propertyName
, since otherwise PropertyValuesHolder has
+ * no way of determining what the value should be.
+ *
+ * @param values One or more values that the animation will animate between.
+ */
+ public void setObjectValues(Object... values) {
+ mValueType = values[0].getClass();
+ mKeyframeSet = KeyframeSet.ofObject(values);
+ }
+
+ /**
+ * Determine the setter or getter function using the JavaBeans convention of setFoo or
+ * getFoo for a property named 'foo'. This function figures out what the name of the
+ * function should be and uses reflection to find the Method with that name on the
+ * target object.
+ *
+ * @param targetClass The class to search for the method
+ * @param prefix "set" or "get", depending on whether we need a setter or getter.
+ * @param valueType The type of the parameter (in the case of a setter). This type
+ * is derived from the values set on this PropertyValuesHolder. This type is used as
+ * a first guess at the parameter type, but we check for methods with several different
+ * types to avoid problems with slight mis-matches between supplied values and actual
+ * value types used on the setter.
+ * @return Method the method associated with mPropertyName.
+ */
+ private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) {
+ // TODO: faster implementation...
+ Method returnVal = null;
+ String methodName = getMethodName(prefix, mPropertyName);
+ Class args[] = null;
+ if (valueType == null) {
+ try {
+ returnVal = targetClass.getMethod(methodName, args);
+ } catch (NoSuchMethodException e) {
+ Log.e("PropertyValuesHolder", targetClass.getSimpleName() + " - " +
+ "Couldn't find no-arg method for property " + mPropertyName + ": " + e);
+ }
+ } else {
+ args = new Class[1];
+ Class typeVariants[];
+ if (mValueType.equals(Float.class)) {
+ typeVariants = FLOAT_VARIANTS;
+ } else if (mValueType.equals(Integer.class)) {
+ typeVariants = INTEGER_VARIANTS;
+ } else if (mValueType.equals(Double.class)) {
+ typeVariants = DOUBLE_VARIANTS;
+ } else {
+ typeVariants = new Class[1];
+ typeVariants[0] = mValueType;
+ }
+ for (Class typeVariant : typeVariants) {
+ args[0] = typeVariant;
+ try {
+ returnVal = targetClass.getMethod(methodName, args);
+ // change the value type to suit
+ mValueType = typeVariant;
+ return returnVal;
+ } catch (NoSuchMethodException e) {
+ // Swallow the error and keep trying other variants
+ }
+ }
+ // If we got here, then no appropriate function was found
+ Log.e("PropertyValuesHolder",
+ "Couldn't find " + prefix + "ter property " + mPropertyName +
+ " for " + targetClass.getSimpleName() +
+ " with value type "+ mValueType);
+ }
+
+ return returnVal;
+ }
+
+
+ /**
+ * Returns the setter or getter requested. This utility function checks whether the
+ * requested method exists in the propertyMapMap cache. If not, it calls another
+ * utility function to request the Method from the targetClass directly.
+ * @param targetClass The Class on which the requested method should exist.
+ * @param propertyMapMap The cache of setters/getters derived so far.
+ * @param prefix "set" or "get", for the setter or getter.
+ * @param valueType The type of parameter passed into the method (null for getter).
+ * @return Method the method associated with mPropertyName.
+ */
+ private Method setupSetterOrGetter(Class targetClass,
+ HashMapfoo
will result
+ * in a call to the function setFoo()
on the target object. If either
+ * valueFrom
or valueTo
is null, then a getter function will
+ * also be derived and called.
+ *
+ * valueFrom
and valueTo
properties, otherwise the call to
+ * the setter function will fail.foo
will result
+ * in a call to the function setFoo()
on the target object. If either
+ * valueFrom
or valueTo
is null, then a getter function will
+ * also be derived and called.
+ */
+ public String getPropertyName() {
+ return mPropertyName;
+ }
+
+ /**
+ * Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value
+ * most recently calculated in calculateValue().
+ * @return
+ */
+ Object getAnimatedValue() {
+ return mAnimatedValue;
+ }
+
+ @Override
+ public String toString() {
+ return mPropertyName + ": " + mKeyframeSet.toString();
+ }
+
+ /**
+ * Utility method to derive a setter/getter method name from a property name, where the
+ * prefix is typically "set" or "get" and the first letter of the property name is
+ * capitalized.
+ *
+ * @param prefix The precursor to the method name, before the property name begins, typically
+ * "set" or "get".
+ * @param propertyName The name of the property that represents the bulk of the method name
+ * after the prefix. The first letter of this word will be capitalized in the resulting
+ * method name.
+ * @return String the property name converted to a method name according to the conventions
+ * specified above.
+ */
+ static String getMethodName(String prefix, String propertyName) {
+ if (propertyName == null || propertyName.length() == 0) {
+ // shouldn't get here
+ return prefix;
+ }
+ char firstLetter = Character.toUpperCase(propertyName.charAt(0));
+ String theRest = propertyName.substring(1);
+ return prefix + firstLetter + theRest;
+ }
+
+ static class IntPropertyValuesHolder extends PropertyValuesHolder {
+
+ // Cache JNI functions to avoid looking them up twice
+ //private static final HashMapfraction
representing the proportion between the start and end values. The
+ * calculation is a simple parametric calculation: result = x0 + t * (v1 - v0)
,
+ * where x0
is startValue
, x1
is endValue
,
+ * and t
is fraction
.
+ *
+ * @param fraction The fraction from the starting to the ending values
+ * @param startValue The start value.
+ * @param endValue The end value.
+ * @return A linear interpolation between the start and end values, given the
+ * fraction
parameter.
+ */
+ public T evaluate(float fraction, T startValue, T endValue);
+
+}
\ No newline at end of file
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
new file mode 100644
index 000000000..d8a12c688
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
@@ -0,0 +1,1265 @@
+/*
+ * 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 com.actionbarsherlock.internal.nineoldandroids.animation;
+
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.util.AndroidRuntimeException;
+import android.view.animation.AccelerateDecelerateInterpolator;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
+import android.view.animation.LinearInterpolator;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * This class provides a simple timing engine for running animations
+ * which calculate animated values and set them on target objects.
+ *
+ * repeatCount
is INFINITE
+ * or a positive value, the animation restarts from the beginning.
+ */
+ public static final int RESTART = 1;
+ /**
+ * When the animation reaches the end and repeatCount
is INFINITE
+ * or a positive value, the animation reverses direction on every iteration.
+ */
+ public static final int REVERSE = 2;
+ /**
+ * This value used used with the {@link #setRepeatCount(int)} property to repeat
+ * the animation indefinitely.
+ */
+ public static final int INFINITE = -1;
+
+ /**
+ * Creates a new ValueAnimator object. This default constructor is primarily for
+ * use internally; the factory methods which take parameters are more generally
+ * useful.
+ */
+ public ValueAnimator() {
+ }
+
+ /**
+ * Constructs and returns a ValueAnimator that animates between int values. A single
+ * value implies that that value is the one being animated to. However, this is not typically
+ * useful in a ValueAnimator object because there is no way for the object to determine the
+ * starting value for the animation (unlike ObjectAnimator, which can derive that value
+ * from the target object and property being animated). Therefore, there should typically
+ * be two or more values.
+ *
+ * @param values A set of values that the animation will animate between over time.
+ * @return A ValueAnimator object that is set up to animate between the given values.
+ */
+ public static ValueAnimator ofInt(int... values) {
+ ValueAnimator anim = new ValueAnimator();
+ anim.setIntValues(values);
+ return anim;
+ }
+
+ /**
+ * Constructs and returns a ValueAnimator that animates between float values. A single
+ * value implies that that value is the one being animated to. However, this is not typically
+ * useful in a ValueAnimator object because there is no way for the object to determine the
+ * starting value for the animation (unlike ObjectAnimator, which can derive that value
+ * from the target object and property being animated). Therefore, there should typically
+ * be two or more values.
+ *
+ * @param values A set of values that the animation will animate between over time.
+ * @return A ValueAnimator object that is set up to animate between the given values.
+ */
+ public static ValueAnimator ofFloat(float... values) {
+ ValueAnimator anim = new ValueAnimator();
+ anim.setFloatValues(values);
+ return anim;
+ }
+
+ /**
+ * Constructs and returns a ValueAnimator that animates between the values
+ * specified in the PropertyValuesHolder objects.
+ *
+ * @param values A set of PropertyValuesHolder objects whose values will be animated
+ * between over time.
+ * @return A ValueAnimator object that is set up to animate between the given values.
+ */
+ public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) {
+ ValueAnimator anim = new ValueAnimator();
+ anim.setValues(values);
+ return anim;
+ }
+ /**
+ * Constructs and returns a ValueAnimator that animates between Object values. A single
+ * value implies that that value is the one being animated to. However, this is not typically
+ * useful in a ValueAnimator object because there is no way for the object to determine the
+ * starting value for the animation (unlike ObjectAnimator, which can derive that value
+ * from the target object and property being animated). Therefore, there should typically
+ * be two or more values.
+ *
+ * startDelay
, the
+ * function is called after that delay ends.
+ * It takes care of the final initialization steps for the
+ * animation.
+ *
+ * ValueAnimator.ofInt(0, 10).setDuration(500).start()
.
+ */
+ public ValueAnimator setDuration(long duration) {
+ if (duration < 0) {
+ throw new IllegalArgumentException("Animators cannot have negative duration: " +
+ duration);
+ }
+ mDuration = duration;
+ return this;
+ }
+
+ /**
+ * Gets the length of the animation. The default duration is 300 milliseconds.
+ *
+ * @return The length of the animation, in milliseconds.
+ */
+ public long getDuration() {
+ return mDuration;
+ }
+
+ /**
+ * Sets the position of the animation to the specified point in time. This time should
+ * be between 0 and the total duration of the animation, including any repetition. If
+ * the animation has not yet been started, then it will not advance forward after it is
+ * set to this time; it will simply set the time to this value and perform any appropriate
+ * actions based on that time. If the animation is already running, then setCurrentPlayTime()
+ * will set the current playing time to this value and continue playing from that point.
+ *
+ * @param playTime The time, in milliseconds, to which the animation is advanced or rewound.
+ */
+ public void setCurrentPlayTime(long playTime) {
+ initAnimation();
+ long currentTime = AnimationUtils.currentAnimationTimeMillis();
+ if (mPlayingState != RUNNING) {
+ mSeekTime = playTime;
+ mPlayingState = SEEKED;
+ }
+ mStartTime = currentTime - playTime;
+ animationFrame(currentTime);
+ }
+
+ /**
+ * Gets the current position of the animation in time, which is equal to the current
+ * time minus the time that the animation started. An animation that is not yet started will
+ * return a value of zero.
+ *
+ * @return The current position in time of the animation.
+ */
+ public long getCurrentPlayTime() {
+ if (!mInitialized || mPlayingState == STOPPED) {
+ return 0;
+ }
+ return AnimationUtils.currentAnimationTimeMillis() - mStartTime;
+ }
+
+ /**
+ * This custom, static handler handles the timing pulse that is shared by
+ * all active animations. This approach ensures that the setting of animation
+ * values will happen on the UI thread and that all animations will share
+ * the same times for calculating their values, which makes synchronizing
+ * animations possible.
+ *
+ */
+ private static class AnimationHandler extends Handler {
+ /**
+ * There are only two messages that we care about: ANIMATION_START and
+ * ANIMATION_FRAME. The START message is sent when an animation's start()
+ * method is called. It cannot start synchronously when start() is called
+ * because the call may be on the wrong thread, and it would also not be
+ * synchronized with other animations because it would not start on a common
+ * timing pulse. So each animation sends a START message to the handler, which
+ * causes the handler to place the animation on the active animations queue and
+ * start processing frames for that animation.
+ * The FRAME message is the one that is sent over and over while there are any
+ * active animations to process.
+ */
+ @Override
+ public void handleMessage(Message msg) {
+ boolean callAgain = true;
+ ArrayListValueAnimator
when there is just one
+ * property being animated. This value is only sensible while the animation is running. The main
+ * purpose for this read-only property is to retrieve the value from the ValueAnimator
+ * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
+ * is called during each animation frame, immediately after the value is calculated.
+ *
+ * @return animatedValue The value most recently calculated by this ValueAnimator
for
+ * the single property being animated. If there are several properties being animated
+ * (specified by several PropertyValuesHolder objects in the constructor), this function
+ * returns the animated value for the first of those objects.
+ */
+ public Object getAnimatedValue() {
+ if (mValues != null && mValues.length > 0) {
+ return mValues[0].getAnimatedValue();
+ }
+ // Shouldn't get here; should always have values unless ValueAnimator was set up wrong
+ return null;
+ }
+
+ /**
+ * The most recent value calculated by this ValueAnimator
for propertyName
.
+ * The main purpose for this read-only property is to retrieve the value from the
+ * ValueAnimator
during a call to
+ * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
+ * is called during each animation frame, immediately after the value is calculated.
+ *
+ * @return animatedValue The value most recently calculated for the named property
+ * by this ValueAnimator
.
+ */
+ public Object getAnimatedValue(String propertyName) {
+ PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName);
+ if (valuesHolder != null) {
+ return valuesHolder.getAnimatedValue();
+ } else {
+ // At least avoid crashing if called with bogus propertyName
+ return null;
+ }
+ }
+
+ /**
+ * Sets how many times the animation should be repeated. If the repeat
+ * count is 0, the animation is never repeated. If the repeat count is
+ * greater than 0 or {@link #INFINITE}, the repeat mode will be taken
+ * into account. The repeat count is 0 by default.
+ *
+ * @param value the number of times the animation should be repeated
+ */
+ public void setRepeatCount(int value) {
+ mRepeatCount = value;
+ }
+ /**
+ * Defines how many times the animation should repeat. The default value
+ * is 0.
+ *
+ * @return the number of times the animation should repeat, or {@link #INFINITE}
+ */
+ public int getRepeatCount() {
+ return mRepeatCount;
+ }
+
+ /**
+ * Defines what this animation should do when it reaches the end. This
+ * setting is applied only when the repeat count is either greater than
+ * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}.
+ *
+ * @param value {@link #RESTART} or {@link #REVERSE}
+ */
+ public void setRepeatMode(int value) {
+ mRepeatMode = value;
+ }
+
+ /**
+ * Defines what this animation should do when it reaches the end.
+ *
+ * @return either one of {@link #REVERSE} or {@link #RESTART}
+ */
+ public int getRepeatMode() {
+ return mRepeatMode;
+ }
+
+ /**
+ * Adds a listener to the set of listeners that are sent update events through the life of
+ * an animation. This method is called on all listeners for every frame of the animation,
+ * after the values for the animation have been calculated.
+ *
+ * @param listener the listener to be added to the current set of listeners for this animation.
+ */
+ public void addUpdateListener(AnimatorUpdateListener listener) {
+ if (mUpdateListeners == null) {
+ mUpdateListeners = new ArrayListnull
+ * will result in linear interpolation.
+ */
+ @Override
+ public void setInterpolator(/*Time*/Interpolator value) {
+ if (value != null) {
+ mInterpolator = value;
+ } else {
+ mInterpolator = new LinearInterpolator();
+ }
+ }
+
+ /**
+ * Returns the timing interpolator that this ValueAnimator uses.
+ *
+ * @return The timing interpolator for this ValueAnimator.
+ */
+ public /*Time*/Interpolator getInterpolator() {
+ return mInterpolator;
+ }
+
+ /**
+ * The type evaluator to be used when calculating the animated values of this animation.
+ * The system will automatically assign a float or int evaluator based on the type
+ * of startValue
and endValue
in the constructor. But if these values
+ * are not one of these primitive types, or if different evaluation is desired (such as is
+ * necessary with int values that represent colors), a custom evaluator needs to be assigned.
+ * For example, when running an animation on color values, the {@link ArgbEvaluator}
+ * should be used to get correct RGB color interpolation.
+ *
+ * startDelay
phase. The return value indicates whether it
+ * should be woken up and put on the active animations queue.
+ *
+ * @param currentTime The current animation time, used to calculate whether the animation
+ * has exceeded its startDelay
and should be started.
+ * @return True if the animation's startDelay
has been exceeded and the animation
+ * should be added to the set of active animations.
+ */
+ private boolean delayedAnimationFrame(long currentTime) {
+ if (!mStartedDelay) {
+ mStartedDelay = true;
+ mDelayStartTime = currentTime;
+ } else {
+ long deltaTime = currentTime - mDelayStartTime;
+ if (deltaTime > mStartDelay) {
+ // startDelay ended - start the anim and record the
+ // mStartTime appropriately
+ mStartTime = currentTime - (deltaTime - mStartDelay);
+ mPlayingState = RUNNING;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * This internal function processes a single animation frame for a given animation. The
+ * currentTime parameter is the timing pulse sent by the handler, used to calculate the
+ * elapsed duration, and therefore
+ * the elapsed fraction, of the animation. The return value indicates whether the animation
+ * should be ended (which happens when the elapsed time of the animation exceeds the
+ * animation's duration, including the repeatCount).
+ *
+ * @param currentTime The current time, as tracked by the static timing handler
+ * @return true if the animation's duration, including any repetitions due to
+ * repeatCount
has been exceeded and the animation should be ended.
+ */
+ boolean animationFrame(long currentTime) {
+ boolean done = false;
+
+ if (mPlayingState == STOPPED) {
+ mPlayingState = RUNNING;
+ if (mSeekTime < 0) {
+ mStartTime = currentTime;
+ } else {
+ mStartTime = currentTime - mSeekTime;
+ // Now that we're playing, reset the seek time
+ mSeekTime = -1;
+ }
+ }
+ switch (mPlayingState) {
+ case RUNNING:
+ case SEEKED:
+ float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f;
+ if (fraction >= 1f) {
+ if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) {
+ // Time to repeat
+ if (mListeners != null) {
+ int numListeners = mListeners.size();
+ for (int i = 0; i < numListeners; ++i) {
+ mListeners.get(i).onAnimationRepeat(this);
+ }
+ }
+ if (mRepeatMode == REVERSE) {
+ mPlayingBackwards = mPlayingBackwards ? false : true;
+ }
+ mCurrentIteration += (int)fraction;
+ fraction = fraction % 1f;
+ mStartTime += mDuration;
+ } else {
+ done = true;
+ fraction = Math.min(fraction, 1.0f);
+ }
+ }
+ if (mPlayingBackwards) {
+ fraction = 1f - fraction;
+ }
+ animateValue(fraction);
+ break;
+ }
+
+ return done;
+ }
+
+ /**
+ * Returns the current animation fraction, which is the elapsed/interpolated fraction used in
+ * the most recent frame update on the animation.
+ *
+ * @return Elapsed/interpolated fraction of the animation.
+ */
+ public float getAnimatedFraction() {
+ return mCurrentFraction;
+ }
+
+ /**
+ * This method is called with the elapsed fraction of the animation during every
+ * animation frame. This function turns the elapsed fraction into an interpolated fraction
+ * and then into an animated value (from the evaluator. The function is called mostly during
+ * animation updates, but it is also called when the end()
+ * function is called, to set the final value on the property.
+ *
+ * ValueAnimator
instance to receive callbacks on every animation
+ * frame, after the current frame's values have been calculated for that
+ * ValueAnimator
.
+ */
+ public static interface AnimatorUpdateListener {
+ /**
+ * Developer Guides
+ *
+ * public class MyActivity extends Activity {
+ * private static final int PROGRESS = 0x1;
+ *
+ * private ProgressBar mProgress;
+ * private int mProgressStatus = 0;
+ *
+ * private Handler mHandler = new Handler();
+ *
+ * protected void onCreate(Bundle icicle) {
+ * super.onCreate(icicle);
+ *
+ * setContentView(R.layout.progressbar_activity);
+ *
+ * mProgress = (ProgressBar) findViewById(R.id.progress_bar);
+ *
+ * // Start lengthy operation in a background thread
+ * new Thread(new Runnable() {
+ * public void run() {
+ * while (mProgressStatus < 100) {
+ * mProgressStatus = doWork();
+ *
+ * // Update the progress bar
+ * mHandler.post(new Runnable() {
+ * public void run() {
+ * mProgress.setProgress(mProgressStatus);
+ * }
+ * });
+ * }
+ * }
+ * }).start();
+ * }
+ * }
+ *
+ *
+ * <ProgressBar
+ * style="@android:style/Widget.ProgressBar.Horizontal"
+ * ... />
+ *
+ *
+ * <LinearLayout
+ * android:orientation="horizontal"
+ * ... >
+ * <ProgressBar
+ * android:layout_width="wrap_content"
+ * android:layout_height="wrap_content"
+ * style="@android:style/Widget.ProgressBar.Small"
+ * android:layout_marginRight="5dp" />
+ * <TextView
+ * android:layout_width="wrap_content"
+ * android:layout_height="wrap_content"
+ * android:text="@string/loading" />
+ * </LinearLayout>
+ *
+ *
+ *
+ *
+ *
+ */
+ private void initProgressBar() {
+ mMax = 100;
+ mProgress = 0;
+ mSecondaryProgress = 0;
+ mIndeterminate = false;
+ mOnlyIndeterminate = false;
+ mDuration = 4000;
+ mBehavior = AlphaAnimation.RESTART;
+ mMinWidth = 24;
+ mMaxWidth = 48;
+ mMinHeight = 24;
+ mMaxHeight = 48;
+ }
+
+ /**
+ *
+ *
+ */
+ 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/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java
new file mode 100644
index 000000000..ae7cb1fe0
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/view/ActionProvider.java
@@ -0,0 +1,170 @@
+/*
+ * 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 com.actionbarsherlock.view;
+
+import android.content.Context;
+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.
+ *
+ *
+ *
+ *
+ *
+ * <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" />
+ *
+ *
+ *
+ *
+ *
+ *
+ * Developer Guides
+ * R.menu.main_activity
)
+ * @param menu The Menu to inflate into. The items and submenus will be
+ * added to this Menu.
+ */
+ public void inflate(int menuRes, Menu menu) {
+ XmlResourceParser parser = null;
+ try {
+ parser = mContext.getResources().getLayout(menuRes);
+ AttributeSet attrs = Xml.asAttributeSet(parser);
+
+ parseMenu(parser, attrs, menu);
+ } catch (XmlPullParserException e) {
+ throw new InflateException("Error inflating menu XML", e);
+ } catch (IOException e) {
+ throw new InflateException("Error inflating menu XML", e);
+ } finally {
+ if (parser != null) parser.close();
+ }
+ }
+
+ /**
+ * Called internally to fill the given menu. If a sub menu is seen, it will
+ * call this recursively.
+ */
+ private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu)
+ throws XmlPullParserException, IOException {
+ MenuState menuState = new MenuState(menu);
+
+ int eventType = parser.getEventType();
+ String tagName;
+ boolean lookingForEndOfUnknownTag = false;
+ String unknownTagName = null;
+
+ // This loop will skip to the menu start tag
+ do {
+ if (eventType == XmlPullParser.START_TAG) {
+ tagName = parser.getName();
+ if (tagName.equals(XML_MENU)) {
+ // Go to next tag
+ eventType = parser.next();
+ break;
+ }
+
+ throw new RuntimeException("Expecting menu, got " + tagName);
+ }
+ eventType = parser.next();
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+
+ boolean reachedEndOfMenu = false;
+ while (!reachedEndOfMenu) {
+ switch (eventType) {
+ case XmlPullParser.START_TAG:
+ if (lookingForEndOfUnknownTag) {
+ break;
+ }
+
+ tagName = parser.getName();
+ if (tagName.equals(XML_GROUP)) {
+ menuState.readGroup(attrs);
+ } else if (tagName.equals(XML_ITEM)) {
+ menuState.readItem(attrs);
+ } else if (tagName.equals(XML_MENU)) {
+ // A menu start tag denotes a submenu for an item
+ SubMenu subMenu = menuState.addSubMenuItem();
+
+ // Parse the submenu into returned SubMenu
+ parseMenu(parser, attrs, subMenu);
+ } else {
+ lookingForEndOfUnknownTag = true;
+ unknownTagName = tagName;
+ }
+ break;
+
+ case XmlPullParser.END_TAG:
+ tagName = parser.getName();
+ if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) {
+ lookingForEndOfUnknownTag = false;
+ unknownTagName = null;
+ } else if (tagName.equals(XML_GROUP)) {
+ menuState.resetGroup();
+ } else if (tagName.equals(XML_ITEM)) {
+ // Add the item if it hasn't been added (if the item was
+ // a submenu, it would have been added already)
+ if (!menuState.hasAddedItem()) {
+ if (menuState.itemActionProvider != null &&
+ menuState.itemActionProvider.hasSubMenu()) {
+ menuState.addSubMenuItem();
+ } else {
+ menuState.addItem();
+ }
+ }
+ } else if (tagName.equals(XML_MENU)) {
+ reachedEndOfMenu = true;
+ }
+ break;
+
+ case XmlPullParser.END_DOCUMENT:
+ throw new RuntimeException("Unexpected end of document");
+ }
+
+ eventType = parser.next();
+ }
+ }
+
+ private static class InflatedOnMenuItemClickListener
+ implements MenuItem.OnMenuItemClickListener {
+ private static final Class>[] PARAM_TYPES = new Class[] { MenuItem.class };
+
+ private Object mRealOwner;
+ private Method mMethod;
+
+ public InflatedOnMenuItemClickListener(Object realOwner, String methodName) {
+ mRealOwner = realOwner;
+ Class> c = realOwner.getClass();
+ try {
+ mMethod = c.getMethod(methodName, PARAM_TYPES);
+ } catch (Exception e) {
+ InflateException ex = new InflateException(
+ "Couldn't resolve menu item onClick handler " + methodName +
+ " in class " + c.getName());
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ public boolean onMenuItemClick(MenuItem item) {
+ try {
+ if (mMethod.getReturnType() == Boolean.TYPE) {
+ return (Boolean) mMethod.invoke(mRealOwner, item);
+ } else {
+ mMethod.invoke(mRealOwner, item);
+ return true;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * State for the current menu.
+ * Developer Guides
+ * Developer Guides
+ *
+ *
+ * // Get a model and set it to a couple of clients with semantically similar function.
+ * ActivityChooserModel dataModel =
+ * ActivityChooserModel.get(context, "task_specific_history_file_name.xml");
+ *
+ * ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1();
+ * modelClient1.setActivityChooserModel(dataModel);
+ *
+ * ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2();
+ * modelClient2.setActivityChooserModel(dataModel);
+ *
+ * // Set an intent to choose a an activity for.
+ * dataModel.setIntent(intent);
+ *
+ *
+ *
activities
in descending order of relevance
+ * based on previous history and an intent.
+ *
+ * @param intent The {@link Intent}.
+ * @param activities Activities to be sorted.
+ * @param historicalRecords Historical records.
+ */
+ // This cannot be done by a simple comparator since an Activity weight
+ // is computed from history. Note that Activity implements Comparable.
+ public void sort(Intent intent, Listnull
for the file name. In such
+ * case a new model is returned for each invocation.
+ * null
+ * if the model should not be backed by a file. In this case the activities
+ * will be ordered only by data from the current session.
+ *
+ * @return The model.
+ */
+ public static ActivityChooserModel get(Context context, String historyFileName) {
+ synchronized (sRegistryLock) {
+ ActivityChooserModel dataModel = sDataModelRegistry.get(historyFileName);
+ if (dataModel == null) {
+ dataModel = new ActivityChooserModel(context, historyFileName);
+ sDataModelRegistry.put(historyFileName, dataModel);
+ }
+ dataModel.readHistoricalData();
+ return dataModel;
+ }
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @param context Context for loading resources.
+ * @param historyFileName The history XML file.
+ */
+ private ActivityChooserModel(Context context, String historyFileName) {
+ mContext = context.getApplicationContext();
+ if (!TextUtils.isEmpty(historyFileName)
+ && !historyFileName.endsWith(HISTORY_FILE_EXTENSION)) {
+ mHistoryFileName = historyFileName + HISTORY_FILE_EXTENSION;
+ } else {
+ mHistoryFileName = historyFileName;
+ }
+ }
+
+ /**
+ * Sets an intent for which to choose a activity.
+ * null
id not activities.
+ *
+ * @see #getActivity(int)
+ */
+ public ResolveInfo getDefaultActivity() {
+ synchronized (mInstanceLock) {
+ if (!mActivites.isEmpty()) {
+ return mActivites.get(0).resolveInfo;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets the default activity. The default activity is set by adding a
+ * historical record with weight high enough that this activity will
+ * become the highest ranked. Such a strategy guarantees that the default
+ * will eventually change if not used. Also the weight of the record for
+ * setting a default is inflated with a constant amount to guarantee that
+ * it will stay as default for awhile.
+ *
+ * @param index The index of the activity to set as default.
+ */
+ public void setDefaultActivity(int index) {
+ ActivityResolveInfo newDefaultActivity = mActivites.get(index);
+ ActivityResolveInfo oldDefaultActivity = mActivites.get(0);
+
+ final float weight;
+ if (oldDefaultActivity != null) {
+ // Add a record with weight enough to boost the chosen at the top.
+ weight = oldDefaultActivity.weight - newDefaultActivity.weight
+ + DEFAULT_ACTIVITY_INFLATION;
+ } else {
+ weight = DEFAULT_HISTORICAL_RECORD_WEIGHT;
+ }
+
+ ComponentName defaultName = new ComponentName(
+ newDefaultActivity.resolveInfo.activityInfo.packageName,
+ newDefaultActivity.resolveInfo.activityInfo.name);
+ HistoricalRecord historicalRecord = new HistoricalRecord(defaultName,
+ System.currentTimeMillis(), weight);
+ addHisoricalRecord(historicalRecord);
+ }
+
+ /**
+ * Reads the history data from the backing file if the latter
+ * was provided. Calling this method more than once before a call
+ * to {@link #persistHistoricalData()} has been made has no effect.
+ *
+ *
+ * Developer Guides
+ * null
if none.
+ * @return true if a successful launch, false if could not (e.g. bad position).
+ */
+ private boolean launchSuggestion(int position, int actionKey, String actionMsg) {
+ Cursor c = mSuggestionsAdapter.getCursor();
+ if ((c != null) && c.moveToPosition(position)) {
+
+ Intent intent = createIntentFromSuggestion(c, actionKey, actionMsg);
+
+ // launch the intent
+ launchIntent(intent);
+
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Launches an intent, including any special intent handling.
+ */
+ private void launchIntent(Intent intent) {
+ if (intent == null) {
+ return;
+ }
+ try {
+ // If the intent was created from a suggestion, it will always have an explicit
+ // component here.
+ getContext().startActivity(intent);
+ } catch (RuntimeException ex) {
+ Log.e(LOG_TAG, "Failed launch activity: " + intent, ex);
+ }
+ }
+
+ /**
+ * Sets the text in the query box, without updating the suggestions.
+ */
+ private void setQuery(CharSequence query) {
+ setText(mQueryTextView, query, true);
+ // Move the cursor to the end
+ mQueryTextView.setSelection(TextUtils.isEmpty(query) ? 0 : query.length());
+ }
+
+ private void launchQuerySearch(int actionKey, String actionMsg, String query) {
+ String action = Intent.ACTION_SEARCH;
+ Intent intent = createIntent(action, null, null, query, actionKey, actionMsg);
+ getContext().startActivity(intent);
+ }
+
+ /**
+ * Constructs an intent from the given information and the search dialog state.
+ *
+ * @param action Intent action.
+ * @param data Intent data, or null
.
+ * @param extraData Data for {@link SearchManager#EXTRA_DATA_KEY} or null
.
+ * @param query Intent query, or null
.
+ * @param actionKey The key code of the action key that was pressed,
+ * or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
+ * @param actionMsg The message for the action key that was pressed,
+ * or null
if none.
+ * @return The intent.
+ */
+ private Intent createIntent(String action, Uri data, String extraData, String query,
+ int actionKey, String actionMsg) {
+ // Now build the Intent
+ Intent intent = new Intent(action);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ // We need CLEAR_TOP to avoid reusing an old task that has other activities
+ // on top of the one we want. We don't want to do this in in-app search though,
+ // as it can be destructive to the activity stack.
+ if (data != null) {
+ intent.setData(data);
+ }
+ intent.putExtra(SearchManager.USER_QUERY, mUserQuery);
+ if (query != null) {
+ intent.putExtra(SearchManager.QUERY, query);
+ }
+ if (extraData != null) {
+ intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
+ }
+ if (mAppSearchData != null) {
+ intent.putExtra(SearchManager.APP_DATA, mAppSearchData);
+ }
+ if (actionKey != KeyEvent.KEYCODE_UNKNOWN) {
+ intent.putExtra(SearchManager.ACTION_KEY, actionKey);
+ intent.putExtra(SearchManager.ACTION_MSG, actionMsg);
+ }
+ intent.setComponent(mSearchable.getSearchActivity());
+ return intent;
+ }
+
+ /**
+ * Create and return an Intent that can launch the voice search activity for web search.
+ */
+ private Intent createVoiceWebSearchIntent(Intent baseIntent, SearchableInfo searchable) {
+ Intent voiceIntent = new Intent(baseIntent);
+ ComponentName searchActivity = searchable.getSearchActivity();
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
+ : searchActivity.flattenToShortString());
+ return voiceIntent;
+ }
+
+ /**
+ * Create and return an Intent that can launch the voice search activity, perform a specific
+ * voice transcription, and forward the results to the searchable activity.
+ *
+ * @param baseIntent The voice app search intent to start from
+ * @return A completely-configured intent ready to send to the voice search activity
+ */
+ private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
+ ComponentName searchActivity = searchable.getSearchActivity();
+
+ // create the necessary intent to set up a search-and-forward operation
+ // in the voice search system. We have to keep the bundle separate,
+ // because it becomes immutable once it enters the PendingIntent
+ Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
+ queryIntent.setComponent(searchActivity);
+ PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent,
+ PendingIntent.FLAG_ONE_SHOT);
+
+ // Now set up the bundle that will be inserted into the pending intent
+ // when it's time to do the search. We always build it here (even if empty)
+ // because the voice search activity will always need to insert "QUERY" into
+ // it anyway.
+ Bundle queryExtras = new Bundle();
+
+ // Now build the intent to launch the voice search. Add all necessary
+ // extras to launch the voice recognizer, and then all the necessary extras
+ // to forward the results to the searchable activity
+ Intent voiceIntent = new Intent(baseIntent);
+
+ // Add all of the configuration options supplied by the searchable's metadata
+ String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
+ String prompt = null;
+ String language = null;
+ int maxResults = 1;
+
+ Resources resources = getResources();
+ if (searchable.getVoiceLanguageModeId() != 0) {
+ languageModel = resources.getString(searchable.getVoiceLanguageModeId());
+ }
+ if (searchable.getVoicePromptTextId() != 0) {
+ prompt = resources.getString(searchable.getVoicePromptTextId());
+ }
+ if (searchable.getVoiceLanguageId() != 0) {
+ language = resources.getString(searchable.getVoiceLanguageId());
+ }
+ if (searchable.getVoiceMaxResults() != 0) {
+ maxResults = searchable.getVoiceMaxResults();
+ }
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
+ : searchActivity.flattenToShortString());
+
+ // Add the values that configure forwarding the results
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
+ voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
+
+ return voiceIntent;
+ }
+
+ /**
+ * When a particular suggestion has been selected, perform the various lookups required
+ * to use the suggestion. This includes checking the cursor for suggestion-specific data,
+ * and/or falling back to the XML for defaults; It also creates REST style Uri data when
+ * the suggestion includes a data id.
+ *
+ * @param c The suggestions cursor, moved to the row of the user's selection
+ * @param actionKey The key code of the action key that was pressed,
+ * or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
+ * @param actionMsg The message for the action key that was pressed,
+ * or null
if none.
+ * @return An intent for the suggestion at the cursor's position.
+ */
+ private Intent createIntentFromSuggestion(Cursor c, int actionKey, String actionMsg) {
+ try {
+ // use specific action if supplied, or default action if supplied, or fixed default
+ String action = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_ACTION);
+
+ if (action == null) {
+ action = mSearchable.getSuggestIntentAction();
+ }
+ if (action == null) {
+ action = Intent.ACTION_SEARCH;
+ }
+
+ // use specific data if supplied, or default data if supplied
+ String data = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_DATA);
+ if (data == null) {
+ data = mSearchable.getSuggestIntentData();
+ }
+ // then, if an ID was provided, append it.
+ if (data != null) {
+ String id = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID);
+ if (id != null) {
+ data = data + "/" + Uri.encode(id);
+ }
+ }
+ Uri dataUri = (data == null) ? null : Uri.parse(data);
+
+ String query = getColumnString(c, SearchManager.SUGGEST_COLUMN_QUERY);
+ String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
+
+ return createIntent(action, dataUri, extraData, query, actionKey, actionMsg);
+ } catch (RuntimeException e ) {
+ int rowNum;
+ try { // be really paranoid now
+ rowNum = c.getPosition();
+ } catch (RuntimeException e2 ) {
+ rowNum = -1;
+ }
+ Log.w(LOG_TAG, "Search suggestions cursor at row " + rowNum +
+ " returned exception.", e);
+ return null;
+ }
+ }
+
+ private void forceSuggestionQuery() {
+ try {
+ Method before = SearchAutoComplete.class.getMethod("doBeforeTextChanged");
+ Method after = SearchAutoComplete.class.getMethod("doAfterTextChanged");
+ before.setAccessible(true);
+ after.setAccessible(true);
+ before.invoke(mQueryTextView);
+ after.invoke(mQueryTextView);
+ } catch (Exception e) {
+ // Oh well...
+ }
+ }
+
+ static boolean isLandscapeMode(Context context) {
+ return context.getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_LANDSCAPE;
+ }
+
+ /**
+ * Callback to watch the text field for empty/non-empty
+ */
+ private TextWatcher mTextWatcher = new TextWatcher() {
+
+ public void beforeTextChanged(CharSequence s, int start, int before, int after) { }
+
+ public void onTextChanged(CharSequence s, int start,
+ int before, int after) {
+ SearchView.this.onTextChanged(s);
+ }
+
+ public void afterTextChanged(Editable s) {
+ }
+ };
+
+ /**
+ * Local subclass for AutoCompleteTextView.
+ * @hide
+ */
+ public static class SearchAutoComplete extends AutoCompleteTextView {
+
+ private int mThreshold;
+ private SearchView mSearchView;
+
+ public SearchAutoComplete(Context context) {
+ super(context);
+ mThreshold = getThreshold();
+ }
+
+ public SearchAutoComplete(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mThreshold = getThreshold();
+ }
+
+ public SearchAutoComplete(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mThreshold = getThreshold();
+ }
+
+ void setSearchView(SearchView searchView) {
+ mSearchView = searchView;
+ }
+
+ @Override
+ public void setThreshold(int threshold) {
+ super.setThreshold(threshold);
+ mThreshold = threshold;
+ }
+
+ /**
+ * Returns true if the text field is empty, or contains only whitespace.
+ */
+ private boolean isEmpty() {
+ return TextUtils.getTrimmedLength(getText()) == 0;
+ }
+
+ /**
+ * We override this method to avoid replacing the query box text when a
+ * suggestion is clicked.
+ */
+ @Override
+ protected void replaceText(CharSequence text) {
+ }
+
+ /**
+ * We override this method to avoid an extra onItemClick being called on
+ * the drop-down's OnItemClickListener by
+ * {@link AutoCompleteTextView#onKeyUp(int, KeyEvent)} when an item is
+ * clicked with the trackball.
+ */
+ @Override
+ public void performCompletion() {
+ }
+
+ /**
+ * We override this method to be sure and show the soft keyboard if
+ * appropriate when the TextView has focus.
+ */
+ @Override
+ public void onWindowFocusChanged(boolean hasWindowFocus) {
+ super.onWindowFocusChanged(hasWindowFocus);
+
+ if (hasWindowFocus && mSearchView.hasFocus() && getVisibility() == VISIBLE) {
+ InputMethodManager inputManager = (InputMethodManager) getContext()
+ .getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputManager.showSoftInput(this, 0);
+ // If in landscape mode, then make sure that
+ // the ime is in front of the dropdown.
+ if (isLandscapeMode(getContext())) {
+ ensureImeVisible(this, true);
+ }
+ }
+ }
+
+ @Override
+ protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
+ super.onFocusChanged(focused, direction, previouslyFocusedRect);
+ mSearchView.onTextFocusChanged();
+ }
+
+ /**
+ * We override this method so that we can allow a threshold of zero,
+ * which ACTV does not.
+ */
+ @Override
+ public boolean enoughToFilter() {
+ return mThreshold <= 0 || super.enoughToFilter();
+ }
+
+ @Override
+ public boolean onKeyPreIme(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ // special case for the back key, we do not even try to send it
+ // to the drop down list but instead, consume it immediately
+ if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
+ KeyEvent.DispatcherState state = getKeyDispatcherState();
+ if (state != null) {
+ state.startTracking(event, this);
+ }
+ return true;
+ } else if (event.getAction() == KeyEvent.ACTION_UP) {
+ KeyEvent.DispatcherState state = getKeyDispatcherState();
+ if (state != null) {
+ state.handleUpEvent(event);
+ }
+ if (event.isTracking() && !event.isCanceled()) {
+ mSearchView.clearFocus();
+ mSearchView.setImeVisibility(false);
+ return true;
+ }
+ }
+ }
+ return super.onKeyPreIme(keyCode, event);
+ }
+
+ }
+
+ private static void ensureImeVisible(AutoCompleteTextView view, boolean visible) {
+ try {
+ Method method = AutoCompleteTextView.class.getMethod("ensureImeVisible", boolean.class);
+ method.setAccessible(true);
+ method.invoke(view, visible);
+ } catch (Exception e) {
+ //Oh well...
+ }
+ }
+
+ private static void showSoftInputUnchecked(View view, InputMethodManager imm, int flags) {
+ try {
+ Method method = imm.getClass().getMethod("showSoftInputUnchecked", int.class, ResultReceiver.class);
+ method.setAccessible(true);
+ method.invoke(imm, flags, null);
+ } catch (Exception e) {
+ //Fallback to public API which hopefully does mostly the same thing
+ imm.showSoftInput(view, flags);
+ }
+ }
+
+ private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
+ try {
+ Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
+ method.setAccessible(true);
+ method.invoke(view, text, filter);
+ } catch (Exception e) {
+ //Fallback to public API which hopefully does mostly the same thing
+ view.setText(text);
+ }
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java
new file mode 100644
index 000000000..83e9f0ca9
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/ShareActionProvider.java
@@ -0,0 +1,316 @@
+/*
+ * 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 com.actionbarsherlock.widget;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Drawable;
+import android.util.TypedValue;
+import android.view.View;
+
+import com.actionbarsherlock.R;
+import com.actionbarsherlock.view.ActionProvider;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
+import com.actionbarsherlock.view.SubMenu;
+import com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener;
+
+/**
+ * This is a provider for a share action. It is responsible for creating views
+ * that enable data sharing and also to show a sub menu with sharing activities
+ * if the hosting item is placed on the overflow menu.
+ *
+ *
+ *
+ * // In Activity#onCreateOptionsMenu
+ * public boolean onCreateOptionsMenu(Menu menu) {
+ * // Get the menu item.
+ * MenuItem menuItem = menu.findItem(R.id.my_menu_item);
+ * // Get the provider and hold onto it to set/change the share intent.
+ * mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
+ * // Set history different from the default before getting the action
+ * // view since a call to {@link MenuItem#getActionView() MenuItem.getActionView()} calls
+ * // {@link ActionProvider#onCreateActionView()} which uses the backing file name. Omit this
+ * // line if using the default share history file is desired.
+ * mShareActionProvider.setShareHistoryFileName("custom_share_history.xml");
+ * . . .
+ * }
+ *
+ * // Somewhere in the application.
+ * public void doShare(Intent shareIntent) {
+ * // When you want to share set the share intent.
+ * mShareActionProvider.setShareIntent(shareIntent);
+ * }
+ *
+ * Note: While the sample snippet demonstrates how to use this provider + * in the context of a menu item, the use of the provider is not limited to menu items. + *
+ * + * @see ActionProvider + */ +public class ShareActionProvider extends ActionProvider { + + /** + * Listener for the event of selecting a share target. + */ + public interface OnShareTargetSelectedListener { + + /** + * Called when a share target has been selected. The client can + * decide whether to handle the intent or rely on the default + * behavior which is launching it. + *+ * Note: Modifying the intent is not permitted and + * any changes to the latter will be ignored. + *
+ * + * @param source The source of the notification. + * @param intent The intent for launching the chosen share target. + * @return Whether the client has handled the intent. + */ + public boolean onShareTargetSelected(ShareActionProvider source, Intent intent); + } + + /** + * The default for the maximal number of activities shown in the sub-menu. + */ + private static final int DEFAULT_INITIAL_ACTIVITY_COUNT = 4; + + /** + * The the maximum number activities shown in the sub-menu. + */ + private int mMaxShownActivityCount = DEFAULT_INITIAL_ACTIVITY_COUNT; + + /** + * Listener for handling menu item clicks. + */ + private final ShareMenuItemOnMenuItemClickListener mOnMenuItemClickListener = + new ShareMenuItemOnMenuItemClickListener(); + + /** + * The default name for storing share history. + */ + public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml"; + + /** + * Context for accessing resources. + */ + private final Context mContext; + + /** + * The name of the file with share history data. + */ + private String mShareHistoryFileName = DEFAULT_SHARE_HISTORY_FILE_NAME; + + private OnShareTargetSelectedListener mOnShareTargetSelectedListener; + + private OnChooseActivityListener mOnChooseActivityListener; + + /** + * Creates a new instance. + * + * @param context Context for accessing resources. + */ + public ShareActionProvider(Context context) { + super(context); + mContext = context; + } + + /** + * Sets a listener to be notified when a share target has been selected. + * The listener can optionally decide to handle the selection and + * not rely on the default behavior which is to launch the activity. + *+ * Note: If you choose the backing share history file + * you will still be notified in this callback. + *
+ * @param listener The listener. + */ + public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) { + mOnShareTargetSelectedListener = listener; + setActivityChooserPolicyIfNeeded(); + } + + /** + * {@inheritDoc} + */ + @Override + public View onCreateActionView() { + // Create the view and set its data model. + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + ActivityChooserView activityChooserView = new ActivityChooserView(mContext); + activityChooserView.setActivityChooserModel(dataModel); + + // Lookup and set the expand action icon. + TypedValue outTypedValue = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); + Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); + activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); + activityChooserView.setProvider(this); + + // Set content description. + activityChooserView.setDefaultActionButtonContentDescription( + R.string.abs__shareactionprovider_share_with_application); + activityChooserView.setExpandActivityOverflowButtonContentDescription( + R.string.abs__shareactionprovider_share_with); + + return activityChooserView; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasSubMenu() { + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public void onPrepareSubMenu(SubMenu subMenu) { + // Clear since the order of items may change. + subMenu.clear(); + + ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName); + PackageManager packageManager = mContext.getPackageManager(); + + final int expandedActivityCount = dataModel.getActivityCount(); + final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount); + + // Populate the sub-menu with a sub set of the activities. + for (int i = 0; i < collapsedActivityCount; i++) { + ResolveInfo activity = dataModel.getActivity(i); + subMenu.add(0, i, i, activity.loadLabel(packageManager)) + .setIcon(activity.loadIcon(packageManager)) + .setOnMenuItemClickListener(mOnMenuItemClickListener); + } + + if (collapsedActivityCount < expandedActivityCount) { + // Add a sub-menu for showing all activities as a list item. + SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, + collapsedActivityCount, + mContext.getString(R.string.abs__activity_chooser_view_see_all)); + for (int i = 0; i < expandedActivityCount; i++) { + ResolveInfo activity = dataModel.getActivity(i); + expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)) + .setIcon(activity.loadIcon(packageManager)) + .setOnMenuItemClickListener(mOnMenuItemClickListener); + } + } + } + + /** + * Sets the file name of a file for persisting the share history which + * history will be used for ordering share targets. This file will be used + * for all view created by {@link #onCreateActionView()}. Defaults to + * {@link #DEFAULT_SHARE_HISTORY_FILE_NAME}. Set tonull
+ * if share history should not be persisted between sessions.
+ * + * Note: The history file name can be set any time, however + * only the action views created by {@link #onCreateActionView()} after setting + * the file name will be backed by the provided file. + *
+ * + * @param shareHistoryFile The share history file name. + */ + public void setShareHistoryFileName(String shareHistoryFile) { + mShareHistoryFileName = shareHistoryFile; + setActivityChooserPolicyIfNeeded(); + } + + /** + * Sets an intent with information about the share action. Here is a + * sample for constructing a share intent: + *
+ *
+ *
+ * Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ * shareIntent.setType("image/*");
+ * Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
+ * shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
+ *
+ *
+ *
+ *
+ * @param shareIntent The share intent.
+ *
+ * @see Intent#ACTION_SEND
+ * @see Intent#ACTION_SEND_MULTIPLE
+ */
+ public void setShareIntent(Intent shareIntent) {
+ ActivityChooserModel dataModel = ActivityChooserModel.get(mContext,
+ mShareHistoryFileName);
+ dataModel.setIntent(shareIntent);
+ }
+
+ /**
+ * Reusable listener for handling share item clicks.
+ */
+ private class ShareMenuItemOnMenuItemClickListener implements OnMenuItemClickListener {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ ActivityChooserModel dataModel = ActivityChooserModel.get(mContext,
+ mShareHistoryFileName);
+ final int itemId = item.getItemId();
+ Intent launchIntent = dataModel.chooseActivity(itemId);
+ if (launchIntent != null) {
+ mContext.startActivity(launchIntent);
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Set the activity chooser policy of the model backed by the current
+ * share history file if needed which is if there is a registered callback.
+ */
+ private void setActivityChooserPolicyIfNeeded() {
+ if (mOnShareTargetSelectedListener == null) {
+ return;
+ }
+ if (mOnChooseActivityListener == null) {
+ mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy();
+ }
+ ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
+ dataModel.setOnChooseActivityListener(mOnChooseActivityListener);
+ }
+
+ /**
+ * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such.
+ */
+ private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener {
+ @Override
+ public boolean onChooseActivity(ActivityChooserModel host, Intent intent) {
+ if (mOnShareTargetSelectedListener != null) {
+ return mOnShareTargetSelectedListener.onShareTargetSelected(
+ ShareActionProvider.this, intent);
+ }
+ return false;
+ }
+ }
+}
diff --git a/libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java b/libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java
new file mode 100644
index 000000000..bd5cbd718
--- /dev/null
+++ b/libraries/ActionBarSherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java
@@ -0,0 +1,733 @@
+/*
+ * Copyright (C) 2009 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 com.actionbarsherlock.widget;
+
+import android.app.SearchManager;
+import android.app.SearchableInfo;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
+import android.database.Cursor;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.widget.ResourceCursorAdapter;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.style.TextAppearanceSpan;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.actionbarsherlock.R;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.WeakHashMap;
+
+/**
+ * Provides the contents for the suggestion drop-down list.
+ *
+ * @hide
+ */
+class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListener {
+
+ private static final boolean DBG = false;
+ private static final String LOG_TAG = "SuggestionsAdapter";
+ private static final int QUERY_LIMIT = 50;
+
+ static final int REFINE_NONE = 0;
+ static final int REFINE_BY_ENTRY = 1;
+ static final int REFINE_ALL = 2;
+
+ private SearchManager mSearchManager;
+ private SearchView mSearchView;
+ private Context mProviderContext;
+ private WeakHashMap
+ *
+ * @param refineWhat which queries to refine. Possible values are {@link #REFINE_NONE},
+ * {@link #REFINE_BY_ENTRY}, and {@link #REFINE_ALL}.
+ */
+ public void setQueryRefinement(int refineWhat) {
+ mQueryRefinement = refineWhat;
+ }
+
+ /**
+ * Returns the current query refinement preference.
+ * @return value of query refinement preference
+ */
+ public int getQueryRefinement() {
+ return mQueryRefinement;
+ }
+
+ /**
+ * Overridden to always return false
, since we cannot be sure that
+ * suggestion sources return stable IDs.
+ */
+ @Override
+ public boolean hasStableIds() {
+ return false;
+ }
+
+ /**
+ * Use the search suggestions provider to obtain a live cursor. This will be called
+ * in a worker thread, so it's OK if the query is slow (e.g. round trip for suggestions).
+ * The results will be processed in the UI thread and changeCursor() will be called.
+ */
+ @Override
+ public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
+ if (DBG) Log.d(LOG_TAG, "runQueryOnBackgroundThread(" + constraint + ")");
+ String query = (constraint == null) ? "" : constraint.toString();
+ /**
+ * for in app search we show the progress spinner until the cursor is returned with
+ * the results.
+ */
+ Cursor cursor = null;
+ if (mSearchView.getVisibility() != View.VISIBLE
+ || mSearchView.getWindowVisibility() != View.VISIBLE) {
+ return null;
+ }
+ //mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
+ try {
+ cursor = getSuggestions(query, QUERY_LIMIT);
+ // trigger fill window so the spinner stays up until the results are copied over and
+ // closer to being ready
+ if (cursor != null) {
+ cursor.getCount();
+ return cursor;
+ }
+ } catch (RuntimeException e) {
+ Log.w(LOG_TAG, "Search suggestions query threw an exception.", e);
+ }
+ // If cursor is null or an exception was thrown, stop the spinner and return null.
+ // changeCursor doesn't get called if cursor is null
+ // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
+ return null;
+ }
+
+ public Cursor getSuggestions(String query, int limit) {
+ Uri.Builder uriBuilder = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel()
+ .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
+
+ // append standard suggestion query path
+ uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
+
+ // inject query, either as selection args or inline
+ uriBuilder.appendPath(query);
+
+ if (limit > 0) {
+ uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT, String.valueOf(limit));
+ }
+
+ Uri uri = uriBuilder.build();
+
+ // finally, make the query
+ return mContext.getContentResolver().query(uri, null, null, null, null);
+ }
+
+ public void close() {
+ if (DBG) Log.d(LOG_TAG, "close()");
+ changeCursor(null);
+ mClosed = true;
+ }
+
+ @Override
+ public void notifyDataSetChanged() {
+ if (DBG) Log.d(LOG_TAG, "notifyDataSetChanged");
+ super.notifyDataSetChanged();
+
+ // mSearchView.onDataSetChanged(); // TODO:
+
+ updateSpinnerState(getCursor());
+ }
+
+ @Override
+ public void notifyDataSetInvalidated() {
+ if (DBG) Log.d(LOG_TAG, "notifyDataSetInvalidated");
+ super.notifyDataSetInvalidated();
+
+ updateSpinnerState(getCursor());
+ }
+
+ private void updateSpinnerState(Cursor cursor) {
+ Bundle extras = cursor != null ? cursor.getExtras() : null;
+ if (DBG) {
+ Log.d(LOG_TAG, "updateSpinnerState - extra = "
+ + (extras != null
+ ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)
+ : null));
+ }
+ // Check if the Cursor indicates that the query is not complete and show the spinner
+ if (extras != null
+ && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
+ // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
+ return;
+ }
+ // If cursor is null or is done, stop the spinner
+ // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
+ }
+
+ /**
+ * Cache columns.
+ */
+ @Override
+ public void changeCursor(Cursor c) {
+ if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")");
+
+ if (mClosed) {
+ Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
+ if (c != null) c.close();
+ return;
+ }
+
+ try {
+ super.changeCursor(c);
+
+ if (c != null) {
+ mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
+ mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2);
+ mText2UrlCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
+ mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1);
+ mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2);
+ mFlagsCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FLAGS);
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "error changing cursor and caching columns", e);
+ }
+ }
+
+ /**
+ * Tags the view with cached child view look-ups.
+ */
+ @Override
+ public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ View v = super.newView(context, cursor, parent);
+ v.setTag(new ChildViewCache(v));
+ return v;
+ }
+
+ /**
+ * Cache of the child views of drop-drown list items, to avoid looking up the children
+ * each time the contents of a list item are changed.
+ */
+ private final static class ChildViewCache {
+ public final TextView mText1;
+ public final TextView mText2;
+ public final ImageView mIcon1;
+ public final ImageView mIcon2;
+ public final ImageView mIconRefine;
+
+ public ChildViewCache(View v) {
+ mText1 = (TextView) v.findViewById(android.R.id.text1);
+ mText2 = (TextView) v.findViewById(android.R.id.text2);
+ mIcon1 = (ImageView) v.findViewById(android.R.id.icon1);
+ mIcon2 = (ImageView) v.findViewById(android.R.id.icon2);
+ mIconRefine = (ImageView) v.findViewById(R.id.edit_query);
+ }
+ }
+
+ @Override
+ public void bindView(View view, Context context, Cursor cursor) {
+ ChildViewCache views = (ChildViewCache) view.getTag();
+
+ int flags = 0;
+ if (mFlagsCol != INVALID_INDEX) {
+ flags = cursor.getInt(mFlagsCol);
+ }
+ if (views.mText1 != null) {
+ String text1 = getStringOrNull(cursor, mText1Col);
+ setViewText(views.mText1, text1);
+ }
+ if (views.mText2 != null) {
+ // First check TEXT_2_URL
+ CharSequence text2 = getStringOrNull(cursor, mText2UrlCol);
+ if (text2 != null) {
+ text2 = formatUrl(text2);
+ } else {
+ text2 = getStringOrNull(cursor, mText2Col);
+ }
+
+ // If no second line of text is indicated, allow the first line of text
+ // to be up to two lines if it wants to be.
+ if (TextUtils.isEmpty(text2)) {
+ if (views.mText1 != null) {
+ views.mText1.setSingleLine(false);
+ views.mText1.setMaxLines(2);
+ }
+ } else {
+ if (views.mText1 != null) {
+ views.mText1.setSingleLine(true);
+ views.mText1.setMaxLines(1);
+ }
+ }
+ setViewText(views.mText2, text2);
+ }
+
+ if (views.mIcon1 != null) {
+ setViewDrawable(views.mIcon1, getIcon1(cursor), View.INVISIBLE);
+ }
+ if (views.mIcon2 != null) {
+ setViewDrawable(views.mIcon2, getIcon2(cursor), View.GONE);
+ }
+ if (mQueryRefinement == REFINE_ALL
+ || (mQueryRefinement == REFINE_BY_ENTRY
+ && (flags & SearchManager.FLAG_QUERY_REFINEMENT) != 0)) {
+ views.mIconRefine.setVisibility(View.VISIBLE);
+ views.mIconRefine.setTag(views.mText1.getText());
+ views.mIconRefine.setOnClickListener(this);
+ } else {
+ views.mIconRefine.setVisibility(View.GONE);
+ }
+ }
+
+ public void onClick(View v) {
+ Object tag = v.getTag();
+ if (tag instanceof CharSequence) {
+ mSearchView.onQueryRefine((CharSequence) tag);
+ }
+ }
+
+ private CharSequence formatUrl(CharSequence url) {
+ if (mUrlColor == null) {
+ // Lazily get the URL color from the current theme.
+ TypedValue colorValue = new TypedValue();
+ mContext.getTheme().resolveAttribute(R.attr.textColorSearchUrl, colorValue, true);
+ mUrlColor = mContext.getResources().getColorStateList(colorValue.resourceId);
+ }
+
+ SpannableString text = new SpannableString(url);
+ text.setSpan(new TextAppearanceSpan(null, 0, 0, mUrlColor, null),
+ 0, url.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return text;
+ }
+
+ private void setViewText(TextView v, CharSequence text) {
+ // Set the text even if it's null, since we need to clear any previous text.
+ v.setText(text);
+
+ if (TextUtils.isEmpty(text)) {
+ v.setVisibility(View.GONE);
+ } else {
+ v.setVisibility(View.VISIBLE);
+ }
+ }
+
+ private Drawable getIcon1(Cursor cursor) {
+ if (mIconName1Col == INVALID_INDEX) {
+ return null;
+ }
+ String value = cursor.getString(mIconName1Col);
+ Drawable drawable = getDrawableFromResourceValue(value);
+ if (drawable != null) {
+ return drawable;
+ }
+ return getDefaultIcon1(cursor);
+ }
+
+ private Drawable getIcon2(Cursor cursor) {
+ if (mIconName2Col == INVALID_INDEX) {
+ return null;
+ }
+ String value = cursor.getString(mIconName2Col);
+ return getDrawableFromResourceValue(value);
+ }
+
+ /**
+ * Sets the drawable in an image view, makes sure the view is only visible if there
+ * is a drawable.
+ */
+ private void setViewDrawable(ImageView v, Drawable drawable, int nullVisibility) {
+ // Set the icon even if the drawable is null, since we need to clear any
+ // previous icon.
+ v.setImageDrawable(drawable);
+
+ if (drawable == null) {
+ v.setVisibility(nullVisibility);
+ } else {
+ v.setVisibility(View.VISIBLE);
+
+ // This is a hack to get any animated drawables (like a 'working' spinner)
+ // to animate. You have to setVisible true on an AnimationDrawable to get
+ // it to start animating, but it must first have been false or else the
+ // call to setVisible will be ineffective. We need to clear up the story
+ // about animated drawables in the future, see http://b/1878430.
+ drawable.setVisible(false, false);
+ drawable.setVisible(true, false);
+ }
+ }
+
+ /**
+ * Gets the text to show in the query field when a suggestion is selected.
+ *
+ * @param cursor The Cursor to read the suggestion data from. The Cursor should already
+ * be moved to the suggestion that is to be read from.
+ * @return The text to show, or null
if the query should not be
+ * changed when selecting this suggestion.
+ */
+ @Override
+ public CharSequence convertToString(Cursor cursor) {
+ if (cursor == null) {
+ return null;
+ }
+
+ String query = getColumnString(cursor, SearchManager.SUGGEST_COLUMN_QUERY);
+ if (query != null) {
+ return query;
+ }
+
+ return null;
+ }
+
+ /**
+ * This method is overridden purely to provide a bit of protection against
+ * flaky content providers.
+ *
+ * @see android.widget.ListAdapter#getView(int, View, ViewGroup)
+ */
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ try {
+ return super.getView(position, convertView, parent);
+ } catch (RuntimeException e) {
+ Log.w(LOG_TAG, "Search suggestions cursor threw exception.", e);
+ // Put exception string in item title
+ View v = newView(mContext, mCursor, parent);
+ if (v != null) {
+ ChildViewCache views = (ChildViewCache) v.getTag();
+ TextView tv = views.mText1;
+ tv.setText(e.toString());
+ }
+ return v;
+ }
+ }
+
+ /**
+ * Gets a drawable given a value provided by a suggestion provider.
+ *
+ * This value could be just the string value of a resource id
+ * (e.g., "2130837524"), in which case we will try to retrieve a drawable from
+ * the provider's resources. If the value is not an integer, it is
+ * treated as a Uri and opened with
+ * {@link ContentResolver#openOutputStream(android.net.Uri, String)}.
+ *
+ * All resources and URIs are read using the suggestion provider's context.
+ *
+ * If the string is not formatted as expected, or no drawable can be found for
+ * the provided value, this method returns null.
+ *
+ * @param drawableId a string like "2130837524",
+ * "android.resource://com.android.alarmclock/2130837524",
+ * or "content://contacts/photos/253".
+ * @return a Drawable, or null if none found
+ */
+ private Drawable getDrawableFromResourceValue(String drawableId) {
+ if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) {
+ return null;
+ }
+ try {
+ // First, see if it's just an integer
+ int resourceId = Integer.parseInt(drawableId);
+ // It's an int, look for it in the cache
+ String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE
+ + "://" + mProviderContext.getPackageName() + "/" + resourceId;
+ // Must use URI as cache key, since ints are app-specific
+ Drawable drawable = checkIconCache(drawableUri);
+ if (drawable != null) {
+ return drawable;
+ }
+ // Not cached, find it by resource ID
+ drawable = mProviderContext.getResources().getDrawable(resourceId);
+ // Stick it in the cache, using the URI as key
+ storeInIconCache(drawableUri, drawable);
+ return drawable;
+ } catch (NumberFormatException nfe) {
+ // It's not an integer, use it as a URI
+ Drawable drawable = checkIconCache(drawableId);
+ if (drawable != null) {
+ return drawable;
+ }
+ Uri uri = Uri.parse(drawableId);
+ drawable = getDrawable(uri);
+ storeInIconCache(drawableId, drawable);
+ return drawable;
+ } catch (Resources.NotFoundException nfe) {
+ // It was an integer, but it couldn't be found, bail out
+ Log.w(LOG_TAG, "Icon resource not found: " + drawableId);
+ return null;
+ }
+ }
+
+ /**
+ * Gets a drawable by URI, without using the cache.
+ *
+ * @return A drawable, or {@code null} if the drawable could not be loaded.
+ */
+ private Drawable getDrawable(Uri uri) {
+ try {
+ String scheme = uri.getScheme();
+ if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(scheme)) {
+ // Load drawables through Resources, to get the source density information
+ try {
+ return getTheDrawable(uri);
+ } catch (Resources.NotFoundException ex) {
+ throw new FileNotFoundException("Resource does not exist: " + uri);
+ }
+ } else {
+ // Let the ContentResolver handle content and file URIs.
+ InputStream stream = mProviderContext.getContentResolver().openInputStream(uri);
+ if (stream == null) {
+ throw new FileNotFoundException("Failed to open " + uri);
+ }
+ try {
+ return Drawable.createFromStream(stream, null);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException ex) {
+ Log.e(LOG_TAG, "Error closing icon stream for " + uri, ex);
+ }
+ }
+ }
+ } catch (FileNotFoundException fnfe) {
+ Log.w(LOG_TAG, "Icon not found: " + uri + ", " + fnfe.getMessage());
+ return null;
+ }
+ }
+
+ public Drawable getTheDrawable(Uri uri) throws FileNotFoundException {
+ String authority = uri.getAuthority();
+ Resources r;
+ if (TextUtils.isEmpty(authority)) {
+ throw new FileNotFoundException("No authority: " + uri);
+ } else {
+ try {
+ r = mContext.getPackageManager().getResourcesForApplication(authority);
+ } catch (NameNotFoundException ex) {
+ throw new FileNotFoundException("No package found for authority: " + uri);
+ }
+ }
+ Listnull
+ * if the cursor does not contain the given column.
+ */
+ public static String getColumnString(Cursor cursor, String columnName) {
+ int col = cursor.getColumnIndex(columnName);
+ return getStringOrNull(cursor, col);
+ }
+
+ private static String getStringOrNull(Cursor cursor, int col) {
+ if (col == INVALID_INDEX) {
+ return null;
+ }
+ try {
+ return cursor.getString(col);
+ } catch (Exception e) {
+ Log.e(LOG_TAG,
+ "unexpected error retrieving valid column from cursor, "
+ + "did the remote process die?", e);
+ return null;
+ }
+ }
+}
diff --git a/libraries/ActionBarSherlock/test/com/actionbarsherlock/internal/ManifestParsingTest.java b/libraries/ActionBarSherlock/test/com/actionbarsherlock/internal/ManifestParsingTest.java
new file mode 100644
index 000000000..47475c574
--- /dev/null
+++ b/libraries/ActionBarSherlock/test/com/actionbarsherlock/internal/ManifestParsingTest.java
@@ -0,0 +1,37 @@
+package com.actionbarsherlock.internal;
+
+import org.junit.Test;
+
+import static com.actionbarsherlock.internal.ActionBarSherlockCompat.cleanActivityName;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class ManifestParsingTest {
+ @Test
+ public void testFullyQualifiedClassName() {
+ String expected = "com.other.package.SomeClass";
+ String actual = cleanActivityName("com.jakewharton.test", "com.other.package.SomeClass");
+ assertThat(expected, equalTo(actual));
+ }
+
+ @Test
+ public void testFullyQualifiedClassNameSamePackage() {
+ String expected = "com.jakewharton.test.SomeClass";
+ String actual = cleanActivityName("com.jakewharton.test", "com.jakewharton.test.SomeClass");
+ assertThat(expected, equalTo(actual));
+ }
+
+ @Test
+ public void testUnqualifiedClassName() {
+ String expected = "com.jakewharton.test.SomeClass";
+ String actual = cleanActivityName("com.jakewharton.test", "SomeClass");
+ assertThat(expected, equalTo(actual));
+ }
+
+ @Test
+ public void testRelativeClassName() {
+ String expected = "com.jakewharton.test.ui.SomeClass";
+ String actual = cleanActivityName("com.jakewharton.test", ".ui.SomeClass");
+ assertThat(expected, equalTo(actual));
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 000000000..9df383b2a
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':OpenPGP-Keychain', ':libraries:ActionBarSherlock'
--
cgit v1.2.3