diff --git a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java index 6fe870e2..418427de 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java @@ -25,7 +25,8 @@ public Option(String name, int id, boolean checked) { public Option openInBrowser = new Option("open_in_browser", R.string.switch_open_in_browser, false); public Option preventMarkAsRead = new Option("prevent_mark_as_read", R.string.switch_prevent_mark_as_read, false); public Option preventUnsendMessage = new Option("prevent_unsend_message", R.string.switch_prevent_unsend_message, false); - public static final int size = 12; + public Option deleteKeepUnread = new Option("delete_keep_unread", R.string.switch_delete_keep_unread, false); + public static final int size = 13; public Option getByIndex(int idx) { switch (idx) { @@ -53,6 +54,8 @@ public Option getByIndex(int idx) { return preventMarkAsRead; case 11: return preventUnsendMessage; + case 12: + return deleteKeepUnread; default: throw new IllegalArgumentException("Invalid index: " + idx); } diff --git a/app/src/main/java/io/github/chipppppppppp/lime/Main.java b/app/src/main/java/io/github/chipppppppppp/lime/Main.java index 4a78cf27..f659d5b9 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/Main.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/Main.java @@ -417,40 +417,43 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); - hookTarget = lparam.classLoader.loadClass("jp.naver.line.android.common.view.listview.PopupListView"); - XposedBridge.hookAllConstructors(hookTarget, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - ViewGroup viewGroup = (ViewGroup) param.thisObject; - Context context = viewGroup.getContext(); + if (!limeOptions.deleteKeepUnread.checked) { + hookTarget = lparam.classLoader.loadClass("jp.naver.line.android.common.view.listview.PopupListView"); + XposedBridge.hookAllConstructors(hookTarget, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + ViewGroup viewGroup = (ViewGroup) param.thisObject; + Context context = viewGroup.getContext(); - RelativeLayout layout = new RelativeLayout(context); - RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( - RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); - layout.setLayoutParams(layoutParams); + RelativeLayout layout = new RelativeLayout(context); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); + layout.setLayoutParams(layoutParams); - Switch switchView = new Switch(context); - RelativeLayout.LayoutParams switchParams = new RelativeLayout.LayoutParams( - RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - switchParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); + Switch switchView = new Switch(context); + RelativeLayout.LayoutParams switchParams = new RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + switchParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); - switchView.setChecked(false); - switchView.setOnCheckedChangeListener((buttonView, isChecked) -> { - keepUnread = isChecked; - }); + switchView.setChecked(false); + switchView.setOnCheckedChangeListener((buttonView, isChecked) -> { + keepUnread = isChecked; + }); - layout.addView(switchView, switchParams); + layout.addView(switchView, switchParams); - ((ListView) viewGroup.getChildAt(0)).addFooterView(layout); - } - }); - hookTarget = lparam.classLoader.loadClass("bd1.d$d"); - XposedBridge.hookAllMethods(hookTarget, "run", new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - if (keepUnread) param.setResult(null); - } - }); + ((ListView) viewGroup.getChildAt(0)).addFooterView(layout); + } + }); + + hookTarget = lparam.classLoader.loadClass("bd1.d$d"); + XposedBridge.hookAllMethods(hookTarget, "run", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (keepUnread) param.setResult(null); + } + }); + } } @Override diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index f0aa6976..00000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index c520a3e2..503db518 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -20,6 +20,7 @@ 通知から \"通知をオフ\" アクションを削除 WebView を既定のブラウザにリダイレクト ブラウザアプリで開く - 既読をつけない + 常に既読をつけない 送信取り消しを拒否 + トーク画面右上のメニューにある「未読のまま閲覧」スイッチを削除 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3b0c519f..af23ebc5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -20,6 +20,7 @@ Delete \"Mute chat\" action from notifications Redirect WebView to the default browser Open in the browser app - Prevent marking as read + Always prevent marking as read Prevent messages from unsending + Delete the \"Keep unread\" switch from the menu in the top right corner of the chat tab \ No newline at end of file