mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-01 00:02:55 +01:00
make minutes translatable
This commit is contained in:
parent
53e585237b
commit
69f44095f6
@ -1,5 +1,23 @@
|
|||||||
package pl.jakubweg;
|
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.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -22,28 +40,10 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import pl.jakubweg.requests.Requester;
|
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
|
@SuppressWarnings({"unused", "deprecation"}) // injected
|
||||||
public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
public static final DecimalFormat FORMATTER = new DecimalFormat("#,###,###");
|
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<Preference> preferencesToDisableWhenSBDisabled = new ArrayList<>();
|
private final ArrayList<Preference> preferencesToDisableWhenSBDisabled = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
package pl.jakubweg;
|
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.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -34,24 +52,6 @@ import pl.jakubweg.objects.SponsorSegment;
|
|||||||
import pl.jakubweg.objects.UserStats;
|
import pl.jakubweg.objects.UserStats;
|
||||||
import pl.jakubweg.requests.Requester;
|
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"})
|
@SuppressWarnings({"LongLogTag"})
|
||||||
public abstract class SponsorBlockUtils {
|
public abstract class SponsorBlockUtils {
|
||||||
public static final String TAG = "jakubweg.SponsorBlockUtils";
|
public static final String TAG = "jakubweg.SponsorBlockUtils";
|
||||||
@ -492,6 +492,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
category.removePreference(loadingPreference);
|
category.removePreference(loadingPreference);
|
||||||
|
|
||||||
Context context = category.getContext();
|
Context context = category.getContext();
|
||||||
|
String minutesStr = str("minutes");
|
||||||
|
|
||||||
{
|
{
|
||||||
EditTextPreference preference = new EditTextPreference(context);
|
EditTextPreference preference = new EditTextPreference(context);
|
||||||
@ -522,7 +523,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
double saved = stats.getMinutesSaved();
|
double saved = stats.getMinutesSaved();
|
||||||
int hoursSaved = (int) (saved / 60);
|
int hoursSaved = (int) (saved / 60);
|
||||||
double minutesSaved = 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.setTitle(fromHtml(str("stats_saved", formatted)));
|
||||||
preference.setSummary(fromHtml(str("stats_saved_sum", formattedSaved)));
|
preference.setSummary(fromHtml(str("stats_saved_sum", formattedSaved)));
|
||||||
@ -541,7 +542,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
|
|
||||||
long hoursSaved = skippedTime / 3600000;
|
long hoursSaved = skippedTime / 3600000;
|
||||||
double minutesSaved = (skippedTime / 60000d) % 60;
|
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.setTitle(fromHtml(str("stats_self_saved", formatted)));
|
||||||
preference.setSummary(fromHtml(str("stats_self_saved_sum", formattedSaved)));
|
preference.setSummary(fromHtml(str("stats_self_saved_sum", formattedSaved)));
|
||||||
|
@ -203,6 +203,7 @@
|
|||||||
<string name="stats_saved_sum" formatted="false">That\'s <b>%s</b> of their lives. Click to see the leaderboard</string>
|
<string name="stats_saved_sum" formatted="false">That\'s <b>%s</b> of their lives. Click to see the leaderboard</string>
|
||||||
<string name="stats_self_saved" formatted="false">You\'ve skipped <b>%s</b> segments.</string>
|
<string name="stats_self_saved" formatted="false">You\'ve skipped <b>%s</b> segments.</string>
|
||||||
<string name="stats_self_saved_sum" formatted="false">That\'s <b>%s</b>.</string>
|
<string name="stats_self_saved_sum" formatted="false">That\'s <b>%s</b>.</string>
|
||||||
|
<string name="minutes">minutes</string>
|
||||||
|
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
<string name="about_api">This app uses the API from SponsorBlock</string>
|
<string name="about_api">This app uses the API from SponsorBlock</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user