diff options
author | Chung-yih Wang <cywang@google.com> | 2011-08-04 12:49:18 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2011-08-05 14:59:39 +0800 |
commit | b5c569214281e11dc7e8ffc313fbb27e5ff6e5c5 (patch) | |
tree | 6c58969925574c402bbbe53b818a7105fff3de81 | |
parent | bed7386688cd7810cba23732ab71f370fe3222ff (diff) | |
download | LegacyCamera-b5c569214281e11dc7e8ffc313fbb27e5ff6e5c5.zip LegacyCamera-b5c569214281e11dc7e8ffc313fbb27e5ff6e5c5.tar.gz LegacyCamera-b5c569214281e11dc7e8ffc313fbb27e5ff6e5c5.tar.bz2 |
Add the CameraPicker for PhoneUI.
+recover the removed CameraPicker.
Change-Id: I5e45c4f73ce7c082cf420d27a86b922283a83bcc
-rw-r--r-- | res/layout-w1024dp/camera_control.xml | 4 | ||||
-rw-r--r-- | res/layout-w1024dp/mode_picker.xml | 4 | ||||
-rw-r--r-- | res/layout/camera_control.xml | 14 | ||||
-rw-r--r-- | res/layout/mode_picker.xml | 4 | ||||
-rw-r--r-- | res/layout/review_thumbnail.xml | 7 | ||||
-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 |
10 files changed, 86 insertions, 12 deletions
diff --git a/res/layout-w1024dp/camera_control.xml b/res/layout-w1024dp/camera_control.xml index b86d593..ca70b44 100644 --- a/res/layout-w1024dp/camera_control.xml +++ b/res/layout-w1024dp/camera_control.xml @@ -54,6 +54,10 @@ android:src="@drawable/btn_zoom_out" android:visibility="gone" /> + <com.android.camera.ui.CameraPicker android:id="@+id/camera_picker" + android:clickable="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> </com.android.camera.ui.IndicatorWheel> <include layout="@layout/mode_picker"/> diff --git a/res/layout-w1024dp/mode_picker.xml b/res/layout-w1024dp/mode_picker.xml index 90cc008..1ee6226 100644 --- a/res/layout-w1024dp/mode_picker.xml +++ b/res/layout-w1024dp/mode_picker.xml @@ -26,6 +26,7 @@ android:layout_alignParentRight="true" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:background="@drawable/btn_mode_background" android:src="@drawable/btn_ic_camera" /> <LinearLayout android:id="@+id/mode_selection" @@ -40,14 +41,17 @@ <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:src="@drawable/btn_ic_panorama" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_video" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:src="@drawable/btn_ic_video" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_camera" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:src="@drawable/btn_ic_camera" /> </LinearLayout> </com.android.camera.ModePicker> diff --git a/res/layout/camera_control.xml b/res/layout/camera_control.xml index ef16dd7..2185c32 100644 --- a/res/layout/camera_control.xml +++ b/res/layout/camera_control.xml @@ -19,12 +19,20 @@ android:layout_alignParentRight="true" android:layout_height="match_parent" android:layout_width="76dp" - android:orientation="vertical" - android:paddingTop="24dp" - android:paddingBottom="3dp"> + android:orientation="vertical"> <include layout="@layout/review_thumbnail"/> + <com.android.camera.ui.CameraPicker android:id="@+id/camera_picker" + android:clickable="true" + android:layout_centerVertical="true" + android:layout_centerHorizontal="true" + android:layout_below="@+id/share_button" + android:layout_above="@+id/shutter_button" + android:layout_width="36dp" + android:layout_height="36dp" /> + <!-- need fixed size of the view since the source icon(HDPI) will be too large for phones --> + <com.android.camera.ShutterButton android:id="@+id/shutter_button" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/res/layout/mode_picker.xml b/res/layout/mode_picker.xml index f9f8530..abbdf76 100644 --- a/res/layout/mode_picker.xml +++ b/res/layout/mode_picker.xml @@ -24,6 +24,7 @@ android:layout_alignParentBottom="true" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:background="@drawable/btn_mode_background" android:src="@drawable/btn_ic_camera" /> <LinearLayout android:id="@+id/mode_selection" @@ -37,14 +38,17 @@ <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:src="@drawable/btn_ic_panorama" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_video" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:src="@drawable/btn_ic_video" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_camera" android:layout_height="62dp" android:layout_width="62dp" + android:scaleType="center" android:src="@drawable/btn_ic_camera" /> </LinearLayout> </com.android.camera.ModePicker> diff --git a/res/layout/review_thumbnail.xml b/res/layout/review_thumbnail.xml index f94a186..ef5e821 100644 --- a/res/layout/review_thumbnail.xml +++ b/res/layout/review_thumbnail.xml @@ -27,9 +27,4 @@ <com.android.camera.ui.RotateImageView android:id="@+id/thumbnail" android:layout_width="52dp" android:layout_height="52dp"/> - <com.android.camera.ui.RotateImageView android:id="@+id/share_icon" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:src="@drawable/ic_viewfinder_share" - android:background="@android:color/black" /> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index a89c676..b5dab84 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.GLRootView; import com.android.camera.ui.IndicatorControl; @@ -181,6 +182,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. @@ -566,6 +570,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); @@ -1031,6 +1048,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, // parameters. initializeIndicatorControl(); initializeZoomPicker(); + initializeCameraPicker(); } private void overrideCameraSettings(final String flashMode, @@ -1080,7 +1098,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[] { @@ -1104,6 +1121,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); } @@ -1142,6 +1160,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 @@ -2345,4 +2364,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 54871f2..688a65a 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() { @@ -1968,4 +1987,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 414ec4e..ed963ab 100644 --- a/src/com/android/camera/ui/AbstractIndicatorButton.java +++ b/src/com/android/camera/ui/AbstractIndicatorButton.java @@ -41,6 +41,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 2791c20..a408595 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); |