Skip to content

feat(YouTube - Settings): Add a color picker #4981

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 46 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b6ec1a5
feat(YouTube - Settings): Add a color picker
MarcaDian May 17, 2025
89443ac
Merge remote-tracking branch 'upstream/dev' into color-picker-pref
LisoUseInAIKyrios May 18, 2025
1dba359
fix edit text not showing correct color after resetting
LisoUseInAIKyrios May 18, 2025
e10fb68
random refactoring
LisoUseInAIKyrios May 18, 2025
a004602
fix color string not updating?
LisoUseInAIKyrios May 18, 2025
490a22b
fix refactoring
LisoUseInAIKyrios May 18, 2025
344e94c
Work in progress: refactor to a single dialog
MarcaDian May 18, 2025
5103bd8
fix Reset button behavior
MarcaDian May 18, 2025
c7212fe
refactor
LisoUseInAIKyrios May 18, 2025
38711c7
fix preview color disappearing after touch and drag event. removed c…
LisoUseInAIKyrios May 18, 2025
8c1a00e
fix bad text input
LisoUseInAIKyrios May 18, 2025
74e2315
refactor -> del preview colors
MarcaDian May 18, 2025
99833e1
refactor -> SB color picker layout
MarcaDian May 18, 2025
2eea5c6
refactor -> make the color picker narrower and move the hue slider ve…
MarcaDian May 18, 2025
539c227
refactor -> add more toasts
MarcaDian May 18, 2025
3b0b0b0
refactor -> move colored dot from title to the widget area
MarcaDian May 19, 2025
9ffa465
refactor
LisoUseInAIKyrios May 19, 2025
feac37c
Use better validation of input as the user types. Fix crash if impor…
LisoUseInAIKyrios May 19, 2025
ab8c8b7
cleanup
LisoUseInAIKyrios May 19, 2025
54a9fa1
fix user deleting all text
LisoUseInAIKyrios May 19, 2025
7a276a2
reduce the size of color dot
MarcaDian May 19, 2025
f4f4afc
dot is dimmed when the preference is disabled
MarcaDian May 19, 2025
59315ca
restore "reset color" setting string
LisoUseInAIKyrios May 19, 2025
71bf410
fix transparent color selection ring on first launch
MarcaDian May 19, 2025
6c8d166
implement the expanded touch area for the hue slider
MarcaDian May 19, 2025
8ef143c
Show toast if user doesn't enter a full color string
LisoUseInAIKyrios May 19, 2025
d433abf
use monospace font so the text string doesn't wiggle in size when dra…
LisoUseInAIKyrios May 19, 2025
914dc59
add padding so text view doesn't show a huge horizontal underlined te…
LisoUseInAIKyrios May 19, 2025
ad6b5af
remove unnecessary "Color changed" toast when changing SB category se…
LisoUseInAIKyrios May 19, 2025
cd0aaea
Keep SB category dialog open if color is reset. Use zero alpha color…
LisoUseInAIKyrios May 19, 2025
8ca3610
fix resetting category colors saves if user later cancels dialog
LisoUseInAIKyrios May 19, 2025
bfe947c
refactor -> using drawable instead of dot symbol in widget area
MarcaDian May 19, 2025
d3d23e7
fix selector color
LisoUseInAIKyrios May 20, 2025
7fb203c
refactor
LisoUseInAIKyrios May 20, 2025
60be330
fix selector fill color bleeding out past the white selector border
LisoUseInAIKyrios May 20, 2025
ad31dbe
Don't close color preference if reset, Miscellaneous refactoring,
LisoUseInAIKyrios May 20, 2025
c3611e8
Use slightly off white color for selector handle outline. Could use …
LisoUseInAIKyrios May 20, 2025
03922c9
add a thin dark outlines for the handles
MarcaDian May 21, 2025
8d0e429
Use slightly brighter selector edge color
LisoUseInAIKyrios May 22, 2025
fff5018
fix selector hang
MarcaDian May 22, 2025
cdb0717
refactor
LisoUseInAIKyrios May 22, 2025
7a03bd7
Merge remote-tracking branch 'upstream/dev' into color-picker-pref
LisoUseInAIKyrios May 22, 2025
ab4d9f9
Material Design emulation for colored dot in settings.
MarcaDian May 23, 2025
9761b3a
Merge remote-tracking branch 'revanced/dev' into color-picker-pref
MarcaDian May 23, 2025
8b879f6
Don't call the listener unless the color actually changed
LisoUseInAIKyrios May 23, 2025
0c5acfa
refactor
LisoUseInAIKyrios May 23, 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 @@ -23,6 +23,7 @@
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.util.Pair;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
Expand Down Expand Up @@ -557,14 +558,14 @@ private static void showToast(@NonNull String messageToToast, int toastDuration)
);
}

public static boolean isDarkModeEnabled(Context context) {
Configuration config = context.getResources().getConfiguration();
public static boolean isDarkModeEnabled() {
Configuration config = Resources.getSystem().getConfiguration();
final int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
}

public static boolean isLandscapeOrientation() {
final int orientation = context.getResources().getConfiguration().orientation;
final int orientation = Resources.getSystem().getConfiguration().orientation;
return orientation == Configuration.ORIENTATION_LANDSCAPE;
}

Expand Down Expand Up @@ -640,7 +641,11 @@ public static boolean isNetworkConnected() {
|| networkType == NetworkType.OTHER;
}

@SuppressLint({"MissingPermission", "deprecation"}) // Permission already included in YouTube.
/**
* Calling extension code must ensure the target app has the
* <code>ACCESS_NETWORK_STATE</code> app manifest permission.
*/
@SuppressWarnings({"deprecation", "MissingPermission"})
public static NetworkType getNetworkType() {
Context networkContext = getContext();
if (networkContext == null) {
Expand Down Expand Up @@ -852,6 +857,20 @@ public static int getColorFromString(String colorString) throws IllegalArgumentE
return getResourceColor(colorString);
}

/**
* Converts dip value to actual device pixels.
*
* @param dip The density-independent pixels value
* @return The device pixel value
*/
public static int dipToPixels(float dip) {
return (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
dip,
Resources.getSystem().getDisplayMetrics()
);
}

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