diff options
author | Chung-yih Wang <cywang@google.com> | 2011-08-05 01:14:35 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-05 01:14:35 -0700 |
commit | 0980ef20897b2b83ee1ddce300044c121192f599 (patch) | |
tree | cd0396f2a3d76b94db114627742b66146bf31410 /src/com | |
parent | 141cf9386c6053e655ef054f499230cfafba3ff6 (diff) | |
parent | b5c569214281e11dc7e8ffc313fbb27e5ff6e5c5 (diff) | |
download | LegacyCamera-0980ef20897b2b83ee1ddce300044c121192f599.zip LegacyCamera-0980ef20897b2b83ee1ddce300044c121192f599.tar.gz LegacyCamera-0980ef20897b2b83ee1ddce300044c121192f599.tar.bz2 |
Merge "Add the CameraPicker for PhoneUI."
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/camera/Camera.java | 27 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 29 | ||||
-rw-r--r-- | src/com/android/camera/ui/AbstractIndicatorButton.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControl.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/ui/RotateImageView.java | 7 |
5 files changed, 62 insertions, 3 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 151eecb..2090d30 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -16,6 +16,7 @@ package com.android.camera; +import com.android.camera.ui.CameraPicker; import com.android.camera.ui.FocusRectangle; import com.android.camera.ui.IndicatorControl; import com.android.camera.ui.RotateImageView; @@ -176,6 +177,9 @@ public class Camera extends ActivityBase implements View.OnClickListener, private View mGpsNoSignalView; private View mGpsHasSignalView; + // front/back camera switch. + private CameraPicker mCameraPicker; + /** * An unpublished intent flag requesting to return as soon as capturing * is completed. @@ -586,6 +590,19 @@ public class Camera extends ActivityBase implements View.OnClickListener, } }; + private void initializeCameraPicker() { + mCameraPicker = (CameraPicker) findViewById(R.id.camera_picker); + if (mCameraPicker != null) { + mCameraPicker.setImageResource(R.drawable.camera_toggle); + ListPreference pref = mPreferenceGroup.findPreference( + CameraSettings.KEY_CAMERA_ID); + if (pref != null) { + mCameraPicker.initialize(pref); + mCameraPicker.setListener(new MyCameraPickerListener()); + } + } + } + private void initializeZoomPicker() { View zoomIncrement = findViewById(R.id.zoom_increment); View zoomDecrement = findViewById(R.id.zoom_decrement); @@ -1051,6 +1068,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, // parameters. initializeIndicatorControl(); initializeZoomPicker(); + initializeCameraPicker(); } private void overrideCameraSettings(final String flashMode, @@ -1100,7 +1118,6 @@ public class Camera extends ActivityBase implements View.OnClickListener, } else { SETTING_KEYS = new String[] { CameraSettings.KEY_FLASH_MODE, - CameraSettings.KEY_CAMERA_ID, CameraSettings.KEY_COLOR_EFFECT, CameraSettings.KEY_WHITE_BALANCE}; OTHER_SETTING_KEYS = new String[] { @@ -1124,6 +1141,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, private void enableCameraControls(boolean enable) { if (mIndicatorControl != null) mIndicatorControl.setEnabled(enable); + if (mCameraPicker != null) mCameraPicker.setEnabled(enable); if (mZoomPicker != null) mZoomPicker.setEnabled(enable); if (mModePicker != null) mModePicker.setEnabled(enable); } @@ -1162,6 +1180,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, if (mModePicker != null) mModePicker.setDegree(degree); if (mSharePopup != null) mSharePopup.setOrientation(degree); if (mIndicatorControl != null) mIndicatorControl.setDegree(degree); + if (mCameraPicker != null) mCameraPicker.setDegree(degree); } @Override @@ -2367,4 +2386,10 @@ public class Camera extends ActivityBase implements View.OnClickListener, Camera.this.onOverriddenPreferencesClicked(); } } + + private class MyCameraPickerListener implements CameraPicker.Listener { + public void onSharedPreferenceChanged() { + Camera.this.onSharedPreferenceChanged(); + } + } } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index bcbb68b..b730e0d 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -16,6 +16,7 @@ package com.android.camera; +import com.android.camera.ui.CameraPicker; import com.android.camera.ui.GLRootView; import com.android.camera.ui.IndicatorControl; import com.android.camera.ui.IndicatorWheel; @@ -246,6 +247,9 @@ public class VideoCamera extends ActivityBase private ZoomPicker mZoomPicker; private final ZoomListener mZoomListener = new ZoomListener(); + // front/back camera switch. + private CameraPicker mCameraPicker; + // This Handler is used to post message back onto the main thread of the // application private class MainHandler extends Handler { @@ -456,6 +460,7 @@ public class VideoCamera extends ActivityBase // Initialize after startPreview becuase this need mParameters. initializeIndicatorControl(); initializeZoomPicker(); + initializeCameraPicker(); } private void initializeZoomPicker() { @@ -467,6 +472,19 @@ public class VideoCamera extends ActivityBase } } + private void initializeCameraPicker() { + mCameraPicker = (CameraPicker) findViewById(R.id.camera_picker); + if (mCameraPicker != null) { + mCameraPicker.setImageResource(R.drawable.camera_toggle_video); + ListPreference pref = mPreferenceGroup.findPreference( + CameraSettings.KEY_CAMERA_ID); + if (pref != null) { + mCameraPicker.initialize(pref); + mCameraPicker.setListener(new MyCameraPickerListener()); + } + } + } + private void loadCameraPreferences() { CameraSettings settings = new CameraSettings(this, mParameters, mCameraId, CameraHolder.instance().getCameraInfo()); @@ -483,6 +501,7 @@ public class VideoCamera extends ActivityBase private void enableCameraControls(boolean enable) { if (mIndicatorControl != null) mIndicatorControl.setEnabled(enable); if (mModePicker != null) mModePicker.setEnabled(enable); + if (mCameraPicker != null) mCameraPicker.setEnabled(enable); } private void initializeIndicatorControl() { @@ -501,8 +520,7 @@ public class VideoCamera extends ActivityBase SETTING_KEYS = new String[] { CameraSettings.KEY_WHITE_BALANCE, CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE, - CameraSettings.KEY_VIDEO_QUALITY, - CameraSettings.KEY_CAMERA_ID}; + CameraSettings.KEY_VIDEO_QUALITY}; OTHER_SETTING_KEYS = new String[] { CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL}; } @@ -547,6 +565,7 @@ public class VideoCamera extends ActivityBase if (mModePicker != null) mModePicker.setDegree(degree); if (mSharePopup != null) mSharePopup.setOrientation(degree); if (mIndicatorControl != null) mIndicatorControl.setDegree(degree); + if (mCameraPicker != null) mCameraPicker.setDegree(degree); } private void startPlayVideoActivity() { @@ -1969,4 +1988,10 @@ public class VideoCamera extends ActivityBase setCameraParameters(); } } + + private class MyCameraPickerListener implements CameraPicker.Listener { + public void onSharedPreferenceChanged() { + VideoCamera.this.onSharedPreferenceChanged(); + } + } } diff --git a/src/com/android/camera/ui/AbstractIndicatorButton.java b/src/com/android/camera/ui/AbstractIndicatorButton.java index 07cdf0d..8893aa8 100644 --- a/src/com/android/camera/ui/AbstractIndicatorButton.java +++ b/src/com/android/camera/ui/AbstractIndicatorButton.java @@ -40,6 +40,7 @@ public abstract class AbstractIndicatorButton extends RotateImageView { mFadeOut = AnimationUtils.loadAnimation(mContext, R.anim.shrink_fade_out_from_right); HIGHLIGHT_COLOR = mContext.getResources().getColor(R.color.review_control_pressed_color); DISABLED_COLOR = mContext.getResources().getColor(R.color.icon_disabled_color); + setScaleType(ImageView.ScaleType.CENTER); } // Whether scene mode affects this indicator and it cannot be changed. diff --git a/src/com/android/camera/ui/IndicatorControl.java b/src/com/android/camera/ui/IndicatorControl.java index 5a2a72c..d90768f 100644 --- a/src/com/android/camera/ui/IndicatorControl.java +++ b/src/com/android/camera/ui/IndicatorControl.java @@ -24,6 +24,7 @@ import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import java.util.ArrayList; diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java index 4085bb2..80752a2 100644 --- a/src/com/android/camera/ui/RotateImageView.java +++ b/src/com/android/camera/ui/RotateImageView.java @@ -121,6 +121,13 @@ public class RotateImageView extends ImageView { int height = getHeight() - top - bottom; int saveCount = canvas.getSaveCount(); + + // Scale down the image first if required. + if ((getScaleType() == ImageView.ScaleType.FIT_CENTER) && + ((width < w) || (height < h))) { + float ratio = Math.min((float) width / w, (float) height / h); + canvas.scale(ratio, ratio, width / 2.0f, height / 2.0f); + } canvas.translate(left + width / 2, top + height / 2); canvas.rotate(-mCurrentDegree); canvas.translate(-w / 2, -h / 2); |