diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index ae2a136ad..800425da6 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -238,7 +238,7 @@ public abstract class BasePlayer implements this.mPrefs = PreferenceManager.getDefaultSharedPreferences(App.getApp()); - isBlockingSponsors = mPrefs.getBoolean(context.getString(R.string.sponsorblock_enable_key), + isBlockingSponsors = mPrefs.getBoolean(context.getString(R.string.sponsor_block_enable_key), false); } @@ -733,7 +733,7 @@ public abstract class BasePlayer implements if (isBlockingSponsors && mPrefs.getBoolean( - context.getString(R.string.sponsorblock_enable_key), false)) { + context.getString(R.string.sponsor_block_enable_key), false)) { final VideoSegment segment = getSkippableSegment(currentProgress); if (segment == null) { return; @@ -744,33 +744,33 @@ public abstract class BasePlayer implements seekTo(skipTo); if (mPrefs.getBoolean( - context.getString(R.string.sponsorblock_notifications_key), false)) { + context.getString(R.string.sponsor_block_notifications_key), false)) { String toastText = ""; switch (segment.category) { case "sponsor": toastText = context - .getString(R.string.sponsorblock_skip_sponsor_message); + .getString(R.string.sponsor_block_skip_sponsor_message); break; case "intro": toastText = context - .getString(R.string.sponsorblock_skip_intro_message); + .getString(R.string.sponsor_block_skip_intro_message); break; case "outro": toastText = context - .getString(R.string.sponsorblock_skip_outro_message); + .getString(R.string.sponsor_block_skip_outro_message); break; case "interaction": toastText = context - .getString(R.string.sponsorblock_skip_interaction_message); + .getString(R.string.sponsor_block_skip_interaction_message); break; case "selfpromo": toastText = context - .getString(R.string.sponsorblock_skip_self_promo_message); + .getString(R.string.sponsor_block_skip_self_promo_message); break; case "music_offtopic": toastText = context - .getString(R.string.sponsorblock_skip_non_music_message); + .getString(R.string.sponsor_block_skip_non_music_message); break; } @@ -778,7 +778,7 @@ public abstract class BasePlayer implements } if (DEBUG) { - Log.d("SPONSOR_BLOCK", "Skipped sponsor: currentProgress = [" + Log.d("SPONSOR_BLOCK", "Skipped segment: currentProgress = [" + currentProgress + "], skipped to = [" + skipTo + "]"); } } @@ -1167,44 +1167,44 @@ public abstract class BasePlayer implements if (info.getUrl().startsWith("https://www.youtube.com")) { final String apiUrl = mPrefs - .getString(context.getString(R.string.sponsorblock_api_url_key), null); + .getString(context.getString(R.string.sponsor_block_api_url_key), null); final boolean isSponsorBlockEnabled = mPrefs - .getBoolean(context.getString(R.string.sponsorblock_enable_key), false); + .getBoolean(context.getString(R.string.sponsor_block_enable_key), false); if (apiUrl != null && !apiUrl.isEmpty() && isSponsorBlockEnabled) { try { final boolean includeSponsorCategory = mPrefs.getBoolean( context.getString( - R.string.sponsorblock_category_sponsor_key), + R.string.sponsor_block_category_sponsor_key), false); final boolean includeIntroCategory = mPrefs.getBoolean( context.getString( - R.string.sponsorblock_category_intro_key), + R.string.sponsor_block_category_intro_key), false); final boolean includeOutroCategory = mPrefs.getBoolean( context.getString( - R.string.sponsorblock_category_outro_key), + R.string.sponsor_block_category_outro_key), false); final boolean includeInteractionCategory = mPrefs.getBoolean( context.getString( - R.string.sponsorblock_category_interaction_key), + R.string.sponsor_block_category_interaction_key), false); final boolean includeSelfPromoCategory = mPrefs.getBoolean( context.getString( - R.string.sponsorblock_category_self_promo_key), + R.string.sponsor_block_category_self_promo_key), false); final boolean includeMusicCategory = mPrefs.getBoolean( context.getString( - R.string.sponsorblock_category_non_music_key), + R.string.sponsor_block_category_non_music_key), false); videoSegments = new SponsorBlockApiTask(apiUrl) @@ -1216,7 +1216,7 @@ public abstract class BasePlayer implements includeSelfPromoCategory, includeMusicCategory); } catch (final Exception e) { - Log.e("SPONSOR_BLOCK", "Error getting YouTube video sponsor times.", e); + Log.e("SPONSOR_BLOCK", "Error getting YouTube video segments.", e); } } } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 23fe2fb9b..b0cfa9e5e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -648,9 +648,6 @@ public abstract class VideoPlayer extends BasePlayer new SeekBarMarker(segment.startTime, segment.endTime, (int) simpleExoPlayer.getDuration(), color); markableSeekBar.seekBarMarkers.add(seekBarMarker); - - Log.d("SPONSOR_BLOCK", "Progress bar marker: " - + seekBarMarker.percentStart + ", " + seekBarMarker.percentEnd); } markableSeekBar.drawMarkers(); } @@ -660,9 +657,9 @@ public abstract class VideoPlayer extends BasePlayer final String colorStr; switch (category) { case "sponsor": - key = context.getString(R.string.sponsorblock_category_sponsor_key); + key = context.getString(R.string.sponsor_block_category_sponsor_key); if (mPrefs.getBoolean(key, false)) { - key = context.getString(R.string.sponsorblock_category_sponsor_color_key); + key = context.getString(R.string.sponsor_block_category_sponsor_color_key); colorStr = mPrefs.getString(key, null); return colorStr == null ? context.getResources().getColor(R.color.sponsor_segment) @@ -670,9 +667,9 @@ public abstract class VideoPlayer extends BasePlayer } break; case "intro": - key = context.getString(R.string.sponsorblock_category_intro_key); + key = context.getString(R.string.sponsor_block_category_intro_key); if (mPrefs.getBoolean(key, false)) { - key = context.getString(R.string.sponsorblock_category_intro_color_key); + key = context.getString(R.string.sponsor_block_category_intro_color_key); colorStr = mPrefs.getString(key, null); return colorStr == null ? context.getResources().getColor(R.color.intro_segment) @@ -680,9 +677,9 @@ public abstract class VideoPlayer extends BasePlayer } break; case "outro": - key = context.getString(R.string.sponsorblock_category_outro_key); + key = context.getString(R.string.sponsor_block_category_outro_key); if (mPrefs.getBoolean(key, false)) { - key = context.getString(R.string.sponsorblock_category_outro_color_key); + key = context.getString(R.string.sponsor_block_category_outro_color_key); colorStr = mPrefs.getString(key, null); return colorStr == null ? context.getResources().getColor(R.color.outro_segment) @@ -690,9 +687,9 @@ public abstract class VideoPlayer extends BasePlayer } break; case "interaction": - key = context.getString(R.string.sponsorblock_category_interaction_key); + key = context.getString(R.string.sponsor_block_category_interaction_key); if (mPrefs.getBoolean(key, false)) { - key = context.getString(R.string.sponsorblock_category_interaction_color_key); + key = context.getString(R.string.sponsor_block_category_interaction_color_key); colorStr = mPrefs.getString(key, null); return colorStr == null ? context.getResources().getColor(R.color.interaction_segment) @@ -700,9 +697,9 @@ public abstract class VideoPlayer extends BasePlayer } break; case "selfpromo": - key = context.getString(R.string.sponsorblock_category_self_promo_key); + key = context.getString(R.string.sponsor_block_category_self_promo_key); if (mPrefs.getBoolean(key, false)) { - key = context.getString(R.string.sponsorblock_category_self_promo_color_key); + key = context.getString(R.string.sponsor_block_category_self_promo_color_key); colorStr = mPrefs.getString(key, null); return colorStr == null ? context.getResources().getColor(R.color.self_promo_segment) @@ -710,9 +707,9 @@ public abstract class VideoPlayer extends BasePlayer } break; case "music_offtopic": - key = context.getString(R.string.sponsorblock_category_non_music_key); + key = context.getString(R.string.sponsor_block_category_non_music_key); if (mPrefs.getBoolean(key, false)) { - key = context.getString(R.string.sponsorblock_category_non_music_color_key); + key = context.getString(R.string.sponsor_block_category_non_music_color_key); colorStr = mPrefs.getString(key, null); return colorStr == null ? context.getResources().getColor(R.color.non_music_segment) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index b833c7788..17c3c9e08 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -386,7 +386,7 @@ public class VideoPlayerImpl extends VideoPlayer muteButton.setVisibility(View.VISIBLE); final boolean isSponsorBlockEnabled = mPrefs.getBoolean( - context.getString(R.string.sponsorblock_enable_key), false); + context.getString(R.string.sponsor_block_enable_key), false); blockSponsorsButton.setVisibility(isSponsorBlockEnabled ? View.VISIBLE : View.GONE); playerCloseButton.setVisibility(isFullscreen ? View.GONE : View.VISIBLE); diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 725e8352d..9243b679f 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -145,25 +145,25 @@ public class ContentSettingsFragment extends BasePreferenceFragment { }); final Preference sponsorBlockWebsitePreference = - findPreference(getString(R.string.sponsorblock_home_page_key)); + findPreference(getString(R.string.sponsor_block_home_page_key)); sponsorBlockWebsitePreference.setOnPreferenceClickListener((Preference p) -> { final Intent i = new Intent(Intent.ACTION_VIEW, - Uri.parse(getString(R.string.sponsorblock_homepage_url))); + Uri.parse(getString(R.string.sponsor_block_homepage_url))); startActivity(i); return true; }); final Preference sponsorBlockPrivacyPreference = - findPreference(getString(R.string.sponsorblock_privacy_key)); + findPreference(getString(R.string.sponsor_block_privacy_key)); sponsorBlockPrivacyPreference.setOnPreferenceClickListener((Preference p) -> { final Intent i = new Intent(Intent.ACTION_VIEW, - Uri.parse(getString(R.string.sponsorblock_privacy_policy_url))); + Uri.parse(getString(R.string.sponsor_block_privacy_policy_url))); startActivity(i); return true; }); final Preference sponsorBlockApiUrlPreference = - findPreference(getString(R.string.sponsorblock_api_url_key)); + findPreference(getString(R.string.sponsor_block_api_url_key)); sponsorBlockApiUrlPreference .setOnPreferenceChangeListener((preference, newValue) -> { updateDependencies(preference, newValue); @@ -176,11 +176,11 @@ public class ContentSettingsFragment extends BasePreferenceFragment { super.onViewCreated(view, savedInstanceState); final Preference sponsorBlockApiUrlPreference = - findPreference(getString(R.string.sponsorblock_api_url_key)); + findPreference(getString(R.string.sponsor_block_api_url_key)); final String sponsorBlockApiUrlPreferenceValue = getPreferenceManager() .getSharedPreferences() - .getString(getString(R.string.sponsorblock_api_url_key), null); + .getString(getString(R.string.sponsor_block_api_url_key), null); updateDependencies(sponsorBlockApiUrlPreference, sponsorBlockApiUrlPreferenceValue); } @@ -380,15 +380,15 @@ public class ContentSettingsFragment extends BasePreferenceFragment { private void updateDependencies(final Preference preference, final Object newValue) { // This is a workaround to force dependency updates for custom preferences. - // sponsorblock_api_url_key - if (preference.getKey().equals(getString(R.string.sponsorblock_api_url_key))) { - findPreference(getString(R.string.sponsorblock_enable_key)) + // sponsor_block_api_url_key + if (preference.getKey().equals(getString(R.string.sponsor_block_api_url_key))) { + findPreference(getString(R.string.sponsor_block_enable_key)) .onDependencyChanged(preference, newValue == null || newValue.equals("")); - findPreference(getString(R.string.sponsorblock_notifications_key)) + findPreference(getString(R.string.sponsor_block_notifications_key)) .onDependencyChanged(preference, newValue == null || newValue.equals("")); - findPreference(getString(R.string.sponsorblock_categories_key)) + findPreference(getString(R.string.sponsor_block_categories_key)) .onDependencyChanged(preference, newValue == null || newValue.equals("")); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java index 4aa817d25..08e0d9b09 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SponsorBlockCategoriesSettingsFragment.java @@ -23,7 +23,7 @@ public class SponsorBlockCategoriesSettingsFragment extends BasePreferenceFragme addPreferencesFromResource(R.xml.sponsor_block_category_settings); final Preference resetPreferenceView = - findPreference(getString(R.string.sponsorblock_category_reset_key)); + findPreference(getString(R.string.sponsor_block_category_reset_key)); if (resetPreferenceView != null) { resetPreferenceView.setOnPreferenceClickListener(preference -> { final Context context = getContext(); @@ -35,27 +35,27 @@ public class SponsorBlockCategoriesSettingsFragment extends BasePreferenceFragme .edit(); setColorPreference(editor, - R.string.sponsorblock_category_sponsor_color_key, + R.string.sponsor_block_category_sponsor_color_key, R.color.sponsor_segment); setColorPreference(editor, - R.string.sponsorblock_category_intro_color_key, + R.string.sponsor_block_category_intro_color_key, R.color.intro_segment); setColorPreference(editor, - R.string.sponsorblock_category_outro_color_key, + R.string.sponsor_block_category_outro_color_key, R.color.outro_segment); setColorPreference(editor, - R.string.sponsorblock_category_interaction_color_key, + R.string.sponsor_block_category_interaction_color_key, R.color.interaction_segment); setColorPreference(editor, - R.string.sponsorblock_category_self_promo_color_key, + R.string.sponsor_block_category_self_promo_color_key, R.color.self_promo_segment); setColorPreference(editor, - R.string.sponsorblock_category_non_music_color_key, + R.string.sponsor_block_category_non_music_color_key, R.color.non_music_segment); editor.apply(); diff --git a/app/src/main/java/org/schabi/newpipe/settings/custom/SponsorBlockApiUrlPreference.java b/app/src/main/java/org/schabi/newpipe/settings/custom/SponsorBlockApiUrlPreference.java index e10ffaa5f..a3425bed3 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/custom/SponsorBlockApiUrlPreference.java +++ b/app/src/main/java/org/schabi/newpipe/settings/custom/SponsorBlockApiUrlPreference.java @@ -39,7 +39,7 @@ public class SponsorBlockApiUrlPreference extends Preference { super.onClick(); final View alertDialogView = LayoutInflater.from(getContext()) - .inflate(R.layout.dialog_sponsorblock_api_url, null); + .inflate(R.layout.dialog_sponsor_block_api_url, null); final EditText editText = alertDialogView.findViewById(R.id.api_url_edit); editText.setText(getSharedPreferences().getString(getKey(), null)); @@ -54,11 +54,11 @@ public class SponsorBlockApiUrlPreference extends Preference { alertDialogView.findViewById(R.id.icon_api_url_help) .setOnClickListener(v -> { final Uri privacyPolicyUri = Uri.parse(getContext() - .getString(R.string.sponsorblock_privacy_policy_url)); + .getString(R.string.sponsor_block_privacy_policy_url)); final View helpDialogView = LayoutInflater.from(getContext()) - .inflate(R.layout.dialog_sponsorblock_api_url_help, null); + .inflate(R.layout.dialog_sponsor_block_api_url_help, null); final View privacyPolicyButton = helpDialogView - .findViewById(R.id.sponsorblock_privacy_policy_button); + .findViewById(R.id.sponsor_block_privacy_policy_button); privacyPolicyButton.setOnClickListener(v1 -> { final Intent i = new Intent(Intent.ACTION_VIEW, privacyPolicyUri); getContext().startActivity(i); @@ -68,7 +68,7 @@ public class SponsorBlockApiUrlPreference extends Preference { .setView(helpDialogView) .setPositiveButton("Use Official", (dialog, which) -> { editText.setText(getContext() - .getString(R.string.sponsorblock_default_api_url)); + .getString(R.string.sponsor_block_default_api_url)); dialog.dismiss(); }) .setNeutralButton("Close", (dialog, which) -> dialog.dismiss()) @@ -79,7 +79,7 @@ public class SponsorBlockApiUrlPreference extends Preference { final AlertDialog alertDialog = new AlertDialog.Builder(getContext()) .setView(alertDialogView) - .setTitle(getContext().getString(R.string.sponsorblock_api_url_title)) + .setTitle(getContext().getString(R.string.sponsor_block_api_url_title)) .setPositiveButton("OK", (dialog, which) -> { final String newValue = editText.getText().toString(); final SharedPreferences.Editor editor = diff --git a/app/src/main/res/layout/dialog_sponsorblock_api_url.xml b/app/src/main/res/layout/dialog_sponsor_block_api_url.xml similarity index 100% rename from app/src/main/res/layout/dialog_sponsorblock_api_url.xml rename to app/src/main/res/layout/dialog_sponsor_block_api_url.xml diff --git a/app/src/main/res/layout/dialog_sponsorblock_api_url_help.xml b/app/src/main/res/layout/dialog_sponsor_block_api_url_help.xml similarity index 82% rename from app/src/main/res/layout/dialog_sponsorblock_api_url_help.xml rename to app/src/main/res/layout/dialog_sponsor_block_api_url_help.xml index 3d91c84da..b803c9143 100644 --- a/app/src/main/res/layout/dialog_sponsorblock_api_url_help.xml +++ b/app/src/main/res/layout/dialog_sponsor_block_api_url_help.xml @@ -15,11 +15,11 @@ android:layout_marginBottom="6dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" - android:text="@string/sponsorblock_api_url_help_text"/> + android:text="@string/sponsor_block_api_url_help_text"/>