summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2011-11-02 17:51:09 +0800
committerAngus Kong <shkong@google.com>2011-11-03 16:16:00 +0800
commitae557ecc220f9d491e8c65b1c895827fbedcdafe (patch)
tree3b5ca7e246f2e7f92cad43075c2c99d5a8ebdd8f /src/com
parentcd2256375a71ae4c19808d22c313d999cc750d0c (diff)
downloadLegacyCamera-ae557ecc220f9d491e8c65b1c895827fbedcdafe.zip
LegacyCamera-ae557ecc220f9d491e8c65b1c895827fbedcdafe.tar.gz
LegacyCamera-ae557ecc220f9d491e8c65b1c895827fbedcdafe.tar.bz2
The dialog for comfirmation is made rotatable.
bug:5481928 Change-Id: Ic9a34b0f9e8d920afa5aec36561892045480e18c
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/Camera.java13
-rw-r--r--src/com/android/camera/RotateDialogController.java157
-rwxr-xr-xsrc/com/android/camera/panorama/PanoramaActivity.java85
3 files changed, 180 insertions, 75 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 1bd759b..b0f376a 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -63,6 +63,7 @@ import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
+import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
@@ -146,6 +147,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private View mPreviewPanel; // The container of PreviewFrameLayout.
private PreviewFrameLayout mPreviewFrameLayout;
private View mPreviewFrame; // Preview frame area.
+ private RotateDialogController mRotateDialog;
// A popup window that contains a bigger thumbnail and a list of apps to share.
private SharePopup mSharePopup;
@@ -189,7 +191,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
*
* TODO: consider publishing by moving into MediaStore.
*/
- private final static String EXTRA_QUICK_CAPTURE =
+ private static final String EXTRA_QUICK_CAPTURE =
"android.intent.extra.quickCapture";
// The display rotation in degrees. This is only valid when mCameraState is
@@ -1052,6 +1054,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
mThumbnailView.setVisibility(View.VISIBLE);
}
+ mRotateDialog = new RotateDialogController(this, R.layout.rotate_dialog);
+
mPreferences.setLocalId(this, mCameraId);
CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
@@ -1225,7 +1229,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private void setOrientationIndicator(int orientation) {
Rotatable[] indicators = {mThumbnailView, mModePicker, mSharePopup,
mIndicatorControlContainer, mZoomControl, mFocusIndicator, mFaceView,
- mReviewCancelButton, mReviewDoneButton};
+ mReviewCancelButton, mReviewDoneButton, mRotateDialog};
for (Rotatable indicator : indicators) {
if (indicator != null) indicator.setOrientation(orientation);
}
@@ -2161,10 +2165,11 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
restorePreferences();
}
};
- MenuHelper.confirmAction(this,
+ mRotateDialog.showAlertDialog(
getString(R.string.confirm_restore_title),
getString(R.string.confirm_restore_message),
- runnable);
+ getString(android.R.string.ok), runnable,
+ getString(android.R.string.cancel), null);
}
private void restorePreferences() {
diff --git a/src/com/android/camera/RotateDialogController.java b/src/com/android/camera/RotateDialogController.java
new file mode 100644
index 0000000..d91ba13
--- /dev/null
+++ b/src/com/android/camera/RotateDialogController.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2011 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.camera;
+
+import com.android.camera.ui.Rotatable;
+import com.android.camera.ui.RotateLayout;
+
+import android.app.Activity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ProgressBar;
+
+public class RotateDialogController implements Rotatable {
+
+ private static final String TAG = "RotateDialogController";
+ private static final long ANIM_DURATION = 150; // millis
+
+ private Activity mActivity;
+ private int mLayoutResourceID;
+ private View mDialogRootLayout;
+ private RotateLayout mRotateDialog;
+ private View mRotateDialogTitleLayout;
+ private View mRotateDialogButtonLayout;
+ private TextView mRotateDialogTitle;
+ private ProgressBar mRotateDialogSpinner;
+ private TextView mRotateDialogText;
+ private TextView mRotateDialogButton1;
+ private TextView mRotateDialogButton2;
+
+ private Animation mFadeInAnim, mFadeOutAnim;
+
+ public RotateDialogController(Activity a, int layoutResource) {
+ mActivity = a;
+ mLayoutResourceID = layoutResource;
+ }
+
+ private void inflateDialogLayout() {
+ if (mDialogRootLayout == null) {
+ ViewGroup layoutRoot = (ViewGroup) mActivity.getWindow().getDecorView();
+ LayoutInflater inflater = mActivity.getLayoutInflater();
+ View v = inflater.inflate(mLayoutResourceID, layoutRoot);
+ mDialogRootLayout = v.findViewById(R.id.rotate_dialog_root_layout);
+ mRotateDialog = (RotateLayout) v.findViewById(R.id.rotate_dialog_layout);
+ mRotateDialogTitleLayout = v.findViewById(R.id.rotate_dialog_title_layout);
+ mRotateDialogButtonLayout = v.findViewById(R.id.rotate_dialog_button_layout);
+ mRotateDialogTitle = (TextView) v.findViewById(R.id.rotate_dialog_title);
+ mRotateDialogSpinner = (ProgressBar) v.findViewById(R.id.rotate_dialog_spinner);
+ mRotateDialogText = (TextView) v.findViewById(R.id.rotate_dialog_text);
+ mRotateDialogButton1 = (Button) v.findViewById(R.id.rotate_dialog_button1);
+ mRotateDialogButton2 = (Button) v.findViewById(R.id.rotate_dialog_button2);
+
+ mFadeInAnim = AnimationUtils.loadAnimation(
+ mActivity, android.R.anim.fade_in);
+ mFadeOutAnim = AnimationUtils.loadAnimation(
+ mActivity, android.R.anim.fade_out);
+ mFadeInAnim.setDuration(ANIM_DURATION);
+ mFadeOutAnim.setDuration(ANIM_DURATION);
+ }
+ }
+
+ @Override
+ public void setOrientation(int orientation) {
+ inflateDialogLayout();
+ mRotateDialog.setOrientation(orientation);
+ }
+
+ public void resetRotateDialog() {
+ inflateDialogLayout();
+ mRotateDialogTitleLayout.setVisibility(View.GONE);
+ mRotateDialogSpinner.setVisibility(View.GONE);
+ mRotateDialogButton1.setVisibility(View.GONE);
+ mRotateDialogButton2.setVisibility(View.GONE);
+ mRotateDialogButtonLayout.setVisibility(View.GONE);
+ }
+
+ private void fadeOutDialog() {
+ mDialogRootLayout.startAnimation(mFadeOutAnim);
+ mDialogRootLayout.setVisibility(View.GONE);
+ }
+
+ private void fadeInDialog() {
+ mDialogRootLayout.startAnimation(mFadeInAnim);
+ mDialogRootLayout.setVisibility(View.VISIBLE);
+ }
+
+ public void dismissDialog() {
+ if (mDialogRootLayout != null && mDialogRootLayout.getVisibility() != View.GONE) {
+ fadeOutDialog();
+ }
+ }
+
+ public void showAlertDialog(String title, String msg, String button1Text,
+ final Runnable r1, String button2Text, final Runnable r2) {
+ resetRotateDialog();
+
+ mRotateDialogTitle.setText(title);
+ mRotateDialogTitleLayout.setVisibility(View.VISIBLE);
+
+ mRotateDialogText.setText(msg);
+
+ if (button1Text != null) {
+ mRotateDialogButton1.setText(button1Text);
+ mRotateDialogButton1.setVisibility(View.VISIBLE);
+ mRotateDialogButton1.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (r1 != null) r1.run();
+ dismissDialog();
+ }
+ });
+ mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
+ }
+ if (button2Text != null) {
+ mRotateDialogButton2.setText(button2Text);
+ mRotateDialogButton2.setVisibility(View.VISIBLE);
+ mRotateDialogButton2.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (r2 != null) r2.run();
+ dismissDialog();
+ }
+ });
+ mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
+ }
+
+ fadeInDialog();
+ }
+
+ public void showWaitingDialog(String msg) {
+ resetRotateDialog();
+
+ mRotateDialogText.setText(msg);
+ mRotateDialogSpinner.setVisibility(View.VISIBLE);
+
+ fadeInDialog();
+ }
+
+}
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index ab220de..98490e5 100755
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -25,6 +25,7 @@ import com.android.camera.MenuHelper;
import com.android.camera.ModePicker;
import com.android.camera.OnClickAttr;
import com.android.camera.R;
+import com.android.camera.RotateDialogController;
import com.android.camera.ShutterButton;
import com.android.camera.SoundPlayer;
import com.android.camera.Storage;
@@ -35,11 +36,8 @@ import com.android.camera.ui.RotateImageView;
import com.android.camera.ui.RotateLayout;
import com.android.camera.ui.SharePopup;
-import android.app.Dialog;
-import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.res.AssetFileDescriptor;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
@@ -50,7 +48,6 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.graphics.YuvImage;
-import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.hardware.Sensor;
@@ -63,23 +60,18 @@ import android.os.ParcelFileDescriptor;
import android.os.SystemProperties;
import android.util.Log;
import android.view.Gravity;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
-import android.widget.Button;
import android.widget.ImageView;
-import android.widget.ProgressBar;
import android.widget.TextView;
import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
import java.io.File;
import java.util.List;
-import java.util.Vector;
/**
* Activity to handle panorama capturing.
@@ -131,15 +123,6 @@ public class PanoramaActivity extends ActivityBase implements
private ShutterButton mShutterButton;
private Object mWaitObject = new Object();
- private RotateLayout mRotateDialog;
- private View mRotateDialogTitleLayout;
- private View mRotateDialogButtonLayout;
- private TextView mRotateDialogTitle;
- private View mRotateDialogTitleSeperator;
- private ProgressBar mRotateDialogSpinner;
- private TextView mRotateDialogText;
- private TextView mRotateDialogButton;
-
private String mPreparePreviewString;
private String mDialogTitle;
private String mDialogOkString;
@@ -196,6 +179,8 @@ public class PanoramaActivity extends ActivityBase implements
private int mDeviceOrientation;
private int mOrientationCompensation;
+ private RotateDialogController mRotateDialog;
+
private class MosaicJpeg {
public MosaicJpeg(byte[] data, int width, int height) {
this.data = data;
@@ -316,8 +301,14 @@ public class PanoramaActivity extends ActivityBase implements
if (mPausing) {
resetToPreview();
} else {
- showAlertDialog(
- mDialogTitle, mDialogPanoramaFailedString, mDialogOkString);
+ mRotateDialog.showAlertDialog(
+ mDialogTitle, mDialogPanoramaFailedString,
+ mDialogOkString, new Runnable() {
+ @Override
+ public void run() {
+ resetToPreview();
+ }},
+ null, null);
}
break;
case MSG_RESET_TO_PREVIEW:
@@ -334,12 +325,6 @@ public class PanoramaActivity extends ActivityBase implements
};
}
- @OnClickAttr
- public void onAlertDialogButtonClicked(View v) {
- dismissDialog();
- resetToPreview();
- }
-
private void setupCamera() {
openCamera();
Parameters parameters = mCameraDevice.getParameters();
@@ -604,7 +589,7 @@ public class PanoramaActivity extends ActivityBase implements
mSurfaceTexture.setOnFrameAvailableListener(null);
if (!aborted && !mThreadRunning) {
- showWaitingDialog(mPreparePreviewString);
+ mRotateDialog.showWaitingDialog(mPreparePreviewString);
runBackgroundThread(new Thread() {
@Override
public void run() {
@@ -716,14 +701,7 @@ public class PanoramaActivity extends ActivityBase implements
mPanoLayout = findViewById(R.id.pano_layout);
- mRotateDialog = (RotateLayout) findViewById(R.id.rotate_dialog_layout);
- mRotateDialogTitleLayout = findViewById(R.id.rotate_dialog_title_layout);
- mRotateDialogButtonLayout = findViewById(R.id.rotate_dialog_button_layout);
- mRotateDialogTitle = (TextView) findViewById(R.id.rotate_dialog_title);
- mRotateDialogTitleSeperator = (View) findViewById(R.id.rotate_dialog_title_divider);
- mRotateDialogSpinner = (ProgressBar) findViewById(R.id.rotate_dialog_spinner);
- mRotateDialogText = (TextView) findViewById(R.id.rotate_dialog_text);
- mRotateDialogButton = (Button) findViewById(R.id.rotate_dialog_button);
+ mRotateDialog = new RotateDialogController(this, R.layout.rotate_dialog);
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
Rotatable[] rotateLayout = {
@@ -845,41 +823,6 @@ public class PanoramaActivity extends ActivityBase implements
reportProgress();
}
- private void resetRotateDialog() {
- mRotateDialogTitleLayout.setVisibility(View.GONE);
- mRotateDialogSpinner.setVisibility(View.GONE);
- mRotateDialogButtonLayout.setVisibility(View.GONE);
- }
-
- private void dismissDialog() {
- if (mRotateDialog.getVisibility() != View.INVISIBLE) {
- mRotateDialog.setVisibility(View.INVISIBLE);
- }
- }
-
- private void showAlertDialog(String title, String msg, String buttonText) {
- resetRotateDialog();
-
- mRotateDialogTitle.setText(title);
- mRotateDialogTitleLayout.setVisibility(View.VISIBLE);
-
- mRotateDialogText.setText(msg);
-
- mRotateDialogButton.setText(buttonText);
- mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
-
- mRotateDialog.setVisibility(View.VISIBLE);
- }
-
- private void showWaitingDialog(String msg) {
- resetRotateDialog();
-
- mRotateDialogText.setText(msg);
- mRotateDialogSpinner.setVisibility(View.VISIBLE);
-
- mRotateDialog.setVisibility(View.VISIBLE);
- }
-
private void runBackgroundThread(Thread thread) {
mThreadRunning = true;
thread.start();
@@ -887,7 +830,7 @@ public class PanoramaActivity extends ActivityBase implements
private void onBackgroundThreadFinished() {
mThreadRunning = false;
- dismissDialog();
+ mRotateDialog.dismissDialog();
}
private void cancelHighResComputation() {