Uses ActionBarSherlock in Gallery
bug: 6927267
Change-Id: I1c22975d1a1f3a36510ad93e6a0cefea110ca38f
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
index 03181ca..c726719 100644
--- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
+++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.common;
-import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.hardware.Camera;
@@ -75,9 +74,6 @@
public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK =
Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU =
- hasMethod(Activity.class, "invalidateOptionsMenu");
-
public static final boolean HAS_REMOTE_VIEWS_SERVICE =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
@@ -130,9 +126,6 @@
public static final boolean HAS_MOTION_EVENT_TRANSFORM =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
- public static final boolean HAS_SHARE_ACTION_PROVIDER =
- Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
-
public static final boolean HAS_EFFECTS_RECORDING = false;
public static final boolean HAS_GET_SUPPORTED_VIDEO_SIZE =
@@ -141,21 +134,12 @@
public static final boolean HAS_SET_ICON_ATTRIBUTE =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
- public static final boolean HAS_ACTION_BAR_SET_LOGO =
- Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
-
- public static final boolean HAS_ACTION_BAR_SET_HOME_BUTTON_ENABLED =
- Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
-
public static final boolean HAS_MEDIA_PROVIDER_FILES_TABLE =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
public static final boolean HAS_SURFACE_TEXTURE_RECORDING =
Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_MENU_ITEM_SHOW_AS_ACTION =
- Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
-
public static final boolean HAS_ACTION_BAR =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
diff --git a/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java b/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java
index 9e327aa..18b7a88 100644
--- a/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java
+++ b/gallerycommon/src/com/android/gallery3d/common/HttpClientFactory.java
@@ -121,7 +121,7 @@
Build.DEVICE,
Build.MODEL,
Build.ID,
- Build.VERSION.SDK,
+ Build.VERSION.SDK_INT,
Build.VERSION.RELEASE,
Build.VERSION.INCREMENTAL);
}
diff --git a/gallerycommon/src/com/android/gallery3d/common/Utils.java b/gallerycommon/src/com/android/gallery3d/common/Utils.java
index 391b225..f5a2667 100644
--- a/gallerycommon/src/com/android/gallery3d/common/Utils.java
+++ b/gallerycommon/src/com/android/gallery3d/common/Utils.java
@@ -310,7 +310,7 @@
Build.DEVICE,
Build.MODEL,
Build.ID,
- Build.VERSION.SDK,
+ Build.VERSION.SDK_INT,
Build.VERSION.RELEASE,
Build.VERSION.INCREMENTAL);
}
diff --git a/src/com/android/gallery3d/actionbar/ActionBarInterface.java b/src/com/android/gallery3d/actionbar/ActionBarInterface.java
deleted file mode 100644
index db73248..0000000
--- a/src/com/android/gallery3d/actionbar/ActionBarInterface.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.view.Menu;
-import android.widget.SpinnerAdapter;
-
-public interface ActionBarInterface extends MenuHolder {
- // These values are copied from android.app.ActionBar
- public static final int NAVIGATION_MODE_LIST = 1;
- public static final int NAVIGATION_MODE_STANDARD = 0;
-
- // These values are copied from android.app.ActionBar
- public static final int DISPLAY_HOME_AS_UP = 4;
- public static final int DISPLAY_SHOW_TITLE = 8;
-
- public static interface OnNavigationListener {
- public boolean onNavigationItemSelected(int itemPosition, long itemId);
- }
-
- public static interface OnMenuVisibilityListener {
- public void onMenuVisibilityChanged(boolean isVisible);
- }
-
- public int getHeight();
-
- public void setListNavigationCallbacks(
- SpinnerAdapter adapter, OnNavigationListener listener);
- public void setNavigationMode(int mode);
- public void setSelectedNavigationItem(int index);
-
- public void addOnMenuVisibilityListener(OnMenuVisibilityListener l);
- public void removeOnMenuVisibilityListener(OnMenuVisibilityListener l);
-
- public void setDisplayOptions(int options, int mask);
- public void setHomeButtonEnabled(boolean enabled);
- public void setTitle(String title);
- public void setSubtitle(String subtitle);
- public void show();
- public void hide();
-
- public void setShareIntent(Intent intent);
-
- public void setLogo(Drawable logo);
-
- public boolean createActionMenu(Menu menu, int menuResId);
- public boolean hasShareMenuItem();
-}
diff --git a/src/com/android/gallery3d/actionbar/ActionBarUtils.java b/src/com/android/gallery3d/actionbar/ActionBarUtils.java
deleted file mode 100644
index 4df8d5c..0000000
--- a/src/com/android/gallery3d/actionbar/ActionBarUtils.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.app.Activity;
-
-import com.android.gallery3d.common.ApiHelper;
-
-public class ActionBarUtils {
-
- public static ActionBarInterface getActionBar(Activity activity) {
- if (ApiHelper.HAS_ACTION_BAR) {
- if (activity.getActionBar() == null) return null;
- return new SystemActionBarWrapper(activity);
- } else {
- return new SimpleActionBar(activity);
- }
- }
-
- public static ActionModeInterface startActionMode(
- Activity activity, ActionModeInterface.Callback callback) {
- return ApiHelper.HAS_ACTION_BAR
- ? new SystemActionModeWrapper(activity, callback)
- : new SimpleActionMode();
- }
-}
diff --git a/src/com/android/gallery3d/actionbar/ActionModeInterface.java b/src/com/android/gallery3d/actionbar/ActionModeInterface.java
deleted file mode 100644
index 32cf815..0000000
--- a/src/com/android/gallery3d/actionbar/ActionModeInterface.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.content.Intent;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
-public interface ActionModeInterface extends MenuHolder {
-
- public static interface Callback {
-
- public boolean onCreateActionMode(ActionModeInterface mode, Menu menu);
-
- public void onDestroyActionMode(ActionModeInterface mode);
-
- public boolean onActionItemClicked(ActionModeInterface mode, MenuItem item);
- }
-
- public static interface OnShareTargetSelectedListener {
- public boolean onShareTargetSelected(Intent shareIntent);
- }
-
- public void inflateMenu(int operation);
- public void setCustomView(View view);
- public void finish();
-
- public void setShareIntent(Intent intent);
- public boolean hasShareButton();
- public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener);
-}
diff --git a/src/com/android/gallery3d/actionbar/MenuHolder.java b/src/com/android/gallery3d/actionbar/MenuHolder.java
deleted file mode 100644
index 2001d08..0000000
--- a/src/com/android/gallery3d/actionbar/MenuHolder.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.content.Intent;
-
-public interface MenuHolder {
- public void setMenuItemVisible(int menuItemId, boolean visible);
- public void setMenuItemTitle(int menuItemId, String title);
- public void setMenuItemIntent(int menuItemId, Intent intent);
-}
diff --git a/src/com/android/gallery3d/actionbar/SimpleActionBar.java b/src/com/android/gallery3d/actionbar/SimpleActionBar.java
deleted file mode 100644
index 8d709a9..0000000
--- a/src/com/android/gallery3d/actionbar/SimpleActionBar.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.view.Menu;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.FrameLayout;
-import android.widget.SpinnerAdapter;
-
-import com.android.gallery3d.R;
-
-public class SimpleActionBar implements ActionBarInterface {
- private final FrameLayout mHeaderView;
- private final SimpleActionBarView mActionBar;
- private final SimpleMenu mOptionsMenu = new SimpleMenu();
- private final Context mContext;
-
- public SimpleActionBar(Activity activity) {
- mContext = activity;
- mHeaderView = (FrameLayout) activity.findViewById(R.id.header);
- mActionBar = new SimpleActionBarView(activity, null);
-
- if (mHeaderView != null) {
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-
- // Unhide the next line to show the menu button
- // mHeaderView.setVisibility(View.VISIBLE);
- mHeaderView.addView(mActionBar, params);
- }
- }
-
- @Override
- public void setMenuItemVisible(int menuItemId, boolean visible) {
- mOptionsMenu.setMenuItemVisible(menuItemId, visible);
- }
-
- @Override
- public void setMenuItemTitle(int menuItemId, String title) {
- mOptionsMenu.setMenuItemTitle(menuItemId, title);
- }
-
- @Override
- public void setMenuItemIntent(int menuItemId, Intent intent) {
- mOptionsMenu.setMenuItemIntent(menuItemId, intent);
- }
-
- @Override
- public int getHeight() {
- return mActionBar.getHeight();
- }
-
- @Override
- public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener listener) {
- }
-
- @Override
- public void setNavigationMode(int mode) {
- }
-
- @Override
- public void setSelectedNavigationItem(int index) {
- }
-
- @Override
- public void addOnMenuVisibilityListener(OnMenuVisibilityListener l) {
- }
-
- @Override
- public void removeOnMenuVisibilityListener(OnMenuVisibilityListener l) {
- }
-
- @Override
- public void setDisplayOptions(int options, int mask) {
- }
-
- @Override
- public void setHomeButtonEnabled(boolean enabled) {
- }
-
- @Override
- public void setTitle(String title) {
- }
-
- @Override
- public void setSubtitle(String subtitle) {
- }
-
- @Override
- public void show() {
- }
-
- @Override
- public void hide() {
- }
-
- @Override
- public void setShareIntent(Intent intent) {
- }
-
- @Override
- public void setLogo(Drawable logo) {
- }
-
- @Override
- public boolean createActionMenu(Menu menu, int menuResId) {
- SimpleMenuInflater inflater = new SimpleMenuInflater(mContext);
- mOptionsMenu.clear();
- inflater.inflate(mOptionsMenu, menuResId);
- mActionBar.setOptionsMenu(mOptionsMenu);
- return false;
- }
-
- @Override
- public boolean hasShareMenuItem() {
- return false;
- }
-}
diff --git a/src/com/android/gallery3d/actionbar/SimpleActionBarView.java b/src/com/android/gallery3d/actionbar/SimpleActionBarView.java
deleted file mode 100644
index 94ba56b..0000000
--- a/src/com/android/gallery3d/actionbar/SimpleActionBarView.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Button;
-import android.widget.LinearLayout;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.ui.PopupList;
-
-
-public class SimpleActionBarView extends LinearLayout {
-
- private PopupList mPopupList;
-
- public SimpleActionBarView(Context context, AttributeSet attrs) {
- super(context, attrs);
- LayoutInflater.from(context).inflate(R.layout.simple_action_bar, this);
- Button button = (Button) findViewById(R.id.menu_button);
- button.setText("Menu");
- mPopupList = new PopupList(context, button);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- mPopupList.show();
- }
- });
- }
-
- public void setOptionsMenu(SimpleMenu menu) {
- mPopupList.clearItems();
- for (int i = 0, n = menu.getItemCount(); i < n; ++i) {
- SimpleMenu.Item item = menu.getItem(i);
- mPopupList.addItem(item.id, item.title);
- }
- }
-}
diff --git a/src/com/android/gallery3d/actionbar/SimpleActionMode.java b/src/com/android/gallery3d/actionbar/SimpleActionMode.java
deleted file mode 100644
index 33733d1..0000000
--- a/src/com/android/gallery3d/actionbar/SimpleActionMode.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.android.gallery3d.actionbar;
-
-import android.content.Intent;
-import android.view.View;
-
-public class SimpleActionMode implements ActionModeInterface {
-
- @Override
- public void setMenuItemVisible(int menuItemId, boolean visible) {
- }
-
- @Override
- public void setMenuItemTitle(int menuItemId, String title) {
- }
-
- @Override
- public void setMenuItemIntent(int menuItemId, Intent intent) {
- }
-
- @Override
- public void inflateMenu(int operation) {
- }
-
- @Override
- public void setCustomView(View view) {
- }
-
- @Override
- public void finish() {
- }
-
- @Override
- public void setShareIntent(Intent intent) {
- }
-
- @Override
- public boolean hasShareButton() {
- return false;
- }
-
- @Override
- public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) {
- }
-}
diff --git a/src/com/android/gallery3d/actionbar/SimpleMenu.java b/src/com/android/gallery3d/actionbar/SimpleMenu.java
deleted file mode 100644
index 8bc5580..0000000
--- a/src/com/android/gallery3d/actionbar/SimpleMenu.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.content.Intent;
-
-import java.util.ArrayList;
-
-public class SimpleMenu implements MenuHolder {
- // These values are copied from MenuItem in HoneyComb
- private static final int SHOW_AS_ACTION_NEVER = 0;
- private static final int SHOW_AS_ACTION_ALWAYS = 1;
- private static final int SHOW_AS_ACTION_IFROOM = 2;
- private static final int SHOW_AS_ACTION_WITH_TEXT = 4;
-
- // A bit mask to get WHEN to show as action. It is one of the following
- // values: SHOW_AS_ACTION_NEVER, SHOW_AS_ACTION_ALWAYS, or
- // SHOW_AS_ACTION_IFROOM.
- private static final int SHOW_AS_ACTION_MASK = 0x03;
-
- public static class Item {
- public int id;
- public int iconId;
- public String title;
- public boolean visible;
- public int showAsAction;
- public Intent intent;
- }
-
- private ArrayList<Item> mItems = new ArrayList<Item>();
-
- public void clear() {
- mItems.clear();
- }
-
- public void addItem(Item item) {
- mItems.add(item);
- }
-
- @Override
- public void setMenuItemVisible(int menuItemId, boolean visible) {
- Item item = findItem(menuItemId);
- if (item != null) item.visible = visible;
- }
-
- public int getItemCount() {
- return mItems.size();
- }
-
- public Item getItem(int index) {
- return mItems.get(index);
- }
-
- public Item findItem(int menuItemId) {
- for (int i = 0, n = mItems.size(); i < n; ++i) {
- Item item = mItems.get(i);
- if (item.id == menuItemId) return item;
- }
- return null;
- }
-
- @Override
- public void setMenuItemTitle(int menuItemId, String title) {
- Item item = findItem(menuItemId);
- if (item != null) item.title = title;
- }
-
- @Override
- public void setMenuItemIntent(int menuItemId, Intent intent) {
- Item item = findItem(menuItemId);
- if (item != null) item.intent = intent;
- }
-}
diff --git a/src/com/android/gallery3d/actionbar/SimpleMenuInflater.java b/src/com/android/gallery3d/actionbar/SimpleMenuInflater.java
deleted file mode 100644
index 885a4d3..0000000
--- a/src/com/android/gallery3d/actionbar/SimpleMenuInflater.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.XmlResourceParser;
-import android.util.AttributeSet;
-import android.util.Xml;
-import android.view.InflateException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-
-public class SimpleMenuInflater {
-
- private static final String TAG_MENU = "menu";
- private static final String TAG_ITEM = "item";
-
- private final Context mContext;
-
- public SimpleMenuInflater(Context context) {
- mContext = context;
- }
-
- public SimpleMenu inflate(SimpleMenu menu, int menuRes) throws InflateException {
- XmlResourceParser parser = mContext.getResources().getXml(menuRes);
- try {
- return inflateInternal(menu, parser);
- } catch (XmlPullParserException e) {
- throw new InflateException(e);
- } catch (IOException e) {
- throw new InflateException(e);
- } finally {
- if (parser != null) parser.close();
- }
- }
-
- private SimpleMenu inflateInternal(SimpleMenu menu, XmlPullParser parser)
- throws XmlPullParserException, IOException {
- int eventType = parser.getEventType();
- do {
- if (eventType == XmlPullParser.START_TAG) {
- String tagName = parser.getName();
- if (TAG_MENU.equals(tagName)) {
- eventType = parser.next();
- break;
- }
- throw new RuntimeException("unexpected tag: " + tagName);
- }
- eventType = parser.next();
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- if (menu == null) menu = new SimpleMenu();
- AttributeSet attrs = Xml.asAttributeSet(parser);
-
- boolean reachedEndOfMenu = false;
- while (!reachedEndOfMenu) {
- switch (eventType) {
- case XmlPullParser.START_TAG: {
- String tagName = parser.getName();
- if (TAG_ITEM.equals(tagName)) {
- menu.addItem(parseItem(attrs));
- } else if (TAG_MENU.equals(tagName)) {
- throw new RuntimeException("nested menu not supported");
- } else {
- // ignore all other tags
- parser.next();
- }
- break;
- }
- case XmlPullParser.END_TAG: {
- String tagName = parser.getName();
- if (TAG_MENU.equals(tagName)) {
- reachedEndOfMenu = true;
- break;
- }
- break;
- }
- case XmlPullParser.END_DOCUMENT: {
- throw new RuntimeException("unexpected end of document");
- }
- }
- eventType = parser.next();
- }
- return menu;
- }
-
- private static final String ATTR_ID = "id";
- private static final String ATTR_ICON = "icon";
- private static final String ATTR_TITLE = "title";
- private static final String ATTR_VISIBLE = "visible";
- private static final String ATTR_SHOW_AS_ACTION = "showAsAction";
-
- private SimpleMenu.Item parseItem(AttributeSet attrs) {
- SimpleMenu.Item item = new SimpleMenu.Item();
- Resources res = mContext.getResources();
- for (int i = 0, n = attrs.getAttributeCount(); i < n; ++i) {
- String attrName = attrs.getAttributeName(i);
- if (ATTR_ID.equals(attrName)) {
- item.id = attrs.getAttributeResourceValue(i, 0);
- } else if (ATTR_ICON.equals(attrName)) {
- item.iconId = attrs.getAttributeResourceValue(i, 0);
- } else if (ATTR_TITLE.equals(attrName)) {
- int id = attrs.getAttributeResourceValue(i, 0);
- item.title = id == 0 ? null : res.getString(id);
- } else if (ATTR_VISIBLE.equals(attrName)) {
- item.visible = attrs.getAttributeBooleanValue(i, true);
- } else if (ATTR_SHOW_AS_ACTION.equals(attrName)) {
- item.showAsAction = attrs.getAttributeIntValue(i, 0);
- }
- }
- return item;
- }
-
-}
diff --git a/src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java b/src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java
deleted file mode 100644
index 2d70aa6..0000000
--- a/src/com/android/gallery3d/actionbar/SystemActionBarWrapper.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.annotation.TargetApi;
-import android.app.ActionBar;
-import android.app.Activity;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.ShareActionProvider;
-import android.widget.SpinnerAdapter;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.util.Holder;
-
-import java.util.HashMap;
-
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
-public class SystemActionBarWrapper implements ActionBarInterface {
- private final ActionBar mActionBar;
- private final Activity mActivity;
- private final HashMap<Integer, Object> mListenerMap = new HashMap<Integer, Object>();
-
- private Menu mMenu;
- private MenuItem mShareMenuItem;
- private Holder<ShareActionProvider> mShareActionProvider = new Holder<ShareActionProvider>();
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public SystemActionBarWrapper(Activity activity) {
- mActivity = activity;
- mActionBar = activity.getActionBar();
- if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- mShareActionProvider.set(new ShareActionProvider(activity));
- }
- }
-
- @Override
- public int getHeight() {
- return mActionBar.getHeight();
- }
-
- @Override
- public void setListNavigationCallbacks(
- SpinnerAdapter adapter, final OnNavigationListener listener) {
- mActionBar.setListNavigationCallbacks(adapter, new ActionBar.OnNavigationListener() {
- @Override
- public boolean onNavigationItemSelected(int itemPosition, long itemId) {
- return listener.onNavigationItemSelected(itemPosition, itemId);
- }
- });
- }
-
- @Override
- public void setNavigationMode(int mode) {
- mActionBar.setNavigationMode(mode);
- }
-
- @Override
- public void setSelectedNavigationItem(int index) {
- mActionBar.setSelectedNavigationItem(index);
- }
-
- @Override
- public void addOnMenuVisibilityListener(final OnMenuVisibilityListener l) {
- ActionBar.OnMenuVisibilityListener wrapper =
- new ActionBar.OnMenuVisibilityListener() {
- @Override
- public void onMenuVisibilityChanged(boolean isVisible) {
- l.onMenuVisibilityChanged(isVisible);
- }
- };
- Utils.assertTrue(mListenerMap.put(System.identityHashCode(l), wrapper) == null);
- mActionBar.addOnMenuVisibilityListener(wrapper);
- }
-
- @Override
- public void removeOnMenuVisibilityListener(OnMenuVisibilityListener l) {
- ActionBar.OnMenuVisibilityListener wrapper = (ActionBar.OnMenuVisibilityListener)
- mListenerMap.remove(System.identityHashCode(l));
- if (wrapper != null) mActionBar.removeOnMenuVisibilityListener(wrapper);
- }
-
- @Override
- public void setDisplayOptions(int options, int mask) {
- mActionBar.setDisplayOptions(options, mask);
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void setHomeButtonEnabled(boolean enabled) {
- if (ApiHelper.HAS_ACTION_BAR_SET_HOME_BUTTON_ENABLED) {
- mActionBar.setHomeButtonEnabled(enabled);
- }
- }
-
- @Override
- public void setTitle(String title) {
- mActionBar.setTitle(title);
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void setLogo(Drawable logo) {
- if (ApiHelper.HAS_ACTION_BAR_SET_LOGO) {
- mActionBar.setLogo(logo);
- }
- }
-
- @Override
- public void setSubtitle(String subtitle) {
- mActionBar.setSubtitle(subtitle);
- }
-
- @Override
- public void show() {
- mActionBar.show();
- }
-
- @Override
- public void hide() {
- mActionBar.hide();
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void setShareIntent(Intent intent) {
- if (mShareMenuItem != null) {
- mShareMenuItem.setEnabled(intent != null);
- if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- mShareActionProvider.get().setShareIntent(intent);
- }
- }
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public boolean createActionMenu(Menu menu, int menuRes) {
- mActivity.getMenuInflater().inflate(menuRes, menu);
- mMenu = menu;
- mShareMenuItem = menu.findItem(R.id.action_share);
- if (mShareMenuItem != null && ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- mShareMenuItem.setActionProvider(mShareActionProvider.get());
- }
- return true;
- }
-
- @Override
- public boolean hasShareMenuItem() {
- return mShareMenuItem != null;
- }
-
- @Override
- public void setMenuItemVisible(int menuItemId, boolean visible) {
- if (mMenu == null) return;
- MenuItem item = mMenu.findItem(menuItemId);
- if (item != null) item.setVisible(visible);
- }
-
- @Override
- public void setMenuItemTitle(int menuItemId, String title) {
- if (mMenu == null) return;
- MenuItem item = mMenu.findItem(menuItemId);
- if (item != null) item.setTitle(title);
- }
-
- @Override
- public void setMenuItemIntent(int menuItemId, Intent intent) {
- if (mMenu == null) return;
- MenuItem item = mMenu.findItem(menuItemId);
- if (item != null) item.setIntent(intent);
- }
-}
\ No newline at end of file
diff --git a/src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java b/src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java
deleted file mode 100644
index 202a585..0000000
--- a/src/com/android/gallery3d/actionbar/SystemActionModeWrapper.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.actionbar;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Intent;
-import android.view.ActionMode;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.ShareActionProvider;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.util.Holder;
-
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
-public class SystemActionModeWrapper implements ActionModeInterface {
- private ActionMode mActionMode;
- private Menu mMenu;
- private MenuItem mShareMenuItem;
- private Holder<ShareActionProvider> mShareActionProvider = new Holder<ShareActionProvider>();
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public SystemActionModeWrapper(Activity activity, ActionModeInterface.Callback callback) {
- if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- mShareActionProvider.set(new ShareActionProvider(activity));
- }
- // mActionMode will be set in callback.onCreateActionMode
- activity.startActionMode(new CallbackWrapper(callback));
- }
-
- private class CallbackWrapper implements ActionMode.Callback {
- ActionModeInterface.Callback mActual;
-
- public CallbackWrapper(Callback callback) {
- mActual = callback;
- }
-
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- mMenu = menu;
- mActionMode = mode;
- return mActual.onCreateActionMode(SystemActionModeWrapper.this, menu);
- }
-
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- // return true to turn on the system action mode
- return true;
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- return mActual.onActionItemClicked(SystemActionModeWrapper.this, item);
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {
- mActual.onDestroyActionMode(SystemActionModeWrapper.this);
- }
- }
-
- @Override
- public void setCustomView(View view) {
- mActionMode.setCustomView(view);
- }
-
- @Override
- public void finish() {
- mActionMode.finish();
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void inflateMenu(int menuRes) {
- Utils.assertTrue(mMenu != null);
- mActionMode.getMenuInflater().inflate(menuRes, mMenu);
- mShareMenuItem = mMenu.findItem(R.id.action_share);
- if (mShareMenuItem != null && ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- mShareMenuItem.setActionProvider(mShareActionProvider.get());
- }
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void setShareIntent(Intent shareIntent) {
- if (mShareMenuItem != null) {
- mShareMenuItem.setEnabled(shareIntent != null);
- if (ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- mShareActionProvider.get().setShareIntent(shareIntent);
- }
- }
- }
-
- @Override
- public boolean hasShareButton() {
- return mShareMenuItem != null;
- }
-
- @Override
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void setOnShareTargetSelectedListener(final OnShareTargetSelectedListener listener) {
- if (mShareActionProvider.get() == null) return;
-
- mShareActionProvider.get().setOnShareTargetSelectedListener(
- new ShareActionProvider.OnShareTargetSelectedListener() {
- @Override
- public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
- return listener.onShareTargetSelected(intent);
- }
- });
- }
-
- @Override
- public void setMenuItemVisible(int menuItemId, boolean visible) {
- MenuItem item = mMenu.findItem(menuItemId);
- if (item != null) item.setVisible(visible);
- }
-
- @Override
- public void setMenuItemTitle(int menuItemId, String title) {
- MenuItem item = mMenu.findItem(menuItemId);
- if (item != null) item.setTitle(title);
- }
-
- @Override
- public void setMenuItemIntent(int menuItemId, Intent intent) {
- MenuItem item = mMenu.findItem(menuItemId);
- if (item != null) item.setIntent(intent);
- }
-}
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
index 6b0b106..b11db39 100644
--- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java
+++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
@@ -17,7 +17,6 @@
package com.android.gallery3d.app;
import android.annotation.TargetApi;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -28,11 +27,12 @@
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.BitmapPool;
@@ -42,7 +42,7 @@
import com.android.gallery3d.ui.GLRootView;
import com.android.gallery3d.util.ThreadPool;
-public class AbstractGalleryActivity extends Activity implements GalleryActivity {
+public class AbstractGalleryActivity extends SherlockActivity implements GalleryContext {
@SuppressWarnings("unused")
private static final String TAG = "AbstractGalleryActivity";
private GLRootView mGLRootView;
@@ -88,27 +88,13 @@
toggleStatusBarByOrientation();
}
- private Menu mOptionsMenu;
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- mOptionsMenu = menu;
super.onCreateOptionsMenu(menu);
return getStateManager().createOptionsMenu(menu);
}
@Override
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- public void invalidateOptionsMenu() {
- if (ApiHelper.HAS_ACTIVITY_INVALIDATE_OPTIONS_MENU) {
- super.invalidateOptionsMenu();
- } else if (mOptionsMenu != null) {
- mOptionsMenu.clear();
- getStateManager().createOptionsMenu(mOptionsMenu);
- }
- }
-
- @Override
public Context getAndroidContext() {
return this;
}
@@ -123,7 +109,6 @@
return ((GalleryApp) getApplication()).getThreadPool();
}
- @Override
public synchronized StateManager getStateManager() {
if (mStateManager == null) {
mStateManager = new StateManager(this);
@@ -131,12 +116,10 @@
return mStateManager;
}
- @Override
public GLRoot getGLRoot() {
return mGLRootView;
}
- @Override
public OrientationManager getOrientationManager() {
return mOrientationManager;
}
@@ -272,7 +255,6 @@
}
}
- @Override
public GalleryActionBar getGalleryActionBar() {
if (mActionBar == null) {
mActionBar = new GalleryActionBar(this);
@@ -307,7 +289,6 @@
}
}
- @Override
public TransitionStore getTransitionStore() {
return mTransitionStore;
}
diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java
index a86351b..aef1ee1 100644
--- a/src/com/android/gallery3d/app/ActivityState.java
+++ b/src/com/android/gallery3d/app/ActivityState.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.app;
-import android.app.ActionBar;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -28,14 +27,15 @@
import android.os.Bundle;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.ActionBarInterface;
-import com.android.gallery3d.actionbar.ActionBarUtils;
import com.android.gallery3d.ui.GLView;
import com.android.gallery3d.util.GalleryUtils;
@@ -51,7 +51,7 @@
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
);
- protected GalleryActivity mActivity;
+ protected AbstractGalleryActivity mActivity;
protected Bundle mData;
protected int mFlags;
@@ -78,7 +78,7 @@
mActivity.getGLRoot().setContentPane(content);
}
- void initialize(GalleryActivity activity, Bundle data) {
+ void initialize(AbstractGalleryActivity activity, Bundle data) {
mActivity = activity;
mData = data;
mContentResolver = activity.getAndroidContext().getContentResolver();
@@ -160,8 +160,8 @@
// should only be called by StateManager
void resume() {
- AbstractGalleryActivity activity = (AbstractGalleryActivity) mActivity;
- ActionBarInterface actionBar = ActionBarUtils.getActionBar(activity);
+ AbstractGalleryActivity activity = mActivity;
+ ActionBar actionBar = ((SherlockActivity) activity).getSupportActionBar();
if (actionBar != null) {
if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
actionBar.hide();
@@ -232,4 +232,8 @@
public boolean isFinishing() {
return mIsFinishing;
}
+
+ protected MenuInflater getSupportMenuInflater() {
+ return ((SherlockActivity) mActivity).getSupportMenuInflater();
+ }
}
diff --git a/src/com/android/gallery3d/app/AlbumDataLoader.java b/src/com/android/gallery3d/app/AlbumDataLoader.java
index 8e6fcf5..ff95052 100644
--- a/src/com/android/gallery3d/app/AlbumDataLoader.java
+++ b/src/com/android/gallery3d/app/AlbumDataLoader.java
@@ -74,7 +74,7 @@
private ReloadTask mReloadTask;
- public AlbumDataLoader(GalleryActivity context, MediaSet mediaSet) {
+ public AlbumDataLoader(AbstractGalleryActivity context, MediaSet mediaSet) {
mSource = mediaSet;
mData = new MediaItem[DATA_CACHE_SIZE];
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index e44dae1..5328678 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -26,10 +26,11 @@
import android.os.Message;
import android.os.Vibrator;
import android.provider.MediaStore;
-import android.view.Menu;
-import android.view.MenuItem;
import android.widget.Toast;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
@@ -310,7 +311,7 @@
private void onGetContent(final MediaItem item) {
DataManager dm = mActivity.getDataManager();
- Activity activity = (Activity) mActivity;
+ Activity activity = mActivity;
if (mData.getString(Gallery.EXTRA_CROP) != null) {
// TODO: Handle MtpImagew
Uri uri = dm.getContentUri(item.getPath());
@@ -456,7 +457,7 @@
private void initializeViews() {
mSelectionManager = new SelectionManager(mActivity, false);
mSelectionManager.setSelectionListener(this);
- Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity);
+ Config.AlbumPage config = Config.AlbumPage.get(mActivity);
mSlotView = new SlotView(mActivity, config.slotViewSpec);
mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView,
mSelectionManager, config.placeholderColor);
@@ -529,30 +530,29 @@
@Override
protected boolean onCreateActionBar(Menu menu) {
GalleryActionBar actionBar = mActivity.getGalleryActionBar();
- boolean result;
+ MenuInflater inflator = getSupportMenuInflater();
if (mGetContent) {
- result = actionBar.createActionMenu(menu, R.menu.pickup);
+ inflator.inflate(R.menu.pickup, menu);
int typeBits = mData.getInt(Gallery.KEY_TYPE_BITS,
DataManager.INCLUDE_IMAGE);
-
actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else {
- result = actionBar.createActionMenu(menu, R.menu.album);
+ inflator.inflate(R.menu.album, menu);
actionBar.setTitle(mMediaSet.getName());
- actionBar.setMenuItemVisible(
- R.id.action_slideshow, !(mMediaSet instanceof MtpDevice));
+
+ menu.findItem(R.id.action_slideshow)
+ .setVisible(!(mMediaSet instanceof MtpDevice));
FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true);
- actionBar.setMenuItemVisible(R.id.action_group_by, mShowClusterMenu);
- actionBar.setMenuItemVisible(R.id.action_camera,
- MediaSetUtils.isCameraSource(mMediaSetPath)
- && GalleryUtils.isCameraAvailable((Activity) mActivity));
- actionBar.setTitle(mMediaSet.getName());
+ menu.findItem(R.id.action_group_by).setVisible(mShowClusterMenu);
+ menu.findItem(R.id.action_camera).setVisible(
+ MediaSetUtils.isCameraSource(mMediaSetPath)
+ && GalleryUtils.isCameraAvailable(mActivity));
+
}
actionBar.setSubtitle(null);
-
- return result;
+ return true;
}
@Override
@@ -591,7 +591,7 @@
return true;
}
case R.id.action_camera: {
- GalleryUtils.startCameraActivity((Activity) mActivity);
+ GalleryUtils.startCameraActivity(mActivity);
return true;
}
default:
@@ -669,7 +669,7 @@
if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive
&& (mAlbumDataAdapter.size() == 0)) {
// show error toast only if the album is empty
- Toast.makeText((Context) mActivity, R.string.sync_album_error,
+ Toast.makeText(mActivity, R.string.sync_album_error,
Toast.LENGTH_LONG).show();
}
} finally {
@@ -687,7 +687,7 @@
mLoadingBits &= ~loadTaskBit;
if (mLoadingBits == 0 && mIsActive) {
if (mAlbumDataAdapter.size() == 0) {
- Toast.makeText((Context) mActivity,
+ Toast.makeText(mActivity,
R.string.empty_album, Toast.LENGTH_LONG).show();
mActivity.getStateManager().finishState(AlbumPage.this);
}
diff --git a/src/com/android/gallery3d/app/AlbumSetDataLoader.java b/src/com/android/gallery3d/app/AlbumSetDataLoader.java
index 9613f99..80bc48a 100644
--- a/src/com/android/gallery3d/app/AlbumSetDataLoader.java
+++ b/src/com/android/gallery3d/app/AlbumSetDataLoader.java
@@ -76,7 +76,7 @@
private final MySourceListener mSourceListener = new MySourceListener();
- public AlbumSetDataLoader(GalleryActivity activity, MediaSet albumSet, int cacheSize) {
+ public AlbumSetDataLoader(AbstractGalleryActivity activity, MediaSet albumSet, int cacheSize) {
mSource = Utils.checkNotNull(albumSet);
mCoverItem = new MediaItem[cacheSize];
mData = new MediaSet[cacheSize];
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index a5a2481..a3d7dc4 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -24,15 +24,15 @@
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
-import android.view.Menu;
-import android.view.MenuItem;
import android.widget.Toast;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaDetails;
-import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
@@ -211,7 +211,7 @@
getSlotCenter(slotIndex, center);
data.putIntArray(AlbumPage.KEY_SET_CENTER, center);
if (mGetAlbum && targetSet.isLeafAlbum()) {
- Activity activity = (Activity) mActivity;
+ Activity activity = mActivity;
Intent result = new Intent()
.putExtra(AlbumPicker.KEY_ALBUM_PATH, targetSet.getPath().toString());
activity.setResult(Activity.RESULT_OK, result);
@@ -303,7 +303,7 @@
// the page. Toast is redundant if we are going to stay on this page.
if ((mAlbumSetDataAdapter.size() == 0)) {
if (mActivity.getStateManager().getStateCount() > 1) {
- Toast.makeText((Context) mActivity,
+ Toast.makeText(mActivity,
R.string.empty_album, Toast.LENGTH_LONG).show();
mActivity.getStateManager().finishState(this);
}
@@ -371,7 +371,7 @@
mSelectionManager = new SelectionManager(mActivity, true);
mSelectionManager.setSelectionListener(this);
- mConfig = Config.AlbumSetPage.get((Context) mActivity);
+ mConfig = Config.AlbumSetPage.get(mActivity);
mSlotView = new SlotView(mActivity, mConfig.slotViewSpec);
mAlbumSetView = new AlbumSetSlotRenderer(
mActivity, mSelectionManager, mSlotView, mConfig.labelSpec,
@@ -411,46 +411,47 @@
@Override
protected boolean onCreateActionBar(Menu menu) {
- Activity activity = (Activity) mActivity;
+ Activity activity = mActivity;
final boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class);
- boolean result;
+ MenuInflater inflater = getSupportMenuInflater();
+
if (mGetContent) {
- result = mActionBar.createActionMenu(menu, R.menu.pickup);
+ inflater.inflate(R.menu.pickup, menu);
int typeBits = mData.getInt(
Gallery.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE);
mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else if (mGetAlbum) {
- result = mActionBar.createActionMenu(menu, R.menu.pickup);
+ inflater.inflate(R.menu.pickup, menu);
mActionBar.setTitle(R.string.select_album);
} else {
- result = mActionBar.createActionMenu(menu, R.menu.albumset);
+ inflater.inflate(R.menu.albumset, menu);
mShowClusterMenu = !inAlbum;
boolean selectAlbums = !inAlbum &&
mActionBar.getClusterTypeAction() == FilterUtils.CLUSTER_BY_ALBUM;
- mActionBar.setMenuItemTitle(R.id.action_select, activity.getString(
+ MenuItem selectItem = menu.findItem(R.id.action_select);
+ selectItem.setTitle(activity.getString(
selectAlbums ? R.string.select_album : R.string.select_group));
+ MenuItem cameraItem = menu.findItem(R.id.action_camera);
+ cameraItem.setVisible(GalleryUtils.isCameraAvailable(activity));
+
FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false);
- mActionBar.setMenuItemVisible(
- R.id.action_camera, GalleryUtils.isCameraAvailable(activity));
-
Intent helpIntent = HelpUtils.getHelpIntent(activity, R.string.help_url_gallery_main);
- if (helpIntent == null) {
- mActionBar.setMenuItemVisible(R.id.action_general_help, false);
- } else {
- mActionBar.setMenuItemVisible(R.id.action_general_help, true);
- mActionBar.setMenuItemIntent(R.id.action_general_help, helpIntent);
- }
+
+ MenuItem helpItem = menu.findItem(R.id.action_general_help);
+ helpItem.setVisible(helpIntent != null);
+ if (helpIntent != null) helpItem.setIntent(helpIntent);
+
mActionBar.setTitle(mTitle);
mActionBar.setSubtitle(mSubtitle);
}
- return result;
+ return true;
}
@Override
protected boolean onItemSelected(MenuItem item) {
- Activity activity = (Activity) mActivity;
+ Activity activity = mActivity;
switch (item.getItemId()) {
case R.id.action_cancel:
activity.setResult(Activity.RESULT_CANCELED);
diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java
index f27e181..7798e76 100644
--- a/src/com/android/gallery3d/app/CropImage.java
+++ b/src/com/android/gallery3d/app/CropImage.java
@@ -40,14 +40,13 @@
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.util.FloatMath;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.ActionBarUtils;
-import com.android.gallery3d.actionbar.ActionBarInterface;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.BitmapUtils;
import com.android.gallery3d.common.ExifTags;
@@ -163,9 +162,9 @@
mCropView = new CropView(this);
getGLRoot().setContentPane(mCropView);
- ActionBarInterface actionBar = ActionBarUtils.getActionBar(this);
- int displayOptions = ActionBarInterface.DISPLAY_HOME_AS_UP
- | ActionBarInterface.DISPLAY_SHOW_TITLE;
+ ActionBar actionBar = getSupportActionBar();
+ int displayOptions = ActionBar.DISPLAY_HOME_AS_UP
+ | ActionBar.DISPLAY_SHOW_TITLE;
actionBar.setDisplayOptions(displayOptions, displayOptions);
Bundle extra = getIntent().getExtras();
@@ -216,7 +215,7 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
- getMenuInflater().inflate(R.menu.crop, menu);
+ getSupportMenuInflater().inflate(R.menu.crop, menu);
return true;
}
diff --git a/src/com/android/gallery3d/app/FilterUtils.java b/src/com/android/gallery3d/app/FilterUtils.java
index 61a261f..bc28a9c 100644
--- a/src/com/android/gallery3d/app/FilterUtils.java
+++ b/src/com/android/gallery3d/app/FilterUtils.java
@@ -77,7 +77,7 @@
private static final int CLUSTER_CURRENT_TYPE = 4;
private static final int FILTER_CURRENT_TYPE = 5;
- public static void setupMenuItems(GalleryActionBar model, Path path, boolean inAlbum) {
+ public static void setupMenuItems(GalleryActionBar actionBar, Path path, boolean inAlbum) {
int[] result = new int[6];
getAppliedFilters(path, result);
int ctype = result[CLUSTER_TYPE];
@@ -86,31 +86,31 @@
int ccurrent = result[CLUSTER_CURRENT_TYPE];
int fcurrent = result[FILTER_CURRENT_TYPE];
- setMenuItemApplied(model, CLUSTER_BY_TIME,
+ setMenuItemApplied(actionBar, CLUSTER_BY_TIME,
(ctype & CLUSTER_BY_TIME) != 0, (ccurrent & CLUSTER_BY_TIME) != 0);
- setMenuItemApplied(model, CLUSTER_BY_LOCATION,
+ setMenuItemApplied(actionBar, CLUSTER_BY_LOCATION,
(ctype & CLUSTER_BY_LOCATION) != 0, (ccurrent & CLUSTER_BY_LOCATION) != 0);
- setMenuItemApplied(model, CLUSTER_BY_TAG,
+ setMenuItemApplied(actionBar, CLUSTER_BY_TAG,
(ctype & CLUSTER_BY_TAG) != 0, (ccurrent & CLUSTER_BY_TAG) != 0);
- setMenuItemApplied(model, CLUSTER_BY_FACE,
+ setMenuItemApplied(actionBar, CLUSTER_BY_FACE,
(ctype & CLUSTER_BY_FACE) != 0, (ccurrent & CLUSTER_BY_FACE) != 0);
- model.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0);
+ actionBar.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0);
- setMenuItemApplied(model, R.id.action_cluster_album, ctype == 0,
+ setMenuItemApplied(actionBar, R.id.action_cluster_album, ctype == 0,
ccurrent == 0);
// A filtering is available if it's not applied, and the old filtering
// (if any) is not fixed.
- setMenuItemAppliedEnabled(model, R.string.show_images_only,
+ setMenuItemAppliedEnabled(actionBar, R.string.show_images_only,
(ftype & FILTER_IMAGE_ONLY) != 0,
(ftype & FILTER_IMAGE_ONLY) == 0 && ftypef == 0,
(fcurrent & FILTER_IMAGE_ONLY) != 0);
- setMenuItemAppliedEnabled(model, R.string.show_videos_only,
+ setMenuItemAppliedEnabled(actionBar, R.string.show_videos_only,
(ftype & FILTER_VIDEO_ONLY) != 0,
(ftype & FILTER_VIDEO_ONLY) == 0 && ftypef == 0,
(fcurrent & FILTER_VIDEO_ONLY) != 0);
- setMenuItemAppliedEnabled(model, R.string.show_all,
+ setMenuItemAppliedEnabled(actionBar, R.string.show_all,
ftype == 0, ftype != 0 && ftypef == 0, fcurrent == 0);
}
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java
index 4c6a563..0f7579e 100644
--- a/src/com/android/gallery3d/app/GalleryActionBar.java
+++ b/src/com/android/gallery3d/app/GalleryActionBar.java
@@ -23,22 +23,23 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
-import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.ActionBar.OnMenuVisibilityListener;
+import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.widget.ShareActionProvider;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.ActionBarInterface;
-import com.android.gallery3d.actionbar.ActionBarInterface.OnMenuVisibilityListener;
-import com.android.gallery3d.actionbar.ActionBarUtils;
-import com.android.gallery3d.actionbar.MenuHolder;
import com.android.gallery3d.common.ApiHelper;
import java.util.ArrayList;
-public class GalleryActionBar implements ActionBarInterface.OnNavigationListener, MenuHolder {
+public class GalleryActionBar implements OnNavigationListener {
@SuppressWarnings("unused")
private static final String TAG = "GalleryActionBar";
@@ -47,8 +48,8 @@
private ArrayList<Integer> mActions;
private Context mContext;
private LayoutInflater mInflater;
- private GalleryActivity mActivity;
- private ActionBarInterface mActionBar;
+ private AbstractGalleryActivity mActivity;
+ private ActionBar mActionBar;
private int mCurrentIndex;
private ClusterAdapter mAdapter = new ClusterAdapter();
@@ -131,8 +132,8 @@
return null;
}
- public GalleryActionBar(GalleryActivity activity) {
- mActionBar = ActionBarUtils.getActionBar((Activity) activity);
+ public GalleryActionBar(AbstractGalleryActivity activity) {
+ mActionBar = activity.getSupportActionBar();
mContext = activity.getAndroidContext();
mActivity = activity;
mInflater = ((Activity) mActivity).getLayoutInflater();
@@ -183,7 +184,7 @@
// Don't set cluster runner until action bar is ready.
mClusterRunner = null;
mActionBar.setListNavigationCallbacks(mAdapter, this);
- mActionBar.setNavigationMode(ActionBarInterface.NAVIGATION_MODE_LIST);
+ mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
setSelectedAction(action);
mClusterRunner = runner;
}
@@ -196,7 +197,7 @@
if (mActionBar != null) {
mClusterRunner = null;
if (hideMenu) {
- mActionBar.setNavigationMode(ActionBarInterface.NAVIGATION_MODE_STANDARD);
+ mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
}
}
@@ -222,19 +223,17 @@
@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setHomeButtonEnabled(boolean enabled) {
- if (ApiHelper.HAS_ACTION_BAR_SET_HOME_BUTTON_ENABLED) {
- mActionBar.setHomeButtonEnabled(enabled);
- }
+ if (mActionBar != null) mActionBar.setHomeButtonEnabled(enabled);
}
public void setDisplayOptions(boolean displayHomeAsUp, boolean showTitle) {
if (mActionBar == null) return;
int options = 0;
- if (displayHomeAsUp) options |= ActionBarInterface.DISPLAY_HOME_AS_UP;
- if (showTitle) options |= ActionBarInterface.DISPLAY_SHOW_TITLE;
+ if (displayHomeAsUp) options |= ActionBar.DISPLAY_HOME_AS_UP;
+ if (showTitle) options |= ActionBar.DISPLAY_SHOW_TITLE;
mActionBar.setDisplayOptions(options,
- ActionBarInterface.DISPLAY_HOME_AS_UP | ActionBarInterface.DISPLAY_SHOW_TITLE);
+ ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
mActionBar.setHomeButtonEnabled(displayHomeAsUp);
}
@@ -297,29 +296,29 @@
return false;
}
+ private Menu mActionBarMenu;
+ private MenuItem mShareMenuItem;
+
+ public void createActionBarMenu(int menuRes, Menu menu) {
+ mActivity.getSupportMenuInflater().inflate(menuRes, menu);
+ mActionBarMenu = menu;
+ mShareMenuItem = menu.findItem(R.id.action_share);
+ }
+
+ public Menu getMenu() {
+ return mActionBarMenu;
+ }
+
public boolean hasShareMenuItem() {
- return mActionBar == null ? false : mActionBar.hasShareMenuItem();
+ return mShareMenuItem != null;
}
- public void setShareIntent(Intent intent) {
- mActionBar.setShareIntent(intent);
+ public void setShareIntent(Intent shareIntent) {
+ ((ShareActionProvider) mShareMenuItem.getActionProvider())
+ .setShareIntent(shareIntent);
}
- public boolean createActionMenu(Menu menu, int menuRes) {
- return mActionBar.createActionMenu(menu, menuRes);
- }
-
- @Override
- public void setMenuItemVisible(int menuItemId, boolean visible) {
- mActionBar.setMenuItemVisible(menuItemId, visible);
- }
-
- @Override
- public void setMenuItemTitle(int menuItemId, String title) {
- mActionBar.setMenuItemTitle(menuItemId, title);
- }
-
- public void setMenuItemIntent(int menuItemId, Intent intent) {
- mActionBar.setMenuItemIntent(menuItemId, intent);
+ public MenuItem findMenuItem(int itemId) {
+ return mActionBarMenu.findItem(itemId);
}
}
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
deleted file mode 100644
index 33c77fb..0000000
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import com.android.gallery3d.ui.GLRoot;
-
-public interface GalleryActivity extends GalleryContext {
- public StateManager getStateManager();
- public GLRoot getGLRoot();
- public GalleryActionBar getGalleryActionBar();
- public OrientationManager getOrientationManager();
- public TransitionStore getTransitionStore();
-}
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index bf24869..820bd10 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -39,9 +39,8 @@
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.widget.ShareActionProvider;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.ActionBarInterface;
-import com.android.gallery3d.actionbar.ActionBarUtils;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
@@ -129,8 +128,9 @@
mUri = intent.getData();
final ActionBar actionBar = getSupportActionBar();
setActionBarLogoFromIntent(intent);
- actionBar.setDisplayOptions(ActionBarInterface.DISPLAY_HOME_AS_UP,
- ActionBarInterface.DISPLAY_HOME_AS_UP);
+ actionBar.setDisplayOptions(
+ ActionBar.DISPLAY_HOME_AS_UP,
+ ActionBar.DISPLAY_HOME_AS_UP);
String title = intent.getStringExtra(Intent.EXTRA_TITLE);
if (title != null) {
@@ -166,17 +166,17 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
- ActionBarInterface actionBar = ActionBarUtils.getActionBar(this);
getSupportMenuInflater().inflate(R.menu.movie, menu);
// Document says EXTRA_STREAM should be a content: Uri
// So, we only share the video if it's "content:".
+ MenuItem shareItem = menu.findItem(R.id.action_share);
if (ContentResolver.SCHEME_CONTENT.equals(mUri.getScheme())) {
- if (actionBar.hasShareMenuItem()) {
- actionBar.setShareIntent(createShareIntent());
- }
+ shareItem.setVisible(true);
+ ((ShareActionProvider) shareItem.getActionProvider())
+ .setShareIntent(createShareIntent());
} else {
- menu.findItem(R.id.action_share).setVisible(false);
+ shareItem.setVisible(false);
}
return true;
}
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index b61e4f4..d565f26 100644
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -169,7 +169,7 @@
// can find the item. If mItemPath is null, then we use the mCurrentIndex to
// find the image being viewed. cameraIndex is the index of the camera
// preview. If cameraIndex < 0, there is no camera preview.
- public PhotoDataAdapter(GalleryActivity activity, PhotoView view,
+ public PhotoDataAdapter(AbstractGalleryActivity activity, PhotoView view,
MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex,
boolean isPanorama, boolean isStaticCamera) {
mSource = Utils.checkNotNull(mediaSet);
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 8b38abb..2458b9a 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -28,13 +28,13 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.animation.AccelerateInterpolator;
import android.widget.Toast;
+import com.actionbarsherlock.app.ActionBar.OnMenuVisibilityListener;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.ActionBarInterface.OnMenuVisibilityListener;
import com.android.gallery3d.anim.FloatAnimation;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
@@ -141,6 +141,8 @@
private NfcAdapter mNfcAdapter;
+ private Menu mActionBarMenu;
+
private final MyMenuVisibilityListener mMenuVisibilityListener =
new MyMenuVisibilityListener();
@@ -419,13 +421,14 @@
}
private void updateMenuOperations() {
- mActionBar.setMenuItemVisible(R.id.action_slideshow, canDoSlideShow());
+ MenuItem item = mActionBar.findMenuItem(R.id.action_slideshow);
+ item.setVisible(canDoSlideShow());
if (mCurrentPhoto == null) return;
int supportedOperations = mCurrentPhoto.getSupportedOperations();
if (!GalleryUtils.isEditorAvailable((Context) mActivity, "image/*")) {
supportedOperations &= ~MediaObject.SUPPORT_EDIT;
}
- MenuExecutor.updateMenuOperation(mActionBar, supportedOperations);
+ MenuExecutor.updateMenuOperation(mActionBar.getMenu(), supportedOperations);
}
private boolean canDoSlideShow() {
@@ -578,12 +581,11 @@
@Override
protected boolean onCreateActionBar(Menu menu) {
- GalleryActionBar actionBar = mActionBar;
- boolean result = actionBar.createActionMenu(menu, R.menu.photo);
+ mActionBar.createActionBarMenu(R.menu.photo, menu);
if (mPendingSharePath != null) updateShareURI(mPendingSharePath);
updateMenuOperations();
updateTitle();
- return result;
+ return true;
}
private MenuExecutor.ProgressListener mConfirmDialogListener =
diff --git a/src/com/android/gallery3d/app/PickerActivity.java b/src/com/android/gallery3d/app/PickerActivity.java
index d5bb218..a26711e 100644
--- a/src/com/android/gallery3d/app/PickerActivity.java
+++ b/src/com/android/gallery3d/app/PickerActivity.java
@@ -17,13 +17,13 @@
package com.android.gallery3d.app;
import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
import com.android.gallery3d.ui.GLRootView;
@@ -62,7 +62,7 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
+ MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.pickup, menu);
return true;
}
diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
index 254f672..2f6f16f 100644
--- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
@@ -52,7 +52,7 @@
private int mLoadingState = LOADING_INIT;
public SinglePhotoDataAdapter(
- GalleryActivity activity, PhotoView view, MediaItem item) {
+ AbstractGalleryActivity activity, PhotoView view, MediaItem item) {
mItem = Utils.checkNotNull(item);
mHasFullImage = (item.getSupportedOperations() &
MediaItem.SUPPORT_FULL_IMAGE) != 0;
diff --git a/src/com/android/gallery3d/app/StateManager.java b/src/com/android/gallery3d/app/StateManager.java
index f05ab01..7cc0ac4 100644
--- a/src/com/android/gallery3d/app/StateManager.java
+++ b/src/com/android/gallery3d/app/StateManager.java
@@ -21,9 +21,9 @@
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Parcelable;
-import android.view.Menu;
-import android.view.MenuItem;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.common.Utils;
import java.util.Stack;
@@ -38,12 +38,12 @@
private static final String KEY_STATE = "bundle";
private static final String KEY_CLASS = "class";
- private GalleryActivity mContext;
+ private AbstractGalleryActivity mActivity;
private Stack<StateEntry> mStack = new Stack<StateEntry>();
private ActivityState.ResultEntry mResult;
- public StateManager(GalleryActivity context) {
- mContext = context;
+ public StateManager(AbstractGalleryActivity activity) {
+ mActivity = activity;
}
public void startState(Class<? extends ActivityState> klass,
@@ -59,7 +59,7 @@
ActivityState top = getTopState();
if (mIsResumed) top.onPause();
}
- state.initialize(mContext, data);
+ state.initialize(mActivity, data);
mStack.push(new StateEntry(data, state));
state.onCreate(data, null);
@@ -75,7 +75,7 @@
} catch (Exception e) {
throw new AssertionError(e);
}
- state.initialize(mContext, data);
+ state.initialize(mActivity, data);
state.mResult = new ActivityState.ResultEntry();
state.mResult.requestCode = requestCode;
@@ -155,7 +155,7 @@
// The finish() request could be rejected (only happens under Monkey),
// If it is rejected, we won't close the last page.
if (mStack.size() == 1) {
- Activity activity = (Activity) mContext.getAndroidContext();
+ Activity activity = (Activity) mActivity.getAndroidContext();
if (mResult != null) {
activity.setResult(mResult.resultCode, mResult.resultData);
}
@@ -183,7 +183,7 @@
mStack.pop();
state.mIsFinishing = true;
if (mIsResumed) state.onPause();
- mContext.getGLRoot().setContentPane(null);
+ mActivity.getGLRoot().setContentPane(null);
state.onDestroy();
if (!mStack.isEmpty()) {
@@ -213,7 +213,7 @@
} catch (Exception e) {
throw new AssertionError(e);
}
- state.initialize(mContext, data);
+ state.initialize(mActivity, data);
mStack.push(new StateEntry(data, state));
state.onCreate(data, null);
if (mIsResumed) state.resume();
@@ -246,7 +246,7 @@
} catch (Exception e) {
throw new AssertionError(e);
}
- activityState.initialize(mContext, data);
+ activityState.initialize(mActivity, data);
activityState.onCreate(data, state);
mStack.push(new StateEntry(data, activityState));
}
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index 7deee5b..379f79c 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -17,23 +17,23 @@
package com.android.gallery3d.ui;
import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.os.Handler;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.ActionMode.Callback;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.widget.ShareActionProvider;
+import com.actionbarsherlock.widget.ShareActionProvider.OnShareTargetSelectedListener;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.ActionBarUtils;
-import com.android.gallery3d.actionbar.ActionModeInterface;
-import com.android.gallery3d.actionbar.ActionModeInterface.OnShareTargetSelectedListener;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
@@ -47,8 +47,7 @@
import java.util.ArrayList;
-public class ActionModeHandler implements
- ActionModeInterface.Callback, PopupList.OnPopupItemClickListener {
+public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickListener {
@SuppressWarnings("unused")
private static final String TAG = "ActionModeHandler";
@@ -61,19 +60,20 @@
public boolean onActionItemClicked(MenuItem item);
}
- private final GalleryActivity mActivity;
+ private final AbstractGalleryActivity mActivity;
private final MenuExecutor mMenuExecutor;
private final SelectionManager mSelectionManager;
private final NfcAdapter mNfcAdapter;
private Menu mMenu;
+ private MenuItem mShareMenuItem;
private SelectionMenu mSelectionMenu;
private ActionModeListener mListener;
private Future<?> mMenuTask;
private final Handler mMainHandler;
- private ActionModeInterface mActionMode;
+ private ActionMode mActionMode;
public ActionModeHandler(
- GalleryActivity activity, SelectionManager selectionManager) {
+ AbstractGalleryActivity activity, SelectionManager selectionManager) {
mActivity = Utils.checkNotNull(activity);
mSelectionManager = Utils.checkNotNull(selectionManager);
mMenuExecutor = new MenuExecutor(activity, selectionManager);
@@ -82,8 +82,8 @@
}
public void startActionMode() {
- Activity a = (Activity) mActivity;
- mActionMode = ActionBarUtils.startActionMode(a, this);
+ SherlockActivity a = mActivity;
+ mActionMode = a.startActionMode(this);
View customView = LayoutInflater.from(a).inflate(
R.layout.action_mode, null);
mActionMode.setCustomView(customView);
@@ -105,7 +105,7 @@
}
@Override
- public boolean onActionItemClicked(ActionModeInterface mode, MenuItem item) {
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
GLRoot root = mActivity.getGLRoot();
root.lockRenderThread();
try {
@@ -164,24 +164,35 @@
mSelectionMenu.updateSelectAllMode(mSelectionManager.inSelectAllMode());
}
- @Override
- public boolean onCreateActionMode(ActionModeInterface mode, Menu menu) {
- mode.inflateMenu(R.menu.operation);
+ private final OnShareTargetSelectedListener mShareTargetSelectedListener =
+ new OnShareTargetSelectedListener() {
+ @Override
+ public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
+ mSelectionManager.leaveSelectionMode();
+ return false;
+ }
+ };
- OnShareTargetSelectedListener listener = new OnShareTargetSelectedListener() {
- @Override
- public boolean onShareTargetSelected(Intent intent) {
- mSelectionManager.leaveSelectionMode();
- return false;
- }
- };
- mode.setOnShareTargetSelectedListener(listener);
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ mode.getMenuInflater().inflate(R.menu.operation, menu);
+
mMenu = menu;
+ mShareMenuItem = menu.findItem(R.id.action_share);
+ if (mShareMenuItem != null) {
+ ((ShareActionProvider) mShareMenuItem.getActionProvider())
+ .setOnShareTargetSelectedListener(mShareTargetSelectedListener);
+ }
return true;
}
@Override
- public void onDestroyActionMode(ActionModeInterface mode) {
+ public void onDestroyActionMode(ActionMode mode) {
mSelectionManager.leaveSelectionMode();
}
@@ -209,7 +220,7 @@
switch (unexpandedPaths.size()) {
case 1:
final String mimeType = MenuExecutor.getMimeType(type);
- if (!GalleryUtils.isEditorAvailable((Context) mActivity, mimeType)) {
+ if (!GalleryUtils.isEditorAvailable(mActivity, mimeType)) {
operation &= ~MediaObject.SUPPORT_EDIT;
}
break;
@@ -223,7 +234,7 @@
@TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
private void setNfcBeamPushUris(Uri[] uris) {
if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) {
- mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity);
+ mNfcAdapter.setBeamPushUris(uris, mActivity);
}
}
@@ -275,15 +286,12 @@
public void updateSupportedOperation() {
// Interrupt previous unfinished task, mMenuTask is only accessed in main thread
- if (mMenuTask != null) {
- mMenuTask.cancel();
- }
+ if (mMenuTask != null) mMenuTask.cancel();
updateSelectionMenu();
// Disable share action until share intent is in good shape
- final boolean hasShareButton = mActionMode.hasShareButton();
- if (hasShareButton) mActionMode.setShareIntent(null);
+ if (mShareMenuItem != null) mShareMenuItem.setEnabled(false);
// Generate sharing intent and update supported operations in the background
// The task can take a long time and be canceled in the mean time.
@@ -294,17 +302,17 @@
final int operation = computeMenuOptions(jc);
// Pass2: Deal with expanded media object list for sharing operation.
- final Intent intent = hasShareButton ? computeSharingIntent(jc) : null;
+ final Intent intent = (mShareMenuItem != null) ? computeSharingIntent(jc) : null;
mMainHandler.post(new Runnable() {
@Override
public void run() {
mMenuTask = null;
- if (!jc.isCancelled()) {
- MenuExecutor.updateMenuOperation(mActionMode, operation);
- if (hasShareButton) {
- mActionMode.setShareIntent(intent);
- mMenuExecutor.setShareIntent(intent);
- }
+ if (jc.isCancelled()) return;
+ MenuExecutor.updateMenuOperation(mMenu, operation);
+ if (mShareMenuItem != null) {
+ mShareMenuItem.setEnabled(true);
+ ((ShareActionProvider) mShareMenuItem.getActionProvider())
+ .setShareIntent(intent);
}
}
});
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index 449c6f9..e32ec51 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -20,8 +20,8 @@
import android.os.Message;
import com.android.gallery3d.R;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumSetDataLoader;
-import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.DataSourceType;
@@ -89,7 +89,7 @@
private BitmapLoader coverLoader;
}
- public AlbumSetSlidingWindow(GalleryActivity activity,
+ public AlbumSetSlidingWindow(AbstractGalleryActivity activity,
AlbumSetDataLoader source, AlbumSetSlotRenderer.LabelSpec labelSpec, int cacheSize) {
source.setModelListener(this);
mSource = source;
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index bdc0e67..a1f2b4c 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -16,10 +16,8 @@
package com.android.gallery3d.ui;
-import android.content.Context;
-
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumSetDataLoader;
-import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.ui.AlbumSetSlidingWindow.AlbumSetEntry;
@@ -31,7 +29,7 @@
private final int mPlaceholderColor;
private final ColorTexture mWaitLoadingTexture;
- private final GalleryActivity mActivity;
+ private final AbstractGalleryActivity mActivity;
private final SelectionManager mSelectionManager;
protected final LabelSpec mLabelSpec;
@@ -58,9 +56,10 @@
public int borderSize;
}
- public AlbumSetSlotRenderer(GalleryActivity activity, SelectionManager selectionManager,
+ public AlbumSetSlotRenderer(AbstractGalleryActivity activity,
+ SelectionManager selectionManager,
SlotView slotView, LabelSpec labelSpec, int placeholderColor) {
- super ((Context) activity);
+ super (activity);
mActivity = activity;
mSelectionManager = selectionManager;
mSlotView = slotView;
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index d5d90a9..e4d636a 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -19,8 +19,8 @@
import android.graphics.Bitmap;
import android.os.Message;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumDataLoader;
-import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.MediaItem;
@@ -73,7 +73,7 @@
private int mActiveRequestCount = 0;
private boolean mIsActive = false;
- public AlbumSlidingWindow(GalleryActivity activity,
+ public AlbumSlidingWindow(AbstractGalleryActivity activity,
AlbumDataLoader source, int cacheSize) {
source.setDataListener(this);
mSource = source;
diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
index f6df3b3..d9e3fb7 100644
--- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
@@ -16,10 +16,8 @@
package com.android.gallery3d.ui;
-import android.content.Context;
-
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumDataLoader;
-import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.Path;
@@ -35,7 +33,7 @@
private static final int CACHE_SIZE = 96;
private AlbumSlidingWindow mDataWindow;
- private final GalleryActivity mActivity;
+ private final AbstractGalleryActivity mActivity;
private final ColorTexture mWaitLoadingTexture;
private final SlotView mSlotView;
private final SelectionManager mSelectionManager;
@@ -47,9 +45,9 @@
private SlotFilter mSlotFilter;
- public AlbumSlotRenderer(GalleryActivity activity, SlotView slotView,
+ public AlbumSlotRenderer(AbstractGalleryActivity activity, SlotView slotView,
SelectionManager selectionManager, int placeholderColor) {
- super((Context) activity);
+ super(activity);
mActivity = activity;
mSlotView = slotView;
mSelectionManager = selectionManager;
diff --git a/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java b/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java
index 611648a..46f7a24 100644
--- a/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java
+++ b/src/com/android/gallery3d/ui/CacheStorageUsageInfo.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.os.StatFs;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.util.ThreadPool.JobContext;
import java.io.File;
@@ -40,11 +40,11 @@
// number of bytes used for the cache if all pending downloads (and removals) are completed.
private long mTargetCacheBytes;
- private GalleryActivity mActivity;
+ private AbstractGalleryActivity mActivity;
private Context mContext;
private long mUserChangeDelta;
- public CacheStorageUsageInfo(GalleryActivity activity) {
+ public CacheStorageUsageInfo(AbstractGalleryActivity activity) {
mActivity = activity;
mContext = activity.getAndroidContext();
}
diff --git a/src/com/android/gallery3d/ui/CropView.java b/src/com/android/gallery3d/ui/CropView.java
index 8c2c3df..1890c76 100644
--- a/src/com/android/gallery3d/ui/CropView.java
+++ b/src/com/android/gallery3d/ui/CropView.java
@@ -33,7 +33,7 @@
import com.android.gallery3d.R;
import com.android.gallery3d.anim.Animation;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.common.Utils;
import java.util.ArrayList;
@@ -92,14 +92,14 @@
private int mImageWidth = SIZE_UNKNOWN;
private int mImageHeight = SIZE_UNKNOWN;
- private GalleryActivity mActivity;
+ private AbstractGalleryActivity mActivity;
private GLPaint mPaint = new GLPaint();
private GLPaint mFacePaint = new GLPaint();
private int mImageRotation;
- public CropView(GalleryActivity activity) {
+ public CropView(AbstractGalleryActivity activity) {
mActivity = activity;
mImageView = new TileImageView(activity);
mFaceDetectionView = new FaceHighlightView();
diff --git a/src/com/android/gallery3d/ui/DetailsAddressResolver.java b/src/com/android/gallery3d/ui/DetailsAddressResolver.java
index 3dd20a5..8de6677 100644
--- a/src/com/android/gallery3d/ui/DetailsAddressResolver.java
+++ b/src/com/android/gallery3d/ui/DetailsAddressResolver.java
@@ -21,7 +21,7 @@
import android.os.Handler;
import android.os.Looper;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
@@ -32,7 +32,7 @@
public class DetailsAddressResolver {
private AddressResolvingListener mListener;
- private final GalleryActivity mContext;
+ private final AbstractGalleryActivity mContext;
private Future<Address> mAddressLookupJob;
private final Handler mHandler;
@@ -54,7 +54,7 @@
public void onAddressAvailable(String address);
}
- public DetailsAddressResolver(GalleryActivity context) {
+ public DetailsAddressResolver(AbstractGalleryActivity context) {
mContext = context;
mHandler = new Handler(Looper.getMainLooper());
}
diff --git a/src/com/android/gallery3d/ui/DetailsHelper.java b/src/com/android/gallery3d/ui/DetailsHelper.java
index f86ffbe..3016011 100644
--- a/src/com/android/gallery3d/ui/DetailsHelper.java
+++ b/src/com/android/gallery3d/ui/DetailsHelper.java
@@ -19,7 +19,7 @@
import android.view.View.MeasureSpec;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.ui.DetailsAddressResolver.AddressResolvingListener;
@@ -44,7 +44,7 @@
public void hide();
}
- public DetailsHelper(GalleryActivity activity, GLView rootPane, DetailsSource source) {
+ public DetailsHelper(AbstractGalleryActivity activity, GLView rootPane, DetailsSource source) {
mContainer = new DialogDetailsView(activity, source);
}
@@ -65,7 +65,7 @@
mContainer.setCloseListener(listener);
}
- public static String resolveAddress(GalleryActivity activity, double[] latlng,
+ public static String resolveAddress(AbstractGalleryActivity activity, double[] latlng,
AddressResolvingListener listener) {
if (sAddressResolver == null) {
sAddressResolver = new DetailsAddressResolver(activity);
diff --git a/src/com/android/gallery3d/ui/DialogDetailsView.java b/src/com/android/gallery3d/ui/DialogDetailsView.java
index a556600..fb6ccf5 100644
--- a/src/com/android/gallery3d/ui/DialogDetailsView.java
+++ b/src/com/android/gallery3d/ui/DialogDetailsView.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.ui;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
@@ -31,7 +30,7 @@
import android.widget.TextView;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.ui.DetailsAddressResolver.AddressResolvingListener;
@@ -46,7 +45,7 @@
@SuppressWarnings("unused")
private static final String TAG = "DialogDetailsView";
- private final GalleryActivity mContext;
+ private final AbstractGalleryActivity mActivity;
private DetailsAdapter mAdapter;
private MediaDetails mDetails;
private final DetailsSource mSource;
@@ -54,8 +53,8 @@
private Dialog mDialog;
private CloseListener mListener;
- public DialogDetailsView(GalleryActivity activity, DetailsSource source) {
- mContext = activity;
+ public DialogDetailsView(AbstractGalleryActivity activity, DetailsSource source) {
+ mActivity = activity;
mSource = source;
}
@@ -86,12 +85,12 @@
private void setDetails(MediaDetails details) {
mAdapter = new DetailsAdapter(details);
String title = String.format(
- mContext.getAndroidContext().getString(R.string.details_title),
+ mActivity.getAndroidContext().getString(R.string.details_title),
mIndex + 1, mSource.size());
- ListView detailsList = (ListView) LayoutInflater.from(mContext.getAndroidContext()).inflate(
+ ListView detailsList = (ListView) LayoutInflater.from(mActivity.getAndroidContext()).inflate(
R.layout.details_list, null, false);
detailsList.setAdapter(mAdapter);
- mDialog = new AlertDialog.Builder((Activity) mContext)
+ mDialog = new AlertDialog.Builder(mActivity)
.setView(detailsList)
.setTitle(title)
.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
@@ -117,7 +116,7 @@
private int mLocationIndex;
public DetailsAdapter(MediaDetails details) {
- Context context = mContext.getAndroidContext();
+ Context context = mActivity.getAndroidContext();
mItems = new ArrayList<String>(details.size());
mLocationIndex = -1;
setDetails(context, details);
@@ -130,7 +129,7 @@
case MediaDetails.INDEX_LOCATION: {
double[] latlng = (double[]) detail.getValue();
mLocationIndex = mItems.size();
- value = DetailsHelper.resolveAddress(mContext, latlng, this);
+ value = DetailsHelper.resolveAddress(mActivity, latlng, this);
break;
}
case MediaDetails.INDEX_SIZE: {
@@ -222,7 +221,7 @@
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv;
if (convertView == null) {
- tv = (TextView) LayoutInflater.from(mContext.getAndroidContext()).inflate(
+ tv = (TextView) LayoutInflater.from(mActivity.getAndroidContext()).inflate(
R.layout.details, parent, false);
} else {
tv = (TextView) convertView;
diff --git a/src/com/android/gallery3d/ui/ImportCompleteListener.java b/src/com/android/gallery3d/ui/ImportCompleteListener.java
index 5b6e0a1..30af470 100644
--- a/src/com/android/gallery3d/ui/ImportCompleteListener.java
+++ b/src/com/android/gallery3d/ui/ImportCompleteListener.java
@@ -23,15 +23,15 @@
import android.widget.Toast;
import com.android.gallery3d.R;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumPage;
-import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.util.MediaSetUtils;
public class ImportCompleteListener implements MenuExecutor.ProgressListener {
- private GalleryActivity mActivity;
+ private AbstractGalleryActivity mActivity;
private PowerManager.WakeLock mWakeLock;
- public ImportCompleteListener(GalleryActivity galleryActivity) {
+ public ImportCompleteListener(AbstractGalleryActivity galleryActivity) {
mActivity = galleryActivity;
PowerManager pm =
(PowerManager) ((Activity) mActivity).getSystemService(Context.POWER_SERVICE);
diff --git a/src/com/android/gallery3d/ui/ManageCacheDrawer.java b/src/com/android/gallery3d/ui/ManageCacheDrawer.java
index 91dc7ac..e989af2 100644
--- a/src/com/android/gallery3d/ui/ManageCacheDrawer.java
+++ b/src/com/android/gallery3d/ui/ManageCacheDrawer.java
@@ -19,7 +19,7 @@
import android.content.Context;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.data.DataSourceType;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
@@ -36,11 +36,11 @@
private final int mCachePinSize;
private final int mCachePinMargin;
- public ManageCacheDrawer(GalleryActivity activity, SelectionManager selectionManager,
+ public ManageCacheDrawer(AbstractGalleryActivity activity, SelectionManager selectionManager,
SlotView slotView, LabelSpec labelSpec, int cachePinSize, int cachePinMargin) {
super(activity, selectionManager, slotView, labelSpec,
activity.getResources().getColor(R.color.cache_placeholder));
- Context context = (Context) activity;
+ Context context = activity;
mCheckedItem = new ResourceTexture(
context, R.drawable.btn_make_offline_normal_on_holo_dark);
mUnCheckedItem = new ResourceTexture(
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index ff6a61f..7bccda8 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -26,13 +26,12 @@
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
-import android.view.MenuItem;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
-import com.android.gallery3d.actionbar.MenuHolder;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.CropImage;
-import com.android.gallery3d.app.GalleryActivity;
-import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
@@ -64,7 +63,7 @@
private boolean mWaitOnStop;
private Intent mShareIntent;
- private final GalleryActivity mActivity;
+ private final AbstractGalleryActivity mActivity;
private final SelectionManager mSelectionManager;
private final Handler mHandler;
@@ -90,7 +89,7 @@
}
public MenuExecutor(
- GalleryActivity activity, SelectionManager selectionManager) {
+ AbstractGalleryActivity activity, SelectionManager selectionManager) {
mActivity = Utils.checkNotNull(activity);
mSelectionManager = Utils.checkNotNull(selectionManager);
mHandler = new SynchronizedHandler(mActivity.getGLRoot()) {
@@ -157,7 +156,7 @@
mHandler.sendMessage(mHandler.obtainMessage(MSG_TASK_COMPLETE, result, 0, listener));
}
- public static void updateMenuOperation(MenuHolder menu, int supported) {
+ public static void updateMenuOperation(Menu menu, int supported) {
boolean supportDelete = (supported & MediaObject.SUPPORT_DELETE) != 0;
boolean supportRotate = (supported & MediaObject.SUPPORT_ROTATE) != 0;
boolean supportCrop = (supported & MediaObject.SUPPORT_CROP) != 0;
@@ -169,16 +168,21 @@
boolean supportInfo = (supported & MediaObject.SUPPORT_INFO) != 0;
boolean supportImport = (supported & MediaObject.SUPPORT_IMPORT) != 0;
- menu.setMenuItemVisible(R.id.action_delete, supportDelete);
- menu.setMenuItemVisible(R.id.action_rotate_ccw, supportRotate);
- menu.setMenuItemVisible(R.id.action_rotate_cw, supportRotate);
- menu.setMenuItemVisible(R.id.action_crop, supportCrop);
- menu.setMenuItemVisible(R.id.action_share, supportShare);
- menu.setMenuItemVisible(R.id.action_setas, supportSetAs);
- menu.setMenuItemVisible(R.id.action_show_on_map, supportShowOnMap);
- menu.setMenuItemVisible(R.id.action_edit, supportEdit);
- menu.setMenuItemVisible(R.id.action_details, supportInfo);
- menu.setMenuItemVisible(R.id.action_import, supportImport);
+ setMenuItemVisible(menu, R.id.action_delete, supportDelete);
+ setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate);
+ setMenuItemVisible(menu, R.id.action_rotate_cw, supportRotate);
+ setMenuItemVisible(menu, R.id.action_crop, supportCrop);
+ setMenuItemVisible(menu, R.id.action_share, supportShare);
+ setMenuItemVisible(menu, R.id.action_setas, supportSetAs);
+ setMenuItemVisible(menu, R.id.action_show_on_map, supportShowOnMap);
+ setMenuItemVisible(menu, R.id.action_edit, supportEdit);
+ setMenuItemVisible(menu, R.id.action_details, supportInfo);
+ setMenuItemVisible(menu, R.id.action_import, supportImport);
+ }
+
+ private static void setMenuItemVisible(Menu menu, int itemId, boolean visible) {
+ MenuItem item = menu.findItem(itemId);
+ if (item != null) item.setVisible(visible);
}
private Path getSingleSelectedPath() {
@@ -244,14 +248,6 @@
case R.id.action_import:
title = R.string.Import;
break;
- case R.id.action_share: {
- if (!ApiHelper.HAS_SHARE_ACTION_PROVIDER) {
- Activity activity = (Activity) mActivity;
- activity.startActivity(Intent.createChooser(
- mShareIntent, activity.getString(R.string.share)));
- }
- return;
- }
default:
return;
}
@@ -326,10 +322,6 @@
mWaitOnStop = waitOnStop;
}
- public void setShareIntent(Intent intent) {
- mShareIntent = intent;
- }
-
public static String getMimeType(int type) {
switch (type) {
case MediaObject.MEDIA_TYPE_IMAGE :
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 16d93ca..25d3154 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -28,7 +28,7 @@
import android.view.animation.AccelerateInterpolator;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -232,7 +232,7 @@
// item. The value Integer.MAX_VALUE means there is no such hint.
private int mUndoIndexHint = Integer.MAX_VALUE;
- public PhotoView(GalleryActivity activity) {
+ public PhotoView(AbstractGalleryActivity activity) {
mTileView = new TileImageView(activity);
addComponent(mTileView);
Context context = activity.getAndroidContext();
diff --git a/src/com/android/gallery3d/ui/SelectionManager.java b/src/com/android/gallery3d/ui/SelectionManager.java
index 86e92da..a6be0dd 100644
--- a/src/com/android/gallery3d/ui/SelectionManager.java
+++ b/src/com/android/gallery3d/ui/SelectionManager.java
@@ -16,7 +16,7 @@
package com.android.gallery3d.ui;
-import com.android.gallery3d.app.GalleryContext;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaSet;
@@ -49,8 +49,8 @@
public void onSelectionChange(Path path, boolean selected);
}
- public SelectionManager(GalleryContext galleryContext, boolean isAlbumSet) {
- mDataManager = galleryContext.getDataManager();
+ public SelectionManager(AbstractGalleryActivity activity, boolean isAlbumSet) {
+ mDataManager = activity.getDataManager();
mClickedSet = new HashSet<Path>();
mIsAlbumSet = isAlbumSet;
mTotal = -1;
diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java
index 1325aec..d77080a 100644
--- a/src/com/android/gallery3d/ui/SlotView.java
+++ b/src/com/android/gallery3d/ui/SlotView.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.ui;
-import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
import android.view.GestureDetector;
@@ -24,7 +23,7 @@
import android.view.animation.DecelerateInterpolator;
import com.android.gallery3d.anim.Animation;
-import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.common.Utils;
public class SlotView extends GLView {
@@ -88,10 +87,9 @@
// to prevent allocating memory
private final Rect mTempRect = new Rect();
- public SlotView(GalleryActivity activity, Spec spec) {
- mGestureDetector = new GestureDetector(
- (Context) activity, new MyGestureListener());
- mScroller = new ScrollerHelper((Context) activity);
+ public SlotView(AbstractGalleryActivity activity, Spec spec) {
+ mGestureDetector = new GestureDetector(activity, new MyGestureListener());
+ mScroller = new ScrollerHelper(activity);
mHandler = new SynchronizedHandler(activity.getGLRoot());
setSlotSpec(spec);
}