summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2011-08-31 20:43:58 +0800
committerAngus Kong <shkong@google.com>2011-09-01 14:45:36 +0800
commit22d4b7fbace56c03092eb088a4df98e04a6681af (patch)
tree591967cfedf04f4174a308087d28787cbe379097 /src
parentb69aa1513070fc9b799c48a9257fddbc04ace7dd (diff)
downloadpackages_apps_LegacyCamera-22d4b7fbace56c03092eb088a4df98e04a6681af.zip
packages_apps_LegacyCamera-22d4b7fbace56c03092eb088a4df98e04a6681af.tar.gz
packages_apps_LegacyCamera-22d4b7fbace56c03092eb088a4df98e04a6681af.tar.bz2
Fix NPE 5238952 when generating panorama fails.
1. Handle the situation of failing to generate the panorama. 2. The string id "details_ok" is changed to "dialog_ok" and used now in the "Ok" button of all the dialogs. bug:5238952 Change-Id: I847255a46667960e604892ad55a642358c4eab02
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Util.java2
-rw-r--r--src/com/android/camera/panorama/PanoramaActivity.java48
2 files changed, 39 insertions, 11 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 948b3eb..848c2c8 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -261,7 +261,7 @@ public class Util {
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.camera_error_title)
.setMessage(msgId)
- .setNeutralButton(R.string.details_ok, buttonListener)
+ .setNeutralButton(R.string.dialog_ok, buttonListener)
.show();
}
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index d4f05f4..b6246ee 100644
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -31,8 +31,10 @@ import com.android.camera.ui.RotateImageView;
import com.android.camera.ui.SharePopup;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ImageFormat;
@@ -77,6 +79,8 @@ public class PanoramaActivity extends Activity implements
private static final int MSG_FINAL_MOSAIC_READY = 1;
private static final int MSG_RESET_TO_PREVIEW_WITH_THUMBNAIL = 2;
+ private static final int MSG_GENERATE_FINAL_MOSAIC_ERROR = 3;
+ private static final int MSG_DISMISS_ALERT_DIALOG_AND_RESET_TO_PREVIEW = 4;
private static final String TAG = "PanoramaActivity";
private static final int PREVIEW_STOPPED = 0;
@@ -106,6 +110,9 @@ public class PanoramaActivity extends Activity implements
private ProgressDialog mProgressDialog;
private String mPreparePreviewString;
private String mGeneratePanoramaString;
+ private String mDialogTitle;
+ private String mDialogOk;
+ private AlertDialog mAlertDialog;
private RotateImageView mThumbnailView;
private Thumbnail mThumbnail;
@@ -162,6 +169,8 @@ public class PanoramaActivity extends Activity implements
getResources().getString(R.string.pano_dialog_prepare_preview);
mGeneratePanoramaString =
getResources().getString(R.string.pano_dialog_generate_panorama);
+ mDialogTitle = getResources().getString(R.string.pano_dialog_title);
+ mDialogOk = getResources().getString(R.string.dialog_ok);
Context context = getApplicationContext();
mSlideIn = AnimationUtils.loadAnimation(context, R.anim.slide_in_from_right);
@@ -184,6 +193,21 @@ public class PanoramaActivity extends Activity implements
}
resetToPreview();
break;
+ case MSG_GENERATE_FINAL_MOSAIC_ERROR:
+ onBackgroundThreadFinished();
+ mAlertDialog = (new AlertDialog.Builder(PanoramaActivity.this))
+ .setTitle(mDialogTitle)
+ .setMessage(R.string.pano_dialog_panorama_failed)
+ .create();
+ mAlertDialog.setButton(DialogInterface.BUTTON_POSITIVE, mDialogOk,
+ obtainMessage(MSG_DISMISS_ALERT_DIALOG_AND_RESET_TO_PREVIEW));
+ mAlertDialog.show();
+ break;
+ case MSG_DISMISS_ALERT_DIALOG_AND_RESET_TO_PREVIEW:
+ mAlertDialog.dismiss();
+ mAlertDialog = null;
+ resetToPreview();
+ break;
}
clearMosaicFrameProcessorIfNeeded();
}
@@ -509,17 +533,21 @@ public class PanoramaActivity extends Activity implements
@Override
public void run() {
MosaicJpeg jpeg = generateFinalMosaic(true);
- int orientation = Exif.getOrientation(jpeg.data);
- Uri uri = savePanorama(jpeg.data, orientation);
- if (uri != null) {
- // Create a thumbnail whose width is equal or bigger than the entire screen.
- int ratio = (int) Math.ceil((double) jpeg.width / mPanoLayout.getWidth());
- int inSampleSize = Integer.highestOneBit(ratio);
- mThumbnail = Thumbnail.createThumbnail(
- jpeg.data, orientation, inSampleSize, uri);
+ if (jpeg == null) {
+ mMainHandler.sendEmptyMessage(MSG_GENERATE_FINAL_MOSAIC_ERROR);
+ } else {
+ int orientation = Exif.getOrientation(jpeg.data);
+ Uri uri = savePanorama(jpeg.data, orientation);
+ if (uri != null) {
+ // Create a thumbnail whose width is equal or bigger than the entire screen.
+ int ratio = (int) Math.ceil((double) jpeg.width / mPanoLayout.getWidth());
+ int inSampleSize = Integer.highestOneBit(ratio);
+ mThumbnail = Thumbnail.createThumbnail(
+ jpeg.data, orientation, inSampleSize, uri);
+ }
+ mMainHandler.sendMessage(
+ mMainHandler.obtainMessage(MSG_RESET_TO_PREVIEW_WITH_THUMBNAIL));
}
- mMainHandler.sendMessage(
- mMainHandler.obtainMessage(MSG_RESET_TO_PREVIEW_WITH_THUMBNAIL));
}
});
reportProgress(true);