mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-06 01:55:50 +01:00
feat: Move strings to resources for localization (#420)
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
e455262725
commit
7ae10be507
@ -10,6 +10,8 @@ import android.net.ConnectivityManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
@ -26,6 +28,8 @@ import androidx.annotation.Nullable;
|
||||
import java.text.Bidi;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
@ -33,6 +37,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import app.revanced.integrations.shared.settings.BooleanSetting;
|
||||
import kotlin.text.Regex;
|
||||
|
||||
public class Utils {
|
||||
|
||||
@ -388,6 +393,45 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Regex punctuationRegex = new Regex("\\p{P}+");
|
||||
|
||||
/**
|
||||
* Sort the preferences by title and ignore the casing.
|
||||
*
|
||||
* Android Preferences are automatically sorted by title,
|
||||
* but if using a localized string key it sorts on the key and not the actual title text that's used at runtime.
|
||||
*
|
||||
* @param menuDepthToSort Maximum menu depth to sort. Menus deeper than this value
|
||||
* will show preferences in the order created in patches.
|
||||
*/
|
||||
public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDepthToSort) {
|
||||
if (menuDepthToSort == 0) return;
|
||||
|
||||
SortedMap<String, Preference> preferences = new TreeMap<>();
|
||||
for (int i = 0, prefCount = group.getPreferenceCount(); i < prefCount; i++) {
|
||||
Preference preference = group.getPreference(i);
|
||||
if (preference instanceof PreferenceGroup) {
|
||||
sortPreferenceGroupByTitle((PreferenceGroup) preference, menuDepthToSort - 1);
|
||||
}
|
||||
preferences.put(removePunctuationConvertToLowercase(preference.getTitle()), preference);
|
||||
}
|
||||
|
||||
int prefIndex = 0;
|
||||
for (Preference pref : preferences.values()) {
|
||||
int indexToSet = prefIndex++;
|
||||
if (pref instanceof PreferenceGroup || pref.getIntent() != null) {
|
||||
// Place preference groups last.
|
||||
// Use an offset to push the group to the end.
|
||||
indexToSet += 1000;
|
||||
}
|
||||
pref.setOrder(indexToSet);
|
||||
}
|
||||
}
|
||||
|
||||
public static String removePunctuationConvertToLowercase(CharSequence original) {
|
||||
return punctuationRegex.replace(original, "").toLowerCase();
|
||||
}
|
||||
|
||||
public enum NetworkType {
|
||||
NONE,
|
||||
MOBILE,
|
||||
|
@ -76,6 +76,7 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
if (identifier == 0) return;
|
||||
addPreferencesFromResource(identifier);
|
||||
Utils.sortPreferenceGroupByTitle(getPreferenceScreen(), 2);
|
||||
}
|
||||
|
||||
private void showSettingUserDialogConfirmation(SwitchPreference switchPref, BooleanSetting setting) {
|
||||
|
@ -18,6 +18,10 @@ import tv.twitch.android.shared.chat.util.ClickableUsernameSpan;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ShowDeletedMessagesPatch {
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean shouldUseSpoiler() {
|
||||
return "spoiler".equals(Settings.SHOW_DELETED_MESSAGES.get());
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.integrations.shared.Logger;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class ChangeStartPagePatch {
|
||||
public static void changeIntent(Intent intent) {
|
||||
public static void changeIntent(final Intent intent) {
|
||||
final var startPage = Settings.START_PAGE.get();
|
||||
if (startPage.isEmpty()) return;
|
||||
|
||||
|
@ -46,14 +46,16 @@ public class GmsCoreSupport {
|
||||
Logger.printInfo(() -> "GmsCore was not found", exception);
|
||||
search(context, getGmsCoreDownloadLink(), str("gms_core_not_installed_warning"));
|
||||
|
||||
// Gracefully exit the app, so it does not crash.
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try (var client = context.getContentResolver().acquireContentProviderClient(GMS_CORE_PROVIDER)) {
|
||||
if (client != null) return;
|
||||
|
||||
Logger.printInfo(() -> "GmsCore is not running in the background");
|
||||
search(context, DONT_KILL_MY_APP_LINK, str("gms_core_not_running_warning"));
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,11 @@ import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import static android.text.Html.FROM_HTML_MODE_COMPACT;
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
import static app.revanced.integrations.youtube.patches.announcements.requests.AnnouncementsRoutes.GET_LATEST_ANNOUNCEMENT;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -39,9 +41,10 @@ public final class AnnouncementsPatch {
|
||||
|
||||
Utils.runOnBackgroundThread(() -> {
|
||||
try {
|
||||
HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute(GET_LATEST_ANNOUNCEMENT, CONSUMER);
|
||||
HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute(
|
||||
GET_LATEST_ANNOUNCEMENT, CONSUMER, Locale.getDefault().toLanguageTag());
|
||||
|
||||
Logger.printDebug(() -> "Get latest announcement route connection url: " + connection.getURL().toString());
|
||||
Logger.printDebug(() -> "Get latest announcement route connection url: " + connection.getURL());
|
||||
|
||||
try {
|
||||
// Do not show the announcement if the request failed.
|
||||
@ -49,7 +52,7 @@ public final class AnnouncementsPatch {
|
||||
if (Settings.ANNOUNCEMENT_LAST_HASH.get().isEmpty()) return;
|
||||
|
||||
Settings.ANNOUNCEMENT_LAST_HASH.resetToDefault();
|
||||
Utils.showToastLong("Failed to get announcement");
|
||||
Utils.showToastLong(str("revanced_announcements_connection_failed"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -11,8 +11,10 @@ import static app.revanced.integrations.youtube.requests.Route.Method.GET;
|
||||
public class AnnouncementsRoutes {
|
||||
private static final String ANNOUNCEMENTS_PROVIDER = "https://api.revanced.app/v2";
|
||||
|
||||
|
||||
public static final Route GET_LATEST_ANNOUNCEMENT = new Route(GET, "/announcements/youtube/latest?consumer={consumer}");
|
||||
/**
|
||||
* 'language' parameter is IETF format (for USA it would be 'en-us').
|
||||
*/
|
||||
public static final Route GET_LATEST_ANNOUNCEMENT = new Route(GET, "/announcements/youtube/latest?consumer={consumer}&language={language}");
|
||||
|
||||
private AnnouncementsRoutes() {
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
import static app.revanced.integrations.shared.Utils.NetworkType;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -43,13 +44,13 @@ public class RememberVideoQualityPatch {
|
||||
String networkTypeMessage;
|
||||
if (Utils.getNetworkType() == NetworkType.MOBILE) {
|
||||
mobileQualitySetting.save(defaultQuality);
|
||||
networkTypeMessage = "mobile";
|
||||
networkTypeMessage = str("revanced_remember_video_quality_mobile");
|
||||
} else {
|
||||
wifiQualitySetting.save(defaultQuality);
|
||||
networkTypeMessage = "Wi-Fi";
|
||||
networkTypeMessage = str("revanced_remember_video_quality_wifi");
|
||||
}
|
||||
Utils.showToastShort("Changed default " + networkTypeMessage
|
||||
+ " quality to: " + defaultQuality +"p");
|
||||
Utils.showToastShort(
|
||||
str("revanced_remember_video_quality_toast", networkTypeMessage, (defaultQuality + "p")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,7 @@
|
||||
package app.revanced.integrations.youtube.patches.playback.speed;
|
||||
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
|
||||
import android.preference.ListPreference;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
@ -62,8 +64,7 @@ public class CustomPlaybackSpeedPatch {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (speed >= MAXIMUM_PLAYBACK_SPEED) {
|
||||
resetCustomSpeeds("Custom speeds must be less than " + MAXIMUM_PLAYBACK_SPEED
|
||||
+ ". Using default values.");
|
||||
resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid", MAXIMUM_PLAYBACK_SPEED));
|
||||
loadCustomSpeeds();
|
||||
return;
|
||||
}
|
||||
@ -71,7 +72,7 @@ public class CustomPlaybackSpeedPatch {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printInfo(() -> "parse error", ex);
|
||||
resetCustomSpeeds("Invalid custom playback speeds. Using default values.");
|
||||
resetCustomSpeeds(str("revanced_custom_playback_speeds_parse_exception"));
|
||||
loadCustomSpeeds();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package app.revanced.integrations.youtube.patches.playback.speed;
|
||||
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
|
||||
import app.revanced.integrations.youtube.patches.VideoInformation;
|
||||
import app.revanced.integrations.youtube.settings.Settings;
|
||||
import app.revanced.integrations.shared.Logger;
|
||||
@ -25,7 +27,7 @@ public final class RememberPlaybackSpeedPatch {
|
||||
public static void userSelectedPlaybackSpeed(float playbackSpeed) {
|
||||
if (Settings.REMEMBER_PLAYBACK_SPEED_LAST_SELECTED.get()) {
|
||||
Settings.PLAYBACK_SPEED_DEFAULT.save(playbackSpeed);
|
||||
Utils.showToastLong("Changed default speed to: " + playbackSpeed + "x");
|
||||
Utils.showToastLong(str("revanced_remember_playback_speed_toast", (playbackSpeed + "x")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.net.SocketTimeoutException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
import static app.revanced.integrations.youtube.patches.spoof.requests.PlayerRoutes.*;
|
||||
|
||||
public class StoryboardRendererRequester {
|
||||
@ -62,14 +63,14 @@ public class StoryboardRendererRequester {
|
||||
if (responseCode == 200) return Requester.parseJSONObject(connection);
|
||||
|
||||
// Always show a toast for this, as a non 200 response means something is broken.
|
||||
// Not a normal code path and should not be reached, so no translations are needed.
|
||||
handleConnectionError("Spoof storyboard not available: " + responseCode,
|
||||
null, showToastOnIOException || BaseSettings.DEBUG_TOAST_ON_ERROR.get());
|
||||
connection.disconnect();
|
||||
} catch (SocketTimeoutException ex) {
|
||||
handleConnectionError("Spoof storyboard temporarily not available (API timed out)",
|
||||
ex, showToastOnIOException);
|
||||
handleConnectionError(str("revanced_spoof_storyboard_timeout"), ex, showToastOnIOException);
|
||||
} catch (IOException ex) {
|
||||
handleConnectionError("Spoof storyboard temporarily not available: " + ex.getMessage(),
|
||||
handleConnectionError(str("revanced_spoof_storyboard_io_exception", ex.getMessage()),
|
||||
ex, showToastOnIOException);
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "Spoof storyboard fetch failed", ex); // Should never happen.
|
||||
|
@ -1,5 +1,7 @@
|
||||
package app.revanced.integrations.youtube.patches.theme;
|
||||
|
||||
import static app.revanced.integrations.shared.StringRef.str;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import app.revanced.integrations.youtube.settings.Settings;
|
||||
@ -48,7 +50,7 @@ public final class SeekbarColorPatch {
|
||||
seekbarColor = Color.parseColor(Settings.SEEKBAR_CUSTOM_COLOR_VALUE.get());
|
||||
Color.colorToHSV(seekbarColor, customSeekbarColorHSV);
|
||||
} catch (Exception ex) {
|
||||
Utils.showToastShort("Invalid seekbar color value. Using default value.");
|
||||
Utils.showToastShort(str("revanced_seekbar_custom_color_invalid"));
|
||||
Settings.SEEKBAR_CUSTOM_COLOR_VALUE.resetToDefault();
|
||||
loadCustomSeekbarColor();
|
||||
}
|
||||
|
@ -41,15 +41,15 @@ public class LicenseActivityHook {
|
||||
String toolbarTitleResourceName;
|
||||
String dataString = licenseActivity.getIntent().getDataString();
|
||||
switch (dataString) {
|
||||
case "sponsorblock_settings":
|
||||
toolbarTitleResourceName = "revanced_sponsorblock_settings_title";
|
||||
case "revanced_sb_settings_intent":
|
||||
toolbarTitleResourceName = "revanced_sb_settings_title";
|
||||
fragment = new SponsorBlockPreferenceFragment();
|
||||
break;
|
||||
case "ryd_settings":
|
||||
case "revanced_ryd_settings_intent":
|
||||
toolbarTitleResourceName = "revanced_ryd_settings_title";
|
||||
fragment = new ReturnYouTubeDislikePreferenceFragment();
|
||||
break;
|
||||
case "revanced_settings":
|
||||
case "revanced_settings_intent":
|
||||
toolbarTitleResourceName = "revanced_settings_title";
|
||||
fragment = new ReVancedPreferenceFragment();
|
||||
break;
|
||||
|
@ -120,9 +120,9 @@ public class ReturnYouTubeDislikePreferenceFragment extends PreferenceFragment {
|
||||
|
||||
toastOnRYDNotAvailable = new SwitchPreference(context);
|
||||
toastOnRYDNotAvailable.setChecked(Settings.RYD_TOAST_ON_CONNECTION_ERROR.get());
|
||||
toastOnRYDNotAvailable.setTitle(str("ryd_toast_on_connection_error_title"));
|
||||
toastOnRYDNotAvailable.setSummaryOn(str("ryd_toast_on_connection_error_summary_on"));
|
||||
toastOnRYDNotAvailable.setSummaryOff(str("ryd_toast_on_connection_error_summary_off"));
|
||||
toastOnRYDNotAvailable.setTitle(str("revanced_ryd_toast_on_connection_error_title"));
|
||||
toastOnRYDNotAvailable.setSummaryOn(str("revanced_ryd_toast_on_connection_error_summary_on"));
|
||||
toastOnRYDNotAvailable.setSummaryOff(str("revanced_ryd_toast_on_connection_error_summary_off"));
|
||||
toastOnRYDNotAvailable.setOnPreferenceChangeListener((pref, newValue) -> {
|
||||
Settings.RYD_TOAST_ON_CONNECTION_ERROR.save((Boolean) newValue);
|
||||
updateUIState();
|
||||
|
@ -101,9 +101,9 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
// If the user has a private user id, then include a subtext that mentions not to share it.
|
||||
String exportSummarySubText = SponsorBlockSettings.userHasSBPrivateId()
|
||||
? str("sb_settings_ie_sum_warning")
|
||||
? str("revanced_sb_settings_ie_sum_warning")
|
||||
: "";
|
||||
importExport.setSummary(str("sb_settings_ie_sum", exportSummarySubText));
|
||||
importExport.setSummary(str("revanced_sb_settings_ie_sum", exportSummarySubText));
|
||||
|
||||
apiUrl.setEnabled(enabled);
|
||||
importExport.setEnabled(enabled);
|
||||
@ -127,8 +127,8 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
SponsorBlockSettings.initialize();
|
||||
|
||||
sbEnabled = new SwitchPreference(context);
|
||||
sbEnabled.setTitle(str("sb_enable_sb"));
|
||||
sbEnabled.setSummary(str("sb_enable_sb_sum"));
|
||||
sbEnabled.setTitle(str("revanced_sb_enable_sb"));
|
||||
sbEnabled.setSummary(str("revanced_sb_enable_sb_sum"));
|
||||
preferenceScreen.addPreference(sbEnabled);
|
||||
sbEnabled.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_ENABLED.save((Boolean) newValue);
|
||||
@ -139,7 +139,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
addAppearanceCategory(context, preferenceScreen);
|
||||
|
||||
segmentCategory = new PreferenceCategory(context);
|
||||
segmentCategory.setTitle(str("sb_diff_segments"));
|
||||
segmentCategory.setTitle(str("revanced_sb_diff_segments"));
|
||||
preferenceScreen.addPreference(segmentCategory);
|
||||
updateSegmentCategories();
|
||||
|
||||
@ -148,7 +148,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
addGeneralCategory(context, preferenceScreen);
|
||||
|
||||
statsCategory = new PreferenceCategory(context);
|
||||
statsCategory.setTitle(str("sb_stats"));
|
||||
statsCategory.setTitle(str("revanced_sb_stats"));
|
||||
preferenceScreen.addPreference(statsCategory);
|
||||
fetchAndDisplayStats();
|
||||
|
||||
@ -163,12 +163,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
private void addAppearanceCategory(Context context, PreferenceScreen screen) {
|
||||
PreferenceCategory category = new PreferenceCategory(context);
|
||||
screen.addPreference(category);
|
||||
category.setTitle(str("sb_appearance_category"));
|
||||
category.setTitle(str("revanced_sb_appearance_category"));
|
||||
|
||||
votingEnabled = new SwitchPreference(context);
|
||||
votingEnabled.setTitle(str("sb_enable_voting"));
|
||||
votingEnabled.setSummaryOn(str("sb_enable_voting_sum_on"));
|
||||
votingEnabled.setSummaryOff(str("sb_enable_voting_sum_off"));
|
||||
votingEnabled.setTitle(str("revanced_sb_enable_voting"));
|
||||
votingEnabled.setSummaryOn(str("revanced_sb_enable_voting_sum_on"));
|
||||
votingEnabled.setSummaryOff(str("revanced_sb_enable_voting_sum_off"));
|
||||
category.addPreference(votingEnabled);
|
||||
votingEnabled.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_VOTING_BUTTON.save((Boolean) newValue);
|
||||
@ -177,9 +177,9 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
});
|
||||
|
||||
compactSkipButton = new SwitchPreference(context);
|
||||
compactSkipButton.setTitle(str("sb_enable_compact_skip_button"));
|
||||
compactSkipButton.setSummaryOn(str("sb_enable_compact_skip_button_sum_on"));
|
||||
compactSkipButton.setSummaryOff(str("sb_enable_compact_skip_button_sum_off"));
|
||||
compactSkipButton.setTitle(str("revanced_sb_enable_compact_skip_button"));
|
||||
compactSkipButton.setSummaryOn(str("revanced_sb_enable_compact_skip_button_sum_on"));
|
||||
compactSkipButton.setSummaryOff(str("revanced_sb_enable_compact_skip_button_sum_off"));
|
||||
category.addPreference(compactSkipButton);
|
||||
compactSkipButton.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_COMPACT_SKIP_BUTTON.save((Boolean) newValue);
|
||||
@ -188,9 +188,9 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
});
|
||||
|
||||
autoHideSkipSegmentButton = new SwitchPreference(context);
|
||||
autoHideSkipSegmentButton.setTitle(str("sb_enable_auto_hide_skip_segment_button"));
|
||||
autoHideSkipSegmentButton.setSummaryOn(str("sb_enable_auto_hide_skip_segment_button_sum_on"));
|
||||
autoHideSkipSegmentButton.setSummaryOff(str("sb_enable_auto_hide_skip_segment_button_sum_off"));
|
||||
autoHideSkipSegmentButton.setTitle(str("revanced_sb_enable_auto_hide_skip_segment_button"));
|
||||
autoHideSkipSegmentButton.setSummaryOn(str("revanced_sb_enable_auto_hide_skip_segment_button_sum_on"));
|
||||
autoHideSkipSegmentButton.setSummaryOff(str("revanced_sb_enable_auto_hide_skip_segment_button_sum_off"));
|
||||
category.addPreference(autoHideSkipSegmentButton);
|
||||
autoHideSkipSegmentButton.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_AUTO_HIDE_SKIP_BUTTON.save((Boolean) newValue);
|
||||
@ -199,11 +199,11 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
});
|
||||
|
||||
showSkipToast = new SwitchPreference(context);
|
||||
showSkipToast.setTitle(str("sb_general_skiptoast"));
|
||||
showSkipToast.setSummaryOn(str("sb_general_skiptoast_sum_on"));
|
||||
showSkipToast.setSummaryOff(str("sb_general_skiptoast_sum_off"));
|
||||
showSkipToast.setTitle(str("revanced_sb_general_skiptoast"));
|
||||
showSkipToast.setSummaryOn(str("revanced_sb_general_skiptoast_sum_on"));
|
||||
showSkipToast.setSummaryOff(str("revanced_sb_general_skiptoast_sum_off"));
|
||||
showSkipToast.setOnPreferenceClickListener(preference1 -> {
|
||||
Utils.showToastShort(str("sb_skipped_sponsor"));
|
||||
Utils.showToastShort(str("revanced_sb_skipped_sponsor"));
|
||||
return false;
|
||||
});
|
||||
showSkipToast.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
@ -214,9 +214,9 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
category.addPreference(showSkipToast);
|
||||
|
||||
showTimeWithoutSegments = new SwitchPreference(context);
|
||||
showTimeWithoutSegments.setTitle(str("sb_general_time_without"));
|
||||
showTimeWithoutSegments.setSummaryOn(str("sb_general_time_without_sum_on"));
|
||||
showTimeWithoutSegments.setSummaryOff(str("sb_general_time_without_sum_off"));
|
||||
showTimeWithoutSegments.setTitle(str("revanced_sb_general_time_without"));
|
||||
showTimeWithoutSegments.setSummaryOn(str("revanced_sb_general_time_without_sum_on"));
|
||||
showTimeWithoutSegments.setSummaryOff(str("revanced_sb_general_time_without_sum_off"));
|
||||
showTimeWithoutSegments.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_VIDEO_LENGTH_WITHOUT_SEGMENTS.save((Boolean) newValue);
|
||||
updateUI();
|
||||
@ -228,21 +228,21 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
private void addCreateSegmentCategory(Context context, PreferenceScreen screen) {
|
||||
PreferenceCategory category = new PreferenceCategory(context);
|
||||
screen.addPreference(category);
|
||||
category.setTitle(str("sb_create_segment_category"));
|
||||
category.setTitle(str("revanced_sb_create_segment_category"));
|
||||
|
||||
addNewSegment = new SwitchPreference(context);
|
||||
addNewSegment.setTitle(str("sb_enable_create_segment"));
|
||||
addNewSegment.setSummaryOn(str("sb_enable_create_segment_sum_on"));
|
||||
addNewSegment.setSummaryOff(str("sb_enable_create_segment_sum_off"));
|
||||
addNewSegment.setTitle(str("revanced_sb_enable_create_segment"));
|
||||
addNewSegment.setSummaryOn(str("revanced_sb_enable_create_segment_sum_on"));
|
||||
addNewSegment.setSummaryOff(str("revanced_sb_enable_create_segment_sum_off"));
|
||||
category.addPreference(addNewSegment);
|
||||
addNewSegment.setOnPreferenceChangeListener((preference1, o) -> {
|
||||
Boolean newValue = (Boolean) o;
|
||||
if (newValue && !Settings.SB_SEEN_GUIDELINES.get()) {
|
||||
new AlertDialog.Builder(preference1.getContext())
|
||||
.setTitle(str("sb_guidelines_popup_title"))
|
||||
.setMessage(str("sb_guidelines_popup_content"))
|
||||
.setNegativeButton(str("sb_guidelines_popup_already_read"), null)
|
||||
.setPositiveButton(str("sb_guidelines_popup_open"), (dialogInterface, i) -> openGuidelines())
|
||||
.setTitle(str("revanced_sb_guidelines_popup_title"))
|
||||
.setMessage(str("revanced_sb_guidelines_popup_content"))
|
||||
.setNegativeButton(str("revanced_sb_guidelines_popup_already_read"), null)
|
||||
.setPositiveButton(str("revanced_sb_guidelines_popup_open"), (dialogInterface, i) -> openGuidelines())
|
||||
.setOnDismissListener(dialog -> Settings.SB_SEEN_GUIDELINES.save(true))
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
@ -253,13 +253,13 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
});
|
||||
|
||||
newSegmentStep = new EditTextPreference(context);
|
||||
newSegmentStep.setTitle(str("sb_general_adjusting"));
|
||||
newSegmentStep.setSummary(str("sb_general_adjusting_sum"));
|
||||
newSegmentStep.setTitle(str("revanced_sb_general_adjusting"));
|
||||
newSegmentStep.setSummary(str("revanced_sb_general_adjusting_sum"));
|
||||
newSegmentStep.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
newSegmentStep.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
final int newAdjustmentValue = Integer.parseInt(newValue.toString());
|
||||
if (newAdjustmentValue == 0) {
|
||||
Utils.showToastLong(str("sb_general_adjusting_invalid"));
|
||||
Utils.showToastLong(str("revanced_sb_general_adjusting_invalid"));
|
||||
return false;
|
||||
}
|
||||
Settings.SB_CREATE_NEW_SEGMENT_STEP.save(newAdjustmentValue);
|
||||
@ -268,8 +268,8 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
category.addPreference(newSegmentStep);
|
||||
|
||||
Preference guidelinePreferences = new Preference(context);
|
||||
guidelinePreferences.setTitle(str("sb_guidelines_preference_title"));
|
||||
guidelinePreferences.setSummary(str("sb_guidelines_preference_sum"));
|
||||
guidelinePreferences.setTitle(str("revanced_sb_guidelines_preference_title"));
|
||||
guidelinePreferences.setSummary(str("revanced_sb_guidelines_preference_sum"));
|
||||
guidelinePreferences.setOnPreferenceClickListener(preference1 -> {
|
||||
openGuidelines();
|
||||
return true;
|
||||
@ -280,12 +280,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
private void addGeneralCategory(final Context context, PreferenceScreen screen) {
|
||||
PreferenceCategory category = new PreferenceCategory(context);
|
||||
screen.addPreference(category);
|
||||
category.setTitle(str("sb_general"));
|
||||
category.setTitle(str("revanced_sb_general"));
|
||||
|
||||
toastOnConnectionError = new SwitchPreference(context);
|
||||
toastOnConnectionError.setTitle(str("sb_toast_on_connection_error_title"));
|
||||
toastOnConnectionError.setSummaryOn(str("sb_toast_on_connection_error_summary_on"));
|
||||
toastOnConnectionError.setSummaryOff(str("sb_toast_on_connection_error_summary_off"));
|
||||
toastOnConnectionError.setTitle(str("revanced_sb_toast_on_connection_error_title"));
|
||||
toastOnConnectionError.setSummaryOn(str("revanced_sb_toast_on_connection_error_summary_on"));
|
||||
toastOnConnectionError.setSummaryOff(str("revanced_sb_toast_on_connection_error_summary_off"));
|
||||
toastOnConnectionError.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_TOAST_ON_CONNECTION_ERROR.save((Boolean) newValue);
|
||||
updateUI();
|
||||
@ -294,9 +294,9 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
category.addPreference(toastOnConnectionError);
|
||||
|
||||
trackSkips = new SwitchPreference(context);
|
||||
trackSkips.setTitle(str("sb_general_skipcount"));
|
||||
trackSkips.setSummaryOn(str("sb_general_skipcount_sum_on"));
|
||||
trackSkips.setSummaryOff(str("sb_general_skipcount_sum_off"));
|
||||
trackSkips.setTitle(str("revanced_sb_general_skipcount"));
|
||||
trackSkips.setSummaryOn(str("revanced_sb_general_skipcount_sum_on"));
|
||||
trackSkips.setSummaryOff(str("revanced_sb_general_skipcount_sum_off"));
|
||||
trackSkips.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_TRACK_SKIP_COUNT.save((Boolean) newValue);
|
||||
updateUI();
|
||||
@ -305,8 +305,8 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
category.addPreference(trackSkips);
|
||||
|
||||
minSegmentDuration = new EditTextPreference(context);
|
||||
minSegmentDuration.setTitle(str("sb_general_min_duration"));
|
||||
minSegmentDuration.setSummary(str("sb_general_min_duration_sum"));
|
||||
minSegmentDuration.setTitle(str("revanced_sb_general_min_duration"));
|
||||
minSegmentDuration.setSummary(str("revanced_sb_general_min_duration_sum"));
|
||||
minSegmentDuration.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
minSegmentDuration.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_SEGMENT_MIN_DURATION.save(Float.valueOf(newValue.toString()));
|
||||
@ -315,12 +315,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
category.addPreference(minSegmentDuration);
|
||||
|
||||
privateUserId = new EditTextPreference(context);
|
||||
privateUserId.setTitle(str("sb_general_uuid"));
|
||||
privateUserId.setSummary(str("sb_general_uuid_sum"));
|
||||
privateUserId.setTitle(str("revanced_sb_general_uuid"));
|
||||
privateUserId.setSummary(str("revanced_sb_general_uuid_sum"));
|
||||
privateUserId.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
String newUUID = newValue.toString();
|
||||
if (!SponsorBlockSettings.isValidSBUserId(newUUID)) {
|
||||
Utils.showToastLong(str("sb_general_uuid_invalid"));
|
||||
Utils.showToastLong(str("revanced_sb_general_uuid_invalid"));
|
||||
return false;
|
||||
}
|
||||
Settings.SB_PRIVATE_USER_ID.save(newUUID);
|
||||
@ -331,8 +331,8 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
category.addPreference(privateUserId);
|
||||
|
||||
apiUrl = new Preference(context);
|
||||
apiUrl.setTitle(str("sb_general_api_url"));
|
||||
apiUrl.setSummary(Html.fromHtml(str("sb_general_api_url_sum")));
|
||||
apiUrl.setTitle(str("revanced_sb_general_api_url"));
|
||||
apiUrl.setSummary(Html.fromHtml(str("revanced_sb_general_api_url_sum")));
|
||||
apiUrl.setOnPreferenceClickListener(preference1 -> {
|
||||
EditText editText = new EditText(context);
|
||||
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
|
||||
@ -341,14 +341,14 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
DialogInterface.OnClickListener urlChangeListener = (dialog, buttonPressed) -> {
|
||||
if (buttonPressed == DialogInterface.BUTTON_NEUTRAL) {
|
||||
Settings.SB_API_URL.resetToDefault();
|
||||
Utils.showToastLong(str("sb_api_url_reset"));
|
||||
Utils.showToastLong(str("revanced_sb_api_url_reset"));
|
||||
} else if (buttonPressed == DialogInterface.BUTTON_POSITIVE) {
|
||||
String serverAddress = editText.getText().toString();
|
||||
if (!SponsorBlockSettings.isValidSBServerAddress(serverAddress)) {
|
||||
Utils.showToastLong(str("sb_api_url_invalid"));
|
||||
Utils.showToastLong(str("revanced_sb_api_url_invalid"));
|
||||
} else if (!serverAddress.equals(Settings.SB_API_URL.get())) {
|
||||
Settings.SB_API_URL.save(serverAddress);
|
||||
Utils.showToastLong(str("sb_api_url_changed"));
|
||||
Utils.showToastLong(str("revanced_sb_api_url_changed"));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -356,7 +356,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
.setTitle(apiUrl.getTitle())
|
||||
.setView(editText)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setNeutralButton(str("sb_reset"), urlChangeListener)
|
||||
.setNeutralButton(str("revanced_sb_reset"), urlChangeListener)
|
||||
.setPositiveButton(android.R.string.ok, urlChangeListener)
|
||||
.show();
|
||||
return true;
|
||||
@ -365,12 +365,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
importExport = new EditTextPreference(context) {
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
builder.setNeutralButton(str("sb_settings_copy"), (dialog, which) -> {
|
||||
builder.setNeutralButton(str("revanced_sb_settings_copy"), (dialog, which) -> {
|
||||
Utils.setClipboard(getEditText().getText().toString());
|
||||
});
|
||||
}
|
||||
};
|
||||
importExport.setTitle(str("sb_settings_ie"));
|
||||
importExport.setTitle(str("revanced_sb_settings_ie"));
|
||||
// Summary is set in updateUI()
|
||||
importExport.getEditText().setInputType(InputType.TYPE_CLASS_TEXT
|
||||
| InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
@ -409,13 +409,13 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
private void addAboutCategory(Context context, PreferenceScreen screen) {
|
||||
PreferenceCategory category = new PreferenceCategory(context);
|
||||
screen.addPreference(category);
|
||||
category.setTitle(str("sb_about"));
|
||||
category.setTitle(str("revanced_sb_about"));
|
||||
|
||||
{
|
||||
Preference preference = new Preference(context);
|
||||
category.addPreference(preference);
|
||||
preference.setTitle(str("sb_about_api"));
|
||||
preference.setSummary(str("sb_about_api_sum"));
|
||||
preference.setTitle(str("revanced_sb_about_api"));
|
||||
preference.setSummary(str("revanced_sb_about_api_sum"));
|
||||
preference.setOnPreferenceClickListener(preference1 -> {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://sponsor.ajay.app"));
|
||||
@ -444,7 +444,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
loadingPlaceholderPreference.setEnabled(false);
|
||||
statsCategory.addPreference(loadingPlaceholderPreference);
|
||||
if (Settings.SB_ENABLED.get()) {
|
||||
loadingPlaceholderPreference.setTitle(str("sb_stats_loading"));
|
||||
loadingPlaceholderPreference.setTitle(str("revanced_sb_stats_loading"));
|
||||
Utils.runOnBackgroundThread(() -> {
|
||||
UserStats stats = SBRequester.retrieveUserStats();
|
||||
Utils.runOnMainThread(() -> { // get back on main thread to modify UI elements
|
||||
@ -453,7 +453,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
loadingPlaceholderPreference.setTitle(str("sb_stats_sb_disabled"));
|
||||
loadingPlaceholderPreference.setTitle(str("revanced_sb_stats_sb_disabled"));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "fetchAndDisplayStats failure", ex);
|
||||
@ -464,7 +464,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
Utils.verifyOnMainThread();
|
||||
try {
|
||||
if (stats == null) {
|
||||
loadingPlaceholder.setTitle(str("sb_stats_connection_failure"));
|
||||
loadingPlaceholder.setTitle(str("revanced_sb_stats_connection_failure"));
|
||||
return;
|
||||
}
|
||||
statsCategory.removeAll();
|
||||
@ -475,8 +475,8 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
EditTextPreference preference = new EditTextPreference(context);
|
||||
statsCategory.addPreference(preference);
|
||||
String userName = stats.userName;
|
||||
preference.setTitle(fromHtml(str("sb_stats_username", userName)));
|
||||
preference.setSummary(str("sb_stats_username_change"));
|
||||
preference.setTitle(fromHtml(str("revanced_sb_stats_username", userName)));
|
||||
preference.setSummary(str("revanced_sb_stats_username_change"));
|
||||
preference.setText(userName);
|
||||
preference.setOnPreferenceChangeListener((preference1, value) -> {
|
||||
Utils.runOnBackgroundThread(() -> {
|
||||
@ -484,9 +484,9 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
String errorMessage = SBRequester.setUsername(newUserName);
|
||||
Utils.runOnMainThread(() -> {
|
||||
if (errorMessage == null) {
|
||||
preference.setTitle(fromHtml(str("sb_stats_username", newUserName)));
|
||||
preference.setTitle(fromHtml(str("revanced_sb_stats_username", newUserName)));
|
||||
preference.setText(newUserName);
|
||||
Utils.showToastLong(str("sb_stats_username_changed"));
|
||||
Utils.showToastLong(str("revanced_sb_stats_username_changed"));
|
||||
} else {
|
||||
preference.setText(userName); // revert to previous
|
||||
Utils.showToastLong(errorMessage);
|
||||
@ -502,7 +502,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
Preference preference = new Preference(context);
|
||||
statsCategory.addPreference(preference);
|
||||
String formatted = SponsorBlockUtils.getNumberOfSkipsString(stats.segmentCount);
|
||||
preference.setTitle(fromHtml(str("sb_stats_submissions", formatted)));
|
||||
preference.setTitle(fromHtml(str("revanced_sb_stats_submissions", formatted)));
|
||||
if (stats.totalSegmentCountIncludingIgnored == 0) {
|
||||
preference.setSelectable(false);
|
||||
} else {
|
||||
@ -519,7 +519,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
// "user reputation". Usually not useful, since it appears most users have zero reputation.
|
||||
// But if there is a reputation, then show it here
|
||||
Preference preference = new Preference(context);
|
||||
preference.setTitle(fromHtml(str("sb_stats_reputation", stats.reputation)));
|
||||
preference.setTitle(fromHtml(str("revanced_sb_stats_reputation", stats.reputation)));
|
||||
preference.setSelectable(false);
|
||||
if (stats.reputation != 0) {
|
||||
statsCategory.addPreference(preference);
|
||||
@ -534,12 +534,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
String stats_saved;
|
||||
String stats_saved_sum;
|
||||
if (stats.totalSegmentCountIncludingIgnored == 0) {
|
||||
stats_saved = str("sb_stats_saved_zero");
|
||||
stats_saved_sum = str("sb_stats_saved_sum_zero");
|
||||
stats_saved = str("revanced_sb_stats_saved_zero");
|
||||
stats_saved_sum = str("revanced_sb_stats_saved_sum_zero");
|
||||
} else {
|
||||
stats_saved = str("sb_stats_saved",
|
||||
stats_saved = str("revanced_sb_stats_saved",
|
||||
SponsorBlockUtils.getNumberOfSkipsString(stats.viewCount));
|
||||
stats_saved_sum = str("sb_stats_saved_sum", SponsorBlockUtils.getTimeSavedString((long) (60 * stats.minutesSaved)));
|
||||
stats_saved_sum = str("revanced_sb_stats_saved_sum", SponsorBlockUtils.getTimeSavedString((long) (60 * stats.minutesSaved)));
|
||||
}
|
||||
preference.setTitle(fromHtml(stats_saved));
|
||||
preference.setSummary(fromHtml(stats_saved_sum));
|
||||
@ -562,14 +562,14 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
Runnable updateStatsSelfSaved = () -> {
|
||||
String formatted = SponsorBlockUtils.getNumberOfSkipsString(Settings.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.get());
|
||||
preference.setTitle(fromHtml(str("sb_stats_self_saved", formatted)));
|
||||
preference.setTitle(fromHtml(str("revanced_sb_stats_self_saved", formatted)));
|
||||
String formattedSaved = SponsorBlockUtils.getTimeSavedString(Settings.SB_LOCAL_TIME_SAVED_MILLISECONDS.get() / 1000);
|
||||
preference.setSummary(fromHtml(str("sb_stats_self_saved_sum", formattedSaved)));
|
||||
preference.setSummary(fromHtml(str("revanced_sb_stats_self_saved_sum", formattedSaved)));
|
||||
};
|
||||
updateStatsSelfSaved.run();
|
||||
preference.setOnPreferenceClickListener(preference1 -> {
|
||||
new AlertDialog.Builder(preference1.getContext())
|
||||
.setTitle(str("sb_stats_self_saved_reset_title"))
|
||||
.setTitle(str("revanced_sb_stats_self_saved_reset_title"))
|
||||
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
|
||||
Settings.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.resetToDefault();
|
||||
Settings.SB_LOCAL_TIME_SAVED_MILLISECONDS.resetToDefault();
|
||||
|
@ -602,7 +602,7 @@ public class SegmentPlaybackController {
|
||||
}
|
||||
Utils.showToastShort(toastNumberOfSegmentsSkipped == 1
|
||||
? toastSegmentSkipped.getSkippedToastText()
|
||||
: str("sb_skipped_multiple_segments"));
|
||||
: str("revanced_sb_skipped_multiple_segments"));
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "showSkippedSegmentToast failure", ex);
|
||||
} finally {
|
||||
|
@ -55,7 +55,7 @@ public class SponsorBlockSettings {
|
||||
final int desktopValue = categorySelectionObject.getInt("option");
|
||||
CategoryBehaviour behaviour = CategoryBehaviour.byDesktopKeyValue(desktopValue);
|
||||
if (behaviour == null) {
|
||||
Utils.showToastLong(categoryKey + " unknown desktop behavior value: " + desktopValue);
|
||||
Utils.showToastLong(categoryKey + " unknown behavior key: " + categoryKey);
|
||||
} else if (category == SegmentCategory.HIGHLIGHT && behaviour == CategoryBehaviour.SKIP_AUTOMATICALLY_ONCE) {
|
||||
Utils.showToastLong("Skip-once behavior not allowed for " + category.keyValue);
|
||||
category.setBehaviour(CategoryBehaviour.SKIP_AUTOMATICALLY); // use closest match
|
||||
@ -104,10 +104,10 @@ public class SponsorBlockSettings {
|
||||
Settings.SB_LOCAL_TIME_SAVED_MILLISECONDS.save((long) (minutesSaved * 60 * 1000));
|
||||
}
|
||||
|
||||
Utils.showToastLong(str("sb_settings_import_successful"));
|
||||
Utils.showToastLong(str("revanced_sb_settings_import_successful"));
|
||||
} catch (Exception ex) {
|
||||
Logger.printInfo(() -> "failed to import settings", ex); // use info level, as we are showing our own toast
|
||||
Utils.showToastLong(str("sb_settings_import_failed", ex.getMessage()));
|
||||
Utils.showToastLong(str("revanced_sb_settings_import_failed", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ public class SponsorBlockSettings {
|
||||
return json.toString(2);
|
||||
} catch (Exception ex) {
|
||||
Logger.printInfo(() -> "failed to export settings", ex); // use info level, as we are showing our own toast
|
||||
Utils.showToastLong(str("sb_settings_export_failed", ex));
|
||||
Utils.showToastLong(str("revanced_sb_settings_export_failed", ex));
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@ -169,8 +169,8 @@ public class SponsorBlockSettings {
|
||||
if (dialogContext != null && SponsorBlockSettings.userHasSBPrivateId()
|
||||
&& !Settings.SB_HIDE_EXPORT_WARNING.get()) {
|
||||
new AlertDialog.Builder(dialogContext)
|
||||
.setMessage(str("sb_settings_revanced_export_user_id_warning"))
|
||||
.setNeutralButton(str("sb_settings_revanced_export_user_id_warning_dismiss"),
|
||||
.setMessage(str("revanced_sb_settings_revanced_export_user_id_warning"))
|
||||
.setNeutralButton(str("revanced_sb_settings_revanced_export_user_id_warning_dismiss"),
|
||||
(dialog, which) -> Settings.SB_HIDE_EXPORT_WARNING.save(true))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setCancelable(false)
|
||||
|
@ -76,7 +76,7 @@ public class SponsorBlockUtils {
|
||||
SegmentCategory category = SegmentCategory.categoriesWithoutHighlights()[which];
|
||||
final boolean enableButton;
|
||||
if (category.behaviour == CategoryBehaviour.IGNORE) {
|
||||
Utils.showToastLong(str("sb_new_segment_disabled_category"));
|
||||
Utils.showToastLong(str("revanced_sb_new_segment_disabled_category"));
|
||||
enableButton = false;
|
||||
} else {
|
||||
newUserCreatedSegmentCategory = category;
|
||||
@ -107,7 +107,7 @@ public class SponsorBlockUtils {
|
||||
|
||||
newUserCreatedSegmentCategory = null;
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(str("sb_new_segment_choose_category"))
|
||||
.setTitle(str("revanced_sb_new_segment_choose_category"))
|
||||
.setSingleChoiceItems(titles, -1, segmentTypeListener)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, segmentCategorySelectedDialogListener)
|
||||
@ -143,10 +143,10 @@ public class SponsorBlockUtils {
|
||||
editByHandSaveDialogListener.settingStart = isStart;
|
||||
editByHandSaveDialogListener.editText = new WeakReference<>(textView);
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(str(isStart ? "sb_new_segment_time_start" : "sb_new_segment_time_end"))
|
||||
.setTitle(str(isStart ? "revanced_sb_new_segment_time_start" : "revanced_sb_new_segment_time_end"))
|
||||
.setView(textView)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setNeutralButton(str("sb_new_segment_now"), editByHandSaveDialogListener)
|
||||
.setNeutralButton(str("revanced_sb_new_segment_now"), editByHandSaveDialogListener)
|
||||
.setPositiveButton(android.R.string.ok, editByHandSaveDialogListener)
|
||||
.show();
|
||||
|
||||
@ -241,14 +241,14 @@ public class SponsorBlockUtils {
|
||||
newSponsorSegmentDialogShownMillis = VideoInformation.getVideoTime();
|
||||
|
||||
new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext())
|
||||
.setTitle(str("sb_new_segment_title"))
|
||||
.setMessage(str("sb_new_segment_mark_time_as_question",
|
||||
.setTitle(str("revanced_sb_new_segment_title"))
|
||||
.setMessage(str("revanced_sb_new_segment_mark_time_as_question",
|
||||
newSponsorSegmentDialogShownMillis / 60000,
|
||||
newSponsorSegmentDialogShownMillis / 1000 % 60,
|
||||
newSponsorSegmentDialogShownMillis % 1000))
|
||||
.setNeutralButton(android.R.string.cancel, null)
|
||||
.setNegativeButton(str("sb_new_segment_mark_start"), newSponsorSegmentDialogListener)
|
||||
.setPositiveButton(str("sb_new_segment_mark_end"), newSponsorSegmentDialogListener)
|
||||
.setNegativeButton(str("revanced_sb_new_segment_mark_start"), newSponsorSegmentDialogListener)
|
||||
.setPositiveButton(str("revanced_sb_new_segment_mark_end"), newSponsorSegmentDialogListener)
|
||||
.show();
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "onMarkLocationClicked failure", ex);
|
||||
@ -259,18 +259,18 @@ public class SponsorBlockUtils {
|
||||
try {
|
||||
Utils.verifyOnMainThread();
|
||||
if (newSponsorSegmentStartMillis < 0 || newSponsorSegmentEndMillis < 0) {
|
||||
Utils.showToastShort(str("sb_new_segment_mark_locations_first"));
|
||||
Utils.showToastShort(str("revanced_sb_new_segment_mark_locations_first"));
|
||||
} else if (newSponsorSegmentStartMillis >= newSponsorSegmentEndMillis) {
|
||||
Utils.showToastShort(str("sb_new_segment_start_is_before_end"));
|
||||
Utils.showToastShort(str("revanced_sb_new_segment_start_is_before_end"));
|
||||
} else if (!newSponsorSegmentPreviewed && newSponsorSegmentStartMillis != 0) {
|
||||
Utils.showToastLong(str("sb_new_segment_preview_segment_first"));
|
||||
Utils.showToastLong(str("revanced_sb_new_segment_preview_segment_first"));
|
||||
} else {
|
||||
long length = (newSponsorSegmentEndMillis - newSponsorSegmentStartMillis) / 1000;
|
||||
long start = (newSponsorSegmentStartMillis) / 1000;
|
||||
long end = (newSponsorSegmentEndMillis) / 1000;
|
||||
new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext())
|
||||
.setTitle(str("sb_new_segment_confirm_title"))
|
||||
.setMessage(str("sb_new_segment_confirm_content",
|
||||
.setTitle(str("revanced_sb_new_segment_confirm_title"))
|
||||
.setMessage(str("revanced_sb_new_segment_confirm_content",
|
||||
start / 60, start % 60,
|
||||
end / 60, end % 60,
|
||||
length / 60, length % 60))
|
||||
@ -291,7 +291,7 @@ public class SponsorBlockUtils {
|
||||
// Button is hidden if no segments exist.
|
||||
// But if prior video had segments, and current video does not,
|
||||
// then the button persists until the overlay fades out (this is intentional, as abruptly hiding the button is jarring).
|
||||
Utils.showToastShort(str("sb_vote_no_segments"));
|
||||
Utils.showToastShort(str("revanced_sb_vote_no_segments"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ public class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(str("sb_new_segment_choose_category"))
|
||||
.setTitle(str("revanced_sb_new_segment_choose_category"))
|
||||
.setItems(titles, (dialog, which) -> SBRequester.voteToChangeCategoryOnBackgroundThread(segment, values[which]))
|
||||
.show();
|
||||
} catch (Exception ex) {
|
||||
@ -359,9 +359,9 @@ public class SponsorBlockUtils {
|
||||
try {
|
||||
Utils.verifyOnMainThread();
|
||||
if (newSponsorSegmentStartMillis < 0 || newSponsorSegmentEndMillis < 0) {
|
||||
Utils.showToastShort(str("sb_new_segment_mark_locations_first"));
|
||||
Utils.showToastShort(str("revanced_sb_new_segment_mark_locations_first"));
|
||||
} else if (newSponsorSegmentStartMillis >= newSponsorSegmentEndMillis) {
|
||||
Utils.showToastShort(str("sb_new_segment_start_is_before_end"));
|
||||
Utils.showToastShort(str("revanced_sb_new_segment_start_is_before_end"));
|
||||
} else {
|
||||
SegmentPlaybackController.removeUnsubmittedSegments(); // If user hits preview more than once before playing.
|
||||
SegmentPlaybackController.addUnsubmittedSegment(
|
||||
@ -393,11 +393,11 @@ public class SponsorBlockUtils {
|
||||
try {
|
||||
Utils.verifyOnMainThread();
|
||||
new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext())
|
||||
.setTitle(str("sb_new_segment_edit_by_hand_title"))
|
||||
.setMessage(str("sb_new_segment_edit_by_hand_content"))
|
||||
.setTitle(str("revanced_sb_new_segment_edit_by_hand_title"))
|
||||
.setMessage(str("revanced_sb_new_segment_edit_by_hand_content"))
|
||||
.setNeutralButton(android.R.string.cancel, null)
|
||||
.setNegativeButton(str("sb_new_segment_mark_start"), editByHandDialogListener)
|
||||
.setPositiveButton(str("sb_new_segment_mark_end"), editByHandDialogListener)
|
||||
.setNegativeButton(str("revanced_sb_new_segment_mark_start"), editByHandDialogListener)
|
||||
.setPositiveButton(str("revanced_sb_new_segment_mark_end"), editByHandDialogListener)
|
||||
.show();
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "onEditByHandClicked failure", ex);
|
||||
@ -417,14 +417,14 @@ public class SponsorBlockUtils {
|
||||
String minutesFormatted = statsNumberFormatter.format(minutes);
|
||||
if (hours > 0) {
|
||||
String hoursFormatted = statsNumberFormatter.format(hours);
|
||||
return str("sb_stats_saved_hour_format", hoursFormatted, minutesFormatted);
|
||||
return str("revanced_sb_stats_saved_hour_format", hoursFormatted, minutesFormatted);
|
||||
}
|
||||
final long seconds = duration.getSeconds() % 60;
|
||||
String secondsFormatted = statsNumberFormatter.format(seconds);
|
||||
if (minutes > 0) {
|
||||
return str("sb_stats_saved_minute_format", minutesFormatted, secondsFormatted);
|
||||
return str("revanced_sb_stats_saved_minute_format", minutesFormatted, secondsFormatted);
|
||||
}
|
||||
return str("sb_stats_saved_second_format", secondsFormatted);
|
||||
return str("revanced_sb_stats_saved_second_format", secondsFormatted);
|
||||
}
|
||||
return "error"; // will never be reached. YouTube requires Android O or greater
|
||||
}
|
||||
@ -453,7 +453,7 @@ public class SponsorBlockUtils {
|
||||
DialogInterface.BUTTON_NEGATIVE :
|
||||
DialogInterface.BUTTON_POSITIVE);
|
||||
} catch (ParseException e) {
|
||||
Utils.showToastLong(str("sb_new_segment_edit_by_hand_parse_error"));
|
||||
Utils.showToastLong(str("revanced_sb_new_segment_edit_by_hand_parse_error"));
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "EditByHandSaveDialogListener failure", ex);
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ import app.revanced.integrations.shared.Utils;
|
||||
import app.revanced.integrations.shared.StringRef;
|
||||
|
||||
public enum CategoryBehaviour {
|
||||
SKIP_AUTOMATICALLY("skip", 2, true, sf("sb_skip_automatically")),
|
||||
SKIP_AUTOMATICALLY("skip", 2, true, sf("revanced_sb_skip_automatically")),
|
||||
// desktop does not have skip-once behavior. Key is unique to ReVanced
|
||||
SKIP_AUTOMATICALLY_ONCE("skip-once", 3, true, sf("sb_skip_automatically_once")),
|
||||
MANUAL_SKIP("manual-skip", 1, false, sf("sb_skip_showbutton")),
|
||||
SHOW_IN_SEEKBAR("seekbar-only", 0, false, sf("sb_skip_seekbaronly")),
|
||||
SKIP_AUTOMATICALLY_ONCE("skip-once", 3, true, sf("revanced_sb_skip_automatically_once")),
|
||||
MANUAL_SKIP("manual-skip", 1, false, sf("revanced_sb_skip_showbutton")),
|
||||
SHOW_IN_SEEKBAR("seekbar-only", 0, false, sf("revanced_sb_skip_seekbaronly")),
|
||||
// ignored categories are not exported to json, and ignore is the default behavior when importing
|
||||
IGNORE("ignore", -1, false, sf("sb_skip_ignore"));
|
||||
IGNORE("ignore", -1, false, sf("revanced_sb_skip_ignore"));
|
||||
|
||||
/**
|
||||
* ReVanced specific value.
|
||||
|
@ -25,36 +25,36 @@ import app.revanced.integrations.shared.Logger;
|
||||
import app.revanced.integrations.shared.StringRef;
|
||||
|
||||
public enum SegmentCategory {
|
||||
SPONSOR("sponsor", sf("sb_segments_sponsor"), sf("sb_segments_sponsor_sum"), sf("sb_skip_button_sponsor"), sf("sb_skipped_sponsor"),
|
||||
SPONSOR("sponsor", sf("revanced_sb_segments_sponsor"), sf("revanced_sb_segments_sponsor_sum"), sf("revanced_sb_skip_button_sponsor"), sf("revanced_sb_skipped_sponsor"),
|
||||
SB_CATEGORY_SPONSOR, SB_CATEGORY_SPONSOR_COLOR),
|
||||
SELF_PROMO("selfpromo", sf("sb_segments_selfpromo"), sf("sb_segments_selfpromo_sum"), sf("sb_skip_button_selfpromo"), sf("sb_skipped_selfpromo"),
|
||||
SELF_PROMO("selfpromo", sf("revanced_sb_segments_selfpromo"), sf("revanced_sb_segments_selfpromo_sum"), sf("revanced_sb_skip_button_selfpromo"), sf("revanced_sb_skipped_selfpromo"),
|
||||
SB_CATEGORY_SELF_PROMO, SB_CATEGORY_SELF_PROMO_COLOR),
|
||||
INTERACTION("interaction", sf("sb_segments_interaction"), sf("sb_segments_interaction_sum"), sf("sb_skip_button_interaction"), sf("sb_skipped_interaction"),
|
||||
INTERACTION("interaction", sf("revanced_sb_segments_interaction"), sf("revanced_sb_segments_interaction_sum"), sf("revanced_sb_skip_button_interaction"), sf("revanced_sb_skipped_interaction"),
|
||||
SB_CATEGORY_INTERACTION, SB_CATEGORY_INTERACTION_COLOR),
|
||||
/**
|
||||
* Unique category that is treated differently than the rest.
|
||||
*/
|
||||
HIGHLIGHT("poi_highlight", sf("sb_segments_highlight"), sf("sb_segments_highlight_sum"), sf("sb_skip_button_highlight"), sf("sb_skipped_highlight"),
|
||||
HIGHLIGHT("poi_highlight", sf("revanced_sb_segments_highlight"), sf("revanced_sb_segments_highlight_sum"), sf("revanced_sb_skip_button_highlight"), sf("revanced_sb_skipped_highlight"),
|
||||
SB_CATEGORY_HIGHLIGHT, SB_CATEGORY_HIGHLIGHT_COLOR),
|
||||
INTRO("intro", sf("sb_segments_intro"), sf("sb_segments_intro_sum"),
|
||||
sf("sb_skip_button_intro_beginning"), sf("sb_skip_button_intro_middle"), sf("sb_skip_button_intro_end"),
|
||||
sf("sb_skipped_intro_beginning"), sf("sb_skipped_intro_middle"), sf("sb_skipped_intro_end"),
|
||||
INTRO("intro", sf("revanced_sb_segments_intro"), sf("revanced_sb_segments_intro_sum"),
|
||||
sf("revanced_sb_skip_button_intro_beginning"), sf("revanced_sb_skip_button_intro_middle"), sf("revanced_sb_skip_button_intro_end"),
|
||||
sf("revanced_sb_skipped_intro_beginning"), sf("revanced_sb_skipped_intro_middle"), sf("revanced_sb_skipped_intro_end"),
|
||||
SB_CATEGORY_INTRO, SB_CATEGORY_INTRO_COLOR),
|
||||
OUTRO("outro", sf("sb_segments_outro"), sf("sb_segments_outro_sum"), sf("sb_skip_button_outro"), sf("sb_skipped_outro"),
|
||||
OUTRO("outro", sf("revanced_sb_segments_outro"), sf("revanced_sb_segments_outro_sum"), sf("revanced_sb_skip_button_outro"), sf("revanced_sb_skipped_outro"),
|
||||
SB_CATEGORY_OUTRO, SB_CATEGORY_OUTRO_COLOR),
|
||||
PREVIEW("preview", sf("sb_segments_preview"), sf("sb_segments_preview_sum"),
|
||||
sf("sb_skip_button_preview_beginning"), sf("sb_skip_button_preview_middle"), sf("sb_skip_button_preview_end"),
|
||||
sf("sb_skipped_preview_beginning"), sf("sb_skipped_preview_middle"), sf("sb_skipped_preview_end"),
|
||||
PREVIEW("preview", sf("revanced_sb_segments_preview"), sf("revanced_sb_segments_preview_sum"),
|
||||
sf("revanced_sb_skip_button_preview_beginning"), sf("revanced_sb_skip_button_preview_middle"), sf("revanced_sb_skip_button_preview_end"),
|
||||
sf("revanced_sb_skipped_preview_beginning"), sf("revanced_sb_skipped_preview_middle"), sf("revanced_sb_skipped_preview_end"),
|
||||
SB_CATEGORY_PREVIEW, SB_CATEGORY_PREVIEW_COLOR),
|
||||
FILLER("filler", sf("sb_segments_filler"), sf("sb_segments_filler_sum"), sf("sb_skip_button_filler"), sf("sb_skipped_filler"),
|
||||
FILLER("filler", sf("revanced_sb_segments_filler"), sf("revanced_sb_segments_filler_sum"), sf("revanced_sb_skip_button_filler"), sf("revanced_sb_skipped_filler"),
|
||||
SB_CATEGORY_FILLER, SB_CATEGORY_FILLER_COLOR),
|
||||
MUSIC_OFFTOPIC("music_offtopic", sf("sb_segments_nomusic"), sf("sb_segments_nomusic_sum"), sf("sb_skip_button_nomusic"), sf("sb_skipped_nomusic"),
|
||||
MUSIC_OFFTOPIC("music_offtopic", sf("revanced_sb_segments_nomusic"), sf("revanced_sb_segments_nomusic_sum"), sf("revanced_sb_skip_button_nomusic"), sf("revanced_sb_skipped_nomusic"),
|
||||
SB_CATEGORY_MUSIC_OFFTOPIC, SB_CATEGORY_MUSIC_OFFTOPIC_COLOR),
|
||||
UNSUBMITTED("unsubmitted", StringRef.empty, StringRef.empty, sf("sb_skip_button_unsubmitted"), sf("sb_skipped_unsubmitted"),
|
||||
UNSUBMITTED("unsubmitted", StringRef.empty, StringRef.empty, sf("revanced_sb_skip_button_unsubmitted"), sf("revanced_sb_skipped_unsubmitted"),
|
||||
SB_CATEGORY_UNSUBMITTED, SB_CATEGORY_UNSUBMITTED_COLOR),;
|
||||
|
||||
private static final StringRef skipSponsorTextCompact = sf("sb_skip_button_compact");
|
||||
private static final StringRef skipSponsorTextCompactHighlight = sf("sb_skip_button_compact_highlight");
|
||||
private static final StringRef skipSponsorTextCompact = sf("revanced_sb_skip_button_compact");
|
||||
private static final StringRef skipSponsorTextCompactHighlight = sf("revanced_sb_skip_button_compact_highlight");
|
||||
|
||||
private static final SegmentCategory[] categoriesWithoutHighlights = new SegmentCategory[]{
|
||||
SPONSOR,
|
||||
|
@ -53,7 +53,7 @@ public class SegmentCategoryListPreference extends ListPreference {
|
||||
TableRow row = new TableRow(context);
|
||||
|
||||
TextView colorTextLabel = new TextView(context);
|
||||
colorTextLabel.setText(str("sb_color_dot_label"));
|
||||
colorTextLabel.setText(str("revanced_sb_color_dot_label"));
|
||||
row.addView(colorTextLabel);
|
||||
|
||||
TextView colorDotView = new TextView(context);
|
||||
@ -102,11 +102,11 @@ public class SegmentCategoryListPreference extends ListPreference {
|
||||
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
});
|
||||
builder.setNeutralButton(str("sb_reset_color"), (dialog, which) -> {
|
||||
builder.setNeutralButton(str("revanced_sb_reset_color"), (dialog, which) -> {
|
||||
try {
|
||||
category.resetColor();
|
||||
updateTitle();
|
||||
Utils.showToastShort(str("sb_color_reset"));
|
||||
Utils.showToastShort(str("revanced_sb_color_reset"));
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "setNeutralButton failure", ex);
|
||||
}
|
||||
@ -134,10 +134,10 @@ public class SegmentCategoryListPreference extends ListPreference {
|
||||
try {
|
||||
if (!colorString.equals(category.colorString())) {
|
||||
category.setColor(colorString);
|
||||
Utils.showToastShort(str("sb_color_changed"));
|
||||
Utils.showToastShort(str("revanced_sb_color_changed"));
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Utils.showToastShort(str("sb_color_invalid"));
|
||||
Utils.showToastShort(str("revanced_sb_color_invalid"));
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import static app.revanced.integrations.shared.StringRef.sf;
|
||||
|
||||
public class SponsorSegment implements Comparable<SponsorSegment> {
|
||||
public enum SegmentVote {
|
||||
UPVOTE(sf("sb_vote_upvote"), 1,false),
|
||||
DOWNVOTE(sf("sb_vote_downvote"), 0, true),
|
||||
CATEGORY_CHANGE(sf("sb_vote_category"), -1, true); // apiVoteType is not used for category change
|
||||
UPVOTE(sf("revanced_sb_vote_upvote"), 1,false),
|
||||
DOWNVOTE(sf("revanced_sb_vote_downvote"), 0, true),
|
||||
CATEGORY_CHANGE(sf("revanced_sb_vote_category"), -1, true); // apiVoteType is not used for category change
|
||||
|
||||
public static final SegmentVote[] voteTypesWithoutCategoryChange = {
|
||||
UPVOTE,
|
||||
|
@ -97,13 +97,13 @@ public class SBRequester {
|
||||
// no segments are found. a normal response
|
||||
Logger.printDebug(() -> "No segments found for video: " + videoId);
|
||||
} else {
|
||||
handleConnectionError(str("sb_sponsorblock_connection_failure_status", responseCode), null);
|
||||
handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_status", responseCode), null);
|
||||
connection.disconnect(); // something went wrong, might as well disconnect
|
||||
}
|
||||
} catch (SocketTimeoutException ex) {
|
||||
handleConnectionError(str("sb_sponsorblock_connection_failure_timeout"), ex);
|
||||
handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_timeout"), ex);
|
||||
} catch (IOException ex) {
|
||||
handleConnectionError(str("sb_sponsorblock_connection_failure_generic"), ex);
|
||||
handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_generic"), ex);
|
||||
} catch (Exception ex) {
|
||||
// Should never happen
|
||||
Logger.printException(() -> "getSegments failure", ex);
|
||||
@ -153,30 +153,30 @@ public class SBRequester {
|
||||
final String messageToToast;
|
||||
switch (responseCode) {
|
||||
case HTTP_STATUS_CODE_SUCCESS:
|
||||
messageToToast = str("sb_submit_succeeded");
|
||||
messageToToast = str("revanced_sb_submit_succeeded");
|
||||
break;
|
||||
case 409:
|
||||
messageToToast = str("sb_submit_failed_duplicate");
|
||||
messageToToast = str("revanced_sb_submit_failed_duplicate");
|
||||
break;
|
||||
case 403:
|
||||
messageToToast = str("sb_submit_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection));
|
||||
messageToToast = str("revanced_sb_submit_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection));
|
||||
break;
|
||||
case 429:
|
||||
messageToToast = str("sb_submit_failed_rate_limit");
|
||||
messageToToast = str("revanced_sb_submit_failed_rate_limit");
|
||||
break;
|
||||
case 400:
|
||||
messageToToast = str("sb_submit_failed_invalid", Requester.parseErrorJsonAndDisconnect(connection));
|
||||
messageToToast = str("revanced_sb_submit_failed_invalid", Requester.parseErrorJsonAndDisconnect(connection));
|
||||
break;
|
||||
default:
|
||||
messageToToast = str("sb_submit_failed_unknown_error", responseCode, connection.getResponseMessage());
|
||||
messageToToast = str("revanced_sb_submit_failed_unknown_error", responseCode, connection.getResponseMessage());
|
||||
break;
|
||||
}
|
||||
Utils.showToastLong(messageToToast);
|
||||
} catch (SocketTimeoutException ex) {
|
||||
// Always show, even if show connection toasts is turned off
|
||||
Utils.showToastLong(str("sb_submit_failed_timeout"));
|
||||
Utils.showToastLong(str("revanced_sb_submit_failed_timeout"));
|
||||
} catch (IOException ex) {
|
||||
Utils.showToastLong(str("sb_submit_failed_unknown_error", 0, ex.getMessage()));
|
||||
Utils.showToastLong(str("revanced_sb_submit_failed_unknown_error", 0, ex.getMessage()));
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "failed to submit segments", ex);
|
||||
}
|
||||
@ -223,17 +223,17 @@ public class SBRequester {
|
||||
break;
|
||||
case 403:
|
||||
Utils.showToastLong(
|
||||
str("sb_vote_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection)));
|
||||
str("revanced_sb_vote_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection)));
|
||||
break;
|
||||
default:
|
||||
Utils.showToastLong(
|
||||
str("sb_vote_failed_unknown_error", responseCode, connection.getResponseMessage()));
|
||||
str("revanced_sb_vote_failed_unknown_error", responseCode, connection.getResponseMessage()));
|
||||
break;
|
||||
}
|
||||
} catch (SocketTimeoutException ex) {
|
||||
Utils.showToastShort(str("sb_vote_failed_timeout"));
|
||||
Utils.showToastShort(str("revanced_sb_vote_failed_timeout"));
|
||||
} catch (IOException ex) {
|
||||
Utils.showToastShort(str("sb_vote_failed_unknown_error", 0, ex.getMessage()));
|
||||
Utils.showToastShort(str("revanced_sb_vote_failed_unknown_error", 0, ex.getMessage()));
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "failed to vote for segment", ex); // should never happen
|
||||
}
|
||||
@ -271,10 +271,10 @@ public class SBRequester {
|
||||
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||
return null;
|
||||
}
|
||||
return str("sb_stats_username_change_unknown_error", responseCode, responseMessage);
|
||||
return str("revanced_sb_stats_username_change_unknown_error", responseCode, responseMessage);
|
||||
} catch (Exception ex) { // should never happen
|
||||
Logger.printInfo(() -> "failed to set username", ex); // do not toast
|
||||
return str("sb_stats_username_change_unknown_error", 0, ex.getMessage());
|
||||
return str("revanced_sb_stats_username_change_unknown_error", 0, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class CreateSegmentButtonController {
|
||||
try {
|
||||
Logger.printDebug(() -> "initializing new segment button");
|
||||
ImageView imageView = Objects.requireNonNull(youtubeControlsLayout.findViewById(
|
||||
getResourceIdentifier("sb_sponsorblock_button", "id")));
|
||||
getResourceIdentifier("revanced_sb_create_segment_button", "id")));
|
||||
imageView.setVisibility(View.GONE);
|
||||
imageView.setOnClickListener(v -> {
|
||||
SponsorBlockViewController.toggleNewSegmentLayoutVisibility();
|
||||
|
@ -44,7 +44,7 @@ public final class NewSegmentLayout extends FrameLayout {
|
||||
super(context, attributeSet, defStyleAttr, defStyleRes);
|
||||
|
||||
LayoutInflater.from(context).inflate(
|
||||
getResourceIdentifier(context, "new_segment", "layout"), this, true
|
||||
getResourceIdentifier(context, "revanced_sb_new_segment", "layout"), this, true
|
||||
);
|
||||
|
||||
TypedValue rippleEffect = new TypedValue();
|
||||
@ -53,42 +53,42 @@ public final class NewSegmentLayout extends FrameLayout {
|
||||
|
||||
initializeButton(
|
||||
context,
|
||||
"sb_new_segment_rewind",
|
||||
"revanced_sb_new_segment_rewind",
|
||||
() -> VideoInformation.seekToRelative(-Settings.SB_CREATE_NEW_SEGMENT_STEP.get()),
|
||||
"Rewind button clicked"
|
||||
);
|
||||
|
||||
initializeButton(
|
||||
context,
|
||||
"sb_new_segment_forward",
|
||||
"revanced_sb_new_segment_forward",
|
||||
() -> VideoInformation.seekToRelative(Settings.SB_CREATE_NEW_SEGMENT_STEP.get()),
|
||||
"Forward button clicked"
|
||||
);
|
||||
|
||||
initializeButton(
|
||||
context,
|
||||
"sb_new_segment_adjust",
|
||||
"revanced_sb_new_segment_adjust",
|
||||
SponsorBlockUtils::onMarkLocationClicked,
|
||||
"Adjust button clicked"
|
||||
);
|
||||
|
||||
initializeButton(
|
||||
context,
|
||||
"sb_new_segment_compare",
|
||||
"revanced_sb_new_segment_compare",
|
||||
SponsorBlockUtils::onPreviewClicked,
|
||||
"Compare button clicked"
|
||||
);
|
||||
|
||||
initializeButton(
|
||||
context,
|
||||
"sb_new_segment_edit",
|
||||
"revanced_sb_new_segment_edit",
|
||||
SponsorBlockUtils::onEditByHandClicked,
|
||||
"Edit button clicked"
|
||||
);
|
||||
|
||||
initializeButton(
|
||||
context,
|
||||
"sb_new_segment_publish",
|
||||
"revanced_sb_new_segment_publish",
|
||||
SponsorBlockUtils::onPublishClicked,
|
||||
"Publish button clicked"
|
||||
);
|
||||
|
@ -47,9 +47,9 @@ public class SkipSponsorButton extends FrameLayout {
|
||||
public SkipSponsorButton(Context context, AttributeSet attributeSet, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attributeSet, defStyleAttr, defStyleRes);
|
||||
|
||||
LayoutInflater.from(context).inflate(getResourceIdentifier(context, "skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button
|
||||
LayoutInflater.from(context).inflate(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button
|
||||
setMinimumHeight(getResourceDimensionPixelSize("ad_skip_ad_button_min_height")); // dimen:ad_skip_ad_button_min_height
|
||||
skipSponsorBtnContainer = Objects.requireNonNull((LinearLayout) findViewById(getResourceIdentifier(context, "sb_skip_sponsor_button_container", "id"))); // id:skip_ad_button_container
|
||||
skipSponsorBtnContainer = Objects.requireNonNull((LinearLayout) findViewById(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button_container", "id"))); // id:skip_ad_button_container
|
||||
background = new Paint();
|
||||
background.setColor(getResourceColor("skip_ad_button_background_color")); // color:skip_ad_button_background_color);
|
||||
background.setStyle(Paint.Style.FILL);
|
||||
@ -57,7 +57,7 @@ public class SkipSponsorButton extends FrameLayout {
|
||||
border.setColor(getResourceColor("skip_ad_button_border_color")); // color:skip_ad_button_border_color);
|
||||
border.setStrokeWidth(getResourceDimension("ad_skip_ad_button_border_width")); // dimen:ad_skip_ad_button_border_width);
|
||||
border.setStyle(Paint.Style.STROKE);
|
||||
skipSponsorTextView = Objects.requireNonNull((TextView) findViewById(getResourceIdentifier(context, "sb_skip_sponsor_button_text", "id"))); // id:skip_ad_button_text;
|
||||
skipSponsorTextView = Objects.requireNonNull((TextView) findViewById(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button_text", "id"))); // id:skip_ad_button_text;
|
||||
defaultBottomMargin = getResourceDimensionPixelSize("skip_button_default_bottom_margin"); // dimen:skip_button_default_bottom_margin
|
||||
ctaBottomMargin = getResourceDimensionPixelSize("skip_button_cta_bottom_margin"); // dimen:skip_button_cta_bottom_margin
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class SponsorBlockViewController {
|
||||
Context context = Utils.getContext();
|
||||
RelativeLayout layout = new RelativeLayout(context);
|
||||
layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT));
|
||||
LayoutInflater.from(context).inflate(getResourceIdentifier("inline_sponsor_overlay", "layout"), layout);
|
||||
LayoutInflater.from(context).inflate(getResourceIdentifier("revanced_sb_inline_sponsor_overlay", "layout"), layout);
|
||||
inlineSponsorOverlayRef = new WeakReference<>(layout);
|
||||
|
||||
viewGroup.addView(layout);
|
||||
@ -81,11 +81,11 @@ public class SponsorBlockViewController {
|
||||
youtubeOverlaysLayoutRef = new WeakReference<>(viewGroup);
|
||||
|
||||
skipHighlightButtonRef = new WeakReference<>(
|
||||
Objects.requireNonNull(layout.findViewById(getResourceIdentifier("sb_skip_highlight_button", "id"))));
|
||||
Objects.requireNonNull(layout.findViewById(getResourceIdentifier("revanced_sb_skip_highlight_button", "id"))));
|
||||
skipSponsorButtonRef = new WeakReference<>(
|
||||
Objects.requireNonNull(layout.findViewById(getResourceIdentifier("sb_skip_sponsor_button", "id"))));
|
||||
Objects.requireNonNull(layout.findViewById(getResourceIdentifier("revanced_sb_skip_sponsor_button", "id"))));
|
||||
newSegmentLayoutRef = new WeakReference<>(
|
||||
Objects.requireNonNull(layout.findViewById(getResourceIdentifier("sb_new_segment_view", "id"))));
|
||||
Objects.requireNonNull(layout.findViewById(getResourceIdentifier("revanced_sb_new_segment_view", "id"))));
|
||||
|
||||
newSegmentLayoutVisible = false;
|
||||
skipHighlight = null;
|
||||
|
@ -27,7 +27,7 @@ public class VotingButtonController {
|
||||
try {
|
||||
Logger.printDebug(() -> "initializing voting button");
|
||||
ImageView imageView = Objects.requireNonNull(youtubeControlsLayout.findViewById(
|
||||
getResourceIdentifier("sb_voting_button", "id")));
|
||||
getResourceIdentifier("revanced_sb_voting_button", "id")));
|
||||
imageView.setVisibility(View.GONE);
|
||||
imageView.setOnClickListener(v -> {
|
||||
SponsorBlockUtils.onVotingClicked(v.getContext());
|
||||
|
@ -82,10 +82,10 @@ class SwipeControlsOverlayLayout(
|
||||
|
||||
// get icons scaled, assuming square icons
|
||||
val iconHeight = round(feedbackTextView.lineHeight * .8).toInt()
|
||||
autoBrightnessIcon = getDrawable("ic_sc_brightness_auto", iconHeight, iconHeight)
|
||||
manualBrightnessIcon = getDrawable("ic_sc_brightness_manual", iconHeight, iconHeight)
|
||||
mutedVolumeIcon = getDrawable("ic_sc_volume_mute", iconHeight, iconHeight)
|
||||
normalVolumeIcon = getDrawable("ic_sc_volume_normal", iconHeight, iconHeight)
|
||||
autoBrightnessIcon = getDrawable("revanced_ic_sc_brightness_auto", iconHeight, iconHeight)
|
||||
manualBrightnessIcon = getDrawable("revanced_ic_sc_brightness_manual", iconHeight, iconHeight)
|
||||
mutedVolumeIcon = getDrawable("revanced_ic_sc_volume_mute", iconHeight, iconHeight)
|
||||
normalVolumeIcon = getDrawable("revanced_ic_sc_volume_normal", iconHeight, iconHeight)
|
||||
}
|
||||
|
||||
private val feedbackHideHandler = Handler(Looper.getMainLooper())
|
||||
|
@ -16,7 +16,7 @@ public class CopyVideoUrlButton extends BottomControlButton {
|
||||
public CopyVideoUrlButton(ViewGroup viewGroup) {
|
||||
super(
|
||||
viewGroup,
|
||||
"copy_video_url_button",
|
||||
"revanced_copy_video_url_button",
|
||||
Settings.COPY_VIDEO_URL,
|
||||
view -> CopyVideoUrlPatch.copyUrl(false),
|
||||
view -> {
|
||||
|
@ -16,7 +16,7 @@ public class CopyVideoUrlTimestampButton extends BottomControlButton {
|
||||
public CopyVideoUrlTimestampButton(ViewGroup bottomControlsViewGroup) {
|
||||
super(
|
||||
bottomControlsViewGroup,
|
||||
"copy_video_url_timestamp_button",
|
||||
"revanced_copy_video_url_timestamp_button",
|
||||
Settings.COPY_VIDEO_URL_TIMESTAMP,
|
||||
view -> CopyVideoUrlPatch.copyUrl(true),
|
||||
view -> {
|
||||
|
@ -21,7 +21,7 @@ public class ExternalDownloadButton extends BottomControlButton {
|
||||
public ExternalDownloadButton(ViewGroup viewGroup) {
|
||||
super(
|
||||
viewGroup,
|
||||
"external_download_button",
|
||||
"revanced_external_download_button",
|
||||
Settings.EXTERNAL_DOWNLOADER,
|
||||
ExternalDownloadButton::onDownloadClick,
|
||||
null
|
||||
@ -62,7 +62,7 @@ public class ExternalDownloadButton extends BottomControlButton {
|
||||
|
||||
// If the package is not installed, show the toast
|
||||
if (!packageEnabled) {
|
||||
Utils.showToastLong(downloaderPackageName + " " + StringRef.str("external_downloader_not_installed_warning"));
|
||||
Utils.showToastLong(StringRef.str("revanced_external_downloader_not_installed_warning", downloaderPackageName));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user