summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2011-09-15 10:11:52 +0800
committerChung-yih Wang <cywang@google.com>2011-09-20 14:24:03 +0800
commit6b3f2ff14ca0a0d694d5af13e4d5a392c8552191 (patch)
tree2de89479fdb3c6ee37c40cee2440eaf385ff9d73 /src/com
parent23a5e416ca6564cafcc80f7ee7f822e1dbe4d16b (diff)
downloadLegacyCamera-6b3f2ff14ca0a0d694d5af13e4d5a392c8552191.zip
LegacyCamera-6b3f2ff14ca0a0d694d5af13e4d5a392c8552191.tar.gz
LegacyCamera-6b3f2ff14ca0a0d694d5af13e4d5a392c8552191.tar.bz2
Follow UI redlines for indicator bars.
bug:5287560 1. options icons: No dark background. Use the dark background only when in advanced options. Make sure the position of the icons match the redlines, specifically the padding at the top and bottom. 2. second-level indicator bars: Modify the icons and spacing inbetween. Change-Id: Ic8d1382b8e07719c5f86b309e3853023e76dccd3
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/ui/IndicatorControlBar.java6
-rw-r--r--src/com/android/camera/ui/SecondLevelIndicatorControlBar.java49
-rw-r--r--src/com/android/camera/ui/ZoomControlBar.java10
3 files changed, 52 insertions, 13 deletions
diff --git a/src/com/android/camera/ui/IndicatorControlBar.java b/src/com/android/camera/ui/IndicatorControlBar.java
index 3838508..c1e6607 100644
--- a/src/com/android/camera/ui/IndicatorControlBar.java
+++ b/src/com/android/camera/ui/IndicatorControlBar.java
@@ -18,6 +18,7 @@ package com.android.camera.ui;
import com.android.camera.PreferenceGroup;
import com.android.camera.R;
+import com.android.camera.Util;
import android.content.Context;
import android.util.AttributeSet;
@@ -32,6 +33,9 @@ public class IndicatorControlBar extends IndicatorControl implements
View.OnClickListener, View.OnTouchListener {
private static final String TAG = "IndicatorControlBar";
+ // Space between indicator icons.
+ public static final int ICON_SPACING = Util.dpToPixel(16);
+
private ImageView mZoomIcon;
private ImageView mSecondLevelIcon;
@@ -103,7 +107,7 @@ public class IndicatorControlBar extends IndicatorControl implements
View view = getChildAt(i);
if (view instanceof IndicatorButton) {
view.layout(0, offset, width, offset + width);
- offset += width;
+ offset += (width + ICON_SPACING);
}
}
if (mCameraPicker != null) mCameraPicker.layout(0, offset, width, offset + width);
diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
index 670bbb9..386179d 100644
--- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
+++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
@@ -18,6 +18,7 @@ package com.android.camera.ui;
import com.android.camera.PreferenceGroup;
import com.android.camera.R;
+import com.android.camera.Util;
import android.content.Context;
import android.util.AttributeSet;
@@ -32,7 +33,9 @@ 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 ImageView mCloseIcon;
+ private View mDivider; // the divider line
int mDegree = 0;
int mSelectedIndex = -1;
@@ -40,6 +43,11 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
super(context, attrs);
}
+ @Override
+ protected void onFinishInflate() {
+ mDivider = findViewById(R.id.divider);
+ }
+
public void initialize(Context context, PreferenceGroup group,
String[] keys, String[] otherSettingKeys) {
if (mCloseIcon == null) {
@@ -59,6 +67,23 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
OnIndicatorEventListener.EVENT_LEAVE_SECOND_LEVEL_INDICATOR_BAR);
}
+ 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);
+
+ // The first two views are close icon and divider line, we have to
+ // calculate if the touch event is on the rest 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);
+ }
+
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (!onFilterTouchEventForSecurity(event)) return false;
@@ -73,7 +98,8 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
if (x > getWidth()) x = getWidth();
if (y >= height) y = height - 1;
- int index = (int) (y * getChildCount()) / height;
+ int index = getTouchViewIndex((int) y, height);
+ if (index == -1) return true;
View b = getChildAt(index);
b.dispatchTouchEvent(event);
if ((mSelectedIndex != -1) && (index != mSelectedIndex)) {
@@ -107,12 +133,21 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
if (count == 0) return;
int width = right - left;
int height = bottom - top;
- int h = height / count;
-
- // TODO: follow the redlines of UI design in next change. The icons are
- // simply distributed on the bar equally with current implmentation.
- for (int i = 0; i < count; i++) {
- getChildAt(i).layout(0, i * h, width, (i + 1) * h);
+ int iconHeight = mCloseIcon.getMeasuredHeight();
+ int padding = getPaddingTop();
+
+ // The first icon is close button.
+ mCloseIcon.layout(0, padding, width, (padding + iconHeight));
+ // And layout the divider line.
+ mDivider.layout(0, (padding + iconHeight),
+ width, (padding + iconHeight + 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) {
+ getChildAt(i).layout(0, startY, width, startY + iconHeight);
+ startY -= decrement;
}
}
diff --git a/src/com/android/camera/ui/ZoomControlBar.java b/src/com/android/camera/ui/ZoomControlBar.java
index 7de45e7..d906dea 100644
--- a/src/com/android/camera/ui/ZoomControlBar.java
+++ b/src/com/android/camera/ui/ZoomControlBar.java
@@ -96,14 +96,14 @@ public class ZoomControlBar extends ZoomControl {
// the zoom-in button should be on the top.
if (mDegree == 180) {
pos = h - mSliderPosition - width / 2;
- mZoomOut.layout(0, top, width, top + width);
- mZoomIn.layout(0, bottom - width, width, bottom);
+ mZoomOut.layout(0, 0, width, width);
+ mZoomIn.layout(0, height - width, width, height);
} else {
pos = h + mSliderPosition - width / 2;
- mZoomIn.layout(0, top, width, top + width);
- mZoomOut.layout(0, bottom - width, width, bottom);
+ mZoomIn.layout(0, 0, width, width);
+ mZoomOut.layout(0, height - width, width, height);
}
- mBar.layout(0, top + width, width, bottom - width);
+ mBar.layout(0, width, width, height - width);
// TODO: fix the pos once we have correct zoom_big asset.
if (pos < 3 * width / 4) {