Commit 1bd4ff3b authored by Jos's avatar Jos Committed by Jeffrey Schiller

Fix for #1119, thumb shows as a transparent block when deactivated in Lollipop+ (#1197)

parent 4467771c
...@@ -5,6 +5,7 @@ import android.graphics.PorterDuff; ...@@ -5,6 +5,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.SeekBar; import android.widget.SeekBar;
...@@ -96,6 +97,10 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha ...@@ -96,6 +97,10 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha
super(container); super(container);
seekbar = new SeekBar(container.$context()); seekbar = new SeekBar(container.$context());
if (SdkLevel.getLevel() >= SdkLevel.LEVEL_LOLLIPOP) {
seekbar.setSplitTrack(false);
}
fullBar = (LayerDrawable) seekbar.getProgressDrawable(); fullBar = (LayerDrawable) seekbar.getProgressDrawable();
beforeThumb = fullBar.findDrawableByLayerId(R.id.progress); beforeThumb = fullBar.findDrawableByLayerId(R.id.progress);
...@@ -142,15 +147,6 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha ...@@ -142,15 +147,6 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha
beforeThumb.setColorFilter(leftColor, PorterDuff.Mode.SRC); beforeThumb.setColorFilter(leftColor, PorterDuff.Mode.SRC);
} }
/**
* Given min, max, thumb position, this method determines where the thumb position would be
* within normal SeekBar 0-100 range
*
* @param min value for slider
* @param max value for slider
* @param thumb the slider thumb position
*/
// Set the seekbar position based on minValue, maxValue, and thumbPosition // Set the seekbar position based on minValue, maxValue, and thumbPosition
// seekbar position is an integer in the range [0,100] and is determined by MinValue, // seekbar position is an integer in the range [0,100] and is determined by MinValue,
// MaxValue and ThumbPosition // MaxValue and ThumbPosition
...@@ -181,8 +177,14 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha ...@@ -181,8 +177,14 @@ public class Slider extends AndroidViewComponent implements SeekBar.OnSeekBarCha
if (referenceGetThumb) { if (referenceGetThumb) {
new SeekBarHelper().getThumb(alpha); new SeekBarHelper().getThumb(alpha);
} }
seekbar.setEnabled(thumbEnabled);
// The Seekbar will respond to touch without the thumb. Consume the event with thumb disabled.
seekbar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return !thumbEnabled;
}
});
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment