summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2011-08-21 23:53:28 +0800
committerAngus Kong <shkong@google.com>2011-08-22 22:15:01 +0800
commit5fde6d5259fccaed4bc517697a4930d3b69ae860 (patch)
tree03a7519548d9dc8a07202da19c3e1873ecb43b7a
parentcd5f34c389d0d929687b95885e348d574f574d85 (diff)
downloadLegacyCamera-5fde6d5259fccaed4bc517697a4930d3b69ae860.zip
LegacyCamera-5fde6d5259fccaed4bc517697a4930d3b69ae860.tar.gz
LegacyCamera-5fde6d5259fccaed4bc517697a4930d3b69ae860.tar.bz2
Show spinner dialog when generating mosaic.
bug:5141680 Change-Id: I66aa7530361728549da517b1cad1fea881894b4e
-rw-r--r--res/values/strings.xml6
-rw-r--r--src/com/android/camera/panorama/PanoramaActivity.java38
2 files changed, 34 insertions, 10 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 05a479f..77c5513 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -274,6 +274,12 @@
<!-- The text shown when the panorama panning speed is to fast [CHAR LIMIT=12] -->
<string name="pano_too_fast_prompt">Too Fast</string>
+ <!-- The text shown in the progress dialog when panorama preview is generating in the background [CHAR LIMIT=30] -->
+ <string name="pano_dialog_prepare_preview">Preparing preview...</string>
+
+ <!-- The text shown in the progress dialog when generating the final panorama result in the background [CHAR LIMIT=30] -->
+ <string name="pano_dialog_generate_panorama">Generating panorama...</string>
+
<!-- Toast telling users tapping on the viewfinder will trigger autofocus [CHAR LIMIT=24] -->
<string name="tap_to_focus">Tap to focus</string>
</resources>
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index facf7d9..f58b34d 100644
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -26,6 +26,7 @@ import com.android.camera.Storage;
import com.android.camera.Util;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -91,6 +92,10 @@ public class PanoramaActivity extends Activity implements
private MosaicRendererSurfaceView mMosaicView;
private TextView mTooFastPrompt;
+ private ProgressDialog mProgressDialog;
+ private String mPreparePreviewString;
+ private String mGeneratePanoramaString;
+
private int mPreviewWidth;
private int mPreviewHeight;
private Camera mCameraDevice;
@@ -126,16 +131,21 @@ public class PanoramaActivity extends Activity implements
mTransformMatrix = new float[16];
+ mPreparePreviewString =
+ getResources().getString(R.string.pano_dialog_prepare_preview);
+ mGeneratePanoramaString =
+ getResources().getString(R.string.pano_dialog_generate_panorama);
+
mMainHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_FINAL_MOSAIC_READY:
- mThreadRunning = false;
+ onBackgroundThreadFinished();
showFinalMosaic((Bitmap) msg.obj);
break;
case MSG_RESET_TO_PREVIEW:
- mThreadRunning = false;
+ onBackgroundThreadFinished();
resetToPreview();
break;
}
@@ -349,8 +359,7 @@ public class PanoramaActivity extends Activity implements
// TODO: show some dialog for long computation.
if (!mThreadRunning) {
- mThreadRunning = true;
- Thread t = new Thread() {
+ runBackgroundThread(mPreparePreviewString, new Thread() {
@Override
public void run() {
byte[] jpegData = generateFinalMosaic(false);
@@ -361,8 +370,7 @@ public class PanoramaActivity extends Activity implements
mMainHandler.sendMessage(mMainHandler.obtainMessage(
MSG_FINAL_MOSAIC_READY, bitmap));
}
- };
- t.start();
+ });
}
}
@@ -429,16 +437,26 @@ public class PanoramaActivity extends Activity implements
@OnClickAttr
public void onOkButtonClicked(View v) {
if (mPausing || mThreadRunning || mSurfaceTexture == null) return;
- mThreadRunning = true;
- Thread t = new Thread() {
+ runBackgroundThread(mGeneratePanoramaString, new Thread() {
@Override
public void run() {
byte[] jpegData = generateFinalMosaic(true);
savePanorama(jpegData);
mMainHandler.sendMessage(mMainHandler.obtainMessage(MSG_RESET_TO_PREVIEW));
}
- };
- t.start();
+ });
+ }
+
+ private void runBackgroundThread(String str, Thread thread) {
+ mThreadRunning = true;
+ mProgressDialog = ProgressDialog.show(this, "", str);
+ thread.start();
+ }
+
+ private void onBackgroundThreadFinished() {
+ mThreadRunning = false;
+ mProgressDialog.dismiss();
+ mProgressDialog = null;
}
@OnClickAttr