Skip to content

feat(YouTube - Settings): Add ability to search in settings #4881

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 95 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
073e99b
feat(YouTube - Settings): Add SearchView to ReVanced settings
MarcaDian Apr 29, 2025
f616b7f
apply from review
MarcaDian Apr 29, 2025
af49e1e
refactor -> replace SearchView with EditText
MarcaDian Apr 30, 2025
e4e6927
remove unnecessary EditText margin
MarcaDian Apr 30, 2025
768e54c
apply from review -> move search ability to another class
MarcaDian May 1, 2025
80ccc8a
redesign Search bar
MarcaDian May 1, 2025
9315832
refactor -> bring back to SearchView
MarcaDian May 1, 2025
e723218
refactor -> resolve margin problem
MarcaDian May 2, 2025
e98a6d5
refactor -> fix text direction in Arabic and Hebrew
MarcaDian May 2, 2025
2da1a90
Revert "refactor -> fix text direction in Arabic and Hebrew"
MarcaDian May 2, 2025
eef25f9
fix toolbar in other fragments
MarcaDian May 2, 2025
75fd5e6
refactor -> fix text direction in Arabic and Hebrew
MarcaDian May 2, 2025
35c794c
reapply from review
MarcaDian May 2, 2025
f910780
Possible fix for settings flickering when language override is used
LisoUseInAIKyrios May 2, 2025
31b1c1c
fix: Search RYD settings
LisoUseInAIKyrios May 2, 2025
82da35a
cleanup
LisoUseInAIKyrios May 2, 2025
fe6b963
Convert SB work in progress
LisoUseInAIKyrios May 2, 2025
c96fa38
fix export error due to RYD migration code
LisoUseInAIKyrios May 2, 2025
82f488c
fix SB settings not updating after importing settings
LisoUseInAIKyrios May 2, 2025
6b60d9b
Use utility method to check for RTL text layout
LisoUseInAIKyrios May 2, 2025
8ca7973
refactor
LisoUseInAIKyrios May 2, 2025
8e6c2ed
fixes, refactor
LisoUseInAIKyrios May 2, 2025
e8ee20a
refactor: Remove unused preference list
LisoUseInAIKyrios May 2, 2025
30355d6
fix sub-preference search in settings
MarcaDian May 3, 2025
2cb1118
clean
MarcaDian May 3, 2025
f4d9a01
Merge remote-tracking branch 'revanced/dev' into add_searchbar_to_set…
MarcaDian May 3, 2025
00f4944
possibly fix looping
MarcaDian May 3, 2025
98e8993
refactor
LisoUseInAIKyrios May 3, 2025
3a0602a
Work in progress: Show navigation path as preference category
LisoUseInAIKyrios May 3, 2025
e3de443
fix duplicate preference groups
LisoUseInAIKyrios May 3, 2025
ed38d91
refactor
LisoUseInAIKyrios May 3, 2025
f6db6c5
fix settings migration
LisoUseInAIKyrios May 3, 2025
db626ea
refactor
LisoUseInAIKyrios May 3, 2025
1d42739
refactor
LisoUseInAIKyrios May 3, 2025
0fd733d
Work in progress: Category titles are clickable. Needs back button f…
LisoUseInAIKyrios May 3, 2025
04c8572
Revert "Work in progress: Category titles are clickable. Needs back …
LisoUseInAIKyrios May 3, 2025
be884f3
cleanup
LisoUseInAIKyrios May 3, 2025
7079e62
work in progress: Modernize SB settings preferences
LisoUseInAIKyrios May 3, 2025
06769f4
Merge remote-tracking branch 'upstream/dev' into add_searchbar_to_set…
LisoUseInAIKyrios May 4, 2025
212b946
possible fix for missing search results after locking/unlocking
LisoUseInAIKyrios May 4, 2025
eec41da
fix categories displayed in inconsistent order compared to it's enclo…
LisoUseInAIKyrios May 4, 2025
f672ff4
Work in progress modernization of last SB settings. Reverting until …
LisoUseInAIKyrios May 4, 2025
2ea2214
Revert "Work in progress modernization of last SB settings. Revertin…
LisoUseInAIKyrios May 4, 2025
ffc7318
fix SB categories not showing in search
LisoUseInAIKyrios May 4, 2025
93e35f1
fix SB categories not working after importing but not restarting
LisoUseInAIKyrios May 4, 2025
65c20bf
fix query hint
MarcaDian May 4, 2025
3904286
Work in progress: trying to finish SB settings
MarcaDian May 5, 2025
c54acb7
Revert "Work in progress: trying to finish SB settings"
MarcaDian May 5, 2025
2bf675b
fix duplicate SponsorBlock settings showing in search
LisoUseInAIKyrios May 5, 2025
7262b92
Merge remote-tracking branch 'upstream/dev' into add_searchbar_to_set…
LisoUseInAIKyrios May 5, 2025
98d2771
refactor
LisoUseInAIKyrios May 5, 2025
30c8f86
fix: Cache SB stats up to 1 hour, or until the user creates a new seg…
LisoUseInAIKyrios May 5, 2025
9e97edb
refactor
LisoUseInAIKyrios May 5, 2025
dab6a46
Search in switch summary on/off, search in list preference entries an…
LisoUseInAIKyrios May 7, 2025
baf9efe
remove debugging code (all searches run in 1ms or less).
LisoUseInAIKyrios May 7, 2025
6337957
refactor
LisoUseInAIKyrios May 7, 2025
52262bb
refactor
LisoUseInAIKyrios May 7, 2025
50a7a4d
refactor
LisoUseInAIKyrios May 8, 2025
d36a250
refactor
LisoUseInAIKyrios May 8, 2025
ffc80ec
refactor -> highlighting matches in the titles or summary
MarcaDian May 8, 2025
8e12674
refactor -> highlight matches in search results with color
MarcaDian May 9, 2025
e94a55c
refactor -> add placeholder if no preferences are found
MarcaDian May 9, 2025
34625aa
refactor
LisoUseInAIKyrios May 9, 2025
23ac6f6
refactor
LisoUseInAIKyrios May 9, 2025
249f2eb
refactor
LisoUseInAIKyrios May 9, 2025
7678157
refactor
LisoUseInAIKyrios May 9, 2025
ab9e89b
fix icon alignment
MarcaDian May 9, 2025
67fabe3
refactor
LisoUseInAIKyrios May 9, 2025
60378ac
Adjust light mode highlight shade
LisoUseInAIKyrios May 9, 2025
68112c2
refactor -> implement search history
MarcaDian May 9, 2025
8280131
refactor -> fix crashes in some cases
MarcaDian May 9, 2025
208a8e2
refactor
LisoUseInAIKyrios May 9, 2025
76fea2c
Increase maximum search suggestions to 20
LisoUseInAIKyrios May 9, 2025
b2c9596
refactor
LisoUseInAIKyrios May 9, 2025
916d884
refactor -> show search history only once when search is activated an…
MarcaDian May 9, 2025
4e8f052
refactor
LisoUseInAIKyrios May 9, 2025
271d49b
Change search history to 5
LisoUseInAIKyrios May 9, 2025
ec5ba86
refactor
LisoUseInAIKyrios May 9, 2025
ad5f23c
Almost finished clickable preference category paths.
LisoUseInAIKyrios May 9, 2025
4dbff3d
Revert "Almost finished clickable preference category paths."
LisoUseInAIKyrios May 9, 2025
62d9e4c
fix typo
LisoUseInAIKyrios May 10, 2025
2a26ff5
Show most recent searches first
LisoUseInAIKyrios May 10, 2025
9ca2e88
Save search history to settings
LisoUseInAIKyrios May 10, 2025
44bcb31
refactor
LisoUseInAIKyrios May 10, 2025
5fdd3b8
refactor
LisoUseInAIKyrios May 10, 2025
9926fb3
yet more refactoring
LisoUseInAIKyrios May 10, 2025
09fc30d
Make delete search dialog similar to the stock YT dialog when deletin…
LisoUseInAIKyrios May 16, 2025
53141f8
refactor
LisoUseInAIKyrios May 16, 2025
d4f840b
Move sorted preference list behavior into custom classes.
LisoUseInAIKyrios May 16, 2025
3e2404a
Sort any new entry/values.
LisoUseInAIKyrios May 16, 2025
13753d4
fix UI error when exiting re-entering settings menu
LisoUseInAIKyrios May 16, 2025
bcd15c7
refactor
LisoUseInAIKyrios May 16, 2025
bd35d1b
refactor: Don't resort list preferences on every search
LisoUseInAIKyrios May 16, 2025
fff5897
add comment why ListPreference cannot show highlighting in the summary
LisoUseInAIKyrios May 16, 2025
f584b62
refactor
LisoUseInAIKyrios May 17, 2025
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 @@ -371,7 +371,7 @@ public static void setContext(Context appContext) {
if (language != AppLanguage.DEFAULT) {
// Create a new context with the desired language.
Logger.printDebug(() -> "Using app language: " + language);
Configuration config = appContext.getResources().getConfiguration();
Configuration config = new Configuration(appContext.getResources().getConfiguration());
config.setLocale(language.getLocale());
context = appContext.createConfigurationContext(config);
}
Expand All @@ -391,16 +391,47 @@ public static boolean isTablet() {
private static Boolean isRightToLeftTextLayout;

/**
* If the device language uses right to left text layout (hebrew, arabic, etc)
* @return If the device language uses right to left text layout (Hebrew, Arabic, etc).
* If this should match any ReVanced language override then instead use
* {@link #isRightToLeftLocale(Locale)} with {@link BaseSettings#REVANCED_LANGUAGE}.
* This is the default locale of the device, which may differ if
* {@link BaseSettings#REVANCED_LANGUAGE} is set to a different language.
*/
public static boolean isRightToLeftTextLayout() {
public static boolean isRightToLeftLocale() {
if (isRightToLeftTextLayout == null) {
String displayLanguage = Locale.getDefault().getDisplayLanguage();
isRightToLeftTextLayout = new Bidi(displayLanguage, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft();
isRightToLeftTextLayout = isRightToLeftLocale(Locale.getDefault());
}
return isRightToLeftTextLayout;
}

/**
* @return If the locale uses right to left text layout (Hebrew, Arabic, etc).
*/
public static boolean isRightToLeftLocale(Locale locale) {
String displayLanguage = locale.getDisplayLanguage();
return new Bidi(displayLanguage, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft();
}

/**
* @return A UTF8 string containing a left-to-right or right-to-left
* character of the device locale. If this should match any ReVanced language
* override then instead use {@link #getTextDirectionString(Locale)} with
* {@link BaseSettings#REVANCED_LANGUAGE}.
*/
public static String getTextDirectionString() {
return getTextDirectionString(isRightToLeftLocale());
}

public static String getTextDirectionString(Locale locale) {
return getTextDirectionString(isRightToLeftLocale(locale));
}

private static String getTextDirectionString(boolean isRightToLeft) {
return isRightToLeft
? "\u200F" // u200F = right to left character.
: "\u200E"; // u200E = left to right character.
}

/**
* @return if the text contains at least 1 number character,
* including any unicode numbers such as Arabic.
Expand Down Expand Up @@ -692,9 +723,10 @@ static Sort fromKey(@Nullable String key, @NonNull Sort defaultSort) {
/**
* Strips all punctuation and converts to lower case. A null parameter returns an empty string.
*/
public static String removePunctuationConvertToLowercase(@Nullable CharSequence original) {
public static String removePunctuationToLowercase(@Nullable CharSequence original) {
if (original == null) return "";
return punctuationPattern.matcher(original).replaceAll("").toLowerCase();
return punctuationPattern.matcher(original).replaceAll("")
.toLowerCase(BaseSettings.REVANCED_LANGUAGE.get().getLocale());
}

/**
Expand Down Expand Up @@ -726,7 +758,7 @@ public static void sortPreferenceGroups(@NonNull PreferenceGroup group) {
final String sortValue;
switch (preferenceSort) {
case BY_TITLE:
sortValue = removePunctuationConvertToLowercase(preference.getTitle());
sortValue = removePunctuationToLowercase(preference.getTitle());
break;
case BY_KEY:
sortValue = preference.getKey();
Expand Down Expand Up @@ -810,4 +842,12 @@ public static int getColorFromString(String colorString) throws IllegalArgumentE
}
return getResourceColor(colorString);
}

public static int clamp(int value, int lower, int upper) {
return Math.max(lower, Math.min(value, upper));
}

public static float clamp(float value, float lower, float upper) {
return Math.max(lower, Math.min(value, upper));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ public enum AppLanguage {
ZU;

private final String language;
private final Locale locale;

AppLanguage() {
language = name().toLowerCase(Locale.US);
locale = Locale.forLanguageTag(language);
}

/**
Expand All @@ -112,6 +114,6 @@ public Locale getLocale() {
return Locale.getDefault();
}

return Locale.forLanguageTag(language);
return locale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public NoTitlePreferenceCategory(Context context, AttributeSet attrs, int defSty
super(context, attrs, defStyleAttr);
}

public NoTitlePreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}

public NoTitlePreferenceCategory(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package app.revanced.extension.youtube;

import static app.revanced.extension.shared.Utils.clamp;

import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Build;
import android.text.style.ReplacementSpan;
import android.text.TextPaint;
import android.view.Window;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import app.revanced.extension.shared.Logger;
Expand Down Expand Up @@ -121,4 +129,43 @@ public static void setNavigationBarColor(@Nullable Window window) {
window.setNavigationBarContrastEnforced(true);
}
}

/**
* Adjusts the brightness of a color by lightening or darkening it based on the given factor.
* <p>
* If the factor is greater than 1, the color is lightened by interpolating toward white (#FFFFFF).
* If the factor is less than or equal to 1, the color is darkened by scaling its RGB components toward black (#000000).
* The alpha channel remains unchanged.
*
* @param color The input color to adjust, in ARGB format.
* @param factor The adjustment factor. Use values > 1.0f to lighten (e.g., 1.11f for slight lightening)
* or values <= 1.0f to darken (e.g., 0.95f for slight darkening).
* @return The adjusted color in ARGB format.
*/
public static int adjustColorBrightness(int color, float factor) {
final int alpha = Color.alpha(color);
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);

if (factor > 1.0f) {
// Lighten: Interpolate toward white (255)
final float t = 1.0f - (1.0f / factor); // Interpolation parameter
red = Math.round(red + (255 - red) * t);
green = Math.round(green + (255 - green) * t);
blue = Math.round(blue + (255 - blue) * t);
} else {
// Darken or no change: Scale toward black
red = (int) (red * factor);
green = (int) (green * factor);
blue = (int) (blue * factor);
}

// Ensure values are within [0, 255]
red = clamp(red, 0, 255);
green = clamp(green, 0, 255);
blue = clamp(blue, 0, 255);

return Color.argb(alpha, red, green, blue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import app.revanced.extension.shared.Utils;
import app.revanced.extension.youtube.patches.components.ReturnYouTubeDislikeFilterPatch;
import app.revanced.extension.youtube.returnyoutubedislike.ReturnYouTubeDislike;
import app.revanced.extension.youtube.returnyoutubedislike.requests.ReturnYouTubeDislikeApi;
import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.youtube.shared.PlayerType;

Expand Down Expand Up @@ -69,13 +68,6 @@ public class ReturnYouTubeDislikePatch {
@Nullable
private static volatile String lastPrefetchedVideoId;

public static void onRYDStatusChange(boolean rydEnabled) {
ReturnYouTubeDislikeApi.resetRateLimits();
// Must remove all values to protect against using stale data
// if the user enables RYD while a video is on screen.
clearData();
}

private static void clearData() {
currentVideoData = null;
lastLithoShortsVideoData = null;
Expand Down Expand Up @@ -274,7 +266,7 @@ private static void addRollingNumberPatchChanges(TextView view) {
Logger.printDebug(() -> "Adding rolling number TextView changes");
view.setCompoundDrawablePadding(ReturnYouTubeDislike.leftSeparatorShapePaddingPixels);
ShapeDrawable separator = ReturnYouTubeDislike.getLeftSeparatorDrawable();
if (Utils.isRightToLeftTextLayout()) {
if (Utils.isRightToLeftLocale()) {
view.setCompoundDrawables(null, null, separator, null);
} else {
view.setCompoundDrawables(separator, null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void setActionBar(View view) {
final int paddingStart = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
8, Resources.getSystem().getDisplayMetrics());

if (Utils.isRightToLeftTextLayout()) {
if (Utils.isRightToLeftLocale()) {
searchBarView.setPadding(paddingLeft, paddingTop, paddingStart, paddingBottom);
} else {
searchBarView.setPadding(paddingStart, paddingTop, paddingRight, paddingBottom);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.revanced.extension.youtube.patches.theme;

import static app.revanced.extension.shared.StringRef.str;
import static app.revanced.extension.shared.Utils.clamp;

import android.content.res.Resources;
import android.graphics.Color;
Expand Down Expand Up @@ -378,14 +379,4 @@ private static int getSeekbarColorValue(int originalColor) {
return originalColor;
}
}

/** @noinspection SameParameterValue */
private static int clamp(int value, int lower, int upper) {
return Math.max(lower, Math.min(value, upper));
}

/** @noinspection SameParameterValue */
private static float clamp(float value, float lower, float upper) {
return Math.max(lower, Math.min(value, upper));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable,
final boolean compactLayout = Settings.RYD_COMPACT_LAYOUT.get();

if (!compactLayout) {
String leftSeparatorString = getTextDirectionString();
String leftSeparatorString = Utils.getTextDirectionString();
final Spannable leftSeparatorSpan;
if (isRollingNumber) {
leftSeparatorSpan = new SpannableString(leftSeparatorString);
Expand Down Expand Up @@ -279,12 +279,6 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable,
return new SpannableString(builder);
}

private static @NonNull String getTextDirectionString() {
return Utils.isRightToLeftTextLayout()
? "\u200F" // u200F = right to left character
: "\u200E"; // u200E = left to right character
}

/**
* @return If the text is likely for a previously created likes/dislikes segmented span.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package app.revanced.extension.youtube.returnyoutubedislike.ui;

import android.content.Context;
import android.util.AttributeSet;

import app.revanced.extension.youtube.settings.preference.UrlLinkPreference;

/**
* Allows tapping the RYD about preference to open the website.
*/
@SuppressWarnings("unused")
public class ReturnYouTubeDislikeAboutPreference extends UrlLinkPreference {
{
externalUrl = "https://returnyoutubedislike.com";
}

public ReturnYouTubeDislikeAboutPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public ReturnYouTubeDislikeAboutPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public ReturnYouTubeDislikeAboutPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ReturnYouTubeDislikeAboutPreference(Context context) {
super(context);
}
}
Loading
Loading