refactor: Strings

closes #29
This commit is contained in:
OxrxL
2022-06-30 13:32:08 +02:00
committed by GitHub
parent aecafc5380
commit 7a9c61b71b
20 changed files with 319 additions and 236 deletions

View File

@ -147,9 +147,9 @@ public class Whitelist {
boolean success = updateWhitelist(whitelistType, channels, context);
String friendlyName = whitelistType.getFriendlyName();
if (success) {
Toast.makeText(context, str("vanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, str("vanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
}
}

View File

@ -5,8 +5,8 @@ import static app.revanced.integrations.sponsorblock.StringRef.str;
import app.revanced.integrations.utils.SharedPrefHelper;
public enum WhitelistType {
ADS(SharedPrefHelper.SharedPrefNames.YOUTUBE, "vanced_whitelist_ads_enabled"),
SPONSORBLOCK(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, "vanced_whitelist_sb_enabled");
ADS(SharedPrefHelper.SharedPrefNames.YOUTUBE, "revanced_whitelist_ads_enabled"),
SPONSORBLOCK(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, "revanced_whitelist_sb_enabled");
private final String friendlyName;
private final String preferencesName;
@ -14,7 +14,7 @@ public enum WhitelistType {
private final SharedPrefHelper.SharedPrefNames name;
WhitelistType(SharedPrefHelper.SharedPrefNames name, String preferenceEnabledName) {
this.friendlyName = str("vanced_whitelisting_" + name().toLowerCase());
this.friendlyName = str("revanced_whitelisting_" + name().toLowerCase());
this.name = name;
this.preferencesName = "whitelist_" + name();
this.preferenceEnabledName = preferenceEnabledName;

View File

@ -58,17 +58,17 @@ public class WhitelistRequester {
runOnMainThread(() -> {
if (success) {
buttonIcon.setEnabled(whitelistType != WhitelistType.SPONSORBLOCK);
Toast.makeText(context, str("vanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
} else {
buttonIcon.setEnabled(whitelistType == WhitelistType.SPONSORBLOCK);
Toast.makeText(context, str("vanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
}
view.setEnabled(true);
});
} else {
LogHelper.debug("WhitelistRequester", "player fetch response was " + responseCode);
runOnMainThread(() -> {
Toast.makeText(context, str("vanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
Toast.makeText(context, str("revanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
buttonIcon.setEnabled(true);
view.setEnabled(true);
});

View File

@ -44,25 +44,25 @@ public class Dialogs {
} else {
builder = new AlertDialog.Builder(activity);
}
builder.setTitle(str("vanced_ryd"));
builder.setTitle(str("revanced_ryd"));
builder.setIcon(ReVancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
builder.setCancelable(false);
builder.setMessage(str("vanced_ryd_firstrun"));
builder.setPositiveButton(str("vanced_enable"),
builder.setMessage(str("revanced_ryd_firstrun"));
builder.setPositiveButton(str("revanced_enable"),
(dialog, id) -> {
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, true);
dialog.dismiss();
});
builder.setNegativeButton(str("vanced_disable"),
builder.setNegativeButton(str("revanced_disable"),
(dialog, id) -> {
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
dialog.dismiss();
});
builder.setNeutralButton(str("vanced_learnmore"), null);
builder.setNeutralButton(str("revanced_learnmore"), null);
AlertDialog dialog = builder.create();
dialog.show();

View File

@ -60,7 +60,7 @@ public class Settings {
}
public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) {
if (!SettingsEnum.OLD_LAYOUT_XFILE_ENABLED_BOOLEAN.getBoolean()) {
if (!SettingsEnum.OLD_LAYOUT_ENABLED_BOOLEAN.getBoolean()) {
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group", config).putLong("com.google.android.libraries.youtube.innertube.cold_stored_timestamp", timeStamp).apply();
LogHelper.debug("Settings", "setOldLayout: true");
return;

View File

@ -8,10 +8,10 @@ import app.revanced.integrations.utils.SharedPrefHelper;
public enum SettingsEnum {
DEBUG_BOOLEAN("debug_xfile_enabled", false),
DEBUG_BOOLEAN("debug_revanced_enabled", false),
MANUFACTURER_OVERRIDE_STRING("override_manufacturer", null),
MODEL_OVERRIDE_STRING("override_model", null),
CODEC_OVERRIDE_BOOLEAN("override_resolution_xfile_enabled", true),
CODEC_OVERRIDE_BOOLEAN("revanced_vp9_enabled", true),
PREFERRED_RESOLUTION_WIFI_INTEGER("pref_video_quality_wifi", -2),
PREFERRED_RESOLUTION_MOBILE_INTEGER("pref_video_quality_mobile", -2),
PREFERRED_VIDEO_SPEED_FLOAT("pref_video_speed", -2.0f),
@ -22,12 +22,12 @@ public enum SettingsEnum {
REEL_BUTTON_SHOWN_BOOLEAN("reel_button_enabled", false),
SHORTS_BUTTON_SHOWN_BOOLEAN("shorts_button_enabled", false),
CAST_BUTTON_SHOWN_BOOLEAN("cast_button_enabled", false),
CREATE_BUTTON_SHOWN_BOOLEAN("xfile_create_button_enabled", false),
CREATE_BUTTON_SHOWN_BOOLEAN("revanced_create_button_enabled", false),
SUGGESTIONS_SHOWN_BOOLEAN("info_card_suggestions_enabled", false),
INFO_CARDS_SHOWN_BOOLEAN("info_cards_enabled", false),
BRANDING_SHOWN_BOOLEAN("branding_watermark_enabled", false),
USE_TABLET_MINIPLAYER_BOOLEAN("tablet_miniplayer", false),
USE_NEW_ACTIONBAR_BOOLEAN("xfile_new_actionbar", false),
USE_NEW_ACTIONBAR_BOOLEAN("revanced_new_actionbar", false),
USE_DARK_THEME_BOOLEAN("app_theme_dark", false),
USE_HDR_BRIGHTNESS_BOOLEAN("pref_hdr_autobrightness", true),
ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("pref_xfenster_brightness", true),
@ -39,7 +39,7 @@ public enum SettingsEnum {
PLAYBACK_MAX_BUFFER_INTEGER("pref_buffer_for_playback_ms", 2500),
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("pref_buffer_for_playback_after_rebuffer_ms", 5000),
OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("old_style_quality_settings", true),
TAP_SEEKING_ENABLED_BOOLEAN("xfile_enable_tap_seeking", true),
TAP_SEEKING_ENABLED_BOOLEAN("revanced_enable_tap_seeking", true),
;
private final String path;

View File

@ -38,8 +38,8 @@ public class RYDSettingsFragment extends PreferenceFragment {
preference.setKey(PREFERENCES_KEY_RYD_ENABLED);
preference.setDefaultValue(false);
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED));
preference.setTitle(str("vanced_ryd_title"));
preference.setSummary(str("vanced_ryd_summary"));
preference.setTitle(str("revanced_ryd_title"));
preference.setSummary(str("revanced_ryd_summary"));
preference.setOnPreferenceChangeListener((pref, newValue) -> {
final boolean value = (Boolean) newValue;
ReturnYouTubeDislikes.onEnabledChange(value);
@ -71,8 +71,8 @@ public class RYDSettingsFragment extends PreferenceFragment {
{
Preference preference = new Preference(context);
screen.addPreference(preference);
preference.setTitle(str("vanced_ryd_attribution_title"));
preference.setSummary(str("vanced_ryd_attribution_summary"));
preference.setTitle(str("revanced_ryd_attribution_title"));
preference.setSummary(str("revanced_ryd_attribution_summary"));
preference.setOnPreferenceClickListener(pref -> {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://returnyoutubedislike.com"));

View File

@ -205,7 +205,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
SwipeGestureListener.TOP_PADDING = val;
SettingsEnum.SWIPE_PADDING_TOP_INTEGER.setValue(val);
}
} else if ("vanced_ryd_enabled".equals(str) && ReVancedUtils.getContext() != null && settingsInitialized) {
} else if ("revanced_ryd_enabled".equals(str) && ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(ReVancedSettingsFragment.this.getActivity());
} else if (str.equals("pref_auto_repeat_button")) {
AutoRepeatLinks();
@ -224,7 +224,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName("youtube");
try {
int identifier = getResources().getIdentifier("xfile_prefs", "xml", getPackageName());
int identifier = getResources().getIdentifier("revanced_prefs", "xml", getPackageName());
addPreferencesFromResource(identifier);
String stringByName = ReVancedUtils.getStringByName(getActivity(), "quality_auto");
@ -237,11 +237,11 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
} else {
this.videoSpeedEntries[4] = stringByName2;
}
this.minimizedVideoEntries[1] = ReVancedUtils.getStringByName(getActivity(), "xfile_miniplayer_style_video");
this.minimizedVideoEntries[2] = ReVancedUtils.getStringByName(getActivity(), "xfile_miniplayer_style_video_controls");
this.minimizedVideoEntries[1] = ReVancedUtils.getStringByName(getActivity(), "revanced_miniplayer_style_video");
this.minimizedVideoEntries[2] = ReVancedUtils.getStringByName(getActivity(), "revanced_miniplayer_style_video_controls");
SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
this.sharedPreferences = sharedPreferences;
this.settingsInitialized = sharedPreferences.getBoolean("xfile_initialized", false);
this.settingsInitialized = sharedPreferences.getBoolean("revanced_initialized", false);
this.sharedPreferences.registerOnSharedPreferenceChangeListener(this.listener);
this.Registered = true;
this.codecPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("codec_override");
@ -252,7 +252,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
this.bufferSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("buffer_screen");
this.miscsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("misc_screen");
this.xSwipeControlPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("xfenster_screen");
this.vp9Override = (SwitchPreference) this.codecPreferenceScreen.findPreference("vp9_xfile_enabled");
this.vp9Override = (SwitchPreference) this.codecPreferenceScreen.findPreference("revanced_vp9_enabled");
this.manufacturerOverride = (EditTextPreference) this.codecPreferenceScreen.findPreference("override_manufacturer");
this.modelOverride = (EditTextPreference) this.codecPreferenceScreen.findPreference("override_model");
this.codecDefault = this.codecPreferenceScreen.findPreference("pref_default_override");
@ -303,10 +303,10 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
}
this.sharedPreferences.edit().putBoolean("xfile_initialized", true);
this.sharedPreferences.edit().putBoolean("revanced_initialized", true);
this.settingsInitialized = true;
} catch (Throwable th) {
LogHelper.printException("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th);
LogHelper.printException("ReVancedSettingsFragment", "Unable to retrieve resourceId for revanced_prefs", th);
}
}

View File

@ -36,10 +36,10 @@ public class XSettingActivity extends Activity {
trySetTitle(getIdentifier("sb_settings", "string"));
getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new SponsorBlockSettingsFragment()).commit();
} else if (dataString.equalsIgnoreCase("ryd_settings")) {
trySetTitle(getIdentifier("vanced_ryd_settings_title", "string"));
trySetTitle(getIdentifier("revanced_ryd_settings_title", "string"));
getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new RYDSettingsFragment()).commit();
} else {
trySetTitle(getIdentifier("xfile_settings", "string"));
trySetTitle(getIdentifier("revanced_settings", "string"));
getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new ReVancedSettingsFragment()).commit();
}
context = getApplicationContext();

View File

@ -26,7 +26,7 @@ public class AdButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_ad_button", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("revanced_yt_ad_button", "drawable"));
this.button_text.setText(str("action_ads"));
changeEnabled(Whitelist.shouldShowAds());
}

View File

@ -17,7 +17,7 @@ public class CopyButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_copy_icon", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("revanced_yt_copy_icon", "drawable"));
this.button_text.setText(str("action_copy"));
}

View File

@ -17,7 +17,7 @@ public class CopyWithTimestamp extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_copy_icon_with_time", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("revanced_yt_copy_icon_with_time", "drawable"));
this.button_text.setText(str("action_tcopy"));
}

View File

@ -24,7 +24,7 @@ public class SBBrowserButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_sb_browser", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("revanced_sb_browser", "drawable"));
this.button_text.setText(str("action_browser"));
}

View File

@ -26,7 +26,7 @@ public class SBWhitelistButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_sb_button", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("revanced_yt_sb_button", "drawable"));
this.button_text.setText(str("action_segments"));
changeEnabled(Whitelist.isChannelSBWhitelisted());
}

View File

@ -15,7 +15,7 @@ public class SponsorBlockVoting extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_sb_voting", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("revanced_sb_voting", "drawable"));
this.button_text.setText("SB Voting");
}

View File

@ -19,7 +19,7 @@ public class BrightnessSeekBar {
public int Progress;
private boolean enabled;
Handler handler;
private final String mBrightnessKey = "xfile_brightness_value";
private final String mBrightnessKey = "revanced_brightness_value";
Context mContext;
TextView mTextView;
ViewGroup mViewGroup;
@ -30,7 +30,7 @@ public class BrightnessSeekBar {
this.mContext = context;
float systemBrightness = android.provider.Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
this.Progress = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
this.Progress = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "revanced_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
this.Max = 100;
this.mTextView = new TextView(context);
this.mTextView.setTextSize(24.0f);
@ -111,7 +111,7 @@ public class BrightnessSeekBar {
public void disable() {
this.enabled = false;
SharedPrefHelper.saveInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"xfile_brightness_value", Integer.valueOf(this.Progress));
SharedPrefHelper.saveInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"revanced_brightness_value", Integer.valueOf(this.Progress));
disableBrightness();
LogHelper.debug("XDebug", "Brightness swipe disabled");
}
@ -120,7 +120,7 @@ public class BrightnessSeekBar {
this.enabled = true;
float systemBrightness = android.provider.Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
int brightness = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
int brightness = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"revanced_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
if (brightness < 0) {
brightness = 0;
} else if (brightness > 100) {