Skip to content

Commit

Permalink
Merge pull request #33 from Mahmud0808/shizuku
Browse files Browse the repository at this point in the history
Add rootless theming support using Shizuku
  • Loading branch information
Mahmud0808 authored Feb 6, 2024
2 parents 452d8de + 4809f6f commit ea4ae5b
Show file tree
Hide file tree
Showing 44 changed files with 1,157 additions and 445 deletions.
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
Elevate your creativity with effortless material customization. Instantly tweak colors for a personalized touch in just a few taps.
</p>
<div align="center">

<br>
<a href="https://www.buymeacoffee.com/DrDisagree"><img src="https://raw.githubusercontent.com/Mahmud0808/ColorBlendr/master/.github/resources/bmc-button.png" width="30%" alt="Buy me a coffee" /></a>
<br><br>
<img src="https://raw.githubusercontent.com/Mahmud0808/ColorBlendr/master/.github/resources/features.png" width="100%" alt="Features">
</div>

Expand All @@ -31,26 +33,36 @@ Elevate your creativity with effortless material customization. Instantly tweak
- Background lightness changer

- Pitch black theme in dark mode

- Manual color overriding

- and many more to come...
- and many more...

## Requirements 🛠

- Android 12+ device

- Working Root or Shizuku environment

## How to Use 🚀

- Download and install the apk.
- Download and install the apk

- Allow permissions and root access for the app.
- Allow permissions for the app

- Select root or shizuku mode

- That's it. Now you are good to go!

## Translation 🌐
## Note 📝

- Assist in translating ColorBlendr into your preferred language through [our Crowdin platform](https://crowdin.com/project/ColorBlendr). Your contribution will help make ColorBlendr accessible to a wider audience.
- Root is recommended if you want to have the full experience

## Donation 💰
- Shizuku is also supported but customizations are limited

If this project help you in any way, you can give me a cup of coffee :)
## Translation 🌐

<a href="https://www.buymeacoffee.com/DrDisagree"><img src="https://raw.githubusercontent.com/Mahmud0808/ColorBlendr/master/.github/resources/bmc-button.png" width="30%" alt="Buy me a coffee" /></a>
- Assist in translating ColorBlendr into your preferred language through [our Crowdin platform](https://crowdin.com/project/ColorBlendr). Your contribution will help make ColorBlendr accessible to a wider audience.

## Credits 🤝

Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ dependencies {
implementation(libs.libsu.core)
implementation(libs.libsu.service)
implementation(libs.shizuku.api)
implementation(libs.shizuku.provider)
implementation(libs.lsposed.hiddenapibypass)

implementation(libs.appcompat)
implementation(libs.material)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
android:directBootAware="true"
android:exported="true"
tools:ignore="ExportedContentProvider" />

<provider
android:name="rikka.shizuku.ShizukuProvider"
android:authorities="${applicationId}.shizuku"
android:enabled="true"
android:exported="true"
android:multiprocess="false"
android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.drdisagree.colorblendr.service;
import android.content.om.OverlayIdentifier;
import com.drdisagree.colorblendr.utils.fabricated.FabricatedOverlayResource;

interface IRootService {
interface IRootConnection {
boolean isRooted();
void setSystemUIRestartListener();
boolean isOverlayInstalled(String packageName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.drdisagree.colorblendr.service;

interface IShizukuConnection {
void destroy() = 16777114;
void exit() = 1;
void applyFabricatedColors(String jsonString) = 2;
void removeFabricatedColors() = 3;
}
22 changes: 18 additions & 4 deletions app/src/main/java/com/drdisagree/colorblendr/ColorBlendr.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import android.app.Application;
import android.content.Context;

import com.drdisagree.colorblendr.provider.RootServiceProvider;
import com.drdisagree.colorblendr.service.IRootService;
import com.drdisagree.colorblendr.provider.RootConnectionProvider;
import com.drdisagree.colorblendr.provider.ShizukuConnectionProvider;
import com.drdisagree.colorblendr.service.IRootConnection;
import com.drdisagree.colorblendr.service.IShizukuConnection;
import com.google.android.material.color.DynamicColors;

import org.lsposed.hiddenapibypass.HiddenApiBypass;

import java.lang.ref.WeakReference;

public class ColorBlendr extends Application {
Expand Down Expand Up @@ -35,7 +39,17 @@ private static ColorBlendr getInstance() {
return instance;
}

public static IRootService getRootService() {
return RootServiceProvider.getRootServiceProvider();
public static IRootConnection getRootConnection() {
return RootConnectionProvider.getServiceProvider();
}

public static IShizukuConnection getShizukuConnection() {
return ShizukuConnectionProvider.getServiceProvider();
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
HiddenApiBypass.addHiddenApiExemptions("L");
}
}
30 changes: 30 additions & 0 deletions app/src/main/java/com/drdisagree/colorblendr/common/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Const {
// System packages
public static final String FRAMEWORK_PACKAGE = "android";
public static final String SYSTEMUI_PACKAGE = "com.android.systemui";
public static final String SHELL_PACKAGE = "com.android.shell";

// General preferences
public static final String FIRST_RUN = "firstRun";
Expand All @@ -32,13 +33,17 @@ public class Const {
public static final String MONET_SEED_COLOR_ENABLED = "monetSeedColorEnabled";
public static final String MANUAL_OVERRIDE_COLORS = "manualOverrideColors";
public static final String MONET_LAST_UPDATED = "monetLastUpdated";
public static final String MONET_STYLE_ORIGINAL_NAME = "monetStyleOriginalName";
public static final String FABRICATED_OVERLAY_SOURCE_PACKAGE = FRAMEWORK_PACKAGE;
public static final String FABRICATED_OVERLAY_NAME_SYSTEM = BuildConfig.APPLICATION_ID + "_dynamic_theme";
public static final String FABRICATED_OVERLAY_NAME_APPS = BuildConfig.APPLICATION_ID + ".%s_dynamic_theme";
public static final String WALLPAPER_COLOR_LIST = "wallpaperColorList";
public static final String FABRICATED_OVERLAY_FOR_APPS_STATE = "fabricatedOverlayForAppsState";
public static final String SHOW_PER_APP_THEME_WARN = "showPerAppThemeWarn";
public static final String TINT_TEXT_COLOR = "tintTextColor";
public static final int SHIZUKU_PERMISSION_REQUEST_ID = 100;
public static final String THEME_CUSTOMIZATION_OVERLAY_PACKAGES = "theme_customization_overlay_packages";
public static final String SHIZUKU_THEMING_ENABLED = "shizukuThemingEnabled";

// Service preferences
public static final Gson GSON = new Gson();
Expand All @@ -64,4 +69,29 @@ public static HashMap<String, Boolean> getSelectedFabricatedApps() {
return Const.GSON.fromJson(selectedApps, new TypeToken<HashMap<String, Boolean>>() {
}.getType());
}

// Working method of app
public enum WORK_METHOD {
NULL,
ROOT,
SHIZUKU;

public static WORK_METHOD fromString(String str) {
try {
return valueOf(str);
} catch (Exception e) {
return NULL;
}
}
}

public static WORK_METHOD WORKING_METHOD = WORK_METHOD.NULL;

public static WORK_METHOD getWorkingMethod() {
return WORK_METHOD.fromString(RPrefs.getString(PREF_WORKING_METHOD, WORK_METHOD.NULL.toString()));
}

public static void saveWorkingMethod(WORK_METHOD workMethod) {
RPrefs.putString(PREF_WORKING_METHOD, workMethod.toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.drdisagree.colorblendr.extension;

import static com.drdisagree.colorblendr.common.Const.MONET_SEED_COLOR;
import static com.drdisagree.colorblendr.common.Const.MONET_STYLE_ORIGINAL_NAME;

import android.graphics.Color;
import android.util.Log;

import com.drdisagree.colorblendr.config.RPrefs;
import com.drdisagree.colorblendr.utils.ColorUtil;

import org.json.JSONObject;

public class ThemeOverlayPackage {

private static final String TAG = ThemeOverlayPackage.class.getSimpleName();
private static final String THEME_STYLE = "android.theme.customization.theme_style";
private static final String COLOR_SOURCE = "android.theme.customization.color_source";
private static final String SYSTEM_PALETTE = "android.theme.customization.system_palette";

public static JSONObject getThemeCustomizationOverlayPackages() {
JSONObject object = new JSONObject();

try {
object.putOpt(
THEME_STYLE,
RPrefs.getString(MONET_STYLE_ORIGINAL_NAME, "TONAL_SPOT")
);
object.putOpt(COLOR_SOURCE, "preset");
object.putOpt(
SYSTEM_PALETTE,
ColorUtil.intToHexColorNoHash(RPrefs.getInt(MONET_SEED_COLOR, Color.BLUE))
);
} catch (Exception e) {
Log.e(TAG, "getThemeCustomizationOverlayPackages:", e);
}

return object;
}
}
Loading

0 comments on commit ea4ae5b

Please sign in to comment.