Skip to content

Commit

Permalink
Add a switch to delete the switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipppppppppp committed Feb 17, 2024
1 parent 6666b7a commit 1dd6562
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
61 changes: 32 additions & 29 deletions app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
98 changes: 0 additions & 98 deletions app/src/main/res/layout/activity_main.xml

This file was deleted.

3 changes: 2 additions & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<string name="switch_delete_reply_mute">通知から \"通知をオフ\" アクションを削除</string>
<string name="switch_redirect_webview">WebView を既定のブラウザにリダイレクト</string>
<string name="switch_open_in_browser">ブラウザアプリで開く</string>
<string name="switch_prevent_mark_as_read">既読をつけない</string>
<string name="switch_prevent_mark_as_read">常に既読をつけない</string>
<string name="switch_prevent_unsend_message">送信取り消しを拒否</string>
<string name="switch_delete_keep_unread">トーク画面右上のメニューにある「未読のまま閲覧」スイッチを削除</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<string name="switch_delete_reply_mute">Delete \"Mute chat\" action from notifications</string>
<string name="switch_redirect_webview">Redirect WebView to the default browser</string>
<string name="switch_open_in_browser">Open in the browser app</string>
<string name="switch_prevent_mark_as_read">Prevent marking as read</string>
<string name="switch_prevent_mark_as_read">Always prevent marking as read</string>
<string name="switch_prevent_unsend_message">Prevent messages from unsending</string>
<string name="switch_delete_keep_unread">Delete the \"Keep unread\" switch from the menu in the top right corner of the chat tab</string>
</resources>

0 comments on commit 1dd6562

Please sign in to comment.