merge in ics-mr1-release history after reset to ics-mr1
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index c31e920..fb26fc6 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -443,6 +443,7 @@
                 }
             }
 
+            FilterUtils.setupMenuItems(actionBar, mMediaSet.getPath(), false);
             MenuItem switchCamera = menu.findItem(R.id.action_camera);
             if (switchCamera != null) {
                 switchCamera.setVisible(GalleryUtils.isCameraAvailable(activity));
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java
index 98a35a1..717f16c 100644
--- a/src/com/android/gallery3d/app/GalleryActionBar.java
+++ b/src/com/android/gallery3d/app/GalleryActionBar.java
@@ -228,7 +228,7 @@
     public boolean setSelectedAction(int type) {
         for (int i = 0, n = sClusterItems.length; i < n; i++) {
             ActionItem item = sClusterItems[i];
-            if (item.visible && item.action == type) {
+            if (item.action == type) {
                 mActionBar.setSelectedNavigationItem(i);
                 mCurrentIndex = i;
                 return true;
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index ec7d161..ed67b08 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -17,8 +17,8 @@
 package com.android.gallery3d.app;
 
 import android.app.ActionBar;
-import android.app.Activity;
 import android.app.ActionBar.OnMenuVisibilityListener;
+import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
@@ -30,8 +30,8 @@
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
-import android.view.WindowManager;
 import android.view.View.MeasureSpec;
+import android.view.WindowManager;
 import android.widget.ShareActionProvider;
 import android.widget.Toast;
 
@@ -300,19 +300,33 @@
     }
 
     private void updateMenuOperations() {
-        if (mCurrentPhoto == null || mMenu == null) return;
+        if (mMenu == null) return;
+        MenuItem item = mMenu.findItem(R.id.action_slideshow);
+        if (item != null) {
+            item.setVisible(canDoSlideShow());
+        }
+        if (mCurrentPhoto == null) return;
         int supportedOperations = mCurrentPhoto.getSupportedOperations();
         if (!GalleryUtils.isEditorAvailable((Context) mActivity, "image/*")) {
             supportedOperations &= ~MediaObject.SUPPORT_EDIT;
         }
-        MenuItem item = mMenu.findItem(R.id.action_slideshow);
-        if (item != null) {
-            item.setVisible(mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE);
-        }
 
         MenuExecutor.updateMenuOperation(mMenu, supportedOperations);
     }
 
+    private boolean canDoSlideShow() {
+        if (mMediaSet == null || mCurrentPhoto == null) {
+            return false;
+        }
+        if (mCurrentPhoto.getMediaType() != MediaObject.MEDIA_TYPE_IMAGE) {
+            return false;
+        }
+        if (mMediaSet instanceof MtpDevice) {
+            return false;
+        }
+        return true;
+    }
+
     private void showBars() {
         if (mShowBars) return;
         mShowBars = true;
@@ -344,6 +358,7 @@
         }
     }
 
+    @Override
     public void onUserInteraction() {
         showBars();
         refreshHidingMessage();
@@ -359,15 +374,21 @@
         }
     }
 
+    @Override
     public void onUserInteractionBegin() {
         showBars();
         mIsInteracting = true;
         refreshHidingMessage();
     }
 
+    @Override
     public void onUserInteractionEnd() {
         mIsInteracting = false;
-        refreshHidingMessage();
+
+        // This function could be called from GL thread (in SlotView.render)
+        // and post to the main thread. So, it could be executed while the
+        // activity is paused.
+        if (mIsActive) refreshHidingMessage();
     }
 
     @Override
@@ -394,8 +415,6 @@
     protected boolean onCreateActionBar(Menu menu) {
         MenuInflater inflater = ((Activity) mActivity).getMenuInflater();
         inflater.inflate(R.menu.photo, menu);
-        menu.findItem(R.id.action_slideshow).setVisible(
-                mMediaSet != null && !(mMediaSet instanceof MtpDevice));
         mShareActionProvider = GalleryActionBar.initializeShareActionProvider(menu);
         if (mPendingSharePath != null) updateShareURI(mPendingSharePath);
         mMenu = menu;
diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java
index a6e94d2..3e0e2f2 100644
--- a/src/com/android/gallery3d/ui/SlotView.java
+++ b/src/com/android/gallery3d/ui/SlotView.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.graphics.Rect;
+import android.os.Handler;
 import android.view.GestureDetector;
 import android.view.MotionEvent;
 import android.view.animation.DecelerateInterpolator;
@@ -81,6 +82,7 @@
     // whether the down action happened while the view is scrolling.
     private boolean mDownInScrolling;
     private int mOverscrollEffect = OVERSCROLL_3D;
+    private final Handler mHandler;
 
     public static final int OVERSCROLL_3D = 0;
     public static final int OVERSCROLL_SYSTEM = 1;
@@ -90,6 +92,7 @@
         mGestureDetector =
                 new GestureDetector(context, new MyGestureListener());
         mScroller = new ScrollerHelper(context);
+        mHandler = new Handler(context.getMainLooper());
     }
 
     public void setCenterIndex(int index) {
@@ -323,8 +326,15 @@
         }
 
         if (more) invalidate();
-        if (mMoreAnimation && !more && mUIListener != null) {
-            mUIListener.onUserInteractionEnd();
+
+        final UserInteractionListener listener = mUIListener;
+        if (mMoreAnimation && !more && listener != null) {
+            mHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    listener.onUserInteractionEnd();
+                }
+            });
         }
         mMoreAnimation = more;
     }