Skip to content

Commit

Permalink
fix most of things - 84.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Juby210 committed Jul 15, 2021
1 parent fe3fba4 commit 7e194cb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
### Important: Simple mode in Themer currently doesn't support latest versions of Discord, fix will be dispatched soon!

# DiscordThemer
Xposed module that allows you to change colors in Discord. Requires enabled Resource Hooks in EdXposed / LSPosed Manager settings.

Expand All @@ -10,6 +8,11 @@ If you don't use [LSPosed](https://github.com/LSPosed/LSPosed) you may need to r
[Support Server](https://discord.gg/EsNDvBaHVU)

### TODO
- Rewrite module to kotlin and ui to jetpack compose
- Updater
- More fixes for latests versions
- Revert rebrand theme
- Update descriptions for advanced mode to match latest version of Discord
- Customize more things than colors

### Screenshots
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId = "com.aliucord.themer"
minSdk = 21
targetSdk = 30
versionCode = 2
versionName = "0.0.2.1"
versionCode = 3
versionName = "0.0.3-rc1"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/aliucord/themer/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class Constants {
public static final String[] ACCENT_NAMES = new String[]{
"link", "link_light", "brand", "brand_500", "brand_600", "purple_brand", "purple_brand_dark" };
"link", "link_light", "brand", "brand_360", "brand_500", "brand_600", "brand_new", "brand_new_360", "brand_new_500", "brand_new_530", "brand_new_560", "brand_new_600" };

public static final String[] BACKGROUND_NAMES = new String[]{
"dark_grey_2", "primary_600", "primary_660", "primary_800", "primary_dark_600", "primary_dark_630", "primary_dark_800" };
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/aliucord/themer/Descriptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.HashMap;
import java.util.Map;

// TODO: Update them to match latest Discord version, and as well, add more descriptions.

public class Descriptions {
public static Map<String, String> colors = new HashMap<String, String>(){{
String accent = "Accent color";
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/aliucord/themer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void handleInitPackageResources(XC_InitPackageResources.InitPackageResour
if (prefs.contains("simple_accent_color")) {
int accent = prefs.getInt("simple_accent_color", res.getColor(res.getIdentifier("brand", "color", packageName)));
replaceAllColors(res, packageName, Constants.ACCENT_NAMES, accent);
res.setReplacement(packageName, "color", "purple_brand_alpha_10", getColorWithAlpha("1a", accent));

fixNitroIcon(res, packageName, accent);
}
Expand Down Expand Up @@ -172,7 +171,7 @@ private void setStatusBarColor(ClassLoader classLoader, int color) {
} catch (Throwable e) { logError(e); }
}

private int getColorWithAlpha(String hexAlpha, int color) {
public static int getColorWithAlpha(String hexAlpha, int color) {
return Color.parseColor("#" + hexAlpha + Integer.toHexString(color).substring(2));
}

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/aliucord/themer/ReplaceAttrs.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private Map<String, ColorEntry> getRawMap() {
String simplea = "simple_accent_color";
String simplebg = "simple_bg_color";
String simplebgs = "simple_bg_secondary_color";
put("color_brand", new ColorEntry("color_brand_new", simplea));
put("colorControlBrandForeground", new ColorEntry("color_brand_360", simplea));
put("colorSurface", new ColorEntry("color_primary_dark_800", simplebg));
put("colorBackgroundFloating", new ColorEntry("color_primary_dark_800", simplebg));
put("colorTabsBackground", new ColorEntry("color_primary_dark_800", simplebg));
Expand All @@ -42,6 +44,8 @@ private Map<String, ColorEntry> getRawMap() {
put("colorTextLink", new ColorEntry("color_link", simplea));
put("primary_700", new ColorEntry("color_primary_700", simplebgs));
put("primary_900", new ColorEntry("color_primary_900", "__"));
put("theme_chat_mention_background", new ColorEntry("color_brand_500_alpha_20", "__alpha_10_" + simplea));
put("theme_chat_mention_foreground", new ColorEntry("color_brand_new_530", simplea));
put("theme_chat_mentioned_me", new ColorEntry("mention_highlight"));
put("theme_chat_spoiler_bg", new ColorEntry("color_primary_700", simplebgs));
put("theme_chat_spoiler_inapp_bg", new ColorEntry("color_primary_600", simplebg));
Expand All @@ -64,8 +68,12 @@ public ReplaceAttrs(Resources res, String packageName, Map<String, ?> allPrefs)
public ReplaceAttrs(Resources res, String packageName, SharedPreferences prefs) {
for (Map.Entry<String, ColorEntry> entry : getRawMap().entrySet()) {
String color = entry.getValue().simple;
if (!color.equals("__") && prefs.contains(color))
map.put(res.getIdentifier(entry.getKey(), "attr", packageName), prefs.getInt(color, Color.BLACK));
boolean a10 = color.startsWith("__alpha_10_");
if (a10) color = color.replace("__alpha_10_", "");
if (!color.equals("__") && prefs.contains(color)) {
int c = prefs.getInt(color, Color.BLACK);
map.put(res.getIdentifier(entry.getKey(), "attr", packageName), a10 ? Main.getColorWithAlpha("1a", c) : c);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<string name="simple_settings">Simple settings</string>
<string name="statusbar_color">Status bar color</string>
<string name="support_server">Support Server</string>
<string name="tested_on">Tested on: 65.0 (1467), 67.3 (1492), 67.7 (1498) and 67.8 (1499)</string>
<string name="tested_on">Tested on: 84.1 - Alpha</string>
<string name="xposed_not_detected">Xposed module isn\'t enabled or resource hooks in xposed settings, if you enabled them, try to reboot your device</string>

<string-array name="scope">
Expand Down

0 comments on commit 7e194cb

Please sign in to comment.