From 6efbd7283aea80eef8e5001291eb53c9e156e88c Mon Sep 17 00:00:00 2001 From: Wei Huang Date: Thu, 15 Mar 2012 15:23:00 -0700 Subject: bug #6176711: guard against null GalleryActionBar. When entering Gallery app from WallPaper picker, the activity is DialogPicker, which doesn't initialize GalleryActionbar so getGalleryActionbar() returns null. Guard against using the null object. I fixed the obvious NPE here, but Ray or Yuli should take a closer look, to see why this is broken. Change-Id: Ic6923c388ea7b72ab402131fc3b039546509e340 --- src/com/android/gallery3d/app/ActivityState.java | 5 ++++- src/com/android/gallery3d/app/AlbumPage.java | 5 ++++- src/com/android/gallery3d/app/PhotoPage.java | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java index 443e2bd29..384ae734b 100644 --- a/src/com/android/gallery3d/app/ActivityState.java +++ b/src/com/android/gallery3d/app/ActivityState.java @@ -141,7 +141,10 @@ abstract public class ActivityState { actionBar.show(); } int stateCount = mActivity.getStateManager().getStateCount(); - mActivity.getGalleryActionBar().setDisplayOptions(stateCount > 1, true); + GalleryActionBar galleryActionbar = mActivity.getGalleryActionBar(); + if (galleryActionbar != null) { + galleryActionbar.setDisplayOptions(stateCount > 1, true); + } // Default behavior, this can be overridden in ActivityState's onResume. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 411464e86..32c5b7fc2 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -319,7 +319,10 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster Path path = mMediaSet.getPath(); boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) | mParentMediaSetString != null; - mActivity.getGalleryActionBar().setDisplayOptions(enableHomeButton, true); + GalleryActionBar galleryActionBar = mActivity.getGalleryActionBar(); + if (galleryActionBar != null) { + galleryActionBar.setDisplayOptions(enableHomeButton, true); + } // Set the reload bit here to prevent it exit this page in clearLoadingBit(). setLoadingBit(BIT_LOADING_RELOAD); diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 8040a2fc6..a8c69b567 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -630,8 +630,10 @@ public class PhotoPage extends ActivityState if (mMenuVisibilityListener == null) { mMenuVisibilityListener = new MyMenuVisibilityListener(); } - mActivity.getGalleryActionBar().setDisplayOptions(mSetPathString != null, true); - + GalleryActionBar galleryActionBar = mActivity.getGalleryActionBar(); + if (galleryActionBar != null) { + galleryActionBar.setDisplayOptions(mSetPathString != null, true); + } mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener); onUserInteraction(); } -- cgit v1.2.3 From 88d715de7a950616371b771dbb6a124b1718914b Mon Sep 17 00:00:00 2001 From: Yuli Huang Date: Thu, 12 Apr 2012 23:45:49 +0800 Subject: Fix SinglePhotoDataAdapter getScreenNail() bug:6322259 Change-Id: I6cf5de88fc07e4b73b028faa3b2a063b4d47fd20 --- src/com/android/gallery3d/app/SinglePhotoDataAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java index 6ef5040f3..315f5b59c 100644 --- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java @@ -158,7 +158,7 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter } public ScreenNail getScreenNail(int offset) { - return null; + return (offset == 0) ? getScreenNail() : null; } public void next() { -- cgit v1.2.3 From a9f3be9c7e80e26c0c09ca45d829269c49d8835d Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 13 Apr 2012 12:33:29 +0800 Subject: Fix ANR in PhotoPage. This bugs happens because we open too many PhotoPage(s) (and onSingleTapUp is a delayed event). However, each of the PhotoPage need a Thread to run tile decoder. When we close one of the PhotoPage, it will wait the tile decoder to get finished first. However, the title decoder may still waiting in the queue and never got a chance to run. Change-Id: I113d1150729892edb4fe36bc5a1dc131db300476 fix: 6319833 --- src/com/android/gallery3d/app/AlbumPage.java | 1 + src/com/android/gallery3d/app/AlbumSetPage.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index efffe4075..0fcd7a759 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -164,6 +164,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster } private void onSingleTapUp(int slotIndex) { + if (!mIsActive) return; MediaItem item = mAlbumDataAdapter.get(slotIndex); if (item == null) { Log.w(TAG, "item not ready yet, ignore the click"); diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index cbd6789b4..60de019de 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -172,6 +172,7 @@ public class AlbumSetPage extends ActivityState implements } public void onSingleTapUp(int slotIndex) { + if (!mIsActive) return; MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex); if (targetSet == null) return; // Content is dirty, we shall reload soon -- cgit v1.2.3 From c6aae5f6356fa3bad1b82a71b51fddff8e21858b Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Mon, 30 Apr 2012 23:49:17 +0800 Subject: Fix crash when select all is pressed. bug:6411186 Change-Id: Iaa71a320bc4d6d70aade41d5144f75ba6db36e6d --- src/com/android/gallery3d/ui/MenuExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java index a0f344982..a052c500d 100644 --- a/src/com/android/gallery3d/ui/MenuExecutor.java +++ b/src/com/android/gallery3d/ui/MenuExecutor.java @@ -185,12 +185,14 @@ public class MenuExecutor { } else { mSelectionManager.selectAll(); } + return; case R.id.action_crop: { Path path = getSingleSelectedPath(); String mimeType = getMimeType(manager.getMediaType(path)); Intent intent = new Intent(CropImage.ACTION_CROP) .setDataAndType(manager.getContentUri(path), mimeType); ((Activity) mActivity).startActivity(intent); + return; } case R.id.action_setas: { Path path = getSingleSelectedPath(); @@ -203,6 +205,7 @@ public class MenuExecutor { Activity activity = (Activity) mActivity; activity.startActivity(Intent.createChooser( intent, activity.getString(R.string.set_as))); + return; } case R.id.action_delete: title = R.string.delete; @@ -368,4 +371,3 @@ public class MenuExecutor { } } } - -- cgit v1.2.3 From ca4dafb77b8c427838803983e360d7c9fe70b32b Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Tue, 1 May 2012 02:25:09 +0800 Subject: Fix black screen when viewing Gmail image file attachment. Bug: 6415848 Change-Id: Iec369866be6b5546fbd8cb77eb95a29f92e00b84 --- src/com/android/gallery3d/ui/PositionController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index ac0d191f4..03fe65b1c 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -1012,7 +1012,8 @@ class PositionController { float hFactor = 1.0f; int viewW, viewH; - if (!mFilmMode && mConstrained && b == mBoxes.get(0)) { + if (!mFilmMode && mConstrained && !mConstrainedFrame.isEmpty() + && b == mBoxes.get(0)) { viewW = mConstrainedFrame.width(); viewH = mConstrainedFrame.height(); } else { -- cgit v1.2.3 From faac4c284d470bc5fa380a37a22272a65931cad7 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 16 May 2012 11:29:06 -0700 Subject: Restore deleted string still referenced from menu resource. Change-Id: I518dc004a92ee68682c2085c8d2f002896198feb --- res/values/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index bba7e33e6..4d23b0f10 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -59,6 +59,9 @@ Start over + + OK OK -- cgit v1.2.3 From 8130925c60b786759e852a6088776c626d8ee0e2 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 16 May 2012 10:54:14 -0700 Subject: Fix a dead lock while we freeze the screen. bug: 6504696 Change-Id: If960967142bb0df773ce075bf76f5726c37e1d27 --- src/com/android/gallery3d/app/PhotoPage.java | 1 - src/com/android/gallery3d/ui/GLRoot.java | 1 + src/com/android/gallery3d/ui/GLRootView.java | 40 +++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index a46c777fa..2022a6e2d 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -56,7 +56,6 @@ import com.android.gallery3d.ui.GLView; import com.android.gallery3d.ui.ImportCompleteListener; import com.android.gallery3d.ui.MenuExecutor; import com.android.gallery3d.ui.PhotoView; -import com.android.gallery3d.ui.ScreenNail; import com.android.gallery3d.ui.SelectionManager; import com.android.gallery3d.ui.SynchronizedHandler; import com.android.gallery3d.util.GalleryUtils; diff --git a/src/com/android/gallery3d/ui/GLRoot.java b/src/com/android/gallery3d/ui/GLRoot.java index 5ed323a88..f4b7572a7 100644 --- a/src/com/android/gallery3d/ui/GLRoot.java +++ b/src/com/android/gallery3d/ui/GLRoot.java @@ -17,6 +17,7 @@ package com.android.gallery3d.ui; import android.graphics.Matrix; + import com.android.gallery3d.anim.CanvasAnimation; public interface GLRoot { diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index 1f25b9085..73e982509 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -19,12 +19,12 @@ package com.android.gallery3d.ui; import android.content.Context; import android.graphics.Matrix; import android.graphics.PixelFormat; -import android.graphics.Rect; import android.opengl.GLSurfaceView; import android.os.Process; import android.os.SystemClock; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.SurfaceHolder; import com.android.gallery3d.anim.CanvasAnimation; import com.android.gallery3d.common.Utils; @@ -467,6 +467,7 @@ public class GLRootView extends GLSurfaceView @Override public void onPause() { + unfreeze(); super.onPause(); if (DEBUG_PROFILE) { Log.d(TAG, "Stop profiling"); @@ -510,4 +511,41 @@ public class GLRootView extends GLSurfaceView mFreezeCondition.signalAll(); mRenderLock.unlock(); } + + // We need to unfreeze in the following methods and in onPause(). + // These methods will wait on GLThread. If we have freezed the GLRootView, + // the GLThread will wait on main thread to call unfreeze and cause dead + // lock. + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { + unfreeze(); + super.surfaceChanged(holder, format, w, h); + } + + @Override + public void surfaceCreated(SurfaceHolder holder) { + unfreeze(); + super.surfaceCreated(holder); + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + unfreeze(); + super.surfaceDestroyed(holder); + } + + @Override + protected void onDetachedFromWindow() { + unfreeze(); + super.onDetachedFromWindow(); + } + + @Override + protected void finalize() throws Throwable { + try { + unfreeze(); + } finally { + super.finalize(); + } + } } -- cgit v1.2.3 From 92fc4eb8ea97843b42431eadcfa2277a8b236dc2 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Thu, 17 May 2012 13:04:35 -0700 Subject: Fix a NPE found by Moneky. AlbumLabelMaker.mBitmapPool could be null if the setLabelWidth() has never been called or called with width as 0. bug:6510386 Change-Id: Idaaa0a1a7239271ba3ae3217e65029b382464c10 --- src/com/android/gallery3d/ui/AlbumLabelMaker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/ui/AlbumLabelMaker.java b/src/com/android/gallery3d/ui/AlbumLabelMaker.java index f837092b8..93b37ce13 100644 --- a/src/com/android/gallery3d/ui/AlbumLabelMaker.java +++ b/src/com/android/gallery3d/ui/AlbumLabelMaker.java @@ -211,6 +211,6 @@ public class AlbumLabelMaker { } public void clearRecycledLabels() { - mBitmapPool.clear(); + if (mBitmapPool != null) mBitmapPool.clear(); } } -- cgit v1.2.3