diff options
Diffstat (limited to 'src/com/android/camera/ui')
9 files changed, 112 insertions, 31 deletions
diff --git a/src/com/android/camera/ui/AbstractIndicatorButton.java b/src/com/android/camera/ui/AbstractIndicatorButton.java index 311a3f5..aa632f7 100644 --- a/src/com/android/camera/ui/AbstractIndicatorButton.java +++ b/src/com/android/camera/ui/AbstractIndicatorButton.java @@ -33,7 +33,6 @@ public abstract class AbstractIndicatorButton extends RotateImageView { protected Context mContext; protected Animation mFadeIn, mFadeOut; protected final int HIGHLIGHT_COLOR; - protected final int DISABLED_COLOR; protected AbstractSettingPopup mPopup; protected Handler mHandler = new MainHandler(); private final int MSG_DISMISS_POPUP = 0; @@ -44,7 +43,6 @@ public abstract class AbstractIndicatorButton extends RotateImageView { mFadeIn = AnimationUtils.loadAnimation(mContext, R.anim.grow_fade_in_from_right); 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); } @@ -86,11 +84,6 @@ public abstract class AbstractIndicatorButton extends RotateImageView { // the "highlight" state. if (isEnabled() ^ enabled) { super.setEnabled(enabled); - if (enabled) { - clearColorFilter(); - } else { - setColorFilter(DISABLED_COLOR); - } } } diff --git a/src/com/android/camera/ui/CameraPicker.java b/src/com/android/camera/ui/CameraPicker.java index a3fa352..78e2b27 100644 --- a/src/com/android/camera/ui/CameraPicker.java +++ b/src/com/android/camera/ui/CameraPicker.java @@ -34,11 +34,9 @@ public class CameraPicker extends RotateImageView implements View.OnClickListene private ListPreference mPreference; private CharSequence[] mCameras; private int mCameraFacing; - private final int DISABLED_COLOR; public CameraPicker(Context context) { super(context); - DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color); setImageResource(mImageResource); } @@ -74,14 +72,4 @@ public class CameraPicker extends RotateImageView implements View.OnClickListene mPreference.setValue((String) mCameras[mCameraFacing]); mListener.onSharedPreferenceChanged(); } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (enabled) { - clearColorFilter(); - } else { - setColorFilter(DISABLED_COLOR); - } - } } diff --git a/src/com/android/camera/ui/ColorFilterImageView.java b/src/com/android/camera/ui/ColorFilterImageView.java new file mode 100644 index 0000000..bce7809 --- /dev/null +++ b/src/com/android/camera/ui/ColorFilterImageView.java @@ -0,0 +1,49 @@ +/* + * 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. + */ + +package com.android.camera.ui; + +import com.android.camera.R; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ImageView; + +/** + * A @{code ImageView} which grey out the icon if disabled. + */ +public class ColorFilterImageView extends ImageView { + private int DISABLED_COLOR; + + public ColorFilterImageView(Context context, AttributeSet attrs) { + super(context, attrs); + DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color); + } + + public ColorFilterImageView(Context context) { + this(context, null); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (enabled) { + clearColorFilter(); + } else { + setColorFilter(DISABLED_COLOR); + } + } +} diff --git a/src/com/android/camera/ui/IndicatorControl.java b/src/com/android/camera/ui/IndicatorControl.java index 2dd8777..78d51c1 100644 --- a/src/com/android/camera/ui/IndicatorControl.java +++ b/src/com/android/camera/ui/IndicatorControl.java @@ -37,6 +37,8 @@ import java.util.ArrayList; public abstract class IndicatorControl extends RelativeLayout implements IndicatorButton.Listener, OtherSettingsPopup.Listener { private static final String TAG = "IndicatorControl"; + public static final int MODE_CAMERA = 0; + public static final int MODE_VIDEO = 1; private Context mContext; private OnPreferenceChangedListener mListener; @@ -46,6 +48,8 @@ public abstract class IndicatorControl extends RelativeLayout implements private PreferenceGroup mPreferenceGroup; private int mDegree = 0; + protected int mCurrentMode = MODE_CAMERA; + ArrayList<AbstractIndicatorButton> mIndicators = new ArrayList<AbstractIndicatorButton>(); @@ -76,6 +80,12 @@ public abstract class IndicatorControl extends RelativeLayout implements public void setPreferenceGroup(PreferenceGroup group) { mPreferenceGroup = group; + // Preset the current mode from the title of preference group. + String title = group.getTitle(); + if (title.equals(mContext.getString( + R.string.pref_camcorder_settings_category))) { + mCurrentMode = MODE_VIDEO; + } } protected void addControls(String[] keys, String[] otherSettingKeys) { @@ -186,8 +196,17 @@ public abstract class IndicatorControl extends RelativeLayout implements // Zoom buttons and shutter button are controlled by the activity. if (v instanceof AbstractIndicatorButton) { v.setEnabled(enabled); + // Show or hide the indicator buttons during recording. + if (mCurrentMode == MODE_VIDEO) { + v.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); + } + } + } + if (mCameraPicker != null) { + mCameraPicker.setEnabled(enabled); + if (mCurrentMode == MODE_VIDEO) { + mCameraPicker.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); } } - if (mCameraPicker != null) mCameraPicker.setEnabled(enabled); } } diff --git a/src/com/android/camera/ui/IndicatorControlBar.java b/src/com/android/camera/ui/IndicatorControlBar.java index ed47f96..773645f 100644 --- a/src/com/android/camera/ui/IndicatorControlBar.java +++ b/src/com/android/camera/ui/IndicatorControlBar.java @@ -103,4 +103,16 @@ public class IndicatorControlBar extends IndicatorControl implements } if (mCameraPicker != null) mCameraPicker.layout(0, offset, width, offset + width); } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (mCurrentMode == MODE_VIDEO) { + mSecondLevelIcon.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); + } else { + // We also disable the zoom button during snapshot. + if (mZoomIcon != null) mZoomIcon.setEnabled(enabled); + } + mSecondLevelIcon.setEnabled(enabled); + } } diff --git a/src/com/android/camera/ui/IndicatorControlBarContainer.java b/src/com/android/camera/ui/IndicatorControlBarContainer.java index 56e887d..0783065 100644 --- a/src/com/android/camera/ui/IndicatorControlBarContainer.java +++ b/src/com/android/camera/ui/IndicatorControlBarContainer.java @@ -158,4 +158,10 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer mSecondLevelIndicatorControlBar.overrideSettings(keyvalues); } } + + @Override + public void setEnabled(boolean enabled) { + mIndicatorControlBar.setEnabled(enabled); + mSecondLevelIndicatorControlBar.setEnabled(enabled); + } } diff --git a/src/com/android/camera/ui/IndicatorControlWheel.java b/src/com/android/camera/ui/IndicatorControlWheel.java index 8d37b19..9279cc2 100644 --- a/src/com/android/camera/ui/IndicatorControlWheel.java +++ b/src/com/android/camera/ui/IndicatorControlWheel.java @@ -88,7 +88,6 @@ public class IndicatorControlWheel extends IndicatorControl implements // 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; @@ -110,7 +109,7 @@ public class IndicatorControlWheel extends IndicatorControl implements private double mSectorRadians[] = new double[2]; private double mTouchSectorRadians[] = new double[2]; - private View mZoomIcon; + private ImageView mZoomIcon; public IndicatorControlWheel(Context context, AttributeSet attrs) { super(context, attrs); @@ -125,7 +124,6 @@ public class IndicatorControlWheel extends IndicatorControl implements mBackgroundPaint.setAntiAlias(true); mBackgroundRect = new RectF(); - DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color); } private int getChildCountByLevel(int level) { @@ -182,7 +180,12 @@ public class IndicatorControlWheel extends IndicatorControl implements } private ImageView addImageButton(Context context, int resourceId, boolean rotatable) { - ImageView view = rotatable ? new RotateImageView(context) : new ImageView(context); + ImageView view; + if (rotatable) { + view = new RotateImageView(context); + } else { + view = new ColorFilterImageView(context); + } view.setImageResource(resourceId); view.setOnClickListener(this); addView(view); @@ -309,6 +312,7 @@ public class IndicatorControlWheel extends IndicatorControl implements // The icons are spreaded on the left side of the shutter button. for (int i = 0; i < getChildCount(); ++i) { View view = getChildAt(i); + if (!view.isEnabled()) continue; double radian = mChildRadians[i]; double startVisibleRadians = mInAnimation ? mStartVisibleRadians[1] @@ -467,12 +471,13 @@ public class IndicatorControlWheel extends IndicatorControl implements @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); - if (enabled) { - mSecondLevelIcon.clearColorFilter(); - mCloseIcon.clearColorFilter(); + if (mCurrentMode == MODE_VIDEO) { + mSecondLevelIcon.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); + mCloseIcon.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); + requestLayout(); } else { - mSecondLevelIcon.setColorFilter(DISABLED_COLOR); - mCloseIcon.setColorFilter(DISABLED_COLOR); + // We also disable the zoom button during snapshot. + if (mZoomIcon != null) mZoomIcon.setEnabled(enabled); } mSecondLevelIcon.setEnabled(enabled); mCloseIcon.setEnabled(enabled); diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java index c58d0c9..81faaec 100644 --- a/src/com/android/camera/ui/RotateImageView.java +++ b/src/com/android/camera/ui/RotateImageView.java @@ -32,7 +32,7 @@ import android.widget.ImageView; /** * A @{code ImageView} which can rotate it's content. */ -public class RotateImageView extends ImageView { +public class RotateImageView extends ColorFilterImageView { @SuppressWarnings("unused") private static final String TAG = "RotateImageView"; diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java index 5ce586e..b725002 100644 --- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java +++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java @@ -43,7 +43,7 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements public void initialize(Context context, PreferenceGroup group, String[] keys, String[] otherSettingKeys) { if (mCloseIcon == null) { - mCloseIcon = new ImageView(context); + mCloseIcon = new ColorFilterImageView(context); mCloseIcon.setImageResource(R.drawable.btn_close_settings); mCloseIcon.setOnClickListener(this); addView(mCloseIcon); @@ -112,4 +112,13 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements top + i * height / count + h); } } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (mCurrentMode == MODE_VIDEO) { + mCloseIcon.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); + } + mCloseIcon.setEnabled(enabled); + } } |