diff options
author | Yuli Huang <yuli@google.com> | 2012-04-02 21:40:25 +0800 |
---|---|---|
committer | Yuli Huang <yuli@google.com> | 2012-04-02 22:58:51 +0800 |
commit | ed56097798bd587243962af29986a314174b60ac (patch) | |
tree | 7f3cbf30487d09e754ff2a857dd346e42249eb85 | |
parent | 49b137806386ff0c8cf5caba4bf7e0a9aab4b7b9 (diff) | |
download | android_packages_apps_Gallery2-ed56097798bd587243962af29986a314174b60ac.tar.gz android_packages_apps_Gallery2-ed56097798bd587243962af29986a314174b60ac.tar.bz2 android_packages_apps_Gallery2-ed56097798bd587243962af29986a314174b60ac.zip |
Fix b/5974240: Sliders may not be responsive to touches.
Add padding around sliders to increase its touchable areas.
Change-Id: I034e25804811b14ce6137c72472191dabd7bdef8
-rw-r--r-- | res/layout/photoeditor_color_seekbar.xml | 7 | ||||
-rw-r--r-- | res/layout/photoeditor_effect_tool_panel.xml | 5 | ||||
-rw-r--r-- | res/layout/photoeditor_scale_seekbar.xml | 7 | ||||
-rwxr-xr-x | res/values-sw320dp/photoeditor_dimens.xml | 10 | ||||
-rwxr-xr-x | res/values-sw600dp/photoeditor_dimens.xml | 10 | ||||
-rwxr-xr-x | res/values-sw800dp/photoeditor_dimens.xml | 10 | ||||
-rw-r--r-- | res/values/photoeditor_styles.xml | 14 | ||||
-rw-r--r-- | src/com/android/gallery3d/photoeditor/actions/AbstractSeekBar.java | 20 | ||||
-rw-r--r-- | src/com/android/gallery3d/photoeditor/actions/ColorSeekBar.java | 33 | ||||
-rw-r--r-- | src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java | 15 |
10 files changed, 73 insertions, 58 deletions
diff --git a/res/layout/photoeditor_color_seekbar.xml b/res/layout/photoeditor_color_seekbar.xml index fb9386992..ca8509de1 100644 --- a/res/layout/photoeditor_color_seekbar.xml +++ b/res/layout/photoeditor_color_seekbar.xml @@ -16,9 +16,4 @@ <com.android.gallery3d.photoeditor.actions.ColorSeekBar xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="@dimen/seekbar_width" - android:layout_height="@dimen/seekbar_height" - android:layout_marginBottom="@dimen/seekbar_margin_bottom" - android:minHeight="@dimen/seekbar_height" - android:maxHeight="@dimen/seekbar_height" - android:progressDrawable="@android:color/transparent"/> + style="@style/SeekBar"/> diff --git a/res/layout/photoeditor_effect_tool_panel.xml b/res/layout/photoeditor_effect_tool_panel.xml index 7fd92571c..4ffd52d90 100644 --- a/res/layout/photoeditor_effect_tool_panel.xml +++ b/res/layout/photoeditor_effect_tool_panel.xml @@ -18,12 +18,13 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:padding="@dimen/effect_tool_panel_padding" + android:paddingTop="@dimen/effect_tool_panel_padding_top" + android:paddingBottom="@dimen/effect_tool_panel_padding_bottom" android:background="@color/translucent_black" android:gravity="center_horizontal" android:orientation="vertical"> <TextView android:id="@+id/effect_label" - style="@style/EffectLabel"/> + style="@style/EffectLabelInToolPanel"/> </LinearLayout> diff --git a/res/layout/photoeditor_scale_seekbar.xml b/res/layout/photoeditor_scale_seekbar.xml index d8df19fb0..15fc2346b 100644 --- a/res/layout/photoeditor_scale_seekbar.xml +++ b/res/layout/photoeditor_scale_seekbar.xml @@ -16,9 +16,4 @@ <com.android.gallery3d.photoeditor.actions.ScaleSeekBar xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="@dimen/seekbar_width" - android:layout_height="@dimen/seekbar_height" - android:layout_marginBottom="@dimen/seekbar_margin_bottom" - android:minHeight="@dimen/seekbar_height" - android:maxHeight="@dimen/seekbar_height" - android:progressDrawable="@android:color/transparent"/> + style="@style/SeekBar"/> diff --git a/res/values-sw320dp/photoeditor_dimens.xml b/res/values-sw320dp/photoeditor_dimens.xml index ff76e2557..a7d6a24b1 100755 --- a/res/values-sw320dp/photoeditor_dimens.xml +++ b/res/values-sw320dp/photoeditor_dimens.xml @@ -27,9 +27,11 @@ <dimen name="action_bar_icon_padding_right">5dp</dimen> <dimen name="action_button_padding_horizontal">13dp</dimen> <dimen name="effects_menu_container_width">320dp</dimen> - <dimen name="effect_tool_panel_padding">10dp</dimen> - <dimen name="seekbar_width">290dp</dimen> - <dimen name="seekbar_height">27dp</dimen> - <dimen name="seekbar_margin_bottom">3dp</dimen> + <dimen name="effect_tool_panel_padding_top">3dp</dimen> + <dimen name="effect_tool_panel_padding_bottom">8dp</dimen> + <dimen name="seekbar_width">350dp</dimen> + <dimen name="seekbar_height">43dp</dimen> + <dimen name="seekbar_padding_horizontal">30dp</dimen> + <dimen name="seekbar_padding_vertical">8dp</dimen> <dimen name="crop_indicator_size">35dp</dimen> </resources> diff --git a/res/values-sw600dp/photoeditor_dimens.xml b/res/values-sw600dp/photoeditor_dimens.xml index 29d7f5336..b861150c9 100755 --- a/res/values-sw600dp/photoeditor_dimens.xml +++ b/res/values-sw600dp/photoeditor_dimens.xml @@ -29,9 +29,11 @@ <dimen name="action_button_padding_vertical">8dp</dimen> <dimen name="action_button_padding_horizontal">22dp</dimen> <dimen name="effects_menu_container_width">400dp</dimen> - <dimen name="effect_tool_panel_padding">13dp</dimen> - <dimen name="seekbar_width">560dp</dimen> - <dimen name="seekbar_height">35dp</dimen> - <dimen name="seekbar_margin_bottom">4dp</dimen> + <dimen name="effect_tool_panel_padding_top">4dp</dimen> + <dimen name="effect_tool_panel_padding_bottom">11dp</dimen> + <dimen name="seekbar_width">640dp</dimen> + <dimen name="seekbar_height">57dp</dimen> + <dimen name="seekbar_padding_horizontal">40dp</dimen> + <dimen name="seekbar_padding_vertical">11dp</dimen> <dimen name="crop_indicator_size">43dp</dimen> </resources> diff --git a/res/values-sw800dp/photoeditor_dimens.xml b/res/values-sw800dp/photoeditor_dimens.xml index e869acf55..804a8cae7 100755 --- a/res/values-sw800dp/photoeditor_dimens.xml +++ b/res/values-sw800dp/photoeditor_dimens.xml @@ -29,9 +29,11 @@ <dimen name="action_button_padding_vertical">8dp</dimen> <dimen name="action_button_padding_horizontal">28dp</dimen> <dimen name="effects_menu_container_width">400dp</dimen> - <dimen name="effect_tool_panel_padding">15dp</dimen> - <dimen name="seekbar_width">560dp</dimen> - <dimen name="seekbar_height">35dp</dimen> - <dimen name="seekbar_margin_bottom">5dp</dimen> + <dimen name="effect_tool_panel_padding_top">5dp</dimen> + <dimen name="effect_tool_panel_padding_bottom">13dp</dimen> + <dimen name="seekbar_width">640dp</dimen> + <dimen name="seekbar_height">61dp</dimen> + <dimen name="seekbar_padding_horizontal">40dp</dimen> + <dimen name="seekbar_padding_vertical">13dp</dimen> <dimen name="crop_indicator_size">48dp</dimen> </resources> diff --git a/res/values/photoeditor_styles.xml b/res/values/photoeditor_styles.xml index 7bd7fd098..c02296df4 100644 --- a/res/values/photoeditor_styles.xml +++ b/res/values/photoeditor_styles.xml @@ -54,6 +54,20 @@ <item name="android:layout_alignParentBottom">true</item> <item name="android:orientation">vertical</item> </style> + <style name="EffectLabelInToolPanel" parent="@style/EffectLabel"> + <item name="android:layout_marginTop">0dp</item> + </style> + <style name="SeekBar"> + <item name="android:layout_width">@dimen/seekbar_width</item> + <item name="android:layout_height">@dimen/seekbar_height</item> + <item name="android:paddingTop">@dimen/seekbar_padding_vertical</item> + <item name="android:paddingBottom">@dimen/seekbar_padding_vertical</item> + <item name="android:paddingLeft">@dimen/seekbar_padding_horizontal</item> + <item name="android:paddingRight">@dimen/seekbar_padding_horizontal</item> + <item name="android:minHeight">@dimen/seekbar_height</item> + <item name="android:maxHeight">@dimen/seekbar_height</item> + <item name="android:background">@android:color/transparent</item> + </style> <style name="ActionBarInner"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">?android:attr/actionBarSize</item> diff --git a/src/com/android/gallery3d/photoeditor/actions/AbstractSeekBar.java b/src/com/android/gallery3d/photoeditor/actions/AbstractSeekBar.java index 27a0bce0b..aaf0e5ba3 100644 --- a/src/com/android/gallery3d/photoeditor/actions/AbstractSeekBar.java +++ b/src/com/android/gallery3d/photoeditor/actions/AbstractSeekBar.java @@ -28,7 +28,7 @@ import android.widget.SeekBar; import com.android.gallery3d.R; /** - * Seek-bar base that implements a draggable thumb that fits seek-bar height. + * Seek-bar base that implements a draggable thumb that fits seek-bar's track height. */ abstract class AbstractSeekBar extends SeekBar { @@ -38,22 +38,22 @@ abstract class AbstractSeekBar extends SeekBar { @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - - // Scale the thumb to fit seek-bar height. + // Scale the thumb to fit seek-bar's track height. Resources res = getResources(); Drawable thumb = res.getDrawable(R.drawable.photoeditor_seekbar_thumb); + int height = h - getPaddingTop() - getPaddingBottom(); + int scaledWidth = thumb.getIntrinsicWidth() * height / thumb.getIntrinsicHeight(); - // Set the left/right padding to half width of the thumb drawn. - int scaledWidth = thumb.getIntrinsicWidth() * h / thumb.getIntrinsicHeight(); - int padding = (scaledWidth + 1) / 2; - setPadding(padding, 0, padding, 0); - - Bitmap bitmap = Bitmap.createBitmap(scaledWidth, h, Bitmap.Config.ARGB_8888); + Bitmap bitmap = Bitmap.createBitmap(scaledWidth, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); thumb.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); thumb.draw(canvas); + // The thumb should not extend out of the track per UX design. setThumb(new BitmapDrawable(res, bitmap)); + setThumbOffset(0); + + // The thumb position is updated here after the thumb is changed. + super.onSizeChanged(w, h, oldw, oldh); } } diff --git a/src/com/android/gallery3d/photoeditor/actions/ColorSeekBar.java b/src/com/android/gallery3d/photoeditor/actions/ColorSeekBar.java index 5f9809be0..41d1f2448 100644 --- a/src/com/android/gallery3d/photoeditor/actions/ColorSeekBar.java +++ b/src/com/android/gallery3d/photoeditor/actions/ColorSeekBar.java @@ -42,7 +42,7 @@ class ColorSeekBar extends AbstractSeekBar { } private final int[] colors; - private Bitmap background; + private Bitmap progressDrawable; public ColorSeekBar(Context context, AttributeSet attrs) { super(context, attrs); @@ -61,46 +61,47 @@ class ColorSeekBar extends AbstractSeekBar { protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); - if (background != null) { - background.recycle(); + if (progressDrawable != null) { + progressDrawable.recycle(); } - background = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(background); + int width = w - getPaddingLeft() - getPaddingRight(); + int height = h - getPaddingTop() - getPaddingBottom(); + progressDrawable = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(progressDrawable); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.FILL); - // Draw two half circles in the first and last colors at seek-bar left/right ends. - int radius = getThumbOffset(); + // Draw two half circles in the first and last colors at the left/right ends. + int radius = height / 2; float left = radius; - float right = w - radius; - float cy = h / 2; + float right = width - radius; canvas.save(); - canvas.clipRect(left, 0, right, h, Op.DIFFERENCE); + canvas.clipRect(left, 0, right, height, Op.DIFFERENCE); paint.setColor(colors[0]); - canvas.drawCircle(left, cy, radius, paint); + canvas.drawCircle(left, radius, radius, paint); paint.setColor(colors[colors.length - 1]); - canvas.drawCircle(right, cy, radius, paint); + canvas.drawCircle(right, radius, radius, paint); canvas.restore(); // Draw color strips that make the thumb stop at every strip's center during seeking. float strip = (right - left) / (colors.length - 1); right = left + strip / 2; paint.setColor(colors[0]); - canvas.drawRect(left, 0, right, h, paint); + canvas.drawRect(left, 0, right, height, paint); left = right; for (int i = 1; i < colors.length - 1; i++) { right = left + strip; paint.setColor(colors[i]); - canvas.drawRect(left, 0, right, h, paint); + canvas.drawRect(left, 0, right, height, paint); left = right; } right = left + strip / 2; paint.setColor(colors[colors.length - 1]); - canvas.drawRect(left, 0, right, h, paint); + canvas.drawRect(left, 0, right, height, paint); - setBackgroundDrawable(new BitmapDrawable(getResources(), background)); + setProgressDrawable(new BitmapDrawable(getResources(), progressDrawable)); } public void setOnColorChangeListener(final OnColorChangeListener listener) { diff --git a/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java b/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java index fbb54d948..285e06b64 100644 --- a/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java +++ b/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java @@ -17,6 +17,8 @@ package com.android.gallery3d.photoeditor.actions; import android.content.Context; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.os.SystemClock; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -109,24 +111,25 @@ public class EffectToolKit { return tool; } - private int getScalePickerBackground(ScaleType type) { + private Drawable getScalePickerProgressDrawable(Resources res, ScaleType type) { switch (type) { case LIGHT: - return R.drawable.photoeditor_scale_seekbar_light; + return res.getDrawable(R.drawable.photoeditor_scale_seekbar_light); case SHADOW: - return R.drawable.photoeditor_scale_seekbar_shadow; + return res.getDrawable(R.drawable.photoeditor_scale_seekbar_shadow); case COLOR: - return R.drawable.photoeditor_scale_seekbar_color; + return res.getDrawable(R.drawable.photoeditor_scale_seekbar_color); } - return R.drawable.photoeditor_scale_seekbar_generic; + return res.getDrawable(R.drawable.photoeditor_scale_seekbar_generic); } public ScaleSeekBar addScalePicker(ScaleType type) { ScaleSeekBar scalePicker = (ScaleSeekBar) addPanelTool( R.layout.photoeditor_scale_seekbar); - scalePicker.setBackgroundResource(getScalePickerBackground(type)); + scalePicker.setProgressDrawable(getScalePickerProgressDrawable( + toolPanel.getResources(), type)); return scalePicker; } |