Skip to content

Commit

Permalink
KeepUnreadボタンをLsPatch用に作成することにより、rootしている端末は、保存するように
Browse files Browse the repository at this point in the history
NaviColorの変更
  • Loading branch information
areteruhiro committed Nov 14, 2024
1 parent 8e978ff commit 99698ce
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public Option(String name, int id, boolean checked) {
public Option outputCommunication = new Option("output_communication", R.string.switch_output_communication, false);
public Option archived = new Option("archived_message", R.string.switch_archived, false);
public Option callTone = new Option("call_tone", R.string.call_tone, false);

public Option NaviColor = new Option("NaviColor", R.string.NaviColor, false);


public Option[] options = {
removeVoom,
removeWallet,
Expand All @@ -62,6 +64,7 @@ public Option(String name, int id, boolean checked) {
blockTracking,
stopVersionCheck,
outputCommunication,
callTone
callTone,
NaviColor
};
}
4 changes: 3 additions & 1 deletion app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.github.chipppppppppp.lime.hooks.KeepUnreadLSpatch;
import io.github.chipppppppppp.lime.hooks.ModifyRequest;
import io.github.chipppppppppp.lime.hooks.ModifyResponse;
import io.github.chipppppppppp.lime.hooks.NaviColor;
import io.github.chipppppppppp.lime.hooks.OutputRequest;
import io.github.chipppppppppp.lime.hooks.OutputResponse;
import io.github.chipppppppppp.lime.hooks.PreventMarkAsRead;
Expand Down Expand Up @@ -69,7 +70,8 @@ public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResou
new Archived(),
new Ringtone(),
new UnsentCap(),
new KeepUnreadLSpatch()
new KeepUnreadLSpatch(),
new NaviColor()
};

public void handleLoadPackage(@NonNull XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Expand Down
138 changes: 138 additions & 0 deletions app/src/main/java/io/github/chipppppppppp/lime/hooks/NaviColor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package io.github.chipppppppppp.lime.hooks;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.chipppppppppp.lime.LimeOptions;


public class NaviColor implements IHook {

@Override
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if (!limeOptions.NaviColor.checked) return;
XposedBridge.hookAllMethods(Activity.class, "onCreate", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Activity activity = (Activity) param.thisObject;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.setNavigationBarColor(Color.BLACK);
}
}
});
XposedHelpers.findAndHookMethod("android.app.Activity", loadPackageParam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Activity activity = (Activity) param.thisObject;
Window window = activity.getWindow();

window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.BLACK);
}
});
}
}
/*
XposedHelpers.findAndHookMethod(
View.class,
"onAttachedToWindow",
new XC_MethodHook() {
View view;
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
view = (View) param.thisObject;
int viewId = view.getId();
String resourceName = getResourceName(view.getContext(), viewId);
XposedBridge.log("View ID: " + viewId + ", Resource Name: " + resourceName);
}
}
);
}
private int getIdByName(Context context, String resourceName) {
return context.getResources().getIdentifier(resourceName, "id", context.getPackageName());
}
private String getResourceName(Context context, int resourceId) {
return context.getResources().getResourceEntryName(resourceId);
}
}
XposedHelpers.findAndHookMethod("android.view.View", loadPackageParam.classLoader, "onAttachedToWindow", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
View view = (View) param.thisObject;
try {
String resourceName = view.getResources().getResourceEntryName(view.getId());
Drawable background = view.getBackground();
if (background instanceof ColorDrawable) {
int bgColor = ((ColorDrawable) background).getColor();
String hexColor = String.format("#%06X", (0xFFFFFF & bgColor)); // 色を16進数形式に変換
if (hexColor.equals("#111111") || hexColor.equals("#1F1F1F")) {
((ColorDrawable) background).setColor(Color.parseColor("#000000"));
XposedBridge.log("Changed Background Color of View Resource Name: " + resourceName + " from " + hexColor + " to #000000");
} else {
XposedBridge.log("View Resource Name: " + resourceName + " Background Color: " + hexColor);
}
}
if (view instanceof TextView) {
int textColor = ((TextView) view).getCurrentTextColor();
String hexTextColor = String.format("#%06X", (0xFFFFFF & textColor)); // 色を16進数形式に変換
if (hexTextColor.equals("#111111")) {
((TextView) view).setTextColor(Color.parseColor("#000000"));
XposedBridge.log("Changed Text Color of View Resource Name: " + resourceName + " from " + hexTextColor + " to #000000");
} else {
XposedBridge.log("View Resource Name: " + resourceName + " Text Color: " + hexTextColor);
}
}
if (view instanceof Button) {
Drawable buttonBackground = view.getBackground();
if (buttonBackground instanceof ColorDrawable) {
int buttonBgColor = ((ColorDrawable) buttonBackground).getColor();
String hexButtonColor = String.format("#%06X", (0xFFFFFF & buttonBgColor)); // 色を16進数形式に変換
if (hexButtonColor.equals("#111111") || hexButtonColor.equals("#1F1F1F")) {
((ColorDrawable) buttonBackground).setColor(Color.parseColor("#000000"));
XposedBridge.log("Changed Button Background Color of Resource Name: " + resourceName + " from " + hexButtonColor + " to #000000");
} else {
XposedBridge.log("Button Resource Name: " + resourceName + " Background Color: " + hexButtonColor);
}
}
}
} catch (Resources.NotFoundException e) {
XposedBridge.log("View ID: " + view.getId() + " - Resource name not found.");
}
}
});
*/




3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@
<string name="no_get_restart_app">Could not get properly.\nPlease restart the app</string>
<string name="switch_KeepUnreadLSpatch">Show \"Read as unread\" switch for LsPatch</string>

<string name="NaviColor">ナビゲーションのボタンの色を黒にする</string>


</resources>

0 comments on commit 99698ce

Please sign in to comment.