diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png deleted file mode 100644 index 79e56f52..00000000 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__dialog_full_holo_dark.9.png and /dev/null differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__dialog_full_holo_light.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__dialog_full_holo_light.9.png deleted file mode 100644 index e029f210..00000000 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__dialog_full_holo_light.9.png and /dev/null differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_commit_search_api_holo_dark.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_commit_search_api_holo_dark.png new file mode 100644 index 00000000..83f36a94 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_commit_search_api_holo_dark.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_commit_search_api_holo_light.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_commit_search_api_holo_light.png new file mode 100644 index 00000000..a3cc21e6 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_commit_search_api_holo_light.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_search.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_search.png index 4be72f10..bf8bd667 100644 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_search.png and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__ic_search.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__toast_frame.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__toast_frame.9.png new file mode 100644 index 00000000..ad2cb5a9 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-hdpi/abs__toast_frame.9.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__dialog_full_holo_dark.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__dialog_full_holo_dark.9.png deleted file mode 100644 index fb3660ea..00000000 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__dialog_full_holo_dark.9.png and /dev/null differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__dialog_full_holo_light.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__dialog_full_holo_light.9.png deleted file mode 100644 index f18050ea..00000000 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__dialog_full_holo_light.9.png and /dev/null differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__ic_commit_search_api_holo_dark.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__ic_commit_search_api_holo_dark.png new file mode 100644 index 00000000..844c99c2 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__ic_commit_search_api_holo_dark.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__ic_commit_search_api_holo_light.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__ic_commit_search_api_holo_light.png new file mode 100644 index 00000000..86c170e9 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__ic_commit_search_api_holo_light.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__toast_frame.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__toast_frame.9.png new file mode 100644 index 00000000..b9105dee Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-mdpi/abs__toast_frame.9.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png deleted file mode 100644 index f4970ad1..00000000 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__dialog_full_holo_dark.9.png and /dev/null differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png deleted file mode 100644 index 172fc3b5..00000000 Binary files a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__dialog_full_holo_light.9.png and /dev/null differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__ic_commit_search_api_holo_dark.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__ic_commit_search_api_holo_dark.png new file mode 100644 index 00000000..d8faf900 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__ic_commit_search_api_holo_dark.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__ic_commit_search_api_holo_light.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__ic_commit_search_api_holo_light.png new file mode 100644 index 00000000..e7c7280a Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__ic_commit_search_api_holo_light.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__toast_frame.9.png b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__toast_frame.9.png new file mode 100644 index 00000000..9f39a774 Binary files /dev/null and b/external/JakeWharton-ActionBarSherlock/library/res/drawable-xhdpi/abs__toast_frame.9.png differ diff --git a/external/JakeWharton-ActionBarSherlock/library/res/layout-xlarge/abs__screen_action_bar.xml b/external/JakeWharton-ActionBarSherlock/library/res/layout-xlarge/abs__screen_action_bar.xml index 040df44a..ab4fa28d 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/layout-xlarge/abs__screen_action_bar.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/layout-xlarge/abs__screen_action_bar.xml @@ -21,6 +21,7 @@ This is an optimized layout for a screen with the Action Bar enabled. + android:fitsSystemWindows="true" + android:splitMotionEvents="false"> diff --git a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__action_bar_tab_bar_view.xml b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__action_bar_tab_bar_view.xml index 0d51220c..9d8f759b 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__action_bar_tab_bar_view.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__action_bar_tab_bar_view.xml @@ -1,6 +1,6 @@ - \ No newline at end of file +/> diff --git a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__dialog_title_holo.xml b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__dialog_title_holo.xml deleted file mode 100644 index ab2b0ee6..00000000 --- a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__dialog_title_holo.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - diff --git a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__list_menu_item_layout.xml b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__list_menu_item_layout.xml deleted file mode 100644 index 147f36fe..00000000 --- a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__list_menu_item_layout.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__screen_action_bar.xml b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__screen_action_bar.xml index 1fb82fe9..68dc7dfe 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__screen_action_bar.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__screen_action_bar.xml @@ -22,7 +22,8 @@ This is an optimized layout for a screen with the Action Bar enabled. android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:fitsSystemWindows="true"> + android:fitsSystemWindows="true" + android:splitMotionEvents="false"> + android:fitsSystemWindows="true" + android:splitMotionEvents="false"> diff --git a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__simple_dropdown_hint.xml b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__simple_dropdown_hint.xml index 8fc0eb12..0088e14a 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__simple_dropdown_hint.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/layout/abs__simple_dropdown_hint.xml @@ -19,7 +19,7 @@ --> 9dip - 64dip + 64dip diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values-large/abs__dimens.xml b/external/JakeWharton-ActionBarSherlock/library/res/values-large/abs__dimens.xml deleted file mode 100644 index 63b12f7f..00000000 --- a/external/JakeWharton-ActionBarSherlock/library/res/values-large/abs__dimens.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - 55% - - 80% - diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values-sw600dp/abs__dimens.xml b/external/JakeWharton-ActionBarSherlock/library/res/values-sw600dp/abs__dimens.xml index f6785381..175a47fe 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values-sw600dp/abs__dimens.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values-sw600dp/abs__dimens.xml @@ -34,5 +34,5 @@ 5 - 64dip + 64dip diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values-v14/abs__themes.xml b/external/JakeWharton-ActionBarSherlock/library/res/values-v14/abs__themes.xml index 5fac1ab5..75e317b4 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values-v14/abs__themes.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values-v14/abs__themes.xml @@ -26,9 +26,4 @@ false true - - - diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__attrs.xml b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__attrs.xml index 32631ca8..af5873d9 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__attrs.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__attrs.xml @@ -181,7 +181,7 @@ - + diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__colors.xml b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__colors.xml index 625c632f..b189e727 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__colors.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__colors.xml @@ -21,7 +21,4 @@ @color/abs__background_holo_dark #ff4c4c4c #ffb2b2b2 - @color/abs__bright_foreground_holo_light - @color/abs__bright_foreground_holo_dark - #ff33b5e5 diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__dimens.xml b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__dimens.xml index 831289e0..9ded2197 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__dimens.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__dimens.xml @@ -36,18 +36,6 @@ 56dip - - 64dip - - - 65% - - 95% - 8dip diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__strings.xml b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__strings.xml index 06a2a2af..cf023592 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__strings.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__strings.xml @@ -29,10 +29,6 @@ See all... - - Select activity - - Share with... Choose an application diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__styles.xml b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__styles.xml index 45a18c18..f86c1b82 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__styles.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__styles.xml @@ -302,25 +302,6 @@ - - - - - - - - + + + + + + + + + + diff --git a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__themes.xml b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__themes.xml index 634fa798..6215e048 100644 --- a/external/JakeWharton-ActionBarSherlock/library/res/values/abs__themes.xml +++ b/external/JakeWharton-ActionBarSherlock/library/res/values/abs__themes.xml @@ -9,8 +9,6 @@ - @@ -182,58 +204,4 @@ false true - - - - diff --git a/external/JakeWharton-ActionBarSherlock/library/src/android/support/v4/app/Watson.java b/external/JakeWharton-ActionBarSherlock/library/src/android/support/v4/app/Watson.java index d93de4c6..ff72cdcf 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/android/support/v4/app/Watson.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/android/support/v4/app/Watson.java @@ -6,15 +6,14 @@ import android.view.Window; import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener; import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener; import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener; +import com.actionbarsherlock.BuildConfig; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; - import java.util.ArrayList; /** I'm in ur package. Stealing ur variables. */ public abstract class Watson extends FragmentActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener { - private static final boolean DEBUG = false; private static final String TAG = "Watson"; /** Fragment interface for menu creation callback. */ @@ -39,11 +38,11 @@ public abstract class Watson extends FragmentActivity implements OnCreatePanelMe @Override public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu); if (featureId == Window.FEATURE_OPTIONS_PANEL) { boolean result = onCreateOptionsMenu(menu); - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] activity create result: " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[onCreatePanelMenu] activity create result: " + result); MenuInflater inflater = getSupportMenuInflater(); boolean show = false; @@ -73,10 +72,10 @@ public abstract class Watson extends FragmentActivity implements OnCreatePanelMe mCreatedMenus = newMenus; - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] fragments create result: " + show); + if (BuildConfig.DEBUG) Log.d(TAG, "[onCreatePanelMenu] fragments create result: " + show); result |= show; - if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); return result; } return false; @@ -84,11 +83,11 @@ public abstract class Watson extends FragmentActivity implements OnCreatePanelMe @Override public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + " menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + " menu: " + menu); if (featureId == Window.FEATURE_OPTIONS_PANEL) { boolean result = onPrepareOptionsMenu(menu); - if (DEBUG) Log.d(TAG, "[onPreparePanel] activity prepare result: " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[onPreparePanel] activity prepare result: " + result); boolean show = false; if (mFragments.mAdded != null) { @@ -101,11 +100,11 @@ public abstract class Watson extends FragmentActivity implements OnCreatePanelMe } } - if (DEBUG) Log.d(TAG, "[onPreparePanel] fragments prepare result: " + show); + if (BuildConfig.DEBUG) Log.d(TAG, "[onPreparePanel] fragments prepare result: " + show); result |= show; result &= menu.hasVisibleItems(); - if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); return result; } return false; @@ -113,7 +112,7 @@ public abstract class Watson extends FragmentActivity implements OnCreatePanelMe @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { - if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); + if (BuildConfig.DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); if (featureId == Window.FEATURE_OPTIONS_PANEL) { if (onOptionsItemSelected(item)) { diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/ActionBarSherlock.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/ActionBarSherlock.java index ab160f83..6d56f511 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/ActionBarSherlock.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/ActionBarSherlock.java @@ -1,14 +1,5 @@ package com.actionbarsherlock; -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Iterator; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; @@ -27,6 +18,16 @@ import com.actionbarsherlock.view.ActionMode; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Iterator; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; /** *

Helper for implementing the action bar design pattern across all versions @@ -40,7 +41,6 @@ import com.actionbarsherlock.view.MenuItem; */ public abstract class ActionBarSherlock { protected static final String TAG = "ActionBarSherlock"; - protected static final boolean DEBUG = false; private static final Class[] CONSTRUCTOR_ARGS = new Class[] { Activity.class, int.class }; private static final HashMap> IMPLEMENTATIONS = @@ -122,12 +122,12 @@ public abstract class ActionBarSherlock { if (!implementationClass.isAnnotationPresent(Implementation.class)) { throw new IllegalArgumentException("Class " + implementationClass.getSimpleName() + " is not annotated with @Implementation"); } else if (IMPLEMENTATIONS.containsValue(implementationClass)) { - if (DEBUG) Log.w(TAG, "Class " + implementationClass.getSimpleName() + " already registered"); + if (BuildConfig.DEBUG) Log.w(TAG, "Class " + implementationClass.getSimpleName() + " already registered"); return; } Implementation impl = implementationClass.getAnnotation(Implementation.class); - if (DEBUG) Log.i(TAG, "Registering " + implementationClass.getSimpleName() + " with qualifier " + impl); + if (BuildConfig.DEBUG) Log.i(TAG, "Registering " + implementationClass.getSimpleName() + " with qualifier " + impl); IMPLEMENTATIONS.put(impl, implementationClass); } @@ -223,7 +223,7 @@ public abstract class ActionBarSherlock { throw new IllegalStateException("No implementations match configuration."); } Class impl = impls.values().iterator().next(); - if (DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); + if (BuildConfig.DEBUG) Log.i(TAG, "Using implementation: " + impl.getSimpleName()); try { Constructor ctor = impl.getConstructor(CONSTRUCTOR_ARGS); @@ -253,7 +253,7 @@ public abstract class ActionBarSherlock { protected ActionBarSherlock(Activity activity, int flags) { - if (DEBUG) Log.d(TAG, "[] activity: " + activity + ", flags: " + flags); + if (BuildConfig.DEBUG) Log.d(TAG, "[] activity: " + activity + ", flags: " + flags); mActivity = activity; mIsDelegate = (flags & FLAG_DELEGATE) != 0; @@ -551,7 +551,7 @@ public abstract class ActionBarSherlock { * @return {@code true} if menu creation should proceed. */ protected final boolean callbackCreateOptionsMenu(Menu menu) { - if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] menu: " + menu); boolean result = true; if (mActivity instanceof OnCreatePanelMenuListener) { @@ -562,7 +562,7 @@ public abstract class ActionBarSherlock { result = listener.onCreateOptionsMenu(menu); } - if (DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[callbackCreateOptionsMenu] returning " + result); return result; } @@ -572,7 +572,7 @@ public abstract class ActionBarSherlock { * @return {@code true} if menu preparation should proceed. */ protected final boolean callbackPrepareOptionsMenu(Menu menu) { - if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] menu: " + menu); boolean result = true; if (mActivity instanceof OnPreparePanelListener) { @@ -583,7 +583,7 @@ public abstract class ActionBarSherlock { result = listener.onPrepareOptionsMenu(menu); } - if (DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[callbackPrepareOptionsMenu] returning " + result); return result; } @@ -595,7 +595,7 @@ public abstract class ActionBarSherlock { * @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()); + if (BuildConfig.DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] item: " + item.getTitleCondensed()); boolean result = false; if (mActivity instanceof OnMenuItemSelectedListener) { @@ -606,7 +606,7 @@ public abstract class ActionBarSherlock { result = listener.onOptionsItemSelected(item); } - if (DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[callbackOptionsItemSelected] returning " + result); return result; } @@ -666,7 +666,7 @@ public abstract class ActionBarSherlock { * @param view The desired content to display. */ public void setContentView(View view) { - if (DEBUG) Log.d(TAG, "[setContentView] view: " + view); + if (BuildConfig.DEBUG) Log.d(TAG, "[setContentView] view: " + view); setContentView(view, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); } @@ -698,7 +698,7 @@ public abstract class ActionBarSherlock { * Change the title associated with this activity. */ public void setTitle(int resId) { - if (DEBUG) Log.d(TAG, "[setTitle] resId: " + resId); + if (BuildConfig.DEBUG) Log.d(TAG, "[setTitle] resId: " + resId); setTitle(mActivity.getString(resId)); } @@ -767,7 +767,7 @@ public abstract class ActionBarSherlock { * @return Menu inflater instance. */ public MenuInflater getMenuInflater() { - if (DEBUG) Log.d(TAG, "[getMenuInflater]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[getMenuInflater]"); // Make sure that action views can get an appropriate theme. if (mMenuInflater == null) { @@ -791,4 +791,9 @@ public abstract class ActionBarSherlock { * @see ActionMode */ public abstract ActionMode startActionMode(ActionMode.Callback callback); + + /** + * Ensure that the action bar is attached. + */ + public void ensureActionBar() {} } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockActivity.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockActivity.java index 7b454364..48a92da6 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockActivity.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockActivity.java @@ -243,6 +243,12 @@ public abstract class SherlockActivity extends Activity implements OnCreatePanel getSherlock().requestFeature((int)featureId); } + @Override + public View findViewById(int id) { + getSherlock().ensureActionBar(); + return super.findViewById(id); + } + /////////////////////////////////////////////////////////////////////////// // Progress Indication diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockDialogFragment.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockDialogFragment.java index a7c856bf..c139325c 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockDialogFragment.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockDialogFragment.java @@ -8,9 +8,9 @@ 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; +import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; +import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; +import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; public class SherlockDialogFragment extends DialogFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { private SherlockFragmentActivity mActivity; diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java index 078f9b0c..9f4e81d1 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockExpandableListActivity.java @@ -232,6 +232,12 @@ public abstract class SherlockExpandableListActivity extends ExpandableListActiv getSherlock().requestFeature((int)featureId); } + @Override + public View findViewById(int id) { + getSherlock().ensureActionBar(); + return super.findViewById(id); + } + /////////////////////////////////////////////////////////////////////////// // Progress Indication diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragment.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragment.java index 0f24e9c8..0bdd068a 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragment.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragment.java @@ -8,9 +8,9 @@ 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; +import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; +import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; +import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { private SherlockFragmentActivity mActivity; diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragmentActivity.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragmentActivity.java index 3d092f03..b09f05e4 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragmentActivity.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockFragmentActivity.java @@ -9,6 +9,7 @@ import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.Window; import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.BuildConfig; import com.actionbarsherlock.view.ActionMode; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; @@ -19,7 +20,6 @@ import static com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListene /** @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; @@ -139,33 +139,33 @@ public class SherlockFragmentActivity extends Watson implements OnActionModeStar /////////////////////////////////////////////////////////////////////////// public MenuInflater getSupportMenuInflater() { - if (DEBUG) Log.d(TAG, "[getSupportMenuInflater]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[getSupportMenuInflater]"); return getSherlock().getMenuInflater(); } public void invalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[invalidateOptionsMenu]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[invalidateOptionsMenu]"); getSherlock().dispatchInvalidateOptionsMenu(); } public void supportInvalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[supportInvalidateOptionsMenu]"); + if (BuildConfig.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 (BuildConfig.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); + if (BuildConfig.DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result); return result; } return super.onCreatePanelMenu(featureId, menu); @@ -178,14 +178,14 @@ public class SherlockFragmentActivity extends Watson implements OnActionModeStar @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 (BuildConfig.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); + if (BuildConfig.DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result); return result; } return super.onPreparePanel(featureId, view, menu); @@ -198,14 +198,14 @@ public class SherlockFragmentActivity extends Watson implements OnActionModeStar @Override public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) { - if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item); + if (BuildConfig.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); + if (BuildConfig.DEBUG) Log.d(TAG, "[onMenuItemSelected] returning " + result); return result; } return super.onMenuItemSelected(featureId, item); @@ -276,6 +276,12 @@ public class SherlockFragmentActivity extends Watson implements OnActionModeStar getSherlock().requestFeature((int)featureId); } + @Override + public View findViewById(int id) { + getSherlock().ensureActionBar(); + return super.findViewById(id); + } + /////////////////////////////////////////////////////////////////////////// // Progress Indication diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListActivity.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListActivity.java index aba6d85e..7ced7812 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListActivity.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListActivity.java @@ -243,6 +243,12 @@ public abstract class SherlockListActivity extends ListActivity implements OnCre getSherlock().requestFeature((int)featureId); } + @Override + public View findViewById(int id) { + getSherlock().ensureActionBar(); + return super.findViewById(id); + } + /////////////////////////////////////////////////////////////////////////// // Progress Indication diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListFragment.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListFragment.java index 13ca3c49..7c4d0951 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListFragment.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockListFragment.java @@ -8,9 +8,9 @@ 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; +import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; +import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; +import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener { private SherlockFragmentActivity mActivity; diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java index bee72cb2..85c6ab21 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/app/SherlockPreferenceActivity.java @@ -243,6 +243,12 @@ public abstract class SherlockPreferenceActivity extends PreferenceActivity impl getSherlock().requestFeature((int)featureId); } + @Override + public View findViewById(int id) { + getSherlock().ensureActionBar(); + return super.findViewById(id); + } + /////////////////////////////////////////////////////////////////////////// // Progress Indication diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java index 5e69275c..421c94bd 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockCompat.java @@ -1,11 +1,5 @@ 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; @@ -28,9 +22,8 @@ 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.BuildConfig; import com.actionbarsherlock.R; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.internal.app.ActionBarImpl; @@ -46,6 +39,13 @@ import com.actionbarsherlock.internal.widget.IcsProgressBar; import com.actionbarsherlock.view.ActionMode; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.xmlpull.v1.XmlPullParser; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; @ActionBarSherlock.Implementation(api = 7) public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBuilder.Callback, com.actionbarsherlock.view.Window.Callback, MenuPresenter.Callback, android.view.MenuItem.OnMenuItemClickListener { @@ -108,13 +108,6 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu /** Parent view in which the context action bar is displayed. */ private ActionBarContextView mActionModeView; - /** Title view used with dialogs. */ - private TextView mTitleView; - /** Current activity title. */ - private CharSequence mTitle = null; - /** Whether or not this "activity" is floating (i.e., a dialog) */ - private boolean mIsFloating; - /////////////////////////////////////////////////////////////////////////// @@ -123,14 +116,14 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public ActionBar getActionBar() { - if (DEBUG) Log.d(TAG, "[getActionBar]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[getActionBar]"); initActionBar(); return aActionBar; } private void initActionBar() { - if (DEBUG) Log.d(TAG, "[initActionBar]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[initActionBar]"); // Initializing the window decor can change window feature flags. // Make sure that we have the correct set before performing the test below. @@ -157,14 +150,14 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setTitle(CharSequence title) { - if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); + if (BuildConfig.DEBUG) Log.d(TAG, "[setTitle] title: " + title); dispatchTitleChanged(title, 0); } @Override public ActionMode startActionMode(ActionMode.Callback callback) { - if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); + if (BuildConfig.DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); if (mActionMode != null) { mActionMode.finish(); @@ -215,7 +208,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchConfigurationChanged(Configuration newConfig) { - if (DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchConfigurationChanged] newConfig: " + newConfig); if (aActionBar != null) { aActionBar.onConfigurationChanged(newConfig); @@ -224,7 +217,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchPostResume() { - if (DEBUG) Log.d(TAG, "[dispatchPostResume]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPostResume]"); if (aActionBar != null) { aActionBar.setShowHideAnimationEnabled(true); @@ -233,7 +226,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchPause() { - if (DEBUG) Log.d(TAG, "[dispatchPause]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPause]"); if (wActionBar != null && wActionBar.isOverflowMenuShowing()) { wActionBar.hideOverflowMenu(); @@ -242,7 +235,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchStop() { - if (DEBUG) Log.d(TAG, "[dispatchStop]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchStop]"); if (aActionBar != null) { aActionBar.setShowHideAnimationEnabled(false); @@ -251,7 +244,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchInvalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); Bundle savedActionViewStates = null; if (mMenu != null) { @@ -275,7 +268,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public boolean dispatchOpenOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchOpenOptionsMenu]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchOpenOptionsMenu]"); if (!isReservingOverflow()) { return false; @@ -286,7 +279,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public boolean dispatchCloseOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchCloseOptionsMenu]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchCloseOptionsMenu]"); if (!isReservingOverflow()) { return false; @@ -300,7 +293,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchPostCreate(Bundle savedInstanceState) { - if (DEBUG) Log.d(TAG, "[dispatchOnPostCreate]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchOnPostCreate]"); if (mIsDelegate) { mIsTitleReady = true; @@ -313,7 +306,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { - if (DEBUG) { + if (BuildConfig.DEBUG) { Log.d(TAG, "[dispatchCreateOptionsMenu] android.view.Menu: " + menu); Log.d(TAG, "[dispatchCreateOptionsMenu] returning true"); } @@ -322,7 +315,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] android.view.Menu: " + menu); if (mActionMode != null) { return false; @@ -348,7 +341,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu } boolean result = mMenu.bindNativeOverflow(menu, this, mNativeItemMap); - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); return result; } @@ -359,7 +352,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public boolean dispatchMenuOpened(int featureId, android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchMenuOpened] featureId: " + featureId + ", menu: " + menu); if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { if (aActionBar != null) { @@ -373,7 +366,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchPanelClosed(int featureId, android.view.Menu menu){ - if (DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { if (aActionBar != null) { @@ -384,22 +377,16 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void dispatchTitleChanged(CharSequence title, int color) { - if (DEBUG) Log.d(TAG, "[dispatchTitleChanged] title: " + title + ", color: " + color); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchTitleChanged] title: " + title + ", color: " + color); - if (!mIsDelegate || mIsTitleReady) { - if (mTitleView != null) { - mTitleView.setText(title); - } else if (wActionBar != null) { - wActionBar.setWindowTitle(title); - } + if ((!mIsDelegate || mIsTitleReady) && (wActionBar != null)) { + wActionBar.setWindowTitle(title); } - - mTitle = title; } @Override public boolean dispatchKeyEvent(KeyEvent event) { - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchKeyEvent] event: " + event); final int keyCode = event.getKeyCode(); @@ -412,7 +399,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu if (action == KeyEvent.ACTION_UP) { mActionMode.finish(); } - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); return true; } @@ -421,12 +408,12 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu if (action == KeyEvent.ACTION_UP) { wActionBar.collapseActionView(); } - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning true"); return true; } } - if (DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning false"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchKeyEvent] returning false"); return false; } @@ -596,7 +583,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public boolean onMenuItemClick(android.view.MenuItem item) { - if (DEBUG) Log.d(TAG, "[mNativeItemListener.onMenuItemClick] item: " + item); + if (BuildConfig.DEBUG) Log.d(TAG, "[mNativeItemListener.onMenuItemClick] item: " + item); final MenuItemImpl sherlockItem = mNativeItemMap.get(item); if (sherlockItem != null) { @@ -620,7 +607,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setProgressBarVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); setFeatureInt(Window.FEATURE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON : Window.PROGRESS_VISIBILITY_OFF); @@ -628,7 +615,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setProgressBarIndeterminateVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, visible ? Window.PROGRESS_VISIBILITY_ON : Window.PROGRESS_VISIBILITY_OFF); @@ -636,7 +623,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setProgressBarIndeterminate(boolean indeterminate) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); setFeatureInt(Window.FEATURE_PROGRESS, indeterminate ? Window.PROGRESS_INDETERMINATE_ON : Window.PROGRESS_INDETERMINATE_OFF); @@ -644,14 +631,14 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setProgress(int progress) { - if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); setFeatureInt(Window.FEATURE_PROGRESS, progress + Window.PROGRESS_START); } @Override public void setSecondaryProgress(int secondaryProgress) { - if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); + if (BuildConfig.DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); setFeatureInt(Window.FEATURE_PROGRESS, secondaryProgress + Window.PROGRESS_SECONDARY_START); @@ -790,23 +777,23 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu /////////////////////////////////////////////////////////////////////////// private int getFeatures() { - if (DEBUG) Log.d(TAG, "[getFeatures] returning " + mFeatures); + if (BuildConfig.DEBUG) Log.d(TAG, "[getFeatures] returning " + mFeatures); return mFeatures; } @Override public boolean hasFeature(int featureId) { - if (DEBUG) Log.d(TAG, "[hasFeature] featureId: " + featureId); + if (BuildConfig.DEBUG) Log.d(TAG, "[hasFeature] featureId: " + featureId); boolean result = (mFeatures & (1 << featureId)) != 0; - if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[hasFeature] returning " + result); return result; } @Override public boolean requestFeature(int featureId) { - if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); + if (BuildConfig.DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); if (mContentParent != null) { throw new AndroidRuntimeException("requestFeature() must be called before adding content"); @@ -829,21 +816,21 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setUiOptions(int uiOptions) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); + if (BuildConfig.DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); mUiOptions = uiOptions; } @Override public void setUiOptions(int uiOptions, int mask) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); + if (BuildConfig.DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); mUiOptions = (mUiOptions & ~mask) | (uiOptions & mask); } @Override public void setContentView(int layoutResId) { - if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); + if (BuildConfig.DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); if (mContentParent == null) { installDecor(); @@ -862,7 +849,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void setContentView(View view, ViewGroup.LayoutParams params) { - if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); + if (BuildConfig.DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); if (mContentParent == null) { installDecor(); @@ -881,7 +868,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu @Override public void addContentView(View view, ViewGroup.LayoutParams params) { - if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); + if (BuildConfig.DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); if (mContentParent == null) { installDecor(); @@ -892,7 +879,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu } private void installDecor() { - if (DEBUG) Log.d(TAG, "[installDecor]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[installDecor]"); if (mDecor == null) { mDecor = (ViewGroup)mActivity.getWindow().getDecorView().findViewById(android.R.id.content); @@ -921,84 +908,70 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu } } - mTitleView = (TextView)mDecor.findViewById(android.R.id.title); - if (mTitleView != null) { - if (hasFeature(Window.FEATURE_NO_TITLE)) { - mTitleView.setVisibility(View.GONE); - if (mContentParent instanceof FrameLayout) { - ((FrameLayout)mContentParent).setForeground(null); - } - } else { - mTitleView.setText(mTitle); + wActionBar = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar); + if (wActionBar != null) { + wActionBar.setWindowCallback(this); + if (wActionBar.getTitle() == null) { + wActionBar.setWindowTitle(mActivity.getTitle()); + } + if (hasFeature(Window.FEATURE_PROGRESS)) { + wActionBar.initProgress(); + } + if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { + wActionBar.initIndeterminateProgress(); } - } else { - wActionBar = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar); - if (wActionBar != null) { - wActionBar.setWindowCallback(this); - if (wActionBar.getTitle() == null) { - wActionBar.setWindowTitle(mActivity.getTitle()); - } - if (hasFeature(Window.FEATURE_PROGRESS)) { - wActionBar.initProgress(); - } - if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) { - wActionBar.initIndeterminateProgress(); - } - //Since we don't require onCreate dispatching, parse for uiOptions here - int uiOptions = loadUiOptionsFromManifest(mActivity); - if (uiOptions != 0) { - mUiOptions = uiOptions; - } + //Since we don't require onCreate dispatching, parse for uiOptions here + int uiOptions = loadUiOptionsFromManifest(mActivity); + if (uiOptions != 0) { + mUiOptions = uiOptions; + } - boolean splitActionBar = false; - final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0; - if (splitWhenNarrow) { - splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow); - } else { - splitActionBar = mActivity.getTheme() - .obtainStyledAttributes(R.styleable.SherlockTheme) - .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false); - } - final ActionBarContainer splitView = (ActionBarContainer)mDecor.findViewById(R.id.abs__split_action_bar); - if (splitView != null) { - wActionBar.setSplitView(splitView); - wActionBar.setSplitActionBar(splitActionBar); - wActionBar.setSplitWhenNarrow(splitWhenNarrow); - - mActionModeView = (ActionBarContextView)mDecor.findViewById(R.id.abs__action_context_bar); - mActionModeView.setSplitView(splitView); - mActionModeView.setSplitActionBar(splitActionBar); - mActionModeView.setSplitWhenNarrow(splitWhenNarrow); - } else if (splitActionBar) { - Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request."); - } + boolean splitActionBar = false; + final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0; + if (splitWhenNarrow) { + splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow); + } else { + splitActionBar = mActivity.getTheme() + .obtainStyledAttributes(R.styleable.SherlockTheme) + .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false); + } + final ActionBarContainer splitView = (ActionBarContainer)mDecor.findViewById(R.id.abs__split_action_bar); + if (splitView != null) { + wActionBar.setSplitView(splitView); + wActionBar.setSplitActionBar(splitActionBar); + wActionBar.setSplitWhenNarrow(splitWhenNarrow); + + mActionModeView = (ActionBarContextView)mDecor.findViewById(R.id.abs__action_context_bar); + mActionModeView.setSplitView(splitView); + mActionModeView.setSplitActionBar(splitActionBar); + mActionModeView.setSplitWhenNarrow(splitWhenNarrow); + } else if (splitActionBar) { + Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request."); + } - // Post the panel invalidate for later; avoid application onCreateOptionsMenu - // being called in the middle of onCreate or similar. - mDecor.post(new Runnable() { - @Override - public void run() { - //Invalidate if the panel menu hasn't been created before this. - if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) { - dispatchInvalidateOptionsMenu(); - } + // Post the panel invalidate for later; avoid application onCreateOptionsMenu + // being called in the middle of onCreate or similar. + mDecor.post(new Runnable() { + @Override + public void run() { + //Invalidate if the panel menu hasn't been created before this. + if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) { + dispatchInvalidateOptionsMenu(); } - }); - } + } + }); } } } private ViewGroup generateLayout() { - if (DEBUG) Log.d(TAG, "[generateLayout]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[generateLayout]"); // Apply data from current theme. TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); - mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false); - if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) { throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative."); } @@ -1022,18 +995,10 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu int layoutResource; if (!hasFeature(Window.FEATURE_NO_TITLE)) { - if (mIsFloating) { - //Trash original dialog LinearLayout - mDecor = (ViewGroup)mDecor.getParent(); - mDecor.removeAllViews(); - - layoutResource = R.layout.abs__dialog_title_holo; + if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { + layoutResource = R.layout.abs__screen_action_bar_overlay; } else { - if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { - layoutResource = R.layout.abs__screen_action_bar_overlay; - } else { - layoutResource = R.layout.abs__screen_action_bar; - } + layoutResource = R.layout.abs__screen_action_bar; } } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) { layoutResource = R.layout.abs__screen_simple_overlay_action_mode; @@ -1041,7 +1006,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu layoutResource = R.layout.abs__screen_simple; } - if (DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource)); + if (BuildConfig.DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource)); View in = mActivity.getLayoutInflater().inflate(layoutResource, null); mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); @@ -1086,7 +1051,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu int uiOptions = 0; try { final String thisPackage = activity.getClass().getName(); - if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); + if (BuildConfig.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); final String packageName = activity.getApplicationInfo().packageName; final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); @@ -1099,10 +1064,10 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu if ("application".equals(name)) { //Check if the has the attribute - if (DEBUG) Log.d(TAG, "Got "); + if (BuildConfig.DEBUG) Log.d(TAG, "Got "); for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + if (BuildConfig.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); if ("uiOptions".equals(xml.getAttributeName(i))) { uiOptions = xml.getAttributeIntValue(i, 0); @@ -1111,13 +1076,13 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu } } else if ("activity".equals(name)) { //Check if the is us and has the attribute - if (DEBUG) Log.d(TAG, "Got "); + if (BuildConfig.DEBUG) Log.d(TAG, "Got "); Integer activityUiOptions = null; String activityPackage = null; boolean isOurActivity = false; for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + if (BuildConfig.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); //We need both uiOptions and name attributes String attrName = xml.getAttributeName(i); @@ -1149,7 +1114,7 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu } catch (Exception e) { e.printStackTrace(); } - if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions)); + if (BuildConfig.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions)); return uiOptions; } @@ -1200,4 +1165,13 @@ public class ActionBarSherlockCompat extends ActionBarSherlock implements MenuBu mActionMode = null; } } + + @Override + public void ensureActionBar() { + if (BuildConfig.DEBUG) Log.d(TAG, "[ensureActionBar]"); + + if (mDecor == null) { + initActionBar(); + } + } } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java index 0824d384..4f67b9fa 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ActionBarSherlockNative.java @@ -1,19 +1,22 @@ package com.actionbarsherlock.internal; -import com.actionbarsherlock.ActionBarSherlock; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.internal.app.ActionBarWrapper; -import com.actionbarsherlock.internal.view.menu.MenuWrapper; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.MenuInflater; import android.app.Activity; import android.content.Context; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; import android.view.View; -import android.view.Window; import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import com.actionbarsherlock.ActionBarSherlock; +import com.actionbarsherlock.BuildConfig; +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.internal.app.ActionBarWrapper; +import com.actionbarsherlock.internal.view.menu.MenuItemWrapper; +import com.actionbarsherlock.internal.view.menu.MenuWrapper; +import com.actionbarsherlock.view.ActionMode; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; @ActionBarSherlock.Implementation(api = 14) public class ActionBarSherlockNative extends ActionBarSherlock { @@ -28,7 +31,7 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public ActionBar getActionBar() { - if (DEBUG) Log.d(TAG, "[getActionBar]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[getActionBar]"); initActionBar(); return mActionBar; @@ -44,77 +47,89 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public void dispatchInvalidateOptionsMenu() { - if (DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]"); mActivity.getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL); + + if (mMenu != null) mMenu.invalidate(); } @Override public boolean dispatchCreateOptionsMenu(android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] menu: " + menu); if (mMenu == null || menu != mMenu.unwrap()) { mMenu = new MenuWrapper(menu); } final boolean result = callbackCreateOptionsMenu(mMenu); - if (DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchCreateOptionsMenu] returning " + result); return result; } @Override public boolean dispatchPrepareOptionsMenu(android.view.Menu menu) { - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] menu: " + menu); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] menu: " + menu); final boolean result = callbackPrepareOptionsMenu(mMenu); - if (DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchPrepareOptionsMenu] returning " + result); return result; } @Override public boolean dispatchOptionsItemSelected(android.view.MenuItem item) { - if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] item: " + item.getTitleCondensed()); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] item: " + item.getTitleCondensed()); - final boolean result = callbackOptionsItemSelected(mMenu.findItem(item)); - if (DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] returning " + result); + MenuItem wrapped; + if (mMenu == null) { + if (item.getItemId() != android.R.id.home) { + throw new IllegalStateException("Non-home action item clicked before onCreateOptionsMenu with ID " + item.getItemId()); + } + // Create a throw-away wrapper for now. + wrapped = new MenuItemWrapper(item); + } else { + wrapped = mMenu.findItem(item); + } + final boolean result = callbackOptionsItemSelected(wrapped); + if (BuildConfig.DEBUG) Log.d(TAG, "[dispatchOptionsItemSelected] returning " + result); return result; } @Override public boolean hasFeature(int feature) { - if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); + if (BuildConfig.DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature); final boolean result = mActivity.getWindow().hasFeature(feature); - if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[hasFeature] returning " + result); return result; } @Override public boolean requestFeature(int featureId) { - if (DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); + if (BuildConfig.DEBUG) Log.d(TAG, "[requestFeature] featureId: " + featureId); final boolean result = mActivity.getWindow().requestFeature(featureId); - if (DEBUG) Log.d(TAG, "[requestFeature] returning " + result); + if (BuildConfig.DEBUG) Log.d(TAG, "[requestFeature] returning " + result); return result; } @Override public void setUiOptions(int uiOptions) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); + if (BuildConfig.DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions); mActivity.getWindow().setUiOptions(uiOptions); } @Override public void setUiOptions(int uiOptions, int mask) { - if (DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); + if (BuildConfig.DEBUG) Log.d(TAG, "[setUiOptions] uiOptions: " + uiOptions + ", mask: " + mask); mActivity.getWindow().setUiOptions(uiOptions, mask); } @Override public void setContentView(int layoutResId) { - if (DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); + if (BuildConfig.DEBUG) Log.d(TAG, "[setContentView] layoutResId: " + layoutResId); mActivity.getWindow().setContentView(layoutResId); initActionBar(); @@ -122,7 +137,7 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public void setContentView(View view, LayoutParams params) { - if (DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); + if (BuildConfig.DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params); mActivity.getWindow().setContentView(view, params); initActionBar(); @@ -130,7 +145,7 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public void addContentView(View view, LayoutParams params) { - if (DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); + if (BuildConfig.DEBUG) Log.d(TAG, "[addContentView] view: " + view + ", params: " + params); mActivity.getWindow().addContentView(view, params); initActionBar(); @@ -138,42 +153,42 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public void setTitle(CharSequence title) { - if (DEBUG) Log.d(TAG, "[setTitle] title: " + title); + if (BuildConfig.DEBUG) Log.d(TAG, "[setTitle] title: " + title); mActivity.getWindow().setTitle(title); } @Override public void setProgressBarVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgressBarVisibility] visible: " + visible); mActivity.setProgressBarVisibility(visible); } @Override public void setProgressBarIndeterminateVisibility(boolean visible) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgressBarIndeterminateVisibility] visible: " + visible); mActivity.setProgressBarIndeterminateVisibility(visible); } @Override public void setProgressBarIndeterminate(boolean indeterminate) { - if (DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgressBarIndeterminate] indeterminate: " + indeterminate); mActivity.setProgressBarIndeterminate(indeterminate); } @Override public void setProgress(int progress) { - if (DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); + if (BuildConfig.DEBUG) Log.d(TAG, "[setProgress] progress: " + progress); mActivity.setProgress(progress); } @Override public void setSecondaryProgress(int secondaryProgress) { - if (DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); + if (BuildConfig.DEBUG) Log.d(TAG, "[setSecondaryProgress] secondaryProgress: " + secondaryProgress); mActivity.setSecondaryProgress(secondaryProgress); } @@ -194,7 +209,7 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public ActionMode startActionMode(com.actionbarsherlock.view.ActionMode.Callback callback) { - if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); + if (BuildConfig.DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); if (mActionMode != null) { mActionMode.finish(); @@ -288,6 +303,7 @@ public class ActionBarSherlockNative extends ActionBarSherlock { @Override public void invalidate() { mActionMode.invalidate(); + if (mMenu != null) mMenu.invalidate(); } @Override diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ResourcesCompat.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ResourcesCompat.java index 8e1efe8c..55a86a87 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ResourcesCompat.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/ResourcesCompat.java @@ -1,11 +1,19 @@ package com.actionbarsherlock.internal; +import android.app.Activity; import android.content.Context; +import android.content.res.AssetManager; +import android.content.res.XmlResourceParser; import android.os.Build; import android.util.DisplayMetrics; +import android.util.Log; +import com.actionbarsherlock.BuildConfig; import com.actionbarsherlock.R; +import org.xmlpull.v1.XmlPullParser; public final class ResourcesCompat { + private static final String TAG = "ResourcesCompat"; + //No instances private ResourcesCompat() {} @@ -92,4 +100,83 @@ public final class ResourcesCompat { throw new IllegalArgumentException("Unknown integer resource ID " + id); } + + /** + * Attempt to programmatically load the logo from the manifest file of an + * activity by using an XML pull parser. This should allow us to read the + * logo attribute regardless of the platform it is being run on. + * + * @param activity Activity instance. + * @return Logo resource ID. + */ + public static int loadLogoFromManifest(Activity activity) { + int logo = 0; + try { + final String thisPackage = activity.getClass().getName(); + if (BuildConfig.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); + + final String packageName = activity.getApplicationInfo().packageName; + final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); + final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); + + int eventType = xml.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String name = xml.getName(); + + if ("application".equals(name)) { + //Check if the has the attribute + if (BuildConfig.DEBUG) Log.d(TAG, "Got "); + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (BuildConfig.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + if ("logo".equals(xml.getAttributeName(i))) { + logo = xml.getAttributeResourceValue(i, 0); + break; //out of for loop + } + } + } else if ("activity".equals(name)) { + //Check if the is us and has the attribute + if (BuildConfig.DEBUG) Log.d(TAG, "Got "); + Integer activityLogo = null; + String activityPackage = null; + boolean isOurActivity = false; + + for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { + if (BuildConfig.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); + + //We need both uiOptions and name attributes + String attrName = xml.getAttributeName(i); + if ("logo".equals(attrName)) { + activityLogo = xml.getAttributeResourceValue(i, 0); + } else if ("name".equals(attrName)) { + activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i)); + if (!thisPackage.equals(activityPackage)) { + break; //on to the next + } + isOurActivity = true; + } + + //Make sure we have both attributes before processing + if ((activityLogo != null) && (activityPackage != null)) { + //Our activity, logo specified, override with our value + logo = activityLogo.intValue(); + } + } + if (isOurActivity) { + //If we matched our activity but it had no logo don't + //do any more processing of the manifest + break; + } + } + } + eventType = xml.nextToken(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (BuildConfig.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo)); + return logo; + } } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarImpl.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarImpl.java index d022a246..81f7d800 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarImpl.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarImpl.java @@ -170,7 +170,12 @@ public class ActionBarImpl extends ActionBar { // Older apps get the home button interaction enabled by default. // Newer apps need to enable it explicitly. - setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion < 14); + boolean homeButtonEnabled = mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH; + + // If the homeAsUp display option is set, always enable the home button. + homeButtonEnabled |= (mActionView.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0; + + setHomeButtonEnabled(homeButtonEnabled); setHasEmbeddedTabs(getResources_getBoolean(mContext, R.bool.abs__action_bar_embed_tabs)); diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java index 840cb3d2..fe479d0b 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/ActionBarWrapper.java @@ -26,6 +26,10 @@ public class ActionBarWrapper extends ActionBar implements android.app.ActionBar mActionBar = activity.getActionBar(); if (mActionBar != null) { mActionBar.addOnMenuVisibilityListener(this); + + // Fixes issue #746 + int displayOptions = mActionBar.getDisplayOptions(); + mActionBar.setHomeButtonEnabled((displayOptions & DISPLAY_HOME_AS_UP) != 0); } } @@ -132,11 +136,19 @@ public class ActionBarWrapper extends ActionBar implements android.app.ActionBar @Override public void setDisplayOptions(int options) { mActionBar.setDisplayOptions(options); + + // Fixes issue #746 + mActionBar.setHomeButtonEnabled((options & DISPLAY_HOME_AS_UP) != 0); } @Override public void setDisplayOptions(int options, int mask) { mActionBar.setDisplayOptions(options, mask); + + // Fixes issue #746 + if ((mask & DISPLAY_HOME_AS_UP) != 0) { + mActionBar.setHomeButtonEnabled((options & DISPLAY_HOME_AS_UP) != 0); + } } @Override diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java index d8a12c68..7f0f93ef 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java @@ -582,6 +582,7 @@ public class ValueAnimator extends Animator { * active animations to process. */ @Override + @SuppressWarnings("fallthrough") public void handleMessage(Message msg) { boolean callAgain = true; ArrayList animations = sAnimations.get(); diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java index dcb50f36..7d36c3b2 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.java @@ -37,6 +37,7 @@ import com.actionbarsherlock.R; import com.actionbarsherlock.internal.view.View_HasStateListenerSupport; import com.actionbarsherlock.internal.view.View_OnAttachStateChangeListener; import com.actionbarsherlock.internal.widget.CapitalizingButton; +import com.actionbarsherlock.internal.widget.IcsToast; import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoolean; @@ -263,7 +264,7 @@ public class ActionMenuItemView extends LinearLayout final int midy = screenPos[1] + height / 2; final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; - Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); + Toast cheatSheet = IcsToast.makeText(context, mItemData.getTitle(), IcsToast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java index 10c74203..51bacd7b 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuBuilder.java @@ -354,11 +354,11 @@ public class MenuBuilder implements Menu { SparseArray viewStates = states.getSparseParcelableArray( getActionViewStatesKey()); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) { - // Fixes Issue #652 with sdk <= 2.3.6 - return; - } - + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) { + //Fixes Issue #652 with sdk <= 2.3.6 + return; + } + final int itemCount = size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = getItem(i); diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java index 3d4dd42f..4eb8d09f 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuWrapper.java @@ -94,11 +94,18 @@ public class MenuWrapper implements Menu { @Override public void removeItem(int id) { + mNativeMap.remove(mNativeMenu.findItem(id)); mNativeMenu.removeItem(id); } @Override public void removeGroup(int groupId) { + for (int i = 0; i < mNativeMenu.size(); i++) { + final android.view.MenuItem item = mNativeMenu.getItem(i); + if (item.getGroupId() == groupId) { + mNativeMap.remove(item); + } + } mNativeMenu.removeGroup(groupId); } @@ -108,6 +115,20 @@ public class MenuWrapper implements Menu { mNativeMenu.clear(); } + public void invalidate() { + if (mNativeMap.isEmpty()) return; + + final WeakHashMap menuMapCopy = new WeakHashMap(mNativeMap.size()); + + for (int i = 0; i < mNativeMenu.size(); i++) { + final android.view.MenuItem item = mNativeMenu.getItem(i); + menuMapCopy.put(item, mNativeMap.get(item)); + } + + mNativeMap.clear(); + mNativeMap.putAll(menuMapCopy); + } + @Override public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { mNativeMenu.setGroupCheckable(group, checkable, exclusive); diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java index 1d9c68b3..0889825c 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarContainer.java @@ -18,7 +18,6 @@ package com.actionbarsherlock.internal.widget; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -27,7 +26,6 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; - import com.actionbarsherlock.R; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout; @@ -65,12 +63,7 @@ public class ActionBarContainer extends NineFrameLayout { //Fix for issue #379 if (mStackedBackground instanceof ColorDrawable && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(bitmap); - mStackedBackground.draw(c); - int color = bitmap.getPixel(0, 0); - bitmap.recycle(); - mStackedBackground = new IcsColorDrawable(color); + mStackedBackground = new IcsColorDrawable((ColorDrawable) mStackedBackground); } if (getId() == R.id.abs__split_action_bar) { diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarView.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarView.java index 4636de17..61e55b0a 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarView.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ActionBarView.java @@ -16,16 +16,14 @@ package com.actionbarsherlock.internal.widget; -import org.xmlpull.v1.XmlPullParser; +import com.actionbarsherlock.internal.ResourcesCompat; import android.app.Activity; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.TypedArray; -import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Parcel; @@ -49,7 +47,6 @@ import android.widget.TextView; import com.actionbarsherlock.R; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar.OnNavigationListener; -import com.actionbarsherlock.internal.ActionBarSherlockCompat; import com.actionbarsherlock.internal.view.menu.ActionMenuItem; import com.actionbarsherlock.internal.view.menu.ActionMenuPresenter; import com.actionbarsherlock.internal.view.menu.ActionMenuView; @@ -70,7 +67,6 @@ import static com.actionbarsherlock.internal.ResourcesCompat.getResources_getBoo */ public class ActionBarView extends AbsActionBarView { private static final String TAG = "ActionBarView"; - private static final boolean DEBUG = false; /** * Display options applied by default @@ -190,7 +186,7 @@ public class ActionBarView extends AbsActionBarView { if (context instanceof Activity) { //Even though native methods existed in API 9 and 10 they don't work //so just parse the manifest to look for the logo pre-Honeycomb - final int resId = loadLogoFromManifest((Activity) context); + final int resId = ResourcesCompat.loadLogoFromManifest((Activity) context); if (resId != 0) { mLogo = context.getResources().getDrawable(resId); } @@ -265,85 +261,6 @@ public class ActionBarView extends AbsActionBarView { mHomeLayout.setFocusable(true); } - /** - * Attempt to programmatically load the logo from the manifest file of an - * activity by using an XML pull parser. This should allow us to read the - * logo attribute regardless of the platform it is being run on. - * - * @param activity Activity instance. - * @return Logo resource ID. - */ - private static int loadLogoFromManifest(Activity activity) { - int logo = 0; - try { - final String thisPackage = activity.getClass().getName(); - if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage); - - final String packageName = activity.getApplicationInfo().packageName; - final AssetManager am = activity.createPackageContext(packageName, 0).getAssets(); - final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); - - int eventType = xml.getEventType(); - while (eventType != XmlPullParser.END_DOCUMENT) { - if (eventType == XmlPullParser.START_TAG) { - String name = xml.getName(); - - if ("application".equals(name)) { - //Check if the has the attribute - if (DEBUG) Log.d(TAG, "Got "); - - for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); - - if ("logo".equals(xml.getAttributeName(i))) { - logo = xml.getAttributeResourceValue(i, 0); - break; //out of for loop - } - } - } else if ("activity".equals(name)) { - //Check if the is us and has the attribute - if (DEBUG) Log.d(TAG, "Got "); - Integer activityLogo = null; - String activityPackage = null; - boolean isOurActivity = false; - - for (int i = xml.getAttributeCount() - 1; i >= 0; i--) { - if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i)); - - //We need both uiOptions and name attributes - String attrName = xml.getAttributeName(i); - if ("logo".equals(attrName)) { - activityLogo = xml.getAttributeResourceValue(i, 0); - } else if ("name".equals(attrName)) { - activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i)); - if (!thisPackage.equals(activityPackage)) { - break; //on to the next - } - isOurActivity = true; - } - - //Make sure we have both attributes before processing - if ((activityLogo != null) && (activityPackage != null)) { - //Our activity, logo specified, override with our value - logo = activityLogo.intValue(); - } - } - if (isOurActivity) { - //If we matched our activity but it had no logo don't - //do any more processing of the manifest - break; - } - } - } - eventType = xml.nextToken(); - } - } catch (Exception e) { - e.printStackTrace(); - } - if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo)); - return logo; - } - /* * Must be public so we can dispatch pre-2.2 via ActionBarImpl. */ diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java index fa3698f3..6a134a16 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/CapitalizingButton.java @@ -29,7 +29,12 @@ public class CapitalizingButton extends Button { public void setTextCompat(CharSequence text) { if (SANS_ICE_CREAM && mAllCaps && text != null) { if (IS_GINGERBREAD) { - setText(text.toString().toUpperCase(Locale.ROOT)); + try { + setText(text.toString().toUpperCase(Locale.ROOT)); + } catch (NoSuchFieldError e) { + //Some manufacturer broke Locale.ROOT. See #572. + setText(text.toString().toUpperCase()); + } } else { setText(text.toString().toUpperCase()); } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java deleted file mode 100644 index ad1b4f0a..00000000 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/FakeDialogPhoneWindow.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.actionbarsherlock.internal.widget; - -import static android.view.View.MeasureSpec.EXACTLY; -import android.content.Context; -import android.content.res.TypedArray; -import android.util.AttributeSet; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.widget.LinearLayout; -import com.actionbarsherlock.R; - -public class FakeDialogPhoneWindow extends LinearLayout { - final TypedValue mMinWidthMajor = new TypedValue(); - final TypedValue mMinWidthMinor = new TypedValue(); - - public FakeDialogPhoneWindow(Context context, AttributeSet attrs) { - super(context, attrs); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme); - - a.getValue(R.styleable.SherlockTheme_windowMinWidthMajor, mMinWidthMajor); - a.getValue(R.styleable.SherlockTheme_windowMinWidthMinor, mMinWidthMinor); - - a.recycle(); - } - - /* Stolen from PhoneWindow */ - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); - final boolean isPortrait = metrics.widthPixels < metrics.heightPixels; - - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - int width = getMeasuredWidth(); - boolean measure = false; - - widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY); - - final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor; - - if (tv.type != TypedValue.TYPE_NULL) { - final int min; - if (tv.type == TypedValue.TYPE_DIMENSION) { - min = (int)tv.getDimension(metrics); - } else if (tv.type == TypedValue.TYPE_FRACTION) { - min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels); - } else { - min = 0; - } - - if (width < min) { - widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY); - measure = true; - } - } - - // TODO: Support height? - - if (measure) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - } -} diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java index a78b3f71..3e022e63 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsColorDrawable.java @@ -1,8 +1,10 @@ package com.actionbarsherlock.internal.widget; +import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; /** @@ -12,6 +14,14 @@ public class IcsColorDrawable extends Drawable { private int color; private final Paint paint = new Paint(); + public IcsColorDrawable(ColorDrawable drawable) { + Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(bitmap); + drawable.draw(c); + this.color = bitmap.getPixel(0, 0); + bitmap.recycle(); + } + public IcsColorDrawable(int color) { this.color = color; } @@ -26,7 +36,7 @@ public class IcsColorDrawable extends Drawable { @Override public void setAlpha(int alpha) { if (alpha != (color >>> 24)) { - color = (color & 0x00FFFFFF) & (alpha << 24); + color = (color & 0x00FFFFFF) | (alpha << 24); invalidateSelf(); } } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java index 4947c41d..b7c6ff31 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsLinearLayout.java @@ -3,10 +3,11 @@ package com.actionbarsherlock.internal.widget; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.os.Build; import android.util.AttributeSet; import android.view.View; -import android.widget.LinearLayout; import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; @@ -20,14 +21,12 @@ import com.actionbarsherlock.internal.nineoldandroids.widget.NineLinearLayout; public class IcsLinearLayout extends NineLinearLayout { private static final int[] R_styleable_LinearLayout = new int[] { /* 0 */ android.R.attr.divider, - /* 1 */ android.R.attr.measureWithLargestChild, /* 2 */ android.R.attr.showDividers, /* 3 */ android.R.attr.dividerPadding, }; private static final int LinearLayout_divider = 0; - private static final int LinearLayout_measureWithLargestChild = 1; - private static final int LinearLayout_showDividers = 2; - private static final int LinearLayout_dividerPadding = 3; + private static final int LinearLayout_showDividers = 1; + private static final int LinearLayout_dividerPadding = 2; /** * Don't show any dividers. @@ -53,8 +52,6 @@ public class IcsLinearLayout extends NineLinearLayout { private int mShowDividers; private int mDividerPadding; - private boolean mUseLargestChild; - public IcsLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); @@ -63,7 +60,6 @@ public class IcsLinearLayout extends NineLinearLayout { setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0); - mUseLargestChild = a.getBoolean(/*com.android.internal.R.styleable.*/LinearLayout_measureWithLargestChild, false); a.recycle(); } @@ -100,6 +96,12 @@ public class IcsLinearLayout extends NineLinearLayout { if (divider == mDivider) { return; } + + //Fix for issue #379 + if (divider instanceof ColorDrawable && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + divider = new IcsColorDrawable((ColorDrawable) divider); + } + mDivider = divider; if (divider != null) { mDividerWidth = divider.getIntrinsicWidth(); @@ -275,136 +277,4 @@ public class IcsLinearLayout extends NineLinearLayout { } return false; } - - /** - * When true, all children with a weight will be considered having - * the minimum size of the largest child. If false, all children are - * measured normally. - * - * @return True to measure children with a weight using the minimum - * size of the largest child, false otherwise. - * - * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild - */ - public boolean isMeasureWithLargestChildEnabled() { - return mUseLargestChild; - } - - /** - * When set to true, all children with a weight will be considered having - * the minimum size of the largest child. If false, all children are - * measured normally. - * - * Disabled by default. - * - * @param enabled True to measure children with a weight using the - * minimum size of the largest child, false otherwise. - * - * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild - */ - public void setMeasureWithLargestChildEnabled(boolean enabled) { - mUseLargestChild = enabled; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - if (mUseLargestChild) { - final int orientation = getOrientation(); - switch (orientation) { - case HORIZONTAL: - useLargestChildHorizontal(); - break; - - case VERTICAL: - useLargestChildVertical(); - break; - } - } - } - - private void useLargestChildHorizontal() { - final int childCount = getChildCount(); - - // Find largest child width - int largestChildWidth = 0; - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - largestChildWidth = Math.max(child.getMeasuredWidth(), largestChildWidth); - } - - int totalWidth = 0; - // Re-measure childs - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - - if (child == null || child.getVisibility() == View.GONE) { - continue; - } - - final LinearLayout.LayoutParams lp = - (LinearLayout.LayoutParams) child.getLayoutParams(); - - float childExtra = lp.weight; - if (childExtra > 0) { - child.measure( - MeasureSpec.makeMeasureSpec(largestChildWidth, - MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(child.getMeasuredHeight(), - MeasureSpec.EXACTLY)); - totalWidth += largestChildWidth; - - } else { - totalWidth += child.getMeasuredWidth(); - } - - totalWidth += lp.leftMargin + lp.rightMargin; - } - - totalWidth += getPaddingLeft() + getPaddingRight(); - setMeasuredDimension(totalWidth, getMeasuredHeight()); - } - - private void useLargestChildVertical() { - final int childCount = getChildCount(); - - // Find largest child width - int largestChildHeight = 0; - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - largestChildHeight = Math.max(child.getMeasuredHeight(), largestChildHeight); - } - - int totalHeight = 0; - // Re-measure childs - for (int i = 0; i < childCount; i++) { - final View child = getChildAt(i); - - if (child == null || child.getVisibility() == View.GONE) { - continue; - } - - final LinearLayout.LayoutParams lp = - (LinearLayout.LayoutParams) child.getLayoutParams(); - - float childExtra = lp.weight; - if (childExtra > 0) { - child.measure( - MeasureSpec.makeMeasureSpec(child.getMeasuredWidth(), - MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(largestChildHeight, - MeasureSpec.EXACTLY)); - totalHeight += largestChildHeight; - - } else { - totalHeight += child.getMeasuredHeight(); - } - - totalHeight += lp.leftMargin + lp.rightMargin; - } - - totalHeight += getPaddingLeft() + getPaddingRight(); - setMeasuredDimension(getMeasuredWidth(), totalHeight); - } } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java index d13c6cea..5da83189 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsListPopupWindow.java @@ -258,6 +258,23 @@ public class IcsListPopupWindow { mPopup.setInputMethodMode(mode); } + /** + * Set the selected position of the list. + * Only valid when {@link #isShowing()} == {@code true}. + * + * @param position List position to set as selected. + */ + public void setSelection(int position) { + DropDownListView list = mDropDownList; + if (isShowing() && list != null) { + list.mListSelectionHidden = false; + list.setSelection(position); + if (list.getChoiceMode() != ListView.CHOICE_MODE_NONE) { + list.setItemChecked(position, true); + } + } + } + public void clearListSelection() { final DropDownListView list = mDropDownList; if (list != null) { diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsToast.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsToast.java new file mode 100644 index 00000000..042648b2 --- /dev/null +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsToast.java @@ -0,0 +1,60 @@ + +package com.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.util.Log; +import android.view.Gravity; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; +import android.widget.TextView; +import android.widget.Toast; + +import com.actionbarsherlock.R; + +public class IcsToast extends Toast { + public static final int LENGTH_LONG = Toast.LENGTH_LONG; + public static final int LENGTH_SHORT = Toast.LENGTH_SHORT; + private static final String TAG = "Toast"; + + public static Toast makeText(Context context, CharSequence s, int duration) { + if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) { + return Toast.makeText(context, s, duration); + } + IcsToast toast = new IcsToast(context); + toast.setDuration(duration); + TextView view = new TextView(context); + view.setText(s); + // Original AOSP using reference on @android:color/bright_foreground_dark + // bright_foreground_dark - reference on @android:color/background_light + // background_light - 0xffffffff + view.setTextColor(0xffffffff); + view.setGravity(Gravity.CENTER); + view.setBackgroundResource(R.drawable.abs__toast_frame); + toast.setView(view); + return toast; + } + + public static Toast makeText(Context context, int resId, int duration) { + return makeText(context, context.getResources().getString(resId), duration); + } + + public IcsToast(Context context) { + super(context); + } + + @Override + public void setText(CharSequence s) { + if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) { + super.setText(s); + return; + } + if (getView() == null) { + return; + } + try { + ((TextView) getView()).setText(s); + } catch (ClassCastException e) { + Log.e(TAG, "This Toast was not created with IcsToast.makeText", e); + } + } +} diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java index 48fb5d8b..eb178e0d 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java @@ -186,7 +186,7 @@ public class ScrollingTabContainerView extends NineHorizontalScrollView } private IcsLinearLayout createTabLayout() { - final IcsLinearLayout tabLayout = (IcsLinearLayout) LayoutInflater.from(getContext()) + final TabsLinearLayout tabLayout = (TabsLinearLayout) LayoutInflater.from(getContext()) .inflate(R.layout.abs__action_bar_tab_bar_view, null); tabLayout.setMeasureWithLargestChildEnabled(true); tabLayout.setLayoutParams(new LinearLayout.LayoutParams( diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/TabsLinearLayout.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/TabsLinearLayout.java new file mode 100644 index 00000000..03d09b1f --- /dev/null +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/TabsLinearLayout.java @@ -0,0 +1,113 @@ +package com.actionbarsherlock.internal.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; +import android.widget.LinearLayout; + +public class TabsLinearLayout extends IcsLinearLayout { + private static final int[] R_styleable_LinearLayout = new int[] { + /* 0 */ android.R.attr.measureWithLargestChild, + }; + private static final int LinearLayout_measureWithLargestChild = 0; + + private boolean mUseLargestChild; + + public TabsLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/R_styleable_LinearLayout); + mUseLargestChild = a.getBoolean(/*com.android.internal.R.styleable.*/LinearLayout_measureWithLargestChild, false); + + a.recycle(); + } + + /** + * When true, all children with a weight will be considered having + * the minimum size of the largest child. If false, all children are + * measured normally. + * + * @return True to measure children with a weight using the minimum + * size of the largest child, false otherwise. + * + * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild + */ + public boolean isMeasureWithLargestChildEnabled() { + return mUseLargestChild; + } + + /** + * When set to true, all children with a weight will be considered having + * the minimum size of the largest child. If false, all children are + * measured normally. + * + * Disabled by default. + * + * @param enabled True to measure children with a weight using the + * minimum size of the largest child, false otherwise. + * + * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild + */ + public void setMeasureWithLargestChildEnabled(boolean enabled) { + mUseLargestChild = enabled; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + final int childCount = getChildCount(); + if (childCount <= 2) return; + + final int mode = MeasureSpec.getMode(widthMeasureSpec); + if (mUseLargestChild && mode == MeasureSpec.UNSPECIFIED) { + final int orientation = getOrientation(); + if (orientation == HORIZONTAL) { + useLargestChildHorizontal(); + } + } + } + + private void useLargestChildHorizontal() { + final int childCount = getChildCount(); + + // Find largest child width + int largestChildWidth = 0; + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + largestChildWidth = Math.max(child.getMeasuredWidth(), largestChildWidth); + } + + int totalWidth = 0; + // Re-measure childs + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + + if (child == null || child.getVisibility() == View.GONE) { + continue; + } + + final LinearLayout.LayoutParams lp = + (LinearLayout.LayoutParams) child.getLayoutParams(); + + float childExtra = lp.weight; + if (childExtra > 0) { + child.measure( + MeasureSpec.makeMeasureSpec(largestChildWidth, + MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(child.getMeasuredHeight(), + MeasureSpec.EXACTLY)); + totalWidth += largestChildWidth; + + } else { + totalWidth += child.getMeasuredWidth(); + } + + totalWidth += lp.leftMargin + lp.rightMargin; + } + + totalWidth += getPaddingLeft() + getPaddingRight(); + setMeasuredDimension(totalWidth, getMeasuredHeight()); + } +} diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserView.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserView.java index e19ea9e9..7eb7330e 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserView.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserView.java @@ -395,7 +395,11 @@ class ActivityChooserView extends ViewGroup implements ActivityChooserModelClien super.onAttachedToWindow(); ActivityChooserModel dataModel = mAdapter.getDataModel(); if (dataModel != null) { - dataModel.registerObserver(mModelDataSetOberver); + try { + dataModel.registerObserver(mModelDataSetOberver); + } catch (IllegalStateException e) { + // Related to #557. + } } mIsAttachedToWindow = true; } @@ -522,6 +526,9 @@ class ActivityChooserView extends ViewGroup implements ActivityChooserModelClien mDefaultActionButtonContentDescription, label); mDefaultActivityButton.setContentDescription(contentDescription); } + + // Work-around for #415. + mAdapter.setShowDefaultActivity(false, false); } else { mDefaultActivityButton.setVisibility(View.GONE); } @@ -644,7 +651,8 @@ class ActivityChooserView extends ViewGroup implements ActivityChooserModelClien private int mMaxActivityCount = MAX_ACTIVITY_COUNT_DEFAULT; - private boolean mShowDefaultActivity; + // Work-around for #415. + private boolean mShowDefaultActivity = true; private boolean mHighlightDefaultActivity; @@ -661,7 +669,11 @@ class ActivityChooserView extends ViewGroup implements ActivityChooserModelClien } mDataModel = dataModel; if (dataModel != null && isShown()) { - dataModel.registerObserver(mModelDataSetOberver); + try { + dataModel.registerObserver(mModelDataSetOberver); + } catch (IllegalStateException e) { + // Related to #557. + } } notifyDataSetChanged(); } diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SearchView.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SearchView.java index c9e7897d..fb831964 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SearchView.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SearchView.java @@ -1623,8 +1623,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { private void forceSuggestionQuery() { try { - Method before = SearchAutoComplete.class.getMethod("doBeforeTextChanged"); - Method after = SearchAutoComplete.class.getMethod("doAfterTextChanged"); + Method before = AutoCompleteTextView.class.getDeclaredMethod("doBeforeTextChanged"); + Method after = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged"); before.setAccessible(true); after.setAccessible(true); before.invoke(mQueryTextView); diff --git a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SuggestionsAdapter.java b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SuggestionsAdapter.java index bd5cbd71..82d4f0c4 100644 --- a/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SuggestionsAdapter.java +++ b/external/JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/widget/SuggestionsAdapter.java @@ -66,6 +66,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene static final int REFINE_ALL = 2; private SearchManager mSearchManager; + private SearchableInfo mSearchable; private SearchView mSearchView; private Context mProviderContext; private WeakHashMap mOutsideDrawablesCache; @@ -94,12 +95,13 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene //private static final long DELETE_KEY_POST_DELAY = 500L; public SuggestionsAdapter(Context context, SearchView searchView, - SearchableInfo mSearchable, WeakHashMap outsideDrawablesCache) { + SearchableInfo searchable, WeakHashMap outsideDrawablesCache) { super(context, R.layout.abs__search_dropdown_item_icons_2line, null, // no initial cursor true); // auto-requery mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); + mSearchable = searchable; mProviderContext = mContext; mSearchView = searchView; @@ -199,25 +201,48 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene } public Cursor getSuggestions(String query, int limit) { + if (mSearchable == null) { + return null; + } + + String authority = mSearchable.getSuggestAuthority(); + if (authority == null) { + return null; + } + Uri.Builder uriBuilder = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) + .authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel() + // if content path provided, insert it now + final String contentPath = mSearchable.getSuggestPath(); + if (contentPath != null) { + uriBuilder.appendEncodedPath(contentPath); + } + // append standard suggestion query path uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY); + // get the query selection, may be null + String selection = mSearchable.getSuggestSelection(); // inject query, either as selection args or inline - uriBuilder.appendPath(query); + String[] selArgs = null; + if (selection != null) { // use selection if provided + selArgs = new String[] { query }; + } else { // no selection, use REST pattern + uriBuilder.appendPath(query); + } if (limit > 0) { - uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT, String.valueOf(limit)); + uriBuilder.appendQueryParameter("limit", String.valueOf(limit)); } Uri uri = uriBuilder.build(); // finally, make the query - return mContext.getContentResolver().query(uri, null, null, null, null); + return mContext.getContentResolver().query(uri, null, selection, selArgs, null); } public void close() {