Show a toast when seek duration was rounded up

This commit is contained in:
Xiang Rong Lin 2020-03-02 20:15:54 +01:00
parent 7d3b21582c
commit e3fff4356a
2 changed files with 12 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.preference.ListPreference;
@ -86,8 +87,16 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
durations.setEntries(displayedDescriptionValues.toArray(new CharSequence[0]));
final int selectedDuration = Integer.parseInt(durations.getValue());
if (selectedDuration / (int) DateUtils.SECOND_IN_MILLIS % 10 == 5) {
durations.setValue(
Integer.toString(selectedDuration + 5 * (int) DateUtils.SECOND_IN_MILLIS));
final int newDuration = selectedDuration / (int) DateUtils.SECOND_IN_MILLIS + 5;
durations.setValue(Integer.toString(newDuration * (int) DateUtils.SECOND_IN_MILLIS));
Toast toast = Toast.makeText(getContext(),
getString(R.string.new_seek_duration_toast) + " " + String.format(
res.getQuantityString(R.plurals.dynamic_seek_duration_description,
newDuration),
newDuration),
Toast.LENGTH_LONG);
toast.show();
}
}

View File

@ -593,6 +593,7 @@
<string name="app_language_title">App language</string>
<string name="systems_language">System default</string>
<string name="dynamic_seek_duration_description">%s seconds</string>
<string name="new_seek_duration_toast">Due to ExoPlayer contraints the seek duration was set to</string>
<plurals name="dynamic_seek_duration_description">
<item quantity="other">%s seconds</item>
</plurals>