Skip to content

Commit b934c89

Browse files
authored
Remove shorts for youtube (uplift to 1.66.x) (#23302)
Uplift of #23130 (squashed) to beta
1 parent 506d4fc commit b934c89

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

android/java/org/chromium/chrome/browser/settings/MediaPreferences.java

+18
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class MediaPreferences extends BravePreferenceFragment
3535
"hide_youtube_recommended_content";
3636
private static final String PREF_HIDE_YOUTUBE_DISTRACTING_ELEMENTS =
3737
"hide_youtube_distracting_elements";
38+
private static final String PREF_HIDE_YOUTUBE_SHORTS = "hide_youtube_shorts";
3839

3940
private FilterListAndroidHandler mFilterListAndroidHandler;
4041

@@ -91,6 +92,11 @@ public void onActivityCreated(Bundle savedInstanceState) {
9192
if (hideYoutubeDistractingElementsPref != null) {
9293
hideYoutubeDistractingElementsPref.setOnPreferenceChangeListener(this);
9394
}
95+
ChromeSwitchPreference hideYoutubeShortsPref =
96+
(ChromeSwitchPreference) findPreference(PREF_HIDE_YOUTUBE_SHORTS);
97+
if (hideYoutubeShortsPref != null) {
98+
hideYoutubeShortsPref.setOnPreferenceChangeListener(this);
99+
}
94100

95101
if (mFilterListAndroidHandler != null) {
96102
mFilterListAndroidHandler.isFilterListEnabled(
@@ -107,6 +113,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
107113
hideYoutubeDistractingElementsPref.setChecked(isEnabled);
108114
}
109115
});
116+
mFilterListAndroidHandler.isFilterListEnabled(
117+
FilterListConstants.HIDE_YOUTUBE_SHORTS_UUID,
118+
isEnabled -> {
119+
if (hideYoutubeShortsPref != null) {
120+
hideYoutubeShortsPref.setChecked(isEnabled);
121+
}
122+
});
110123
}
111124
}
112125

@@ -139,6 +152,11 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
139152
FilterListConstants.HIDE_YOUTUBE_DISTRACTING_ELEMENTS_UUID,
140153
(boolean) newValue);
141154
}
155+
} else if (PREF_HIDE_YOUTUBE_SHORTS.equals(key)) {
156+
if (mFilterListAndroidHandler != null) {
157+
mFilterListAndroidHandler.enableFilter(
158+
FilterListConstants.HIDE_YOUTUBE_SHORTS_UUID, (boolean) newValue);
159+
}
142160
}
143161

144162
if (shouldRelaunch) {

android/java/res/xml/media_preferences.xml

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
android:title="@string/block_youtube_distracting_elements"
3737
android:summary="@string/block_youtube_distracting_elements_description"
3838
android:defaultValue="true" />
39+
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
40+
android:key="hide_youtube_shorts"
41+
android:title="@string/block_youtube_shorts"
42+
android:summary="@string/block_youtube_shorts_description"
43+
android:defaultValue="false" />
3944
</PreferenceCategory>
4045

4146
</PreferenceScreen>

browser/ui/android/strings/android_brave_strings.grd

+6
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
440440
<message name="IDS_BLOCK_YOUTUBE_DISTRACTING_ELEMENTS_DESCRIPTION" desc="Hides the sign in, menu, comments and video info elements on YouTube.">
441441
Blocks the sign in, menu, comments, and video info elements on youtube.com.
442442
</message>
443+
<message name="IDS_BLOCK_YOUTUBE_SHORTS" desc="Hide YouTube shorts">
444+
Block YouTube Shorts
445+
</message>
446+
<message name="IDS_BLOCK_YOUTUBE_SHORTS_DESCRIPTION" desc="Hides shorts on YouTube.">
447+
Blocks Shorts from the home page, trending page and search results on youtube.com.
448+
</message>
443449
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_TITLE" desc="Title for social media blocking.">
444450
Social Media Blocking
445451
</message>

components/brave_shields/core/common/filter_list.mojom

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ const string kHideYoutubeRecommendedContentUuid
3838
= "2D57ADED-3531-419A-9DED-7F8868BC1561";
3939
const string kHideYoutubeDistractingElementsUuid
4040
= "BD308B90-D3BB-4041-9114-22E096B0BA77";
41+
const string kHideYoutubeShortsUuid
42+
= "9E8EC586-4E17-4E5E-99D7-35172C4CEA74";

0 commit comments

Comments
 (0)