From 69f44095f6476b33aaac0be6997ae38f670b4d97 Mon Sep 17 00:00:00 2001 From: caneleex Date: Fri, 30 Jul 2021 19:30:00 +0200 Subject: [PATCH] make minutes translatable --- .../SponsorBlockPreferenceFragment.java | 38 ++++++++--------- .../java/pl/jakubweg/SponsorBlockUtils.java | 41 ++++++++++--------- app/src/main/res/values/strings.xml | 1 + 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java b/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java index 2f529417..e7da30fe 100644 --- a/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java +++ b/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java @@ -1,5 +1,23 @@ package pl.jakubweg; +import static pl.jakubweg.SponsorBlockSettings.DefaultBehaviour; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME; +import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis; +import static pl.jakubweg.SponsorBlockSettings.countSkips; +import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines; +import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments; +import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically; +import static pl.jakubweg.SponsorBlockSettings.uuid; +import static pl.jakubweg.StringRef.str; + import android.app.Activity; import android.app.AlertDialog; import android.content.Context; @@ -22,28 +40,10 @@ import java.util.ArrayList; import pl.jakubweg.requests.Requester; -import static pl.jakubweg.SponsorBlockSettings.DefaultBehaviour; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME; -import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis; -import static pl.jakubweg.SponsorBlockSettings.countSkips; -import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines; -import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments; -import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically; -import static pl.jakubweg.SponsorBlockSettings.uuid; -import static pl.jakubweg.StringRef.str; - @SuppressWarnings({"unused", "deprecation"}) // injected public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public static final DecimalFormat FORMATTER = new DecimalFormat("#,###,###"); - public static final String SAVED_TEMPLATE = "%dh %.1f minutes"; + public static final String SAVED_TEMPLATE = "%dh %.1f %s"; private final ArrayList preferencesToDisableWhenSBDisabled = new ArrayList<>(); @Override diff --git a/app/src/main/java/pl/jakubweg/SponsorBlockUtils.java b/app/src/main/java/pl/jakubweg/SponsorBlockUtils.java index 1bb73bac..29c5c108 100644 --- a/app/src/main/java/pl/jakubweg/SponsorBlockUtils.java +++ b/app/src/main/java/pl/jakubweg/SponsorBlockUtils.java @@ -1,5 +1,23 @@ package pl.jakubweg; +import static android.text.Html.fromHtml; +import static android.view.View.GONE; +import static android.view.View.VISIBLE; +import static fi.razerman.youtube.XGlobals.debug; +import static pl.jakubweg.PlayerController.getCurrentVideoId; +import static pl.jakubweg.PlayerController.getCurrentVideoLength; +import static pl.jakubweg.PlayerController.getLastKnownVideoTime; +import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo; +import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER; +import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE; +import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX; +import static pl.jakubweg.SponsorBlockSettings.isSponsorBlockEnabled; +import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments; +import static pl.jakubweg.SponsorBlockSettings.skippedSegments; +import static pl.jakubweg.SponsorBlockSettings.skippedTime; +import static pl.jakubweg.StringRef.str; +import static pl.jakubweg.requests.Requester.voteForSegment; + import android.annotation.SuppressLint; import android.app.AlertDialog; import android.content.Context; @@ -34,24 +52,6 @@ import pl.jakubweg.objects.SponsorSegment; import pl.jakubweg.objects.UserStats; import pl.jakubweg.requests.Requester; -import static android.text.Html.fromHtml; -import static android.view.View.GONE; -import static android.view.View.VISIBLE; -import static fi.razerman.youtube.XGlobals.debug; -import static pl.jakubweg.PlayerController.getCurrentVideoId; -import static pl.jakubweg.PlayerController.getCurrentVideoLength; -import static pl.jakubweg.PlayerController.getLastKnownVideoTime; -import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo; -import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER; -import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE; -import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX; -import static pl.jakubweg.SponsorBlockSettings.isSponsorBlockEnabled; -import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments; -import static pl.jakubweg.SponsorBlockSettings.skippedSegments; -import static pl.jakubweg.SponsorBlockSettings.skippedTime; -import static pl.jakubweg.StringRef.str; -import static pl.jakubweg.requests.Requester.voteForSegment; - @SuppressWarnings({"LongLogTag"}) public abstract class SponsorBlockUtils { public static final String TAG = "jakubweg.SponsorBlockUtils"; @@ -492,6 +492,7 @@ public abstract class SponsorBlockUtils { category.removePreference(loadingPreference); Context context = category.getContext(); + String minutesStr = str("minutes"); { EditTextPreference preference = new EditTextPreference(context); @@ -522,7 +523,7 @@ public abstract class SponsorBlockUtils { double saved = stats.getMinutesSaved(); int hoursSaved = (int) (saved / 60); double minutesSaved = saved % 60; - String formattedSaved = String.format(SAVED_TEMPLATE, hoursSaved, minutesSaved); + String formattedSaved = String.format(SAVED_TEMPLATE, hoursSaved, minutesSaved, minutesStr); preference.setTitle(fromHtml(str("stats_saved", formatted))); preference.setSummary(fromHtml(str("stats_saved_sum", formattedSaved))); @@ -541,7 +542,7 @@ public abstract class SponsorBlockUtils { long hoursSaved = skippedTime / 3600000; double minutesSaved = (skippedTime / 60000d) % 60; - String formattedSaved = String.format(SAVED_TEMPLATE, hoursSaved, minutesSaved); + String formattedSaved = String.format(SAVED_TEMPLATE, hoursSaved, minutesSaved, minutesStr); preference.setTitle(fromHtml(str("stats_self_saved", formatted))); preference.setSummary(fromHtml(str("stats_self_saved_sum", formattedSaved))); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e1ae50d5..6b9cce5b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -203,6 +203,7 @@ That\'s <b>%s</b> of their lives. Click to see the leaderboard You\'ve skipped <b>%s</b> segments. That\'s <b>%s</b>. + minutes About This app uses the API from SponsorBlock