Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notif_invalid機能の追加 #219

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ public Option(String name, int id, boolean checked) {
public Option preventUnsendMessage = new Option("prevent_unsend_message", R.string.switch_prevent_unsend_message, false);
public Option sendMuteMessage = new Option("mute_message", R.string.switch_send_mute_message, false);
public Option removeKeepUnread = new Option("remove_keep_unread", R.string.switch_remove_keep_unread, false);
public Option KeepUnreadLSpatch = new Option("Keep_UnreadLSpatch", R.string.switch_KeepUnreadLSpatch, false);
public Option blockTracking = new Option("block_tracking", R.string.switch_block_tracking, false);
public Option stopVersionCheck = new Option("stop_version_check", R.string.switch_stop_version_check, false);
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 ReadChecker = new Option("ReadChecker", R.string.ReadChecker, false);
public Option Notif_invalid = new Option("Notif_invalid", R.string.Notif_invalid, false);


public Option[] options = {
removeVoom,
removeWallet,
Expand All @@ -56,10 +61,15 @@ public Option(String name, int id, boolean checked) {
preventUnsendMessage,
archived,
sendMuteMessage,
ReadChecker,
removeKeepUnread,
KeepUnreadLSpatch,
blockTracking,
stopVersionCheck,
outputCommunication,
callTone
callTone,
NaviColor,
Notif_invalid

};
}
10 changes: 9 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 @@ -12,14 +12,18 @@
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.chipppppppppp.lime.hooks.AddRegistrationOptions;
import io.github.chipppppppppp.lime.hooks.Archived;
import io.github.chipppppppppp.lime.hooks.AutomaticBackup;
import io.github.chipppppppppp.lime.hooks.BlockTracking;
import io.github.chipppppppppp.lime.hooks.CheckHookTargetVersion;
import io.github.chipppppppppp.lime.hooks.Constants;
import io.github.chipppppppppp.lime.hooks.EmbedOptions;
import io.github.chipppppppppp.lime.hooks.IHook;
import io.github.chipppppppppp.lime.hooks.KeepUnread;
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.Notif_invalid;
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 @@ -67,7 +71,11 @@ public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResou
new OutputRequest(),
new Archived(),
new Ringtone(),
new UnsentCap()
new UnsentCap(),
new KeepUnreadLSpatch(),
new NaviColor(),
new AutomaticBackup(),
new Notif_invalid()
};

public void handleLoadPackage(@NonNull XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package io.github.chipppppppppp.lime.hooks;


import static android.content.ContentValues.TAG;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

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;
import io.github.chipppppppppp.lime.hooks.IHook;

public class AutomaticBackup implements IHook {
@Override
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {

XposedHelpers.findAndHookMethod("jp.naver.line.android.activity.schemeservice.LineSchemeServiceActivity",
loadPackageParam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Intent intent = ((Activity) param.thisObject).getIntent();
XposedBridge.log("onCreate Intent action: " + intent.getAction());
handleIntent(intent, param.thisObject);
}
});
}
private void handleIntent(Intent intent, Object activity) {
if (intent != null) {
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
if ("トーク履歴のバックアップを開始".equals(text)) {
backupChatHistory(((Activity) activity).getApplicationContext());
}
if ("トーク画像フォルダのバックアップを開始".equals(text)) {
backupChatsFolder(((Activity) activity).getApplicationContext());
}
if ("バックアップを開始".equals(text)) {
backupChatHistory(((Activity) activity).getApplicationContext());
backupChatsFolder(((Activity) activity).getApplicationContext());
}
}
}



private void backupChatHistory(Context appContext) {
File originalDbFile = appContext.getDatabasePath("naver_line");
File backupDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
if (!backupDir.exists() && !backupDir.mkdirs()) {
return;
}
File backupFileWithTimestamp = new File(backupDir, "naver_line_backup" + ".db");

try (FileChannel source = new FileInputStream(originalDbFile).getChannel()) {
try (FileChannel destinationWithTimestamp = new FileOutputStream(backupFileWithTimestamp).getChannel()) {
destinationWithTimestamp.transferFrom(source, 0, source.size());
}
showToast(appContext, "自動バックアップが成功しました"); // トーストをUIスレッドで表示

} catch (IOException e) {
showToast(appContext, "自動バックアップ中にエラーが発生しました: " + e.getMessage());
}
}
private void backupChatsFolder(Context context) {
File originalChatsDir = new File(Environment.getExternalStorageDirectory(), "Android/data/jp.naver.line.android/files/chats");
File backupDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");

if (!backupDir.exists() && !backupDir.mkdirs()) {
return;
}

File backupChatsDir = new File(backupDir, "chats_backup");
if (!backupChatsDir.exists() && !backupChatsDir.mkdirs()) {
return;
}
try {
copyDirectory(originalChatsDir, backupChatsDir);
Toast.makeText(context, "トーク画像フォルダのバックアップが成功しました", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(context, "トーク画像フォルダのバックアップ中にエラーが発生しました", Toast.LENGTH_SHORT).show();
}
}

private void copyDirectory(File sourceDir, File destDir) throws IOException {
if (!sourceDir.exists()) {
throw new IOException("Source directory does not exist: " + sourceDir.getAbsolutePath());
}

if (!destDir.exists()) {
destDir.mkdirs();
}

File[] files = sourceDir.listFiles();
if (files != null) {
for (File file : files) {
File destFile = new File(destDir, file.getName());
if (file.isDirectory()) {
copyDirectory(file, destFile);
} else {
copyFile(file, destFile);
}
}
}
}

private void copyFile(File sourceFile, File destFile) throws IOException {

if (destFile.exists()) {
destFile.delete();
}

try (FileChannel sourceChannel = new FileInputStream(sourceFile).getChannel();
FileChannel destChannel = new FileOutputStream(destFile).getChannel()) {
destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
}
}

private void showToast(final Context context, final String message) {
new android.os.Handler(context.getMainLooper()).post(() ->
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public HookTarget(String className, String methodName) {
static final HookTarget WEBVIEW_CLIENT_HOOK = new HookTarget("qH0.m", "onPageFinished");
static final HookTarget MUTE_MESSAGE_HOOK = new HookTarget("u71.b", "H");
static final HookTarget MARK_AS_READ_HOOK = new HookTarget("JL.e$d", "run");

//以下のクラス名はtestメゾットで出力させることが出来ます、(14.17.0になっています)
static final HookTarget NOTIFICATION_READ_HOOK = new HookTarget("H91.c", "invokeSuspend");

static final HookTarget REQUEST_HOOK = new HookTarget("org.apache.thrift.k", "b");
static final HookTarget RESPONSE_HOOK = new HookTarget("org.apache.thrift.k", "a");
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
import android.widget.Switch;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
Expand Down Expand Up @@ -249,6 +256,19 @@ public void onClick(View v) {
}
});


Button MuteGroups_Button = new Button(context);
MuteGroups_Button.setLayoutParams(buttonParams);
MuteGroups_Button.setText("通知を無効にしているグループ");
MuteGroups_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MuteGroups_Button(context);
}
});
layout.addView(MuteGroups_Button);


buttonLayout.addView(copyButton);

Button pasteButton = new Button(context);
Expand Down Expand Up @@ -302,6 +322,10 @@ public void onDismiss(DialogInterface dialog) {
}
});





AlertDialog dialog = builder.create();

Button button = new Button(context);
Expand Down Expand Up @@ -394,4 +418,67 @@ public void onClick(View view) {
}
);
}


private void MuteGroups_Button(Context context) {
// ファイルパスを指定
File dir = context.getFilesDir(); // 例えば内部ストレージのファイルディレクトリ
File file = new File(dir, "Notification.txt");

// ファイルが存在する場合、内容を読み込む
StringBuilder fileContent = new StringBuilder();
if (file.exists()) {
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String line;
while ((line = reader.readLine()) != null) {
fileContent.append(line).append("\n");
}
} catch (IOException e) {
XposedBridge.log("Error reading the file: " + e.getMessage());
}
}

// 新しい内容を編集できるようにEditTextを表示する
final EditText editText = new EditText(context);
editText.setText(fileContent.toString());
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
editText.setMinLines(10); // 適切な行数を設定
editText.setGravity(Gravity.TOP); // 上から入力されるように設定

// ボタン用のレイアウトパラメータを設定
LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
buttonParams.setMargins(16, 16, 16, 16); // 任意のマージン設定

// 保存ボタンを作成
Button saveButton = new Button(context);
saveButton.setText("Save");
saveButton.setLayoutParams(buttonParams); // レイアウトパラメータを設定
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 編集した内容をファイルに保存
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
writer.write(editText.getText().toString());
XposedBridge.log("File saved successfully.");
} catch (IOException e) {
XposedBridge.log("Error saving the file: " + e.getMessage());
}
}
});

// 編集画面を表示するためのLayoutに追加
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(editText);
layout.addView(saveButton);

// ダイアログを表示して編集画面を表示する
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("通知を無効にしているグループ");
builder.setView(layout);
builder.setNegativeButton("キャンセル", null);
builder.show();
}

}
Loading