Skip to content

Commit

Permalink
既読状態が機能していなかったため
Browse files Browse the repository at this point in the history
  • Loading branch information
areteruhiro committed Nov 30, 2024
1 parent 3b2ae6a commit f18e164
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdk 28
targetSdk 35
versionCode 15
versionName "1.14.1c"
versionName "1.14.2"
multiDexEnabled false
proguardFiles += 'proguard-rules.pro'
buildConfigField 'String', 'HOOK_TARGET_VERSION', '"141910383"'
Expand Down
21 changes: 12 additions & 9 deletions app/src/main/java/io/github/hiro/lime/hooks/KeepUnreadLSpatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@

public class KeepUnreadLSpatch implements IHook {

static boolean keepUnread = false;
static boolean keepUnread = false; // 既読抑制フラグ

@Override
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if (!limeOptions.KeepUnreadLSpatch.checked) return;

XposedHelpers.findAndHookMethod(
"com.linecorp.line.chatlist.view.fragment.ChatListFragment",
loadPackageParam.classLoader,
Expand All @@ -51,21 +52,21 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
switchParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

// デフォルトのスイッチ状態をファイルの存在によって設定
File backupDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
File logFile = new File(backupDir, "no_read.txt");

// ディレクトリが存在しない場合は作成
if (!backupDir.exists()) {
backupDir.mkdirs();
}

// ファイルの存在状態でスイッチの状態を設定
switchView.setChecked(logFile.exists());

keepUnread = logFile.exists();
switchView.setChecked(keepUnread);

switchView.setOnCheckedChangeListener((buttonView, isChecked) -> {
keepUnread = isChecked;
if (isChecked) {
// スイッチが有効になった場合、ファイルを作成

try {
if (!logFile.exists()) {
logFile.createNewFile();
Expand Down Expand Up @@ -95,22 +96,24 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
);


XposedHelpers.findAndHookMethod(
loadPackageParam.classLoader.loadClass(Constants.MARK_AS_READ_HOOK.className),
Constants.MARK_AS_READ_HOOK.methodName,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {

if (keepUnread) {
param.setResult(null);
param.setResult(null); // 既読処理を無効化
}
}
}
);

}
}





2 changes: 1 addition & 1 deletion app/src/main/java/io/github/hiro/lime/hooks/NaviColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void checkAndChangeTextColor(View view) {
private void checkAndChangeBackgroundColor(View view) {
try {
String resourceName = getViewResourceName(view);
XposedBridge.log("Resource Name: " + resourceName);
// XposedBridge.log("Resource Name: " + resourceName);

Drawable background = view.getBackground();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.github.hiro.lime.hooks;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

import java.lang.reflect.Field;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
Expand All @@ -12,7 +16,7 @@ public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPa
if (!limeOptions.preventMarkAsRead.checked) return;


XposedHelpers.findAndHookMethod(
findAndHookMethod(
loadPackageParam.classLoader.loadClass(Constants.MARK_AS_READ_HOOK.className),
Constants.MARK_AS_READ_HOOK.methodName,
new XC_MethodHook() {
Expand All @@ -25,6 +29,8 @@ protected void beforeHookedMethod(MethodHookParam param) {
}
);



XposedBridge.hookAllMethods(
loadPackageParam.classLoader.loadClass(Constants.REQUEST_HOOK.className),
Constants.REQUEST_HOOK.methodName,
Expand All @@ -50,6 +56,26 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
);

findAndHookMethod(
"cj.b",
loadPackageParam.classLoader,
"f",
int.class, byte[].class,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Field field = param.thisObject.getClass().getDeclaredField("b");
field.setAccessible(true); // private フィールドにアクセス可能にする

Object receiveSource = field.get(param.thisObject); // フィールドの値を取得

if (receiveSource == null) {
XposedBridge.log("receiveSource is not set. Skipping method call.");
param.setResult(0); // メソッド呼び出しをスキップして安全に終了
}
}
}
);

}
}

0 comments on commit f18e164

Please sign in to comment.