summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/ic_zoom_big.9.pngbin344 -> 206 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_in_holo_light.pngbin542 -> 515 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_out_holo_light.pngbin404 -> 379 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_slider.pngbin1489 -> 2110 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_big.9.pngbin208 -> 173 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_in_holo_light.pngbin450 -> 465 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_out_holo_light.pngbin381 -> 366 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_slider.pngbin946 -> 1319 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.pngbin0 -> 657 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.pngbin0 -> 450 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.pngbin0 -> 545 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.pngbin0 -> 434 bytes
-rw-r--r--res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.pngbin0 -> 492 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_big.9.pngbin441 -> 211 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_in_holo_light.pngbin583 -> 580 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_out_holo_light.pngbin414 -> 411 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_slider.pngbin1996 -> 2879 bytes
-rw-r--r--res/layout/indicator_bar.xml15
-rw-r--r--src/com/android/camera/Camera.java6
-rw-r--r--src/com/android/camera/VideoCamera.java5
-rw-r--r--src/com/android/camera/ui/IndicatorControl.java2
-rw-r--r--src/com/android/camera/ui/IndicatorControlBar.java48
-rw-r--r--src/com/android/camera/ui/IndicatorControlBarContainer.java32
-rw-r--r--src/com/android/camera/ui/IndicatorControlContainer.java3
-rw-r--r--src/com/android/camera/ui/IndicatorControlWheel.java6
-rw-r--r--src/com/android/camera/ui/IndicatorControlWheelContainer.java7
-rw-r--r--src/com/android/camera/ui/SecondLevelIndicatorControlBar.java2
-rw-r--r--src/com/android/camera/ui/ZoomControl.java92
-rw-r--r--src/com/android/camera/ui/ZoomControlBar.java61
-rw-r--r--src/com/android/camera/ui/ZoomControlWheel.java14
30 files changed, 156 insertions, 137 deletions
diff --git a/res/drawable-hdpi/ic_zoom_big.9.png b/res/drawable-hdpi/ic_zoom_big.9.png
index b960a50..cc40dec 100644
--- a/res/drawable-hdpi/ic_zoom_big.9.png
+++ b/res/drawable-hdpi/ic_zoom_big.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_in_holo_light.png b/res/drawable-hdpi/ic_zoom_in_holo_light.png
index df1e925..89b5f15 100644
--- a/res/drawable-hdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-hdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_out_holo_light.png b/res/drawable-hdpi/ic_zoom_out_holo_light.png
index 5ce6c42..f4a2589 100644
--- a/res/drawable-hdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-hdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_slider.png b/res/drawable-hdpi/ic_zoom_slider.png
index 606fc30..8427e4d 100644
--- a/res/drawable-hdpi/ic_zoom_slider.png
+++ b/res/drawable-hdpi/ic_zoom_slider.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_big.9.png b/res/drawable-mdpi/ic_zoom_big.9.png
index 35d4683..9c2019c 100644
--- a/res/drawable-mdpi/ic_zoom_big.9.png
+++ b/res/drawable-mdpi/ic_zoom_big.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_in_holo_light.png b/res/drawable-mdpi/ic_zoom_in_holo_light.png
index 0d22534..4f33278 100644
--- a/res/drawable-mdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-mdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_out_holo_light.png b/res/drawable-mdpi/ic_zoom_out_holo_light.png
index 9cb7c3d..2631894 100644
--- a/res/drawable-mdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-mdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_slider.png b/res/drawable-mdpi/ic_zoom_slider.png
index 359dae2..16aacf1 100644
--- a/res/drawable-mdpi/ic_zoom_slider.png
+++ b/res/drawable-mdpi/ic_zoom_slider.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png b/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png
new file mode 100644
index 0000000..99d5ef4
--- /dev/null
+++ b/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png b/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png
new file mode 100644
index 0000000..5fa4c95
--- /dev/null
+++ b/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png b/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png
new file mode 100644
index 0000000..fd35207
--- /dev/null
+++ b/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png b/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png
new file mode 100644
index 0000000..e282872
--- /dev/null
+++ b/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png b/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png
new file mode 100644
index 0000000..34064d7
--- /dev/null
+++ b/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_big.9.png b/res/drawable-xhdpi/ic_zoom_big.9.png
index 42fbb32..1e27378 100644
--- a/res/drawable-xhdpi/ic_zoom_big.9.png
+++ b/res/drawable-xhdpi/ic_zoom_big.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_in_holo_light.png b/res/drawable-xhdpi/ic_zoom_in_holo_light.png
index 07ba15f..78178cd 100644
--- a/res/drawable-xhdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-xhdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_out_holo_light.png b/res/drawable-xhdpi/ic_zoom_out_holo_light.png
index f6a5d3a..426aac8 100644
--- a/res/drawable-xhdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-xhdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_slider.png b/res/drawable-xhdpi/ic_zoom_slider.png
index 441220c..9501f92 100644
--- a/res/drawable-xhdpi/ic_zoom_slider.png
+++ b/res/drawable-xhdpi/ic_zoom_slider.png
Binary files differ
diff --git a/res/layout/indicator_bar.xml b/res/layout/indicator_bar.xml
index 0422e68..c39fb93 100644
--- a/res/layout/indicator_bar.xml
+++ b/res/layout/indicator_bar.xml
@@ -45,12 +45,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true">
- <com.android.camera.ui.ColorFilterImageView
- android:id="@+id/zoom_control_icon"
+ <com.android.camera.ui.ZoomControlBar
+ android:id="@+id/zoom_control"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:src="@drawable/btn_zoom_control"
+ android:layout_height="match_parent"
+ android:layout_centerHorizontal="true"
android:visibility="gone" />
<com.android.camera.ui.RotateImageView
android:id="@+id/second_level_indicator_bar_icon"
@@ -60,12 +59,6 @@
android:src="@drawable/ic_settings_holo_light" />
</com.android.camera.ui.IndicatorControlBar>
- <com.android.camera.ui.ZoomControlBar
- android:id="@+id/zoom_control"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerHorizontal="true"
- android:visibility="gone" />
<com.android.camera.ui.SecondLevelIndicatorControlBar
android:id="@+id/second_level_indicator_bar"
android:padding="8dp"
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 5c645a4..1274a72 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -460,7 +460,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private void initializeZoom() {
if (!mParameters.isZoomSupported()) return;
mZoomMax = mParameters.getMaxZoom();
- mSmoothZoomSupported = mParameters.isSmoothZoomSupported();
+ // Currently we use immediate zoom for fast zooming to get better UX and
+ // there is no plan to take advantage of the smooth zoom.
mZoomControl.setZoomMax(mZoomMax);
mZoomControl.setZoomIndex(mParameters.getZoom());
mZoomControl.setSmoothZoomSupported(mSmoothZoomSupported);
@@ -938,6 +939,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
if (mIndicatorControlContainer == null) return;
loadCameraPreferences();
final String[] SETTING_KEYS = {
+ CameraSettings.KEY_FLASH_MODE,
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_SCENE_MODE};
final String[] OTHER_SETTING_KEYS = {
@@ -948,7 +950,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
CameraPicker.setImageResourceId(R.drawable.ic_switch_photo_facing_holo_light);
mIndicatorControlContainer.initialize(this, mPreferenceGroup,
- CameraSettings.KEY_FLASH_MODE, mParameters.isZoomSupported(),
+ mParameters.isZoomSupported(),
SETTING_KEYS, OTHER_SETTING_KEYS);
mIndicatorControlContainer.setListener(this);
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index e9c3133..f100d28 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -469,6 +469,7 @@ public class VideoCamera extends ActivityBase
loadCameraPreferences();
final String[] SETTING_KEYS = {
+ CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
CameraSettings.KEY_VIDEO_EFFECT,
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_VIDEO_QUALITY};
@@ -477,7 +478,6 @@ public class VideoCamera extends ActivityBase
CameraPicker.setImageResourceId(R.drawable.ic_switch_video_facing_holo_light);
mIndicatorControlContainer.initialize(this, mPreferenceGroup,
- CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
mParameters.isZoomSupported(), SETTING_KEYS, OTHER_SETTING_KEYS);
mIndicatorControlContainer.setListener(this);
mPopupGestureDetector = new GestureDetector(this,
@@ -2108,7 +2108,8 @@ public class VideoCamera extends ActivityBase
if (!mParameters.isZoomSupported()) return;
mZoomMax = mParameters.getMaxZoom();
- mSmoothZoomSupported = mParameters.isSmoothZoomSupported();
+ // Currently we use immediate zoom for fast zooming to get better UX and
+ // there is no plan to take advantage of the smooth zoom.
mZoomControl.setZoomMax(mZoomMax);
mZoomControl.setZoomIndex(mParameters.getZoom());
mZoomControl.setSmoothZoomSupported(mSmoothZoomSupported);
diff --git a/src/com/android/camera/ui/IndicatorControl.java b/src/com/android/camera/ui/IndicatorControl.java
index 78d51c1..4bc5d29 100644
--- a/src/com/android/camera/ui/IndicatorControl.java
+++ b/src/com/android/camera/ui/IndicatorControl.java
@@ -70,6 +70,8 @@ public abstract class IndicatorControl extends RelativeLayout implements
View view = getChildAt(i);
if (view instanceof RotateImageView) {
((RotateImageView) view).setDegree(degree);
+ } else if (view instanceof ZoomControl) {
+ ((ZoomControl) view).setDegree(degree);
}
}
}
diff --git a/src/com/android/camera/ui/IndicatorControlBar.java b/src/com/android/camera/ui/IndicatorControlBar.java
index c1e6607..4297528 100644
--- a/src/com/android/camera/ui/IndicatorControlBar.java
+++ b/src/com/android/camera/ui/IndicatorControlBar.java
@@ -30,7 +30,7 @@ import android.widget.ImageView;
* A view that contains the top-level indicator control.
*/
public class IndicatorControlBar extends IndicatorControl implements
- View.OnClickListener, View.OnTouchListener {
+ View.OnClickListener {
private static final String TAG = "IndicatorControlBar";
// Space between indicator icons.
@@ -38,6 +38,7 @@ public class IndicatorControlBar extends IndicatorControl implements
private ImageView mZoomIcon;
private ImageView mSecondLevelIcon;
+ private ZoomControlBar mZoomControl;
public IndicatorControlBar(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -45,27 +46,23 @@ public class IndicatorControlBar extends IndicatorControl implements
@Override
protected void onFinishInflate() {
- mZoomIcon = (ImageView) findViewById(R.id.zoom_control_icon);
mSecondLevelIcon = (ImageView)
findViewById(R.id.second_level_indicator_bar_icon);
mSecondLevelIcon.setOnClickListener(this);
}
public void initialize(Context context, PreferenceGroup group,
- String flashSetting, boolean zoomSupported) {
- // From UI spec, we have camera_flash setting on the first level.
+ boolean zoomSupported) {
setPreferenceGroup(group);
- addControls(new String[] {flashSetting}, null);
// Add CameraPicker control.
initializeCameraPicker();
- // add Zoom Icon.
+ // Add the ZoomControl if supported.
if (zoomSupported) {
- mZoomIcon.setOnTouchListener(this);
- mZoomIcon.setVisibility(View.VISIBLE);
+ mZoomControl = (ZoomControlBar) findViewById(R.id.zoom_control);
+ mZoomControl.setVisibility(View.VISIBLE);
}
-
requestLayout();
}
@@ -76,15 +73,6 @@ public class IndicatorControlBar extends IndicatorControl implements
return true;
}
- public boolean onTouch(View v, MotionEvent event) {
- dismissSettingPopup();
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- mOnIndicatorEventListener.onIndicatorEvent(
- OnIndicatorEventListener.EVENT_ENTER_ZOOM_CONTROL);
- }
- return true;
- }
-
public void onClick(View view) {
dismissSettingPopup();
// Only for the click on mSecondLevelIcon.
@@ -96,21 +84,25 @@ public class IndicatorControlBar extends IndicatorControl implements
protected void onLayout(
boolean changed, int left, int top, int right, int bottom) {
// Layout the static components.
+ int padding = getPaddingTop();
super.onLayout(changed, left, top, right, bottom);
int count = getChildCount();
if (count == 0) return;
int width = right - left;
- int offset = 0;
-
- for (int i = 0 ; i < count ; i++) {
- View view = getChildAt(i);
- if (view instanceof IndicatorButton) {
- view.layout(0, offset, width, offset + width);
- offset += (width + ICON_SPACING);
- }
+
+ // First indicator will be CameraPicker if exists.
+ if (mCameraPicker != null) {
+ mCameraPicker.layout(0, padding, width, padding + width);
}
- if (mCameraPicker != null) mCameraPicker.layout(0, offset, width, offset + width);
+
+ // Layout the zoom control if required.
+ int offset = padding + width; // the padding and the icon height
+ if (mZoomControl != null) {
+ mZoomControl.layout(0, offset, width, bottom - top - offset);
+ }
+
+ mSecondLevelIcon.layout(0, bottom - top - offset, width, bottom - top);
}
@Override
@@ -126,6 +118,6 @@ public class IndicatorControlBar extends IndicatorControl implements
}
public void enableZoom(boolean enabled) {
- if (mZoomIcon != null) mZoomIcon.setEnabled(enabled);
+ if (mZoomControl != null) mZoomControl.setEnabled(enabled);
}
}
diff --git a/src/com/android/camera/ui/IndicatorControlBarContainer.java b/src/com/android/camera/ui/IndicatorControlBarContainer.java
index 60eb6b2..9c01e01 100644
--- a/src/com/android/camera/ui/IndicatorControlBarContainer.java
+++ b/src/com/android/camera/ui/IndicatorControlBarContainer.java
@@ -39,8 +39,6 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer
private Animation mFadeIn, mFadeOut;
private Animation mSecondLevelFadeIn, mSecondLevelFadeOut;
private IndicatorControlBar mIndicatorControlBar;
- private ZoomControlBar mZoomControlBar;
- private ZoomIndexBar mZoomIndexBar;
private SecondLevelIndicatorControlBar mSecondLevelIndicatorControlBar;
public IndicatorControlBarContainer(Context context, AttributeSet attrs) {
@@ -59,10 +57,6 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer
@Override
protected void onFinishInflate() {
- mZoomControlBar = (ZoomControlBar) findViewById(R.id.zoom_control);
- mZoomControlBar.setOnIndicatorEventListener(this);
- mZoomIndexBar = (ZoomIndexBar) findViewById(R.id.zoom_index_bar);
- mZoomControlBar.setOnZoomIndexChangeListener(mZoomIndexBar);
mIndicatorControlBar = (IndicatorControlBar)
findViewById(R.id.indicator_bar);
mIndicatorControlBar.setOnIndicatorEventListener(this);
@@ -73,13 +67,10 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer
@Override
public void initialize(Context context, PreferenceGroup group,
- String flashSetting, boolean isZoomSupported,
- String[] secondLevelKeys, String[] secondLevelOtherSettingKeys) {
+ boolean isZoomSupported, String[] secondLevelKeys,
+ String[] secondLevelOtherSettingKeys) {
- // We need to show/hide the zoom slider icon accordingly.
- // From UI spec, we have camera_flash setting on the first level.
- mIndicatorControlBar.initialize(context, group, flashSetting,
- isZoomSupported);
+ mIndicatorControlBar.initialize(context, group, isZoomSupported);
mSecondLevelIndicatorControlBar.initialize(context, group,
secondLevelKeys, secondLevelOtherSettingKeys);
@@ -88,8 +79,6 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer
public void setDegree(int degree) {
mIndicatorControlBar.setDegree(degree);
mSecondLevelIndicatorControlBar.setDegree(degree);
- mZoomControlBar.setDegree(degree);
- mZoomIndexBar.setDegree(degree);
}
@Override
@@ -98,8 +87,6 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer
return mIndicatorControlBar.dispatchTouchEvent(event);
} else if (mSecondLevelIndicatorControlBar.getVisibility() == View.VISIBLE) {
return mSecondLevelIndicatorControlBar.dispatchTouchEvent(event);
- } else if (mZoomControlBar.getVisibility() == View.VISIBLE) {
- return mZoomControlBar.dispatchTouchEvent(event);
}
return true;
}
@@ -133,19 +120,6 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer
mIndicatorControlBar.setVisibility(View.VISIBLE);
mSecondLevelIndicatorControlBar.startAnimation(mSecondLevelFadeOut);
break;
-
- case OnIndicatorEventListener.EVENT_ENTER_ZOOM_CONTROL:
- mIndicatorControlBar.setVisibility(View.GONE);
- mZoomControlBar.setVisibility(View.VISIBLE);
- mZoomIndexBar.setVisibility(View.VISIBLE);
- mZoomControlBar.startZoomControl();
- break;
-
- case OnIndicatorEventListener.EVENT_LEAVE_ZOOM_CONTROL:
- mZoomControlBar.setVisibility(View.GONE);
- mZoomIndexBar.setVisibility(View.GONE);
- mIndicatorControlBar.setVisibility(View.VISIBLE);
- break;
}
}
diff --git a/src/com/android/camera/ui/IndicatorControlContainer.java b/src/com/android/camera/ui/IndicatorControlContainer.java
index 552c551..3f66acb 100644
--- a/src/com/android/camera/ui/IndicatorControlContainer.java
+++ b/src/com/android/camera/ui/IndicatorControlContainer.java
@@ -23,8 +23,7 @@ import android.util.AttributeSet;
public abstract class IndicatorControlContainer extends IndicatorControl {
public abstract void initialize(Context context, PreferenceGroup group,
- String flashSetting, boolean isZoomSupported,
- String[] keys, String[] otherSettingKeys);
+ boolean isZoomSupported, String[] keys, String[] otherSettingKeys);
public IndicatorControlContainer(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/com/android/camera/ui/IndicatorControlWheel.java b/src/com/android/camera/ui/IndicatorControlWheel.java
index f3f869a..af36e11 100644
--- a/src/com/android/camera/ui/IndicatorControlWheel.java
+++ b/src/com/android/camera/ui/IndicatorControlWheel.java
@@ -146,17 +146,13 @@ public class IndicatorControlWheel extends IndicatorControl implements
}
public void initialize(Context context, PreferenceGroup group,
- String flashSetting, boolean isZoomSupported, String[] keys,
- String[] otherSettingKeys) {
+ boolean isZoomSupported, String[] keys, String[] otherSettingKeys) {
mShutterButtonRadius = IndicatorControlWheelContainer.SHUTTER_BUTTON_RADIUS;
mStrokeWidth = Util.dpToPixel(IndicatorControlWheelContainer.STROKE_WIDTH);
mWheelRadius = mShutterButtonRadius + mStrokeWidth * 0.5;
setPreferenceGroup(group);
- // Add first-level controls.
- addControls(new String[] {flashSetting}, null);
-
// Add Zoom Icon.
if (isZoomSupported) {
mZoomIcon = (ImageView) addImageButton(context, R.drawable.ic_zoom_holo_light, false);
diff --git a/src/com/android/camera/ui/IndicatorControlWheelContainer.java b/src/com/android/camera/ui/IndicatorControlWheelContainer.java
index 4e2a03e..664aa9b 100644
--- a/src/com/android/camera/ui/IndicatorControlWheelContainer.java
+++ b/src/com/android/camera/ui/IndicatorControlWheelContainer.java
@@ -62,10 +62,9 @@ public class IndicatorControlWheelContainer extends IndicatorControlContainer
}
public void initialize(Context context, PreferenceGroup group,
- String flashSetting, boolean isZoomSupported,
- String[] keys, String[] otherSettingKeys) {
- mIndicatorControlWheel.initialize(context, group, flashSetting,
- isZoomSupported, keys, otherSettingKeys);
+ boolean isZoomSupported, String[] keys, String[] otherSettingKeys) {
+ mIndicatorControlWheel.initialize(context, group, isZoomSupported,
+ keys, otherSettingKeys);
mIndicatorControlWheel.setOnIndicatorEventListener(this);
}
diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
index 386179d..bfa9f94 100644
--- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
+++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
@@ -33,7 +33,7 @@ import android.widget.ImageView;
public class SecondLevelIndicatorControlBar extends IndicatorControl implements
View.OnClickListener {
private static final String TAG = "SecondLevelIndicatorControlBar";
- private static int ICON_SPACING = Util.dpToPixel(32);
+ private static int ICON_SPACING = Util.dpToPixel(24);
private ImageView mCloseIcon;
private View mDivider; // the divider line
int mDegree = 0;
diff --git a/src/com/android/camera/ui/ZoomControl.java b/src/com/android/camera/ui/ZoomControl.java
index be2bdb9..662ee92 100644
--- a/src/com/android/camera/ui/ZoomControl.java
+++ b/src/com/android/camera/ui/ZoomControl.java
@@ -20,6 +20,7 @@ import com.android.camera.R;
import android.content.Context;
import android.os.Handler;
+import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
@@ -30,16 +31,20 @@ import android.widget.RelativeLayout;
* if the camera supports zooming.
*/
public abstract class ZoomControl extends RelativeLayout {
- private static final String TAG = "ZoomControl";
+ // The states of zoom button.
+ public static final int ZOOM_IN = 0;
+ public static final int ZOOM_OUT = 1;
+ public static final int ZOOM_STOP = 2;
- public static final int ZOOMING_INTERVAL = 300; // milliseconds
+ private static final String TAG = "ZoomControl";
+ private static final int ZOOMING_INTERVAL = 1000; // milliseconds
protected ImageView mZoomIn;
protected ImageView mZoomOut;
protected ImageView mZoomSlider;
protected int mSliderPosition = 0;
protected int mDegree;
- protected Handler mHandler;
+ private Handler mHandler;
public interface OnZoomChangedListener {
void onZoomValueChanged(int index); // only for immediate zoom
@@ -58,23 +63,13 @@ public abstract class ZoomControl extends RelativeLayout {
private OnZoomChangedListener mListener;
private OnZoomIndexChangedListener mIndexListener;
- // The state of zoom button.
- public static final int ZOOM_IN = 0;
- public static final int ZOOM_OUT = 1;
- public static final int ZOOM_STOP = 2;
-
protected OnIndicatorEventListener mOnIndicatorEventListener;
+ private int mState;
+ private int mStep;
protected final Runnable mRunnable = new Runnable() {
public void run() {
- if (mSliderPosition < 0) {
- zoomIn();
- } else if (mSliderPosition > 0) {
- zoomOut();
- } else {
- stopZooming();
- }
- mHandler.postDelayed(mRunnable, ZOOMING_INTERVAL);
+ performZoom(mState, false);
}
};
@@ -88,7 +83,6 @@ public abstract class ZoomControl extends RelativeLayout {
public void startZoomControl() {
mZoomSlider.setPressed(true);
- mHandler.postDelayed(mRunnable, ZOOMING_INTERVAL);
setZoomIndex(mZoomIndex); // Update the zoom index bar.
}
@@ -100,12 +94,13 @@ public abstract class ZoomControl extends RelativeLayout {
}
public void closeZoomControl() {
- mHandler.removeCallbacks(mRunnable);
- mSliderPosition = 0;
mZoomSlider.setPressed(false);
stopZooming();
- mOnIndicatorEventListener.onIndicatorEvent(
- OnIndicatorEventListener.EVENT_LEAVE_ZOOM_CONTROL);
+ if (!mSmoothZoomSupported) mHandler.removeCallbacks(mRunnable);
+ if (mOnIndicatorEventListener != null) {
+ mOnIndicatorEventListener.onIndicatorEvent(
+ OnIndicatorEventListener.EVENT_LEAVE_ZOOM_CONTROL);
+ }
}
public void setZoomMax(int zoomMax) {
@@ -143,30 +138,71 @@ public abstract class ZoomControl extends RelativeLayout {
mSmoothZoomSupported = smoothZoomSupported;
}
- public boolean zoomIn() {
- return (mZoomIndex == mZoomMax) ? false : changeZoomIndex(mZoomIndex + 1);
+ private boolean zoomIn() {
+ return (mZoomIndex == mZoomMax) ? false : changeZoomIndex(mZoomIndex + mStep);
+ }
+
+ private boolean zoomOut() {
+ return (mZoomIndex == 0) ? false : changeZoomIndex(mZoomIndex - mStep);
}
- public boolean zoomOut() {
- return (mZoomIndex == 0) ? false : changeZoomIndex(mZoomIndex - 1);
+ protected void setZoomStep(int step) {
+ mStep = step;
}
- public void stopZooming() {
+ private void stopZooming() {
if (mSmoothZoomSupported) {
if (mListener != null) mListener.onZoomStateChanged(ZOOM_STOP);
}
}
+ // Called from ZoomControlWheel to change the zoom level.
+ // TODO: merge the zoom control for both platforms.
+ protected void performZoom(int state) {
+ performZoom(state, true);
+ }
+
+ private void performZoom(int state, boolean fromUser) {
+ if ((mState == state) && fromUser) return;
+ if (fromUser) mHandler.removeCallbacks(mRunnable);
+ mState = state;
+ switch (state) {
+ case ZOOM_IN:
+ zoomIn();
+ break;
+ case ZOOM_OUT:
+ zoomOut();
+ break;
+ case ZOOM_STOP:
+ stopZooming();
+ break;
+ }
+ if (!mSmoothZoomSupported) {
+ // Repeat the zoom action on tablet as the user is still holding
+ // the zoom slider.
+ mHandler.postDelayed(mRunnable, ZOOMING_INTERVAL / mZoomMax);
+ }
+ }
+
+ // Called from ZoomControlBar to change the zoom level.
+ protected void performZoom(double zoomPercentage) {
+ int index = (int) (mZoomMax * zoomPercentage);
+ if (mZoomIndex == index) return;
+ changeZoomIndex(index);
+ }
+
private boolean changeZoomIndex(int index) {
- int zoomType = (index < mZoomIndex) ? ZOOM_OUT : ZOOM_IN;
if (mListener != null) {
if (mSmoothZoomSupported) {
+ int zoomType = (index < mZoomIndex) ? ZOOM_OUT : ZOOM_IN;
if (((zoomType == ZOOM_IN) && (mZoomIndex != mZoomMax)) ||
((zoomType == ZOOM_OUT) && (mZoomIndex != 0))) {
mListener.onZoomStateChanged(zoomType);
}
} else {
- mListener.onZoomStateChanged(index);
+ if (index > mZoomMax) index = mZoomMax;
+ if (index < 0) index = 0;
+ mListener.onZoomValueChanged(index);
setZoomIndex(index);
}
}
diff --git a/src/com/android/camera/ui/ZoomControlBar.java b/src/com/android/camera/ui/ZoomControlBar.java
index d906dea..6bbb8f1 100644
--- a/src/com/android/camera/ui/ZoomControlBar.java
+++ b/src/com/android/camera/ui/ZoomControlBar.java
@@ -20,6 +20,7 @@ import com.android.camera.R;
import com.android.camera.Util;
import android.content.Context;
+import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -29,9 +30,9 @@ import android.view.View;
*/
public class ZoomControlBar extends ZoomControl {
private static final String TAG = "ZoomControlBar";
- private static final int STOP_ZOOM_BUFFER = Util.dpToPixel(30);
-
+ private static int THRESHOLD_FIRST_MOVE = Util.dpToPixel(10); // pixels
private View mBar;
+ private boolean mStartChanging;
public ZoomControlBar(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -49,29 +50,42 @@ public class ZoomControlBar extends ZoomControl {
if (!isEnabled()) return false;
double y = (double) event.getY();
- int offset = getHeight() / 2;
+ // Calculate the absolute offset of the slider in the zoom control bar.
// For left-hand users, as the device is rotated for 180 degree for
// landscape mode, the zoom-in bottom should be on the top, so the
// position should be reversed.
- int delta;
+ int offset = 5 * getWidth() / 4; // the padding and the icon height
+ int height = getHeight();
+ int range = height - 2 * offset; // the range of the zoom slider
+ int pos; // the relative position in the zoom slider bar
if (mDegree == 180) {
- delta = offset - (int) y;
+ pos = (int) y - offset;
} else {
- delta = (int) y - offset;
+ pos = height - (int) y - offset;
}
- // We need some space to stop zooming.
- mSliderPosition = (Math.abs(delta) < STOP_ZOOM_BUFFER) ? 0 : delta;
-
- // TODO: add fast zoom change here
+ if (pos < 0) pos = 0;
+ if (pos > range) pos = range;
switch (action) {
case MotionEvent.ACTION_OUTSIDE:
- case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
closeZoomControl();
break;
- default:
+
+ case MotionEvent.ACTION_DOWN:
+ mStartChanging = false;
+ case MotionEvent.ACTION_MOVE:
+ // Make sure the movement is large enough before we start
+ // changing the zoom.
+ if (!mStartChanging && (Math.abs(mSliderPosition - pos)
+ > THRESHOLD_FIRST_MOVE)) {
+ mStartChanging = true;
+ }
+ if (mStartChanging) {
+ performZoom(1.0d * pos / range);
+ mSliderPosition = pos;
+ }
requestLayout();
}
return true;
@@ -87,30 +101,29 @@ public class ZoomControlBar extends ZoomControl {
@Override
protected void onLayout(
boolean changed, int left, int top, int right, int bottom) {
+ if (mZoomMax == 0) return;
+
int width = right - left;
int height = bottom - top;
- int h = height / 2;
+ int range = height - 10 * width / 4;
int pos;
+ // TODO: remove offset once we have correct ic_zoom_big.9.png.
+ int offset = 3 * width / 4;
+
// For left-hand users, as the device is rotated for 180 degree,
// the zoom-in button should be on the top.
if (mDegree == 180) {
- pos = h - mSliderPosition - width / 2;
mZoomOut.layout(0, 0, width, width);
mZoomIn.layout(0, height - width, width, height);
+ pos = offset + mZoomIndex * range / mZoomMax;
+ mZoomSlider.layout(0, pos, width, pos + width);
} else {
- pos = h + mSliderPosition - width / 2;
mZoomIn.layout(0, 0, width, width);
mZoomOut.layout(0, height - width, width, height);
+ pos = offset + (mZoomMax - mZoomIndex) * range / mZoomMax;
+ mZoomSlider.layout(0, pos, width, pos + width);
}
- mBar.layout(0, width, width, height - width);
-
- // TODO: fix the pos once we have correct zoom_big asset.
- if (pos < 3 * width / 4) {
- pos = 3 * width / 4;
- } else if (pos > (height - (7 * width / 4))) {
- pos = height - (7 * width / 4);
- }
- mZoomSlider.layout(0, pos, width, pos + width);
+ mBar.layout(0, width, width, bottom - top - width);
}
}
diff --git a/src/com/android/camera/ui/ZoomControlWheel.java b/src/com/android/camera/ui/ZoomControlWheel.java
index bb70ddf..6a75097 100644
--- a/src/com/android/camera/ui/ZoomControlWheel.java
+++ b/src/com/android/camera/ui/ZoomControlWheel.java
@@ -75,6 +75,17 @@ public class ZoomControlWheel extends ZoomControl {
mShutterButtonRadius = IndicatorControlWheelContainer.SHUTTER_BUTTON_RADIUS;
mStrokeWidth = Util.dpToPixel(IndicatorControlWheelContainer.STROKE_WIDTH);
mWheelRadius = mShutterButtonRadius + mStrokeWidth * 0.5;
+ super.setZoomStep(1); // one zoom level at a time
+ }
+
+ private void performZoom() {
+ if (mSliderRadians > (Math.PI + BUFFER_RADIANS)) {
+ super.performZoom(ZOOM_OUT);
+ } else if (mSliderRadians < (Math.PI - BUFFER_RADIANS)) {
+ super.performZoom(ZOOM_IN);
+ } else {
+ super.performZoom(ZOOM_STOP);
+ }
}
@Override
@@ -102,7 +113,8 @@ public class ZoomControlWheel extends ZoomControl {
case MotionEvent.ACTION_CANCEL:
closeZoomControl();
break;
- default:
+ case MotionEvent.ACTION_MOVE:
+ performZoom();
requestLayout();
}
return true;