diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 59 | ||||
-rw-r--r-- | src/com/android/camera/app/CameraAppUI.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/app/FilmstripBottomPanel.java | 30 | ||||
-rw-r--r-- | src/com/android/camera/session/CaptureSession.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/session/CaptureSessionManager.java | 27 | ||||
-rw-r--r-- | src/com/android/camera/session/CaptureSessionManagerImpl.java | 53 | ||||
-rw-r--r-- | src/com/android/camera/ui/BottomBar.java | 6 |
7 files changed, 173 insertions, 22 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index a2cd182de..4308cc8a0 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -384,6 +384,14 @@ public class CameraActivity extends Activity } return intent; } + + @Override + public void onProgressErrorClicked() { + LocalData data = getCurrentLocalData(); + getServices().getCaptureSessionManager().removeErrorMessage( + data.getContentUri()); + updateBottomControlsByData(data); + } }; private ComboPreferences mPreferences; @@ -682,9 +690,14 @@ public class CameraActivity extends Activity CameraAppUI.BottomPanel controls = mCameraAppUI.getFilmstripBottomControls(); controls.setProgressText(message); controls.hideControls(); + controls.hideProgressError(); controls.showProgress(); } + private void showProcessError(CharSequence message) { + mCameraAppUI.getFilmstripBottomControls().showProgressError(message); + } + private void updateSessionProgress(int progress) { mCameraAppUI.getFilmstripBottomControls().setProgress(progress); } @@ -737,23 +750,23 @@ public class CameraActivity extends Activity @Override public void onSessionQueued(final Uri uri) { notifyNewMedia(uri); - int dataID = mDataAdapter.findDataByContentUri(uri); - if (dataID != -1) { + int dataId = mDataAdapter.findDataByContentUri(uri); + if (dataId != -1) { // Don't allow special UI actions (swipe to // delete, for example) on in-progress data. - LocalData d = mDataAdapter.getLocalData(dataID); + LocalData d = mDataAdapter.getLocalData(dataId); InProgressDataWrapper newData = new InProgressDataWrapper(d); - mDataAdapter.updateData(dataID, newData); + mDataAdapter.updateData(dataId, newData); } } @Override public void onSessionDone(final Uri uri) { Log.v(TAG, "onSessionDone:" + uri); - int doneID = mDataAdapter.findDataByContentUri(uri); + int doneId = mDataAdapter.findDataByContentUri(uri); int currentDataId = mFilmstripController.getCurrentId(); - if (currentDataId == doneID) { + if (currentDataId == doneId) { hideSessionProgress(); updateSessionProgress(0); } @@ -780,6 +793,20 @@ public class CameraActivity extends Activity public void onSessionUpdated(Uri uri) { mDataAdapter.refresh(uri, /* isInProgress */true); } + + @Override + public void onSessionFailed(Uri uri, CharSequence reason) { + Log.v(TAG, "onSessionFailed:" + uri); + + int failedDataId = mDataAdapter.findDataByContentUri(uri); + int currentDataId = mFilmstripController.getCurrentId(); + + if (currentDataId == failedDataId) { + updateSessionProgress(0); + showProcessError(reason); + } + mDataAdapter.refresh(uri, /* isInProgress */false); + } }; @Override @@ -2052,15 +2079,21 @@ public class CameraActivity extends Activity Uri contentUri = currentData.getContentUri(); CaptureSessionManager sessionManager = getServices() .getCaptureSessionManager(); - int sessionProgress = sessionManager.getSessionProgress(contentUri); - if (sessionProgress < 0) { - hideSessionProgress(); + if (sessionManager.hasErrorMessage(contentUri)) { + showProcessError(sessionManager.getErrorMesage(contentUri)); } else { - CharSequence progressMessage = sessionManager - .getSessionProgressMessage(contentUri); - showSessionProgress(progressMessage); - updateSessionProgress(sessionProgress); + filmstripBottomPanel.hideProgressError(); + int sessionProgress = sessionManager.getSessionProgress(contentUri); + + if (sessionProgress < 0) { + hideSessionProgress(); + } else { + CharSequence progressMessage = sessionManager + .getSessionProgressMessage(contentUri); + showSessionProgress(progressMessage); + updateSessionProgress(sessionProgress); + } } /* View button */ diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java index 628d75748..7eefcb077 100644 --- a/src/com/android/camera/app/CameraAppUI.java +++ b/src/com/android/camera/app/CameraAppUI.java @@ -162,6 +162,16 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, void setProgress(int progress); /** + * Replaces the progress UI with an error message. + */ + void showProgressError(CharSequence message); + + /** + * Hide the progress error message. + */ + void hideProgressError(); + + /** * Shows the progress. */ void showProgress(); @@ -211,6 +221,11 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, * Called when the "share" button is pressed. */ public void onShare(); + + /** + * Called when the progress error message is clicked. + */ + public void onProgressErrorClicked(); } } diff --git a/src/com/android/camera/app/FilmstripBottomPanel.java b/src/com/android/camera/app/FilmstripBottomPanel.java index 607dda4e2..987ce2a48 100644 --- a/src/com/android/camera/app/FilmstripBottomPanel.java +++ b/src/com/android/camera/app/FilmstripBottomPanel.java @@ -17,12 +17,12 @@ package com.android.camera.app; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.ProgressBar; import android.widget.TextView; -import com.android.camera.util.CameraUtil; import com.android.camera2.R; /** @@ -34,7 +34,7 @@ class FilmstripBottomPanel implements CameraAppUI.BottomPanel { private final AppController mController; private final ViewGroup mLayout; private Listener mListener; - private View mControlLayout; + private final View mControlLayout; private ImageButton mEditButton; private ImageButton mViewButton; private ImageButton mDeleteButton; @@ -42,6 +42,8 @@ class FilmstripBottomPanel implements CameraAppUI.BottomPanel { private final View mMiddleFiller; private View mProgressLayout; private TextView mProgressText; + private View mProgressErrorLayout; + private TextView mProgressErrorText; private ProgressBar mProgressBar; private boolean mTinyPlanetEnabled; @@ -134,8 +136,22 @@ class FilmstripBottomPanel implements CameraAppUI.BottomPanel { } @Override + public void showProgressError(CharSequence message) { + hideControls(); + hideProgress(); + mProgressErrorLayout.setVisibility(View.VISIBLE); + mProgressErrorText.setText(message); + } + + @Override + public void hideProgressError() { + mProgressErrorLayout.setVisibility(View.INVISIBLE); + } + + @Override public void showProgress() { mProgressLayout.setVisibility(View.VISIBLE); + hideProgressError(); } @Override @@ -222,6 +238,16 @@ class FilmstripBottomPanel implements CameraAppUI.BottomPanel { mProgressBar = (ProgressBar) mLayout.findViewById(R.id.bottom_session_progress_bar); mProgressBar.setMax(100); mProgressLayout.setVisibility(View.INVISIBLE); + mProgressErrorText = (TextView) mLayout.findViewById(R.id.bottom_progress_error_text); + mProgressErrorLayout = mLayout.findViewById(R.id.bottom_progress_error_panel); + mProgressErrorLayout.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.onProgressErrorClicked(); + } + } + }); } /** diff --git a/src/com/android/camera/session/CaptureSession.java b/src/com/android/camera/session/CaptureSession.java index 0c683d54d..bc7698bfb 100644 --- a/src/com/android/camera/session/CaptureSession.java +++ b/src/com/android/camera/session/CaptureSession.java @@ -101,6 +101,11 @@ public interface CaptureSession { public void finish(); /** + * Finish the session and indicate it failed. + */ + public void finishWithFailure(CharSequence reason); + + /** * Returns the path to the final output of this session. This is only * available after startSession has been called. */ diff --git a/src/com/android/camera/session/CaptureSessionManager.java b/src/com/android/camera/session/CaptureSessionManager.java index c4663fbf2..877c891c3 100644 --- a/src/com/android/camera/session/CaptureSessionManager.java +++ b/src/com/android/camera/session/CaptureSessionManager.java @@ -48,6 +48,9 @@ public interface CaptureSessionManager { /** Called when the session with the given Uri finished. */ public void onSessionDone(Uri mediaUri); + /** Called when the session with the given Uri failed processing. */ + public void onSessionFailed(Uri mediaUri, CharSequence reason); + /** Called when the session with the given Uri has progressed. */ public void onSessionProgress(Uri mediaUri, int progress); } @@ -75,7 +78,7 @@ public interface CaptureSessionManager { * @param loc the capture location. * @param width the width of the captured image. * @param height the height of the captured image. - * @param orientation the orientatio of the captured image. + * @param orientation the orientation of the captured image. * @param exif the EXIF data of the captured image. * @param listener called when saving is complete. */ @@ -115,9 +118,25 @@ public interface CaptureSessionManager { public CharSequence getSessionProgressMessage(Uri uri); /** - * Gets the directory to be used for temporary data. - * - * See {@link SessionStorageManager#getSessionDirectory(String)} + * Gets the directory to be used for temporary data. See + * {@link SessionStorageManager#getSessionDirectory(String)} */ public File getSessionDirectory(String subDirectory) throws IOException; + + /** + * @return Whether the session with the given URI exists and has an error + * message. + */ + public boolean hasErrorMessage(Uri uri); + + /** + * @return If existant, returns the error message for the session with the + * given URI. + */ + public CharSequence getErrorMesage(Uri uri); + + /** + * Removes any existing error messages for the session with the given URI. + */ + public void removeErrorMessage(Uri uri); } diff --git a/src/com/android/camera/session/CaptureSessionManagerImpl.java b/src/com/android/camera/session/CaptureSessionManagerImpl.java index 5100f2b9d..9277d4409 100644 --- a/src/com/android/camera/session/CaptureSessionManagerImpl.java +++ b/src/com/android/camera/session/CaptureSessionManagerImpl.java @@ -198,6 +198,23 @@ public class CaptureSessionManagerImpl implements CaptureSessionManager { PlaceholderManager.PLACEHOLDER_MIME_TYPE, /* finalImage */ false); notifySessionUpdate(mPlaceHolderSession.outputUri); } + + @Override + public void finishWithFailure(CharSequence reason) { + if (mPlaceHolderSession == null) { + throw new IllegalStateException( + "Cannot call finish without calling startSession first."); + } + mProgressMessage = reason; + + // Change mime type of session so it's not marked as in progress anymore. + mPlaceholderManager.replacePlaceHolder(mPlaceHolderSession, mLocation, + LocalData.MIME_TYPE_JPEG, /* finalImage */false); + mNotificationManager.notifyCompletion(mNotificationId); + removeSession(mUri.toString()); + mFailedSessionMessages.put(mPlaceHolderSession.outputUri, reason); + notifyTaskFailed(mPlaceHolderSession.outputUri, reason); + } } private final MediaSaver mMediaSaver; @@ -206,6 +223,10 @@ public class CaptureSessionManagerImpl implements CaptureSessionManager { private final SessionStorageManager mSessionStorageManager; private final ContentResolver mContentResolver; + /** Failed session messages. Uri -> message. */ + private final HashMap<Uri, CharSequence> mFailedSessionMessages = + new HashMap<Uri, CharSequence>(); + /** * We use this to fire events to the session listeners from the main thread. */ @@ -336,6 +357,23 @@ public class CaptureSessionManagerImpl implements CaptureSessionManager { } /** + * Notifies all task listeners that the task with the given URI has been + * failed to process. + */ + private void notifyTaskFailed(final Uri uri, final CharSequence reason) { + mMainHandler.post(new Runnable() { + @Override + public void run() { + synchronized (mTaskListeners) { + for (SessionListener listener : mTaskListeners) { + listener.onSessionFailed(uri, reason); + } + } + } + }); + } + + /** * Notifies all task listeners that the task with the given URI has * progressed to the given state. */ @@ -368,4 +406,19 @@ public class CaptureSessionManagerImpl implements CaptureSessionManager { } }); } + + @Override + public boolean hasErrorMessage(Uri uri) { + return mFailedSessionMessages.containsKey(uri); + } + + @Override + public CharSequence getErrorMesage(Uri uri) { + return mFailedSessionMessages.get(uri); + } + + @Override + public void removeErrorMessage(Uri uri) { + mFailedSessionMessages.remove(uri); + } } diff --git a/src/com/android/camera/ui/BottomBar.java b/src/com/android/camera/ui/BottomBar.java index 9dd6c868c..a42a87059 100644 --- a/src/com/android/camera/ui/BottomBar.java +++ b/src/com/android/camera/ui/BottomBar.java @@ -21,8 +21,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Canvas; -import android.graphics.Path; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; @@ -329,8 +329,8 @@ public class BottomBar extends FrameLayout mRect.set( 0.0f, 0.0f, - (float) width, - (float) height); + width, + height); mRectPath.reset(); mRectPath.addRect(mRect, Path.Direction.CW); } |