Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20267] Android: fix slider track showing #8863

Merged
merged 2 commits into from Jun 8, 2017

Conversation

frankieandone
Copy link
Contributor

@frankieandone frankieandone commented Mar 7, 2017

Test Case:
Expect to see track to be visible beneath transparent thumbImage.
screenshot_1496943982

var win = Ti.UI.createWindow();
var sldr = Ti.UI.createSlider({
	min: 1,
	max: 51,
	value: 51,
	thumbImage: "thumb.png",
	splitTrack: false
});
win.add(sldr);
win.open();

JIRA: https://jira.appcelerator.org/browse/TIMOB-20267

@frankieandone frankieandone self-assigned this Mar 7, 2017
@frankieandone frankieandone added this to the 6.1.0 milestone Mar 7, 2017
@frankieandone frankieandone requested review from jquick-axway and removed request for antw12 June 1, 2017 21:11
Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: Pass

@hansemannn hansemannn modified the milestones: 6.2.0, 6.1.0 Jun 5, 2017
@ssjsamir ssjsamir self-requested a review June 8, 2017 18:18
Copy link
Contributor

@ssjsamir ssjsamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FR passed, was able to see the slider track beneath the transparent thumbImage.

Test Steps:

  • Downloaded the SDK Build from this PR
  • Created a new Titanium project
  • Copied the the test case from description
  • Added a transparent thumbimage and background
  • Ran the application
  • Was able to see the track bar under the transparent image

screen shot 2017-06-08 at 11 23 13 am

Test Environment
Appcelerator Command-Line Interface, version 6.2.2
Google Nexus 6P (7.1.1)
Nexus 6 (6.0)
Operating System Name: Mac OS X El Capitan
Operating System Version: 10.11.6
Node.js Version: 6.10.1
Xcode: 8.2
Appcelerator Studio: 4.9.0.201705251638

@ssjsamir ssjsamir merged commit 5c94d44 into tidev:master Jun 8, 2017
if (d.containsKey("thumbImage")) {
updateThumb(seekBar, d);
}

if (d.containsKey(TiC.PROPERTY_SPLIT_TRACK)) {
seekBar.setSplitTrack(TiConvert.toBoolean(d.get(TiC.PROPERTY_SPLIT_TRACK)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you guard this line to apply only for API 21 and above? It causes crashes on lower levels since it was added for Lollipop.

https://developer.android.com/reference/android/widget/AbsSeekBar.html#setSplitTrack(boolean)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Yordan.

We also have to watch out in case the property value is not a boolean. So, the code should look something like this...

if (Build.VERSION.SDK_INT  >= 21) {
	ApiLevel21.setSplitTrack(this.seekBar, TiConvert.toBoolean([[value]], false));
}

private static class ApiLevel21
{
	private ApiLevel21() {}

	public void setSplitTrack(SeekBar seekBar, boolean enabled)
	{
		if (seekBar != null) {
			seekBar.setSplitTrack(enabled);
		}
	}
}

The static inner class above avoids the opcode warning on the lower API levels.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@ypbnv ypbnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guarding for API level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants