diff options
-rw-r--r-- | res/drawable-hdpi/btn_wheel_close_settings.png | bin | 0 -> 513 bytes | |||
-rw-r--r-- | res/drawable-mdpi/btn_wheel_close_settings.png | bin | 0 -> 352 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/btn_wheel_close_settings.png | bin | 0 -> 689 bytes | |||
-rw-r--r-- | src/com/android/camera/Camera.java | 34 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/ui/CameraPicker.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControl.java | 48 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlBar.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlBarContainer.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlWheel.java | 266 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlWheelContainer.java | 5 |
11 files changed, 253 insertions, 122 deletions
diff --git a/res/drawable-hdpi/btn_wheel_close_settings.png b/res/drawable-hdpi/btn_wheel_close_settings.png Binary files differnew file mode 100644 index 0000000..6d2ad46 --- /dev/null +++ b/res/drawable-hdpi/btn_wheel_close_settings.png diff --git a/res/drawable-mdpi/btn_wheel_close_settings.png b/res/drawable-mdpi/btn_wheel_close_settings.png Binary files differnew file mode 100644 index 0000000..7bca4e1 --- /dev/null +++ b/res/drawable-mdpi/btn_wheel_close_settings.png diff --git a/res/drawable-xhdpi/btn_wheel_close_settings.png b/res/drawable-xhdpi/btn_wheel_close_settings.png Binary files differnew file mode 100644 index 0000000..9459243 --- /dev/null +++ b/res/drawable-xhdpi/btn_wheel_close_settings.png diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 1270367..e4b8901 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -44,7 +44,6 @@ import android.hardware.Camera.Size; import android.location.Location; import android.location.LocationManager; import android.location.LocationProvider; -import android.media.AudioManager; import android.media.CameraProfile; import android.media.ToneGenerator; import android.net.Uri; @@ -68,12 +67,10 @@ import android.view.OrientationEventListener; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; -import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.widget.Button; -import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -1103,27 +1100,14 @@ public class Camera extends ActivityBase implements View.OnClickListener, mIndicatorControl = (IndicatorControl) findViewById(R.id.indicator_control); if (mIndicatorControl == null) return; loadCameraPreferences(); - final String[] SETTING_KEYS, OTHER_SETTING_KEYS; - if (Util.isTabletUI()) { - SETTING_KEYS = new String[] { - CameraSettings.KEY_FLASH_MODE, - CameraSettings.KEY_WHITE_BALANCE}; - OTHER_SETTING_KEYS = new String[] { - CameraSettings.KEY_SCENE_MODE, - CameraSettings.KEY_RECORD_LOCATION, - CameraSettings.KEY_FOCUS_MODE, - CameraSettings.KEY_EXPOSURE, - CameraSettings.KEY_PICTURE_SIZE}; - } else { - SETTING_KEYS = new String[] { - CameraSettings.KEY_WHITE_BALANCE, - CameraSettings.KEY_SCENE_MODE}; - OTHER_SETTING_KEYS = new String[] { - CameraSettings.KEY_EXPOSURE, - CameraSettings.KEY_FOCUS_MODE, - CameraSettings.KEY_PICTURE_SIZE, - CameraSettings.KEY_RECORD_LOCATION}; - } + final String[] SETTING_KEYS = { + CameraSettings.KEY_WHITE_BALANCE, + CameraSettings.KEY_SCENE_MODE}; + final String[] OTHER_SETTING_KEYS = { + CameraSettings.KEY_RECORD_LOCATION, + CameraSettings.KEY_FOCUS_MODE, + CameraSettings.KEY_EXPOSURE, + CameraSettings.KEY_PICTURE_SIZE}; mIndicatorControl.initialize(this, mPreferenceGroup, CameraSettings.KEY_FLASH_MODE, SETTING_KEYS, OTHER_SETTING_KEYS); mIndicatorControl.setListener(this); @@ -2176,7 +2160,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, mIndicatorControl.dismissSettingPopup(); CameraSettings.restorePreferences(Camera.this, mPreferences, mParameters); - initializeIndicatorControl(); + mIndicatorControl.reloadPreferences(); onSharedPreferenceChanged(); } } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index cec06c7..0102576 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -472,20 +472,11 @@ public class VideoCamera extends ActivityBase if (mIndicatorControl == null) return; loadCameraPreferences(); - final String[] SETTING_KEYS, OTHER_SETTING_KEYS; - if (Util.isTabletUI()) { - SETTING_KEYS = new String[] {CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE}; - OTHER_SETTING_KEYS = new String[] { - CameraSettings.KEY_VIDEO_QUALITY, - CameraSettings.KEY_WHITE_BALANCE, - CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL}; - } else { - SETTING_KEYS = new String[] { + final String[] SETTING_KEYS = { CameraSettings.KEY_WHITE_BALANCE, CameraSettings.KEY_VIDEO_QUALITY}; - OTHER_SETTING_KEYS = new String[] { + final String[] OTHER_SETTING_KEYS = { CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL}; - } mIndicatorControl.initialize(this, mPreferenceGroup, CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE, SETTING_KEYS, OTHER_SETTING_KEYS); @@ -1749,7 +1740,7 @@ public class VideoCamera extends ActivityBase mIndicatorControl.dismissSettingPopup(); CameraSettings.restorePreferences(VideoCamera.this, mPreferences, mParameters); - initializeIndicatorControl(); + mIndicatorControl.reloadPreferences(); onSharedPreferenceChanged(); } } diff --git a/src/com/android/camera/ui/CameraPicker.java b/src/com/android/camera/ui/CameraPicker.java index f4d7d2f..6bdfe43 100644 --- a/src/com/android/camera/ui/CameraPicker.java +++ b/src/com/android/camera/ui/CameraPicker.java @@ -22,7 +22,6 @@ import com.android.camera.R; import android.content.Context; import android.hardware.Camera.CameraInfo; -import android.util.AttributeSet; import android.view.View; import android.widget.ImageView; diff --git a/src/com/android/camera/ui/IndicatorControl.java b/src/com/android/camera/ui/IndicatorControl.java index 814dc6d..66dcf55 100644 --- a/src/com/android/camera/ui/IndicatorControl.java +++ b/src/com/android/camera/ui/IndicatorControl.java @@ -32,8 +32,7 @@ import android.widget.RelativeLayout; import java.util.ArrayList; /** - * A view that contains camera setting indicators. The indicators are spreaded - * differently based on the screen resolution. + * A view that contains camera setting indicators. */ public abstract class IndicatorControl extends RelativeLayout implements IndicatorButton.Listener, OtherSettingsPopup.Listener { @@ -83,42 +82,39 @@ public abstract class IndicatorControl extends RelativeLayout implements public void initialize(Context context, PreferenceGroup group, String[] keys, String[] otherSettingKeys) { - // Reset the variables and states. - dismissSettingPopup(); - removeIndicators(); - // Initialize all variables and icons. mPreferenceGroup = group; - // Add other settings indicator. - if (otherSettingKeys != null) { - addOtherSettingIndicator(context, R.drawable.ic_settings_holo_light, otherSettingKeys); - } + addControls(keys, otherSettingKeys); + requestLayout(); + } - for (int i = 0; i < keys.length; i++) { - IconListPreference pref = (IconListPreference) group.findPreference(keys[i]); - if (pref != null) { - addIndicator(context, pref); + protected void addControls(String[] keys, String[] otherSettingKeys) { + if (keys != null) { + for (int i = 0; i < keys.length; i++) { + IconListPreference pref = + (IconListPreference) mPreferenceGroup.findPreference(keys[i]); + if (pref != null) { + addIndicator(mContext, pref); + } } } - requestLayout(); + + // Add other settings indicator. + if (otherSettingKeys != null) { + addOtherSettingIndicator(mContext, + R.drawable.ic_settings_holo_light, otherSettingKeys); + } } - public void initializeCameraPicker(Context context, PreferenceGroup group) { - ListPreference pref = group.findPreference( + protected void initializeCameraPicker() { + ListPreference pref = mPreferenceGroup.findPreference( CameraSettings.KEY_CAMERA_ID); - if ((pref == null) || (mCameraPicker != null)) return; - mCameraPicker = new CameraPicker(context); + if (pref == null) return; + mCameraPicker = new CameraPicker(mContext); mCameraPicker.initialize(pref); addView(mCameraPicker); } - private void removeIndicators() { - for (View v: mIndicators) { - removeView(v); - } - mIndicators.clear(); - } - @Override public boolean shouldDelayChildPressedState() { // Return false so the pressed feedback of the back/front camera switch diff --git a/src/com/android/camera/ui/IndicatorControlBar.java b/src/com/android/camera/ui/IndicatorControlBar.java index 49bf409..6c2d15f 100644 --- a/src/com/android/camera/ui/IndicatorControlBar.java +++ b/src/com/android/camera/ui/IndicatorControlBar.java @@ -44,7 +44,7 @@ public class IndicatorControlBar extends IndicatorControl implements super.initialize(context, group, new String[] {flashSetting}, null); // Add CameraPicker control. - initializeCameraPicker(context, group); + initializeCameraPicker(); // add Zoom Icon. if (zoomSupported) { diff --git a/src/com/android/camera/ui/IndicatorControlBarContainer.java b/src/com/android/camera/ui/IndicatorControlBarContainer.java index 6bf9c50..311615b 100644 --- a/src/com/android/camera/ui/IndicatorControlBarContainer.java +++ b/src/com/android/camera/ui/IndicatorControlBarContainer.java @@ -27,8 +27,8 @@ import android.view.animation.Animation; import android.view.animation.AnimationUtils; /** - * A view contains indicator control bar, second-level indicator bar and - * zoom control. + * The IndicatorControlBarContainer is a IndicatorControl containing + * IndicatorControlBar, SecondIndicatorControlBar and ZoomControlBar for Phone UI. */ public class IndicatorControlBarContainer extends IndicatorControl implements OnIndicatorEventListener { diff --git a/src/com/android/camera/ui/IndicatorControlWheel.java b/src/com/android/camera/ui/IndicatorControlWheel.java index 409868f..20f4b9b 100644 --- a/src/com/android/camera/ui/IndicatorControlWheel.java +++ b/src/com/android/camera/ui/IndicatorControlWheel.java @@ -25,22 +25,39 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; +import android.os.Handler; import android.os.SystemClock; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; +import android.widget.ImageView; /** - * A view that contains camera setting indicators. The - * indicators are spreaded around the shutter button. The first child is always - * the shutter button. + * A view that contains camera setting indicators in two levels. The first-level + * indicators including the zoom, camera picker, flash and second-level control. + * The second-level indicators are the merely for the camera settings. */ -public class IndicatorControlWheel extends IndicatorControl { +public class IndicatorControlWheel extends IndicatorControl implements + View.OnClickListener { public static final int HIGHLIGHT_WIDTH = 4; - public static final int HIGHLIGHT_DEGREES = 30; - public static final double HIGHLIGHT_RADIANS = Math.toRadians(HIGHLIGHT_DEGREES); private static final String TAG = "IndicatorControlWheel"; + private static final int HIGHLIGHT_DEGREES = 30; + private static final double HIGHLIGHT_RADIANS = Math.toRadians(HIGHLIGHT_DEGREES); + + // The following angles are based in the zero degree on the right. Here we + // have the fix 45 degrees for each sector in the first-level as we have to + // align the zoom button exactly at degree 180. For second-level indicators, + // the indicators located evenly between start and end angle. In addition, + // these indicators for the second-level hidden in the same wheel with + // larger angle values are visible after rotation. + private static final int FIRST_LEVEL_END_DEGREES = 270; + private static final int FIRST_LEVEL_SECTOR_DEGREES = 45; + private static final int SECOND_LEVEL_START_DEGREES = 60; + private static final int SECOND_LEVEL_END_DEGREES = 300; + private static final int CLOSE_ICON_DEFAULT_DEGREES = 315; + + private static final int ANIMATION_TIME = 300; // milliseconds // The width of the edges on both sides of the wheel, which has less alpha. private static final float EDGE_STROKE_WIDTH = 6f; @@ -70,6 +87,32 @@ public class IndicatorControlWheel extends IndicatorControl { // Remember the last event for event cancelling if out of bound. private MotionEvent mLastMotionEvent; + protected final int DISABLED_COLOR; + private ImageView mSecondLevelIcon; + private ImageView mCloseIcon; + + // Variables for animation. + private long mAnimationStartTime; + private boolean mInAnimation = false; + private Handler mHandler = new Handler(); + private final Runnable mRunnable = new Runnable() { + public void run() { + requestLayout(); + } + }; + + // Variables for level control. + private int mCurrentLevel = 0; + private int mSecondLevelStartIndex = -1; + private double mStartVisibleRadians[] = new double[2]; + private double mEndVisibleRadians[] = new double[2]; + private double mSectorRadians[] = new double[2]; + private double mTouchSectorRadians[] = new double[2]; + + // TODO: we won't need these buttons later once we switch to new zoom control. + private View mZoomIn; + private View mZoomOut; + public IndicatorControlWheel(Context context, AttributeSet attrs) { super(context, attrs); Resources resources = context.getResources(); @@ -83,6 +126,25 @@ public class IndicatorControlWheel extends IndicatorControl { mBackgroundPaint.setAntiAlias(true); mBackgroundRect = new RectF(); + DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color); + } + + private int getChildCountByLevel(int level) { + // Get current child count by level. + if (level == 1) { + return (getChildCount() - mSecondLevelStartIndex); + } else { + return mSecondLevelStartIndex; + } + } + + @Override + public void onClick(View view) { + mPressedIndex = -1; + dismissSettingPopup(); + mInAnimation = true; + mAnimationStartTime = SystemClock.uptimeMillis(); + requestLayout(); } public void initialize(Context context, PreferenceGroup group, @@ -90,30 +152,57 @@ public class IndicatorControlWheel extends IndicatorControl { mShutterButtonRadius = IndicatorControlWheelContainer.SHUTTER_BUTTON_RADIUS; mStrokeWidth = Util.dpToPixel(IndicatorControlWheelContainer.STROKE_WIDTH); mWheelRadius = mShutterButtonRadius + mStrokeWidth * 0.5; - // Add CameraPicker control. - initializeCameraPicker(context, group); - super.initialize(context, group, flashSetting, keys, otherSettingKeys); - // The radian intervals for each icon for touch events. + // Add first-level controls. + super.initialize(context, group, new String[] {flashSetting}, null); + initializeCameraPicker(); + // Add second-level Indicator Icon. + mSecondLevelIcon = addImageButton(context, R.drawable.ic_settings_holo_light, true); + mSecondLevelStartIndex = getChildCount(); + + // Add second-level buttons. + mCloseIcon = addImageButton(context, R.drawable.btn_wheel_close_settings, false); + addControls(keys, otherSettingKeys); + + // The angle(in radians) of each icon for touch events. mChildRadians = new double[getChildCount()]; + presetFirstLevelChildRadians(); + presetSecondLevelChildRadians(); + } + + private ImageView addImageButton(Context context, int resourceId, boolean rotatable) { + ImageView view = rotatable ? new RotateImageView(context) : new ImageView(context); + view.setImageResource(resourceId); + view.setOnClickListener(this); + addView(view); + return view; } private int getTouchIndicatorIndex(double delta) { - // The delta is the touch point in radians. - int count = getChildCount(); + // The delta is the angle of touch point in radians. + if (mInAnimation) return -1; + int count = getChildCountByLevel(mCurrentLevel); if (count == 0) return -1; + int startIndex = (mCurrentLevel == 0) ? 0 : mSecondLevelStartIndex; int sectors = count - 1; - double sectorDegrees = Math.min(HIGHLIGHT_RADIANS, - (count == 1) ? HIGHLIGHT_RADIANS : (Math.PI / sectors)); // Check which indicator is touched. - if ((delta >= (Math.PI - HIGHLIGHT_RADIANS) / 2) && - (delta <= (Math.PI + (Math.PI + HIGHLIGHT_RADIANS) / 2))) { - int index = (int) ((delta - Math.PI / 2) * sectors / Math.PI); - if (index > sectors) return sectors ; // degree greater than 270 - if (index < 0) return 0; // degree less than 90 - if (delta <= (mChildRadians[index] + sectorDegrees / 2)) return index; - if (delta >= (mChildRadians[index + 1] - sectorDegrees / 2)) { - return index + 1; + if ((delta >= (mStartVisibleRadians[mCurrentLevel] - HIGHLIGHT_RADIANS / 2)) && + (delta <= (mEndVisibleRadians[mCurrentLevel] + HIGHLIGHT_RADIANS / 2))) { + int index = (int) ((delta - mStartVisibleRadians[mCurrentLevel]) + / mSectorRadians[mCurrentLevel]); + + // greater than the center of ending indicator + if (index > sectors) return (startIndex + sectors); + // less than the center of starting indicator + if (index < 0) return startIndex; + + if (delta <= (mChildRadians[startIndex + index] + + mTouchSectorRadians[mCurrentLevel] / 2)) { + return (startIndex + index); + } + if (delta >= (mChildRadians[startIndex + index + 1] + - mTouchSectorRadians[mCurrentLevel] / 2)) { + return (startIndex + index + 1); } } return -1; @@ -136,7 +225,7 @@ public class IndicatorControlWheel extends IndicatorControl { double radius = Math.sqrt(dx * dx + dy * dy); // Ignore the event if too far from the shutter button. - if ((radius <= mWheelRadius + mStrokeWidth) && (radius > mShutterButtonRadius)) { + if ((radius <= (mWheelRadius + mStrokeWidth)) && (radius > mShutterButtonRadius)) { double delta = Math.atan2(dy, dx); if (delta < 0) delta += Math.PI * 2; int index = getTouchIndicatorIndex(delta); @@ -161,49 +250,109 @@ public class IndicatorControlWheel extends IndicatorControl { return true; } // The event is not on any of the child. - dismissSettingPopup(); - if (mPressedIndex != -1) { - View cancelChild = getChildAt(mPressedIndex); - event.setAction(MotionEvent.ACTION_CANCEL); - cancelChild.dispatchTouchEvent(event); - mPressedIndex = -1; - } - invalidate(); + onTouchOutBound(); return false; } + private void rotateWheel() { + int totalDegrees = CLOSE_ICON_DEFAULT_DEGREES - SECOND_LEVEL_START_DEGREES; + int startAngle = ((mCurrentLevel == 0) ? CLOSE_ICON_DEFAULT_DEGREES + : SECOND_LEVEL_START_DEGREES); + if (mCurrentLevel == 0) totalDegrees = -totalDegrees; + + int elapsedTime = (int) (SystemClock.uptimeMillis() - mAnimationStartTime); + if (elapsedTime >= ANIMATION_TIME) { + elapsedTime = ANIMATION_TIME; + mCurrentLevel = (mCurrentLevel == 0) ? 1 : 0; + mInAnimation = false; + } + + int expectedAngle = startAngle + (totalDegrees * elapsedTime / ANIMATION_TIME); + double increment = Math.toRadians(expectedAngle) + - mChildRadians[mSecondLevelStartIndex]; + for (int i = 0 ; i < getChildCount(); ++i) mChildRadians[i] += increment; + requestLayout(); + } + @Override protected void onLayout( boolean changed, int left, int top, int right, int bottom) { - int count = getChildCount(); - if (count == 0) return; - + if (mInAnimation) { + rotateWheel(); + mHandler.post(mRunnable); + } mCenterX = right - left - Util.dpToPixel( IndicatorControlWheelContainer.FULL_WHEEL_RADIUS); mCenterY = (bottom - top) / 2; - // Layout the settings. The icons are spreaded on the left side of the - // shutter button. So the angle starts from 90 to 270 degrees. - - // This will just get rid of Divide-By-Zero. - double intervalDegrees = (count == 1) ? 90.0 : 180.0 / (count - 1); - double initialDegrees = 90.0; - - for (int i = 0; i < count; i++) { + // Layout the indicators based on the current level. + // The icons are spreaded on the left side of the shutter button. + for (int i = 0; i < getChildCount(); ++i) { View view = getChildAt(i); - double degree = initialDegrees + intervalDegrees * i; - double radian = Math.toRadians(degree); + double radian = mChildRadians[i]; + double startVisibleRadians = mInAnimation + ? mStartVisibleRadians[1] + : mStartVisibleRadians[mCurrentLevel]; + double endVisibleRadians = mInAnimation + ? mEndVisibleRadians[1] + : mEndVisibleRadians[mCurrentLevel]; + if ((radian < (startVisibleRadians - HIGHLIGHT_RADIANS / 2)) || + (radian > (endVisibleRadians + HIGHLIGHT_RADIANS / 2))) { + view.setVisibility(View.GONE); + continue; + } + view.setVisibility(View.VISIBLE); int x = mCenterX + (int)(mWheelRadius * Math.cos(radian)); int y = mCenterY - (int)(mWheelRadius * Math.sin(radian)); int width = view.getMeasuredWidth(); int height = view.getMeasuredHeight(); view.layout(x - width / 2, y - height / 2, x + width / 2, y + height / 2); - // Store the radian intervals for each icon. - mChildRadians[i] = Math.toRadians(degree); } } + private void presetFirstLevelChildRadians() { + int count = getChildCountByLevel(0); + int sectors = (count <= 1) ? 0 : (count - 1); + double sectorDegrees = FIRST_LEVEL_SECTOR_DEGREES; + mSectorRadians[0] = Math.toRadians(sectorDegrees); + double degrees = (FIRST_LEVEL_END_DEGREES - sectors * sectorDegrees); + mStartVisibleRadians[0] = Math.toRadians(degrees); + + int startIndex = 0; + for (int i = 0; i < count; i++) { + mChildRadians[startIndex + i] = Math.toRadians(degrees); + degrees += sectorDegrees; + } + + // The radians for the touch sector of an indicator. + mTouchSectorRadians[0] = HIGHLIGHT_RADIANS; + mEndVisibleRadians[0] = Math.toRadians(FIRST_LEVEL_END_DEGREES); + } + + private void presetSecondLevelChildRadians() { + int count = getChildCountByLevel(1); + int sectors = (count <= 1) ? 0 : (count - 1); + double sectorDegrees = + ((SECOND_LEVEL_END_DEGREES - SECOND_LEVEL_START_DEGREES) / sectors); + mSectorRadians[1] = Math.toRadians(sectorDegrees); + + double degrees = CLOSE_ICON_DEFAULT_DEGREES; + mStartVisibleRadians[1] = Math.toRadians(SECOND_LEVEL_START_DEGREES); + + int startIndex = mSecondLevelStartIndex; + for (int i = 0; i < count; i++) { + mChildRadians[startIndex + i] = Math.toRadians(degrees); + degrees += sectorDegrees; + } + + // The radians for the touch sector of an indicator. + mTouchSectorRadians[1] = + Math.min(HIGHLIGHT_RADIANS, Math.toRadians(sectorDegrees)); + + mEndVisibleRadians[1] = Math.toRadians(SECOND_LEVEL_END_DEGREES); + } + public void startTimeLapseAnimation(int timeLapseInterval, long startTime) { mTimeLapseInterval = timeLapseInterval; mRecordingStartTime = startTime; @@ -224,7 +373,8 @@ public class IndicatorControlWheel extends IndicatorControl { } } if (mPressedIndex != -1) { - if (!(getChildAt(mPressedIndex) instanceof AbstractIndicatorButton)) { + View v = getChildAt(mPressedIndex); + if (!(v instanceof AbstractIndicatorButton) && v.isEnabled()) { return mPressedIndex; } } @@ -243,11 +393,7 @@ public class IndicatorControlWheel extends IndicatorControl { // Draw the highlight arc if an indicator is selected or being pressed. if (selectedIndex >= 0) { - int count = getChildCount(); - float initialDegrees = 90.0f; - float intervalDegrees = (count <= 1) ? 0.0f : 180.0f / (count - 1); - float degree; - degree = initialDegrees + intervalDegrees * selectedIndex; + int degree = (int) Math.toDegrees(mChildRadians[selectedIndex]); mBackgroundPaint.setStrokeWidth(HIGHLIGHT_WIDTH); mBackgroundPaint.setStrokeCap(Paint.Cap.ROUND); mBackgroundPaint.setColor(HIGHLIGHT_COLOR); @@ -287,9 +433,23 @@ public class IndicatorControlWheel extends IndicatorControl { super.onDraw(canvas); } + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (enabled) { + mSecondLevelIcon.clearColorFilter(); + mCloseIcon.clearColorFilter(); + } else { + mSecondLevelIcon.setColorFilter(DISABLED_COLOR); + mCloseIcon.setColorFilter(DISABLED_COLOR); + } + mSecondLevelIcon.setEnabled(enabled); + mCloseIcon.setEnabled(enabled); + } + public void onTouchOutBound() { + dismissSettingPopup(); if (mPressedIndex != -1) { - dismissSettingPopup(); injectMotionEvent(mPressedIndex, mLastMotionEvent, MotionEvent.ACTION_CANCEL); mPressedIndex = -1; invalidate(); diff --git a/src/com/android/camera/ui/IndicatorControlWheelContainer.java b/src/com/android/camera/ui/IndicatorControlWheelContainer.java index fbf7565..e3b3387 100644 --- a/src/com/android/camera/ui/IndicatorControlWheelContainer.java +++ b/src/com/android/camera/ui/IndicatorControlWheelContainer.java @@ -27,8 +27,9 @@ import android.view.MotionEvent; import android.view.View; /** - * A view that contains shutter button and indicator control wheel - * and zoom control wheel. + * On the tablet UI, we have IndicatorControlWheelContainer which contains a + * ShutterButton, a IndicatorControlWheel (which combines first-level and + * second-level indicators) and a ZoomControlWheel. */ public class IndicatorControlWheelContainer extends IndicatorControl { public static final int STROKE_WIDTH = 87; |