More detailed time display in IdlePreference
This commit is contained in:
parent
025c6e20f8
commit
9224095dba
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (C) 2010 Christopher Eby <kreed@kreed.org>
|
Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -85,13 +85,17 @@ THE SOFTWARE.
|
|||||||
<string name="title_by_artist">%1$s by %2$s</string>
|
<string name="title_by_artist">%1$s by %2$s</string>
|
||||||
|
|
||||||
<!-- Preferences -->
|
<!-- Preferences -->
|
||||||
|
<plurals name="seconds">
|
||||||
|
<item quantity="one">01 second</item>
|
||||||
|
<item quantity="other">%02d seconds</item>
|
||||||
|
</plurals>
|
||||||
<plurals name="minutes">
|
<plurals name="minutes">
|
||||||
<item quantity="one">1 minute</item>
|
<item quantity="one">01 minute</item>
|
||||||
<item quantity="other">%d minutes</item>
|
<item quantity="other">%02d minutes</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<plurals name="hours">
|
<plurals name="hours">
|
||||||
<item quantity="one">1 hour</item>
|
<item quantity="one">01 hour</item>
|
||||||
<item quantity="other">%d hours</item>
|
<item quantity="other">%02d hours</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
<string name="pref_output">Audio Output</string>
|
<string name="pref_output">Audio Output</string>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 Christopher Eby <kreed@kreed.org>
|
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -95,15 +95,21 @@ public class IdlePreference extends DialogPreference implements SeekBar.OnSeekBa
|
|||||||
{
|
{
|
||||||
Resources res = getContext().getResources();
|
Resources res = getContext().getResources();
|
||||||
int value = mValue;
|
int value = mValue;
|
||||||
String text;
|
StringBuilder text = new StringBuilder();
|
||||||
if (value >= 3570) {
|
if (value >= 3600) {
|
||||||
int hours = (int)Math.round(value / 3600f);
|
int hours = value / 3600;
|
||||||
text = res.getQuantityString(R.plurals.hours, hours, hours);
|
text.append(res.getQuantityString(R.plurals.hours, hours, hours));
|
||||||
|
text.append(", ");
|
||||||
|
int minutes = value / 60 - hours * 60;
|
||||||
|
text.append(res.getQuantityString(R.plurals.minutes, minutes, minutes));
|
||||||
} else {
|
} else {
|
||||||
int minutes = (int)Math.round(value / 60f);
|
int minutes = value / 60;
|
||||||
text = res.getQuantityString(R.plurals.minutes, minutes, minutes);
|
text.append(res.getQuantityString(R.plurals.minutes, minutes, minutes));
|
||||||
|
text.append(", ");
|
||||||
|
int seconds = value - minutes * 60;
|
||||||
|
text.append(res.getQuantityString(R.plurals.seconds, seconds, seconds));
|
||||||
}
|
}
|
||||||
mValueText.setText(text);
|
mValueText.setText(text.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,7 +121,7 @@ public class IdlePreference extends DialogPreference implements SeekBar.OnSeekBa
|
|||||||
|
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
||||||
{
|
{
|
||||||
// Approximate an exponential curve with x^4. Produces a value from 60-10860.
|
// Approximate an exponential curve with x^4. Produces a value from MIN-MAX.
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
float value = seekBar.getProgress() / 1000.0f;
|
float value = seekBar.getProgress() / 1000.0f;
|
||||||
value *= value;
|
value *= value;
|
||||||
@ -126,10 +132,10 @@ public class IdlePreference extends DialogPreference implements SeekBar.OnSeekBa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onStartTrackingTouch(SeekBar seekBar)
|
public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar)
|
public void onStopTrackingTouch(SeekBar seekBar)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user