From e3fff4356a5c7cc4138f9a4dde954cf2bdea03ef Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 2 Mar 2020 20:15:54 +0100 Subject: [PATCH] Show a toast when seek duration was rounded up --- .../settings/VideoAudioSettingsFragment.java | 13 +++++++++++-- app/src/main/res/values/strings.xml | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index 134285a41..f68fc5e23 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -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(); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7fe9c2b2..6152221c0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -593,6 +593,7 @@ App language System default %s seconds + Due to ExoPlayer contraints the seek duration was set to %s seconds