diff options
-rw-r--r-- | res/anim/mode_selection_fade_in.xml | 18 | ||||
-rw-r--r-- | res/anim/mode_selection_fade_out.xml | 18 | ||||
-rw-r--r-- | res/drawable-hdpi/ic_switch_camera_holo_light.png | bin | 0 -> 1382 bytes | |||
-rw-r--r-- | res/drawable-hdpi/ic_switch_pan_holo_light.png | bin | 0 -> 1486 bytes | |||
-rw-r--r-- | res/drawable-hdpi/ic_switch_video_holo_light.png | bin | 0 -> 840 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_switch_camera_holo_light.png | bin | 0 -> 967 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_switch_pan_holo_light.png | bin | 0 -> 1030 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_switch_video_holo_light.png | bin | 0 -> 672 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_switch_camera_holo_light.png | bin | 0 -> 1756 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_switch_pan_holo_light.png | bin | 0 -> 1833 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_switch_video_holo_light.png | bin | 0 -> 975 bytes | |||
-rw-r--r-- | res/layout-w1024dp/mode_picker.xml | 54 | ||||
-rw-r--r-- | res/layout/mode_picker.xml | 90 | ||||
-rw-r--r-- | res/values/colors.xml | 2 | ||||
-rw-r--r-- | src/com/android/camera/ModePicker.java | 180 |
15 files changed, 270 insertions, 92 deletions
diff --git a/res/anim/mode_selection_fade_in.xml b/res/anim/mode_selection_fade_in.xml new file mode 100644 index 0000000..bb710bb --- /dev/null +++ b/res/anim/mode_selection_fade_in.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> + <translate android:fromYDelta="66%p" android:toYDelta="0" android:duration="200" /> +</set> diff --git a/res/anim/mode_selection_fade_out.xml b/res/anim/mode_selection_fade_out.xml new file mode 100644 index 0000000..c770420 --- /dev/null +++ b/res/anim/mode_selection_fade_out.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> + <translate android:fromYDelta="0" android:toYDelta="66%p" android:duration="200" /> +</set> diff --git a/res/drawable-hdpi/ic_switch_camera_holo_light.png b/res/drawable-hdpi/ic_switch_camera_holo_light.png Binary files differnew file mode 100644 index 0000000..20b0865 --- /dev/null +++ b/res/drawable-hdpi/ic_switch_camera_holo_light.png diff --git a/res/drawable-hdpi/ic_switch_pan_holo_light.png b/res/drawable-hdpi/ic_switch_pan_holo_light.png Binary files differnew file mode 100644 index 0000000..6633fac --- /dev/null +++ b/res/drawable-hdpi/ic_switch_pan_holo_light.png diff --git a/res/drawable-hdpi/ic_switch_video_holo_light.png b/res/drawable-hdpi/ic_switch_video_holo_light.png Binary files differnew file mode 100644 index 0000000..2b94b13 --- /dev/null +++ b/res/drawable-hdpi/ic_switch_video_holo_light.png diff --git a/res/drawable-mdpi/ic_switch_camera_holo_light.png b/res/drawable-mdpi/ic_switch_camera_holo_light.png Binary files differnew file mode 100644 index 0000000..e600169 --- /dev/null +++ b/res/drawable-mdpi/ic_switch_camera_holo_light.png diff --git a/res/drawable-mdpi/ic_switch_pan_holo_light.png b/res/drawable-mdpi/ic_switch_pan_holo_light.png Binary files differnew file mode 100644 index 0000000..7907e66 --- /dev/null +++ b/res/drawable-mdpi/ic_switch_pan_holo_light.png diff --git a/res/drawable-mdpi/ic_switch_video_holo_light.png b/res/drawable-mdpi/ic_switch_video_holo_light.png Binary files differnew file mode 100644 index 0000000..cf4afeb --- /dev/null +++ b/res/drawable-mdpi/ic_switch_video_holo_light.png diff --git a/res/drawable-xhdpi/ic_switch_camera_holo_light.png b/res/drawable-xhdpi/ic_switch_camera_holo_light.png Binary files differnew file mode 100644 index 0000000..1c011e4 --- /dev/null +++ b/res/drawable-xhdpi/ic_switch_camera_holo_light.png diff --git a/res/drawable-xhdpi/ic_switch_pan_holo_light.png b/res/drawable-xhdpi/ic_switch_pan_holo_light.png Binary files differnew file mode 100644 index 0000000..bec0863 --- /dev/null +++ b/res/drawable-xhdpi/ic_switch_pan_holo_light.png diff --git a/res/drawable-xhdpi/ic_switch_video_holo_light.png b/res/drawable-xhdpi/ic_switch_video_holo_light.png Binary files differnew file mode 100644 index 0000000..26fc157 --- /dev/null +++ b/res/drawable-xhdpi/ic_switch_video_holo_light.png diff --git a/res/layout-w1024dp/mode_picker.xml b/res/layout-w1024dp/mode_picker.xml index a827f95..a77485d 100644 --- a/res/layout-w1024dp/mode_picker.xml +++ b/res/layout-w1024dp/mode_picker.xml @@ -15,44 +15,42 @@ --> <com.android.camera.ModePicker xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mode_picker" - android:layout_width="186dp" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="10dp" - android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:visibility="gone"> - <com.android.camera.ui.RotateImageView android:id="@+id/current_mode" - android:layout_alignParentBottom="true" - 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" /> + <View android:id="@+id/current_mode_bar" + android:layout_width="wrap_content" + android:layout_height="4dp" + android:layout_marginTop="12dp" + android:layout_below="@+id/mode_selection" + android:background="@color/review_control_pressed_color"/> <LinearLayout android:id="@+id/mode_selection" android:orientation="horizontal" + android:layout_alignParentTop="true" + android:layout_marginLeft="32dp" + android:layout_marginRight="32dp" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:background="@android:color/black" - android:layout_alignParentRight="true" - android:layout_alignParentBottom="true" - android:gravity="center" - android:visibility="gone"> - <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" - android:layout_height="62dp" - android:layout_width="62dp" + android:gravity="center"> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_camera" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" android:scaleType="center" - android:src="@drawable/btn_ic_panorama" /> + android:src="@drawable/ic_switch_camera_holo_light" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_video" - android:layout_height="62dp" - android:layout_width="62dp" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" 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:src="@drawable/ic_switch_video_holo_light" /> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" android:scaleType="center" - android:src="@drawable/btn_ic_camera" /> + android:src="@drawable/ic_switch_pan_holo_light" /> </LinearLayout> </com.android.camera.ModePicker> diff --git a/res/layout/mode_picker.xml b/res/layout/mode_picker.xml index 9909307..228a68e 100644 --- a/res/layout/mode_picker.xml +++ b/res/layout/mode_picker.xml @@ -15,39 +15,79 @@ --> <com.android.camera.ModePicker xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mode_picker" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:visibility="gone"> - <com.android.camera.ui.RotateImageView android:id="@+id/current_mode" - android:layout_alignParentBottom="true" - android:layout_height="62dp" - android:layout_width="62dp" - android:scaleType="center" - android:src="@drawable/btn_ic_camera" /> - <LinearLayout android:id="@+id/mode_selection" + <RelativeLayout android:id="@+id/current_mode" + android:orientation="vertical" + android:layout_alignBottom="@+id/mode_selection" + android:layout_width="match_parent" + android:layout_height="55dp" + android:background="@color/mode_picker_background"> + <View android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@android:color/white"/> + <RelativeLayout + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_0" + android:layout_width="32dp" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_alignParentLeft="true" + android:layout_marginLeft="8dp" + android:scaleType="fitCenter" + android:src="@drawable/ic_switch_video_holo_light" /> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_1" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_centerInParent="true" + android:scaleType="fitCenter" + android:src="@drawable/ic_switch_camera_holo_light" /> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_2" + android:layout_width="32dp" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_alignParentRight="true" + android:layout_marginRight="8dp" + android:scaleType="fitCenter" + android:src="@drawable/ic_switch_pan_holo_light" /> + </RelativeLayout> + </RelativeLayout> + <RelativeLayout android:id="@+id/mode_selection" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="198dp" + android:background="@color/mode_picker_background" + android:visibility="gone"> + <View android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_alignParentTop="true" + android:background="@color/mode_selection_border"/> + <LinearLayout android:orientation="vertical" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:background="@android:color/black" - android:layout_alignParentBottom="true" - android:gravity="center" - android:visibility="gone"> - <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" - android:layout_height="62dp" - android:layout_width="62dp" + android:layout_centerVertical="true"> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_camera" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" android:scaleType="center" - android:src="@drawable/btn_ic_panorama" /> + android:src="@drawable/ic_switch_camera_holo_light" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_video" - android:layout_height="62dp" - android:layout_width="62dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" 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:src="@drawable/ic_switch_video_holo_light" /> + <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" + android:layout_width="match_parent" + android:layout_height="wrap_content" android:scaleType="center" - android:src="@drawable/btn_ic_camera" /> + android:src="@drawable/ic_switch_pan_holo_light" /> </LinearLayout> + </RelativeLayout> </com.android.camera.ModePicker> diff --git a/res/values/colors.xml b/res/values/colors.xml index 75ff158..bccc96b 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -32,4 +32,6 @@ <color name="pano_progress_empty">#FF2E2E2E</color> <color name="pano_progress_done">#FF33525E</color> <color name="pano_progress_indication">#FF0099CC</color> + <color name="mode_selection_border">#33B5E5</color> + <color name="mode_picker_background">#33000000</color> </resources> diff --git a/src/com/android/camera/ModePicker.java b/src/com/android/camera/ModePicker.java index 6dc19fc..a89764b 100644 --- a/src/com/android/camera/ModePicker.java +++ b/src/com/android/camera/ModePicker.java @@ -16,6 +16,7 @@ package com.android.camera; +import com.android.camera.Util; import com.android.camera.ui.RotateImageView; import android.content.Context; @@ -24,6 +25,9 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -32,9 +36,9 @@ import android.widget.RelativeLayout; * a current mode indicator. */ public class ModePicker extends RelativeLayout implements View.OnClickListener { - public static final int MODE_PANORAMA = 0; + public static final int MODE_CAMERA = 0; public static final int MODE_VIDEO = 1; - public static final int MODE_CAMERA = 2; + public static final int MODE_PANORAMA = 2; // Total mode number private static final int MODE_NUM = 3; @@ -49,56 +53,111 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener { private final int CURRENT_MODE_BACKGROUND; private OnModeChangeListener mListener; - private View mModeIcons[] = new View[MODE_NUM]; - private View mCurrentModeIcon; - private View mModeSelection; - private int mCurrentMode = MODE_CAMERA; - private Context mContext; + private View mModeSelectionFrame; + private RotateImageView mModeSelectionIcon[]; + private View mCurrentModeFrame; + private RotateImageView mCurrentModeIcon[]; + private View mCurrentModeBar; + private View mSelectedView; + + private int mCurrentMode = -1; + private Animation mFadeIn, mFadeOut; public ModePicker(Context context, AttributeSet attrs) { super(context, attrs); - mContext = context; DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color); CURRENT_MODE_BACKGROUND = R.drawable.btn_mode_background; + mFadeIn = AnimationUtils.loadAnimation( + context, R.anim.mode_selection_fade_in); + mFadeOut = AnimationUtils.loadAnimation( + context, R.anim.mode_selection_fade_out); + mFadeOut.setAnimationListener(mAnimationListener); } protected void onFinishInflate() { super.onFinishInflate(); - mModeSelection = findViewById(R.id.mode_selection); - - mCurrentModeIcon = findViewById(R.id.current_mode); - mCurrentModeIcon.setOnClickListener(this); - mCurrentModeIcon.setBackgroundResource(CURRENT_MODE_BACKGROUND); + mModeSelectionFrame = findViewById(R.id.mode_selection); + mModeSelectionIcon = new RotateImageView[MODE_NUM]; + mModeSelectionIcon[MODE_PANORAMA] = + (RotateImageView) findViewById(R.id.mode_panorama); + mModeSelectionIcon[MODE_VIDEO] = + (RotateImageView) findViewById(R.id.mode_video); + mModeSelectionIcon[MODE_CAMERA] = + (RotateImageView) findViewById(R.id.mode_camera); - mModeIcons[MODE_PANORAMA] = findViewById(R.id.mode_panorama); - mModeIcons[MODE_VIDEO] = findViewById(R.id.mode_video); - mModeIcons[MODE_CAMERA] = findViewById(R.id.mode_camera); + // The current mode frame is for Phone UI only. + mCurrentModeFrame = findViewById(R.id.current_mode); + if (mCurrentModeFrame != null) { + mCurrentModeFrame.setOnClickListener(this); + mCurrentModeIcon = new RotateImageView[MODE_NUM]; + mCurrentModeIcon[0] = (RotateImageView) findViewById(R.id.mode_0); + mCurrentModeIcon[1] = (RotateImageView) findViewById(R.id.mode_1); + mCurrentModeIcon[2] = (RotateImageView) findViewById(R.id.mode_2); + } else { + // current_mode_bar is only for tablet. + mCurrentModeBar = findViewById(R.id.current_mode_bar); + enableModeSelection(true); + } } + private AnimationListener mAnimationListener = new AnimationListener() { + public void onAnimationEnd(Animation animation) { + changeToSelectedMode(); + mCurrentModeFrame.setVisibility(View.VISIBLE); + mModeSelectionFrame.setVisibility(View.GONE); + } + + public void onAnimationRepeat(Animation animation) { + } + + public void onAnimationStart(Animation animation) { + } + }; + private void enableModeSelection(boolean enabled) { - mCurrentModeIcon.setVisibility(enabled ? View.GONE : View.VISIBLE); - mCurrentModeIcon.setOnClickListener(enabled ? null : this); - mModeSelection.setVisibility(enabled ? View.VISIBLE : View.GONE); + if (mCurrentModeFrame != null) { + // Animation Effect is applied on Phone UI only. + mModeSelectionFrame.startAnimation(enabled ? mFadeIn : mFadeOut); + if (enabled) { + mModeSelectionFrame.setVisibility(View.VISIBLE); + mCurrentModeFrame.setVisibility(View.GONE); + } + mCurrentModeFrame.setOnClickListener(enabled ? null : this); + } for (int i = 0; i < MODE_NUM; ++i) { - mModeIcons[i].setOnClickListener(enabled ? this : null); - highlightView(mModeIcons[i], (i == mCurrentMode)); + mModeSelectionIcon[i].setOnClickListener(enabled ? this : null); } + updateModeState(); } - public void onClick(View view) { + private void changeToSelectedMode() { for (int i = 0; i < MODE_NUM; ++i) { - if (view == mModeIcons[i]) { + if (mSelectedView == mModeSelectionIcon[i]) { setCurrentMode(i); - enableModeSelection(false); return; } } - if (view == mCurrentModeIcon) enableModeSelection(true); + } + + public void onClick(View view) { + if (view == mCurrentModeFrame) { + enableModeSelection(true); + } else { + // The view in selection menu is clicked. + mSelectedView = view; + if (mCurrentModeBar == null) { + enableModeSelection(false); + } else { + changeToSelectedMode(); + } + } } private void setMode(int mode) { - for (int i = 0; i < MODE_NUM; ++i) mModeIcons[i].setSelected(mode == i); + for (int i = 0; i < MODE_NUM; ++i) { + mModeSelectionIcon[i].setSelected(mode == i); + } } public void setOnModeChangeListener(OnModeChangeListener listener) { @@ -106,6 +165,7 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener { } public void setCurrentMode(int mode) { + if (mCurrentMode == mode) return; setMode(mode); tryToSetMode(mode); } @@ -117,9 +177,8 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener { return; } } - ((RotateImageView) mCurrentModeIcon).setImageDrawable( - ((RotateImageView) mModeIcons[mode]).getDrawable()); mCurrentMode = mode; + updateModeState(); } public boolean onModeChanged(int mode) { @@ -129,27 +188,27 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener { public void setDegree(int degree) { for (int i = 0; i < MODE_NUM; ++i) { - ((RotateImageView) mModeIcons[i]).setDegree(degree); + mModeSelectionIcon[i].setDegree(degree); + if (mCurrentModeFrame != null) { + mCurrentModeIcon[i].setDegree(degree); + } } - ((RotateImageView) mCurrentModeIcon).setDegree(degree); } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); - mCurrentModeIcon.setEnabled(enabled); - highlightView(mCurrentModeIcon, enabled); - if (enabled) { - mCurrentModeIcon.setBackgroundResource(CURRENT_MODE_BACKGROUND); - } else { - mCurrentModeIcon.setBackgroundColor(Color.BLACK); - } + // Enable or disable the frames. + if (mCurrentModeFrame != null) mCurrentModeFrame.setEnabled(enabled); + mModeSelectionFrame.setEnabled(enabled); - mModeSelection.setEnabled(enabled); + // Enable or disable the icons. for (int i = 0; i < MODE_NUM; ++i) { - mModeIcons[i].setEnabled(enabled); + mModeSelectionIcon[i].setEnabled(enabled); + if (mCurrentModeFrame != null) mCurrentModeIcon[i].setEnabled(enabled); } + if (enabled) updateModeState(); } private void highlightView(View view, boolean enabled) { @@ -159,5 +218,48 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener { } else { drawable.setColorFilter(DISABLED_COLOR, PorterDuff.Mode.SRC_ATOP); } + requestLayout(); + } + + private void updateModeState() { + // Grey-out the unselected icons. + for (int i = 0; i < MODE_NUM; ++i) { + highlightView(mModeSelectionIcon[i], (i == mCurrentMode)); + } + // Update the current mode icons on the Phone UI. The selected mode + // should be in the center of the current mode icon bar. + if (mCurrentModeFrame != null) { + for (int i = 0, j = 0; i < MODE_NUM; ++i) { + int target; + if (i == 1) { + // The second icon is always the selected mode. + target = mCurrentMode; + } else { + // Set the icons in order of camera, video and panorama. + if (j == mCurrentMode) j++; + target = j++; + } + mCurrentModeIcon[i].setImageDrawable( + mModeSelectionIcon[target].getDrawable()); + } + } + } + + @Override + protected void onLayout( + boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + // Layout the current mode indicator bar. + if (mCurrentModeBar != null) { + int viewWidth = mModeSelectionIcon[MODE_CAMERA].getWidth(); + int iconWidth = ((ImageView) mModeSelectionIcon[MODE_CAMERA]) + .getDrawable().getIntrinsicWidth(); + int padding = (viewWidth - iconWidth) / 2; + int l = mModeSelectionFrame.getLeft() + mCurrentMode * viewWidth; + mCurrentModeBar.layout((l + padding), + (bottom - top - mCurrentModeBar.getHeight()), + (l + padding + iconWidth), + (bottom - top)); + } } } |