summaryrefslogtreecommitdiffstats
path: root/ui/android
diff options
context:
space:
mode:
authorpaulnavin@google.com <paulnavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 12:30:28 +0000
committerpaulnavin@google.com <paulnavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 12:30:28 +0000
commitbafa212a4acc0e91a413701e2fe94a44cdd0fe26 (patch)
tree08d0a61caf0d80b6f81b1402a1e38c81fbc07d1a /ui/android
parent6929e3bf2f480d8932a5f8bf1e393a3c74447bc7 (diff)
downloadchromium_src-bafa212a4acc0e91a413701e2fe94a44cdd0fe26.zip
chromium_src-bafa212a4acc0e91a413701e2fe94a44cdd0fe26.tar.gz
chromium_src-bafa212a4acc0e91a413701e2fe94a44cdd0fe26.tar.bz2
Adding backwards compatibility to ColorPicker.
Several features used in the ColorPicker are not available or deprecated in versions less than Jellybean.. These are: - SeekBar.getThumb() - GradientDrawable.setColors(int[]) - View.setBackground(Drawable) This provides alternatives for these for versions less than Jellybean. BUG=247294 Review URL: https://chromiumcodereview.appspot.com/15674008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/android')
-rw-r--r--ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java b/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java
index 259b88c..1e679d5 100644
--- a/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java
+++ b/ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java
@@ -4,11 +4,15 @@
package org.chromium.ui;
+import android.content.Context;
import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.GradientDrawable.Orientation;
+import android.os.Build;
import android.view.View;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
+import org.chromium.base.ApiCompatibilityUtils;
/**
* Encapsulates a single gradient view of the HSV color display, including its label, gradient
@@ -24,7 +28,7 @@ public class ColorPickerAdvancedComponent {
// The set of colors to interpolate the gradient through.
private int[] mGradientColors;
// The Drawable that represents the gradient.
- private final GradientDrawable mGradientDrawable;
+ private GradientDrawable mGradientDrawable;
// The text label for the component.
private final TextView mText;
@@ -49,7 +53,11 @@ public class ColorPickerAdvancedComponent {
mSeekBar.setMax(seekBarMax);
// Setting the thumb offset means the seek bar thumb can move all the way to each end
// of the gradient view.
- mSeekBar.setThumbOffset(mSeekBar.getThumb().getIntrinsicWidth() / 2);
+ Context context = rootView.getContext();
+ int offset = context.getResources()
+ .getDrawable(R.drawable.color_picker_advanced_select_handle)
+ .getIntrinsicWidth();
+ mSeekBar.setThumbOffset(offset / 2);
}
/**
@@ -75,7 +83,12 @@ public class ColorPickerAdvancedComponent {
*/
public void setGradientColors(int[] newColors) {
mGradientColors = newColors.clone();
- mGradientDrawable.setColors(mGradientColors);
- mGradientView.setBackground(mGradientDrawable);
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ Orientation currentOrientation = Orientation.LEFT_RIGHT;
+ mGradientDrawable = new GradientDrawable(currentOrientation, mGradientColors);
+ } else {
+ mGradientDrawable.setColors(mGradientColors);
+ }
+ ApiCompatibilityUtils.setBackgroundForView(mGradientView, mGradientDrawable);
}
}