summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/PhotoMenu.java14
-rw-r--r--src/com/android/camera/PhotoModule.java43
-rw-r--r--src/com/android/camera/PhotoUI.java11
-rw-r--r--src/com/android/camera/VideoModule.java5
-rw-r--r--src/com/android/camera/util/CameraUtil.java14
5 files changed, 54 insertions, 33 deletions
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index b7c126f36..d10a679b3 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -684,8 +684,11 @@ public class PhotoMenu extends MenuController
@Override
public void onClick(View v) {
addSceneMode();
- View view = mUI.getPreviewMenuLayout().getChildAt(0);
- animateSlideIn(view, previewMenuSize, false);
+ ViewGroup menuLayout = mUI.getPreviewMenuLayout();
+ if (menuLayout != null) {
+ View view = menuLayout.getChildAt(0);
+ animateSlideIn(view, previewMenuSize, false);
+ }
}
});
}
@@ -833,8 +836,11 @@ public class PhotoMenu extends MenuController
@Override
public void onClick(View v) {
addFilterMode();
- View view = mUI.getPreviewMenuLayout().getChildAt(0);
- animateSlideIn(view, previewMenuSize, false);
+ ViewGroup menuLayout = mUI.getPreviewMenuLayout();
+ if (menuLayout != null) {
+ View view = mUI.getPreviewMenuLayout().getChildAt(0);
+ animateSlideIn(view, previewMenuSize, false);
+ }
}
});
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 0e97889f5..10f8f622a 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -364,6 +364,7 @@ public class PhotoModule
private boolean mAnimateCapture = true;
private int mJpegFileSizeEstimation = 0;
+ private int mRemainingPhotos = -1;
private MediaSaveService.OnMediaSavedListener mOnMediaSavedListener =
new MediaSaveService.OnMediaSavedListener() {
@@ -1375,7 +1376,7 @@ public class PhotoModule
// the mean time and fill it, but that could have happened between the
// shutter press and saving the JPEG too.
mActivity.updateStorageSpaceAndHint();
- updateRemainingPhotos();
+ mUI.updateRemainingPhotos(--mRemainingPhotos);
long now = System.currentTimeMillis();
mJpegCallbackFinishTime = now - mJpegPictureCallbackTime;
Log.v(TAG, "mJpegCallbackFinishTime = "
@@ -2120,10 +2121,12 @@ public class PhotoModule
}
//Need to disable focus for ZSL mode
- if(mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
- mFocusManager.setZslEnable(true);
- } else {
- mFocusManager.setZslEnable(false);
+ if (mFocusManager != null) {
+ if (mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
+ mFocusManager.setZslEnable(true);
+ } else {
+ mFocusManager.setZslEnable(false);
+ }
}
// If the user wants to do a snapshot while the previous one is still
@@ -2131,7 +2134,8 @@ public class PhotoModule
// one and re-start the preview. Snapshot in progress also includes the
// state that autofocus is focusing and a picture will be taken when
// focus callback arrives.
- if ((mFocusManager.isFocusingSnapOnFinish() || mCameraState == SNAPSHOT_IN_PROGRESS)
+ if ((((mFocusManager != null) && mFocusManager.isFocusingSnapOnFinish())
+ || mCameraState == SNAPSHOT_IN_PROGRESS)
&& !mIsImageCaptureIntent) {
mSnapshotOnIdle = true;
return;
@@ -2263,11 +2267,12 @@ public class PhotoModule
private void updateRemainingPhotos() {
if (mJpegFileSizeEstimation != 0) {
- mUI.updateRemainingPhotos((int) (mActivity.getStorageSpaceBytes()
- / mJpegFileSizeEstimation));
+ mRemainingPhotos = (int) (mActivity.getStorageSpaceBytes()
+ / mJpegFileSizeEstimation);
} else {
- mUI.updateRemainingPhotos(-1);
+ mRemainingPhotos = -1;
}
+ mUI.updateRemainingPhotos(mRemainingPhotos);
}
private void onResumeTasks() {
@@ -2867,7 +2872,11 @@ public class PhotoModule
//mUnsupportedJpegQuality = true;
}else {
mParameters.setJpegQuality(JpegEncodingQualityMappings.getQualityNumber(jpegQuality));
- setJpegFileSizeEstimation(pic_size, jpegQuality);
+ int jpegFileSize = estimateJpegFileSize(pic_size, jpegQuality);
+ if (jpegFileSize != mJpegFileSizeEstimation) {
+ mJpegFileSizeEstimation = jpegFileSize;
+ updateRemainingPhotos();
+ }
}
}
@@ -3265,7 +3274,7 @@ public class PhotoModule
}
}
- private void setJpegFileSizeEstimation(final Size size, final String quality) {
+ private int estimateJpegFileSize(final Size size, final String quality) {
int[] ratios = mActivity.getResources().getIntArray(R.array.jpegquality_compression_ratio);
String[] qualities = mActivity.getResources().getStringArray(
R.array.pref_camera_jpegquality_entryvalues);
@@ -3278,9 +3287,9 @@ public class PhotoModule
}
if (ratio == 0) {
- mJpegFileSizeEstimation = 0;
+ return 0;
} else {
- mJpegFileSizeEstimation = size.width * size.height * 3 / ratio;
+ return size.width * size.height * 3 / ratio;
}
}
@@ -4158,6 +4167,12 @@ public class PhotoModule
return;
}
+ if (CameraSettings.KEY_CAMERA_SAVEPATH.equals(pref.getKey())) {
+ Storage.setSaveSDCard(
+ mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
+ mActivity.updateStorageSpaceAndHint();
+ }
+
//call generic onSharedPreferenceChanged
onSharedPreferenceChanged();
}
@@ -4205,8 +4220,6 @@ public class PhotoModule
disableSkinToneSeekBar();
}
}
- Storage.setSaveSDCard(
- mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
}
@Override
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 86be3165d..d4cec7bc0 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -557,7 +557,9 @@ public class PhotoUI implements PieListener,
mMenuButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- mMenu.openFirstLevel();
+ if(mMenu != null){
+ mMenu.openFirstLevel();
+ }
}
});
if (mController.isImageCaptureIntent()) {
@@ -921,8 +923,11 @@ public class PhotoUI implements PieListener,
}
public boolean sendTouchToMenu(MotionEvent ev) {
- View v = mMenuLayout.getChildAt(0);
- return v.dispatchTouchEvent(ev);
+ if (mMenuLayout != null) {
+ View v = mMenuLayout.getChildAt(0);
+ return v.dispatchTouchEvent(ev);
+ }
+ return false;
}
public void dismissSceneModeMenu() {
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index f5849d18b..59874dd81 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -2276,6 +2276,11 @@ public class VideoModule implements CameraModule,
mParameters.setVideoRotation(videoRotation);
}
+ //set low-power mode if supported
+ String lpmSupported = mParameters.get("low-power-mode-supported");
+ if ("true".equals(lpmSupported)) {
+ mParameters.set("low-power-mode", 1);
+ }
}
@SuppressWarnings("deprecation")
private void setCameraParameters() {
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 08ce84d87..dbd2cc36d 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -1073,18 +1073,10 @@ public class CameraUtil {
}
public static int determineRatio(int width, int height) {
- int s = width, l = height;
- if (width > height) {
- l = width;
- s = height;
- }
- if (l * 3 == s * 4) {
- return RATIO_4_3;
- } else if (l * 9 == s * 16) {
- return RATIO_16_9;
- } else {
- return RATIO_UNKNOWN;
+ if (height != 0) {
+ return determineRatio(((float) width) / height);
}
+ return RATIO_UNKNOWN;
}
public static int determineRatio(float ratio) {