Skip to content

Remove shorts for youtube #23130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class MediaPreferences extends BravePreferenceFragment
"hide_youtube_recommended_content";
private static final String PREF_HIDE_YOUTUBE_DISTRACTING_ELEMENTS =
"hide_youtube_distracting_elements";
private static final String PREF_HIDE_YOUTUBE_SHORTS = "hide_youtube_shorts";

private FilterListAndroidHandler mFilterListAndroidHandler;

Expand Down Expand Up @@ -91,6 +92,11 @@ public void onActivityCreated(Bundle savedInstanceState) {
if (hideYoutubeDistractingElementsPref != null) {
hideYoutubeDistractingElementsPref.setOnPreferenceChangeListener(this);
}
ChromeSwitchPreference hideYoutubeShortsPref =
(ChromeSwitchPreference) findPreference(PREF_HIDE_YOUTUBE_SHORTS);
if (hideYoutubeShortsPref != null) {
hideYoutubeShortsPref.setOnPreferenceChangeListener(this);
}

if (mFilterListAndroidHandler != null) {
mFilterListAndroidHandler.isFilterListEnabled(
Expand All @@ -107,6 +113,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
hideYoutubeDistractingElementsPref.setChecked(isEnabled);
}
});
mFilterListAndroidHandler.isFilterListEnabled(
FilterListConstants.HIDE_YOUTUBE_SHORTS_UUID,
isEnabled -> {
if (hideYoutubeShortsPref != null) {
hideYoutubeShortsPref.setChecked(isEnabled);
}
});
}
}

Expand Down Expand Up @@ -139,6 +152,11 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
FilterListConstants.HIDE_YOUTUBE_DISTRACTING_ELEMENTS_UUID,
(boolean) newValue);
}
} else if (PREF_HIDE_YOUTUBE_SHORTS.equals(key)) {
if (mFilterListAndroidHandler != null) {
mFilterListAndroidHandler.enableFilter(
FilterListConstants.HIDE_YOUTUBE_SHORTS_UUID, (boolean) newValue);
}
}

if (shouldRelaunch) {
Expand Down
5 changes: 5 additions & 0 deletions android/java/res/xml/media_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
android:title="@string/block_youtube_distracting_elements"
android:summary="@string/block_youtube_distracting_elements_description"
android:defaultValue="true" />
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="hide_youtube_shorts"
android:title="@string/block_youtube_shorts"
android:summary="@string/block_youtube_shorts_description"
android:defaultValue="false" />
</PreferenceCategory>

</PreferenceScreen>
6 changes: 6 additions & 0 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
<message name="IDS_BLOCK_YOUTUBE_DISTRACTING_ELEMENTS_DESCRIPTION" desc="Hides the sign in, menu, comments and video info elements on YouTube.">
Blocks the sign in, menu, comments, and video info elements on youtube.com.
</message>
<message name="IDS_BLOCK_YOUTUBE_SHORTS" desc="Hide YouTube shorts">
Block YouTube Shorts
</message>
<message name="IDS_BLOCK_YOUTUBE_SHORTS_DESCRIPTION" desc="Hides shorts on YouTube.">
Blocks Shorts from the home page, trending page and search results on youtube.com.
</message>
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_TITLE" desc="Title for social media blocking.">
Social Media Blocking
</message>
Expand Down
2 changes: 2 additions & 0 deletions components/brave_shields/core/common/filter_list.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ const string kHideYoutubeRecommendedContentUuid
= "2D57ADED-3531-419A-9DED-7F8868BC1561";
const string kHideYoutubeDistractingElementsUuid
= "BD308B90-D3BB-4041-9114-22E096B0BA77";
const string kHideYoutubeShortsUuid
= "9E8EC586-4E17-4E5E-99D7-35172C4CEA74";
Loading