summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java16
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java6
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java9
-rw-r--r--src/com/android/gallery3d/ui/ImportCompleteListener.java36
-rw-r--r--src/com/android/gallery3d/ui/TiledScreenNail.java4
-rw-r--r--src/com/android/gallery3d/ui/TiledTexture.java11
-rw-r--r--src/com/android/gallery3d/ui/WakeLockHoldingProgressListener.java66
8 files changed, 110 insertions, 41 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 7b4ae6691..02acaeab1 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -457,6 +457,9 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
int accessoryPanelWidth = viewPanel.getWidth();
int mainViewWidth = findViewById(R.id.mainView).getWidth();
int mainPanelWidth = mImageShow.getDisplayedImageBounds().width();
+ if (mainPanelWidth == 0) {
+ mainPanelWidth = mainViewWidth;
+ }
int leftOver = mainViewWidth - mainPanelWidth - accessoryPanelWidth;
if (leftOver < 0) {
return -accessoryPanelWidth;
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
index f99e61473..42dd139bc 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
@@ -367,11 +367,13 @@ public abstract class ImageGeometry extends ImageSlave {
getImagePreset().setGeometry(mLocalGeometry);
resetImageCaches(this);
} else {
- ImagePreset copy = new ImagePreset(getImagePreset());
- copy.setGeometry(mLocalGeometry);
- copy.setHistoryName(getName());
- copy.setIsFx(false);
- setImagePreset(copy, true);
+ if (mLocalGeometry.hasModifications()) {
+ ImagePreset copy = new ImagePreset(getImagePreset());
+ copy.setGeometry(mLocalGeometry);
+ copy.setHistoryName(getName());
+ copy.setIsFx(false);
+ setImagePreset(copy, true);
+ }
}
invalidate();
}
@@ -492,7 +494,7 @@ public abstract class ImageGeometry extends ImageSlave {
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
drawCropSafe(canvas, paint);
- paint.setARGB(128, 0, 0, 0);
+ paint.setColor(getDefaultBackgroundColor());
paint.setStyle(Paint.Style.FILL);
drawShadows(canvas, paint, unrotatedCropBounds());
}
@@ -612,7 +614,7 @@ public abstract class ImageGeometry extends ImageSlave {
canvas.drawBitmap(photo, m1, p);
canvas.restore();
- p.setARGB(255, 0, 0, 0);
+ p.setColor(getDefaultBackgroundColor());
p.setStyle(Paint.Style.FILL);
scaledCrop.offset(displayCenter[0] - scaledCrop.centerX(), displayCenter[1]
- scaledCrop.centerY());
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index bf22c891f..0145c24dc 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -83,7 +83,7 @@ public class ImageShow extends View implements OnGestureListener,
private HistoryAdapter mHistoryAdapter = null;
private ImageStateAdapter mImageStateAdapter = null;
- private Rect mImageBounds = null;
+ private Rect mImageBounds = new Rect();
private boolean mTouchShowOriginal = false;
private long mTouchShowOriginalDate = 0;
@@ -125,6 +125,10 @@ public class ImageShow extends View implements OnGestureListener,
mBackgroundColor = value;
}
+ public int getDefaultBackgroundColor() {
+ return mBackgroundColor;
+ }
+
public static void setTextSize(int value) {
mTextSize = value;
}
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index bb195c91e..7191599ad 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -151,6 +151,8 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
mListener = listener;
}
+ private WakeLockHoldingProgressListener mDeleteProgressListener;
+
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
GLRoot root = mActivity.getGLRoot();
@@ -173,9 +175,14 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
int action = item.getItemId();
if (action == R.id.action_import) {
listener = new ImportCompleteListener(mActivity);
- } else if (item.getItemId() == R.id.action_delete) {
+ } else if (action == R.id.action_delete) {
confirmMsg = mActivity.getResources().getQuantityString(
R.plurals.delete_selection, mSelectionManager.getSelectedCount());
+ if (mDeleteProgressListener == null) {
+ mDeleteProgressListener = new WakeLockHoldingProgressListener(mActivity,
+ "Gallery Delete Progress Listener");
+ }
+ listener = mDeleteProgressListener;
}
mMenuExecutor.onMenuClicked(item, confirmMsg, listener);
} finally {
diff --git a/src/com/android/gallery3d/ui/ImportCompleteListener.java b/src/com/android/gallery3d/ui/ImportCompleteListener.java
index 30af47065..8d6e981ce 100644
--- a/src/com/android/gallery3d/ui/ImportCompleteListener.java
+++ b/src/com/android/gallery3d/ui/ImportCompleteListener.java
@@ -16,10 +16,7 @@
package com.android.gallery3d.ui;
-import android.app.Activity;
-import android.content.Context;
import android.os.Bundle;
-import android.os.PowerManager;
import android.widget.Toast;
import com.android.gallery3d.R;
@@ -27,19 +24,16 @@ import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumPage;
import com.android.gallery3d.util.MediaSetUtils;
-public class ImportCompleteListener implements MenuExecutor.ProgressListener {
- private AbstractGalleryActivity mActivity;
- private PowerManager.WakeLock mWakeLock;
+public class ImportCompleteListener extends WakeLockHoldingProgressListener {
+ private static final String WAKE_LOCK_LABEL = "Gallery Album Import";
public ImportCompleteListener(AbstractGalleryActivity galleryActivity) {
- mActivity = galleryActivity;
- PowerManager pm =
- (PowerManager) ((Activity) mActivity).getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "Gallery Album Import");
+ super(galleryActivity, WAKE_LOCK_LABEL);
}
@Override
public void onProgressComplete(int result) {
+ super.onProgressComplete(result);
int message;
if (result == MenuExecutor.EXECUTION_RESULT_SUCCESS) {
message = R.string.import_complete;
@@ -47,31 +41,13 @@ public class ImportCompleteListener implements MenuExecutor.ProgressListener {
} else {
message = R.string.import_fail;
}
- Toast.makeText(mActivity.getAndroidContext(), message, Toast.LENGTH_LONG).show();
- mWakeLock.release();
- }
-
- @Override
- public void onProgressUpdate(int index) {
- }
-
- @Override
- public void onProgressStart() {
- mWakeLock.acquire();
+ Toast.makeText(getActivity().getAndroidContext(), message, Toast.LENGTH_LONG).show();
}
private void goToImportedAlbum() {
String pathOfImportedAlbum = "/local/all/" + MediaSetUtils.IMPORTED_BUCKET_ID;
Bundle data = new Bundle();
data.putString(AlbumPage.KEY_MEDIA_PATH, pathOfImportedAlbum);
- mActivity.getStateManager().startState(AlbumPage.class, data);
- }
-
- @Override
- public void onConfirmDialogDismissed(boolean confirmed) {
- }
-
- @Override
- public void onConfirmDialogShown() {
+ getActivity().getStateManager().startState(AlbumPage.class, data);
}
}
diff --git a/src/com/android/gallery3d/ui/TiledScreenNail.java b/src/com/android/gallery3d/ui/TiledScreenNail.java
index d2b34e3bf..74665f584 100644
--- a/src/com/android/gallery3d/ui/TiledScreenNail.java
+++ b/src/com/android/gallery3d/ui/TiledScreenNail.java
@@ -189,6 +189,10 @@ public class TiledScreenNail implements ScreenNail {
}
public boolean isAnimating() {
+ // The TiledTexture may not be uploaded completely yet.
+ // In that case, we count it as animating state and we will draw
+ // the placeholder in TileImageView.
+ if (mTexture == null || !mTexture.isReady()) return true;
if (mAnimationStartTime < 0) return false;
if (AnimationTime.get() - mAnimationStartTime >= DURATION) {
mAnimationStartTime = ANIMATION_DONE;
diff --git a/src/com/android/gallery3d/ui/TiledTexture.java b/src/com/android/gallery3d/ui/TiledTexture.java
index 22afe310f..8e26221bc 100644
--- a/src/com/android/gallery3d/ui/TiledTexture.java
+++ b/src/com/android/gallery3d/ui/TiledTexture.java
@@ -24,6 +24,7 @@ import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
+import android.os.SystemClock;
import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
@@ -40,6 +41,10 @@ public class TiledTexture implements Texture {
private static final int TILE_SIZE = CONTENT_SIZE + 2 * BORDER_SIZE;
private static final int INIT_CAPACITY = 8;
+ // We are targeting at 60fps, so we have 16ms for each frame.
+ // In this 16ms, we use about 4~8 ms to upload tiles.
+ private static final long UPLOAD_TILE_LIMIT = 4; // ms
+
private static Tile sFreeTileHead = null;
private static final Object sFreeTileLock = new Object();
@@ -79,17 +84,19 @@ public class TiledTexture implements Texture {
mGlRoot.addOnGLIdleListener(this);
}
-
@Override
public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
ArrayDeque<TiledTexture> deque = mTextures;
synchronized (this) {
- if (!deque.isEmpty()) {
+ long now = SystemClock.uptimeMillis();
+ long dueTime = now + UPLOAD_TILE_LIMIT;
+ while(now < dueTime && !deque.isEmpty()) {
TiledTexture t = deque.peekFirst();
if (t.uploadNextTile(canvas)) {
deque.removeFirst();
mGlRoot.requestRender();
}
+ now = SystemClock.uptimeMillis();
}
mIsQueued = !mTextures.isEmpty();
diff --git a/src/com/android/gallery3d/ui/WakeLockHoldingProgressListener.java b/src/com/android/gallery3d/ui/WakeLockHoldingProgressListener.java
new file mode 100644
index 000000000..ee61d8edb
--- /dev/null
+++ b/src/com/android/gallery3d/ui/WakeLockHoldingProgressListener.java
@@ -0,0 +1,66 @@
+/*
+ * 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.ui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.PowerManager;
+
+import com.android.gallery3d.app.AbstractGalleryActivity;
+
+public class WakeLockHoldingProgressListener implements MenuExecutor.ProgressListener {
+ static private final String DEFAULT_WAKE_LOCK_LABEL = "Gallery Progress Listener";
+ private AbstractGalleryActivity mActivity;
+ private PowerManager.WakeLock mWakeLock;
+
+ public WakeLockHoldingProgressListener(AbstractGalleryActivity galleryActivity) {
+ this(galleryActivity, DEFAULT_WAKE_LOCK_LABEL);
+ }
+
+ public WakeLockHoldingProgressListener(AbstractGalleryActivity galleryActivity, String label) {
+ mActivity = galleryActivity;
+ PowerManager pm =
+ (PowerManager) ((Activity) mActivity).getSystemService(Context.POWER_SERVICE);
+ mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, label);
+ }
+
+ @Override
+ public void onProgressComplete(int result) {
+ mWakeLock.release();
+ }
+
+ @Override
+ public void onProgressStart() {
+ mWakeLock.acquire();
+ }
+
+ protected AbstractGalleryActivity getActivity() {
+ return mActivity;
+ }
+
+ @Override
+ public void onProgressUpdate(int index) {
+ }
+
+ @Override
+ public void onConfirmDialogDismissed(boolean confirmed) {
+ }
+
+ @Override
+ public void onConfirmDialogShown() {
+ }
+}