summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
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) {