summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2011-09-22 18:22:44 +0800
committerChung-yih Wang <cywang@google.com>2011-09-23 12:57:01 +0800
commit842f11c8716bc6320b1b7c228742c0dd1cab2d0b (patch)
tree4532c6a076cef81e89dcc5d3c08571d8eabee4f3 /src/com
parentdd28e1cc00373c02adf88dff878dbbe5d8be9e59 (diff)
downloadLegacyCamera-842f11c8716bc6320b1b7c228742c0dd1cab2d0b.zip
LegacyCamera-842f11c8716bc6320b1b7c228742c0dd1cab2d0b.tar.gz
LegacyCamera-842f11c8716bc6320b1b7c228742c0dd1cab2d0b.tar.bz2
Show the hightlight bar of the active indicator button.
bug:5039235 Change-Id: I79d4b7be080748b2715b8826924de65e0d75ef39
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/ui/AbstractIndicatorButton.java13
-rw-r--r--src/com/android/camera/ui/IndicatorControl.java11
-rw-r--r--src/com/android/camera/ui/SecondLevelIndicatorControlBar.java80
-rw-r--r--src/com/android/camera/ui/ZoomIndexBar.java68
4 files changed, 82 insertions, 90 deletions
diff --git a/src/com/android/camera/ui/AbstractIndicatorButton.java b/src/com/android/camera/ui/AbstractIndicatorButton.java
index aa632f7..503d21e 100644
--- a/src/com/android/camera/ui/AbstractIndicatorButton.java
+++ b/src/com/android/camera/ui/AbstractIndicatorButton.java
@@ -36,6 +36,11 @@ public abstract class AbstractIndicatorButton extends RotateImageView {
protected AbstractSettingPopup mPopup;
protected Handler mHandler = new MainHandler();
private final int MSG_DISMISS_POPUP = 0;
+ private PopupChangeListener mListener;
+
+ public static interface PopupChangeListener {
+ public void onShowPopup(View view, boolean showed);
+ }
public AbstractIndicatorButton(Context context) {
super(context);
@@ -46,6 +51,10 @@ public abstract class AbstractIndicatorButton extends RotateImageView {
setScaleType(ImageView.ScaleType.CENTER);
}
+ public void setPopupChangeListener(PopupChangeListener listener) {
+ mListener = listener;
+ }
+
// Whether scene mode affects this indicator and it cannot be changed.
public boolean isOverridden() {
return false;
@@ -105,7 +114,7 @@ public abstract class AbstractIndicatorButton extends RotateImageView {
mPopup.setOrientation(getDegree());
mPopup.clearAnimation();
mPopup.startAnimation(mFadeIn);
- setColorFilter(HIGHLIGHT_COLOR);
+ if (mListener != null) mListener.onShowPopup(this, true);
}
public boolean dismissPopup() {
@@ -114,7 +123,7 @@ public abstract class AbstractIndicatorButton extends RotateImageView {
mPopup.clearAnimation();
mPopup.startAnimation(mFadeOut);
mPopup.setVisibility(View.GONE);
- clearColorFilter();
+ if (mListener != null) mListener.onShowPopup(this, false);
invalidate();
// Indicator wheel needs to update the highlight indicator if this
// is dismissed by MSG_DISMISS_POPUP.
diff --git a/src/com/android/camera/ui/IndicatorControl.java b/src/com/android/camera/ui/IndicatorControl.java
index 4bc5d29..2a24c2e 100644
--- a/src/com/android/camera/ui/IndicatorControl.java
+++ b/src/com/android/camera/ui/IndicatorControl.java
@@ -124,19 +124,22 @@ public abstract class IndicatorControl extends RelativeLayout implements
return false;
}
- public void addIndicator(Context context, IconListPreference pref) {
+ public IndicatorButton addIndicator(Context context, IconListPreference pref) {
IndicatorButton b = new IndicatorButton(context, pref);
b.setSettingChangedListener(this);
addView(b);
mIndicators.add(b);
+ return b;
}
- public void addOtherSettingIndicator(Context context, int resId, String[] keys) {
- OtherSettingIndicatorButton b = new OtherSettingIndicatorButton(context, resId,
- mPreferenceGroup, keys);
+ public OtherSettingIndicatorButton addOtherSettingIndicator(Context context,
+ int resId, String[] keys) {
+ OtherSettingIndicatorButton b = new OtherSettingIndicatorButton(
+ context, resId, mPreferenceGroup, keys);
b.setSettingChangedListener(this);
addView(b);
mIndicators.add(b);
+ return b;
}
@Override
diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
index bfa9f94..9434df8 100644
--- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
+++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
@@ -16,6 +16,7 @@
package com.android.camera.ui;
+import com.android.camera.IconListPreference;
import com.android.camera.PreferenceGroup;
import com.android.camera.R;
import com.android.camera.Util;
@@ -31,13 +32,19 @@ import android.widget.ImageView;
* vertical bar in preview frame.
*/
public class SecondLevelIndicatorControlBar extends IndicatorControl implements
- View.OnClickListener {
+ View.OnClickListener, AbstractIndicatorButton.PopupChangeListener {
private static final String TAG = "SecondLevelIndicatorControlBar";
private static int ICON_SPACING = Util.dpToPixel(24);
private ImageView mCloseIcon;
private View mDivider; // the divider line
+ private View mIndicatorHighlight; // the side highlight bar
+ private View mPopupedIndicator;
int mDegree = 0;
int mSelectedIndex = -1;
+ // There are some views in the ViewGroup before adding the indicator buttons,
+ // such as Close icon, divider line and the hightlight bar, we need to
+ // remember the count of the non-indicator buttons for getTouchViewIndex().
+ int mNonIndicatorButtonCount;
public SecondLevelIndicatorControlBar(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -46,6 +53,7 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
@Override
protected void onFinishInflate() {
mDivider = findViewById(R.id.divider);
+ mIndicatorHighlight = findViewById(R.id.indicator_highlight);
}
public void initialize(Context context, PreferenceGroup group,
@@ -57,6 +65,7 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
addView(mCloseIcon);
}
setPreferenceGroup(group);
+ mNonIndicatorButtonCount = getChildCount();
addControls(keys, otherSettingKeys);
if (mDegree != 0) setDegree(mDegree);
}
@@ -68,20 +77,19 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
}
private int getTouchViewIndex(int y, int height) {
- int padding = getPaddingTop();
- int iconHeight = mCloseIcon.getMeasuredHeight();
- int totalIconHeight = iconHeight + ICON_SPACING;
// If the current touch location is on close icon and above.
- if (y < padding + totalIconHeight) return indexOfChild(mCloseIcon);
+ if (y < mCloseIcon.getBottom()) return indexOfChild(mCloseIcon);
- // The first two views are close icon and divider line, we have to
- // calculate if the touch event is on the rest indicator buttons.
+ // Calculate if the touch event is on the indicator buttons.
int count = getChildCount();
- if (count < 3) return -1;
- int selectionHeight = (count - 2) * totalIconHeight - (ICON_SPACING / 2);
- int selectionY = height - padding - selectionHeight;
- if (y < selectionY) return -1;
- return (2 + (y - selectionY) / totalIconHeight);
+ if (count == mNonIndicatorButtonCount) return -1;
+ // The baseline will be the first indicator button's top minus spacing.
+ View firstIndicatorButton = getChildAt(mNonIndicatorButtonCount);
+ int baselineY = firstIndicatorButton.getTop() - (ICON_SPACING / 2);
+ if (y < baselineY) return -1;
+ int iconHeight = firstIndicatorButton.getMeasuredHeight();
+ int buttonRange = iconHeight + ICON_SPACING;
+ return (mNonIndicatorButtonCount + (y - baselineY) / buttonRange);
}
@Override
@@ -121,6 +129,31 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
}
@Override
+ public IndicatorButton addIndicator(Context context, IconListPreference pref) {
+ IndicatorButton b = super.addIndicator(context, pref);
+ b.setPopupChangeListener(this);
+ return b;
+ }
+
+ @Override
+ public OtherSettingIndicatorButton addOtherSettingIndicator(Context context,
+ int resId, String[] keys) {
+ OtherSettingIndicatorButton b =
+ super.addOtherSettingIndicator(context, resId, keys);
+ b.setPopupChangeListener(this);
+ return b;
+ }
+
+ @Override
+ public void onShowPopup(View view, boolean showed) {
+ // Ignore those events if not current popup.
+ if (!showed && (mPopupedIndicator != view)) return;
+ mPopupedIndicator = (showed ? view : null);
+ // Show or dismiss the side indicator highlight.
+ requestLayout();
+ }
+
+ @Override
public void setDegree(int degree) {
mDegree = degree;
super.setDegree(degree);
@@ -137,19 +170,34 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
int padding = getPaddingTop();
// The first icon is close button.
+ int offsetY = padding;
mCloseIcon.layout(0, padding, width, (padding + iconHeight));
+
// And layout the divider line.
- mDivider.layout(0, (padding + iconHeight),
- width, (padding + iconHeight + mDivider.getMeasuredHeight()));
+ offsetY += (iconHeight + padding);
+ mDivider.layout(padding, offsetY,
+ (width - padding), (offsetY + mDivider.getMeasuredHeight()));
// Layout from the last icon up.
int startY = height - iconHeight - padding;
int decrement = iconHeight + ICON_SPACING;
- for (int i = count - 1; i > 1; --i) {
+ for (int i = count - 1; i >= mNonIndicatorButtonCount; --i) {
getChildAt(i).layout(0, startY, width, startY + iconHeight);
startY -= decrement;
}
- }
+
+ // Hightlight the selected indicator if exists.
+ if (mPopupedIndicator == null) {
+ mIndicatorHighlight.setVisibility(View.GONE);
+ } else {
+ mIndicatorHighlight.setVisibility(View.VISIBLE);
+ // Keep the top and bottom of the hightlight the same as
+ // the 'active' indicator button.
+ mIndicatorHighlight.layout(0, mPopupedIndicator.getTop(),
+ mIndicatorHighlight.getLayoutParams().width,
+ mPopupedIndicator.getBottom());
+ }
+ }
@Override
public void setEnabled(boolean enabled) {
diff --git a/src/com/android/camera/ui/ZoomIndexBar.java b/src/com/android/camera/ui/ZoomIndexBar.java
deleted file mode 100644
index 8a81c50..0000000
--- a/src/com/android/camera/ui/ZoomIndexBar.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.view.View;
-import android.widget.FrameLayout;
-
-/**
- * An indicator bar that indicates the current zoom index.
- */
-public class ZoomIndexBar extends FrameLayout implements
- ZoomControl.OnZoomIndexChangedListener {
- private static final int BAR_HEIGHT_FACTOR = 7;
- private View mIndexBar;
- private double mIndexPosition; // The index position is between 0 and 1.0.
- private int mDegree;
-
- public ZoomIndexBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onFinishInflate() {
- mIndexBar = findViewById(R.id.zoom_index);
- }
-
- public void onZoomIndexChanged(double indexPosition) {
- mIndexPosition = indexPosition;
- requestLayout();
- }
-
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- int height = bottom - top;
- int barHeight = height / BAR_HEIGHT_FACTOR;
- int barTop = (int) ((height - barHeight) * (1 - mIndexPosition));
- if (mDegree == 180) {
- mIndexBar.layout(left, bottom - barTop - barHeight, right,
- bottom - barTop);
- } else {
- mIndexBar.layout(left, barTop, right, barTop + barHeight);
- }
- }
-
- public void setDegree(int degree) {
- if ((degree != mDegree) && ((degree == 180) || (mDegree == 180))) requestLayout();
- mDegree = degree;
- }
-}