summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2011-08-05 01:14:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-05 01:14:35 -0700
commit0980ef20897b2b83ee1ddce300044c121192f599 (patch)
treecd0396f2a3d76b94db114627742b66146bf31410
parent141cf9386c6053e655ef054f499230cfafba3ff6 (diff)
parentb5c569214281e11dc7e8ffc313fbb27e5ff6e5c5 (diff)
downloadLegacyCamera-0980ef20897b2b83ee1ddce300044c121192f599.zip
LegacyCamera-0980ef20897b2b83ee1ddce300044c121192f599.tar.gz
LegacyCamera-0980ef20897b2b83ee1ddce300044c121192f599.tar.bz2
Merge "Add the CameraPicker for PhoneUI."
-rw-r--r--res/layout-w1024dp/camera_control.xml4
-rw-r--r--res/layout-w1024dp/mode_picker.xml4
-rw-r--r--res/layout/camera_control.xml14
-rw-r--r--res/layout/mode_picker.xml4
-rw-r--r--res/layout/review_thumbnail.xml7
-rw-r--r--src/com/android/camera/Camera.java27
-rw-r--r--src/com/android/camera/VideoCamera.java29
-rw-r--r--src/com/android/camera/ui/AbstractIndicatorButton.java1
-rw-r--r--src/com/android/camera/ui/IndicatorControl.java1
-rw-r--r--src/com/android/camera/ui/RotateImageView.java7
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 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);