-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(youtube/theme): theme litho UI components (#176)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package app.revanced.integrations.patches; | ||
|
||
import android.util.Log; | ||
|
||
import app.revanced.integrations.utils.ThemeHelper; | ||
|
||
public class LithoThemePatch { | ||
// color constants used in relation with litho components | ||
private static final int[] WHITECONSTANTS = { | ||
-1, // comments chip background | ||
-394759, // music related results panel background | ||
-83886081, // video chapters list background | ||
}; | ||
|
||
private static final int[] DARKCONSTANTS = { | ||
-14606047, // comments chip background | ||
-15198184, // music related results panel background | ||
-15790321, // comments chip background (new layout) | ||
-98492127 // video chapters list background | ||
}; | ||
|
||
// Used by app.revanced.patches.youtube.layout.theme.patch.LithoThemePatch | ||
public static int applyLithoTheme(int originalValue) { | ||
var isDarkTheme = ThemeHelper.isDarkTheme(); | ||
|
||
if ((isDarkTheme && anyEquals(originalValue, DARKCONSTANTS)) || (!isDarkTheme && anyEquals(originalValue, WHITECONSTANTS))) | ||
return 0; | ||
return originalValue; | ||
} | ||
|
||
private static boolean anyEquals(int value, int... of) { | ||
for (int v : of) if (value == v) return true; | ||
return false; | ||
} | ||
} |