config option for songs without RG tag

This commit is contained in:
Adrian Ulrich 2013-05-01 18:59:01 +02:00
parent 94ff9bd9e4
commit d317d7aebc
4 changed files with 20 additions and 1 deletions

View File

@ -161,6 +161,8 @@ THE SOFTWARE.
<string name="replaygain_album_title">Enable album Replay Gain</string>
<string name="replaygain_album_summary">Preserve album dynamics</string>
<string name="replaygain_bump_title">Replay Gain Pre-amp</string>
<string name="replaygain_untagged_debump_title">Songs without Replay Gain tag</string>
<string name="replaygain_untagged_debump_summary">Decrease volume by</string>
<string name="notifications">Notifications</string>
<string name="notification_mode_title">Notification Mode</string>

View File

@ -39,6 +39,12 @@ THE SOFTWARE.
android:dialogLayout="@layout/shake_pref"
android:title="@string/replaygain_bump_title"
android:defaultValue="75" />
<ch.blinkenlights.android.vanilla.SeekBarPreference
android:key="replaygain_untagged_debump"
android:negativeButtonText="@null"
android:dialogLayout="@layout/shake_pref"
android:title="@string/replaygain_untagged_debump_title"
android:defaultValue="150" />
<EditTextPreference
android:enabled="false"

View File

@ -60,4 +60,5 @@ public class PrefKeys {
public static final String ENABLE_TRACK_REPLAYGAIN = "enable_track_replaygain";
public static final String ENABLE_ALBUM_REPLAYGAIN = "enable_album_replaygain";
public static final String REPLAYGAIN_BUMP = "replaygain_bump";
public static final String REPLAYGAIN_UNTAGGED_DEBUMP = "replaygain_untagged_debump";
}

View File

@ -38,6 +38,12 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
* The current value.
*/
private int mValue;
/**
* Our context (needed for getResources())
*/
private Context mContext;
/**
* TextView to display current threshold.
*/
@ -46,6 +52,7 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
public SeekBarPreference(Context context, AttributeSet attrs)
{
super(context, attrs);
mContext = context;
}
@Override
@ -77,7 +84,10 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
if ("shake_threshold".equals(getKey())) {
return String.valueOf(value / 10.0f);
} else if("replaygain_bump".equals(getKey())) {
return String.format("%+.1fdB", 2*(value-75)/10.0);
return String.format("%+.1fdB", 2*(value-75)/10f);
} else if("replaygain_untagged_debump".equals(getKey())) {
String summary = (String)mContext.getResources().getText(R.string.replaygain_untagged_debump_summary);
return String.format("%s %.1fdB", summary, (value-150)/10f);
} else {
return String.format("%d%% (%+.1fdB)", value, 20 * Math.log10(Math.pow(value / 100.0, 3)));
}