Skip to content

Commit

Permalink
個人チャットで、既読ボタンを表示しないように(保存しないように)
Browse files Browse the repository at this point in the history
  • Loading branch information
areteruhiro committed Oct 31, 2024
1 parent 43e6724 commit 59ab6af
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions app/src/main/java/io/github/hiro/lime/hooks/ReadChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,19 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(chatHistoryActivityClass, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {




if (shouldHookOnCreate && currentGroupId != null) {
Activity activity = (Activity) param.thisObject;
addButton(activity);
// isNoGroupメソッドを使用して、グループが存在しない場合はボタンを追加しない
if (!isNoGroup(currentGroupId)) {
Activity activity = (Activity) param.thisObject;
addButton(activity);
}
}
}
});




}




private boolean isGroupExists(String groupId) {
if (limeDatabase == null) {
XposedBridge.log("Database is not initialized.");
Expand All @@ -141,6 +135,28 @@ private boolean isGroupExists(String groupId) {
return exists;
}

private boolean isNoGroup(String groupId) {
if (limeDatabase == null) {
XposedBridge.log("Database is not initialized.");
return true; // データベースが初期化されていない場合はグループがないと見なす
}

// グループ名を取得するためのクエリ
String query = "SELECT group_name FROM group_messages WHERE group_id = ?";
Cursor cursor = limeDatabase.rawQuery(query, new String[]{groupId});

// グループ名が存在するかどうかのチェック
boolean noGroup = true; // 初期値としてグループがないと見なす

if (cursor.moveToFirst()) {
String groupName = cursor.getString(cursor.getColumnIndex("group_name"));
// グループ名が存在する場合はnoGroupをfalseに設定
noGroup = groupName == null || groupName.isEmpty();
}

cursor.close();
return noGroup;
}

// ボタンを追加するメソッド
private void addButton(Activity activity) {
Expand Down

0 comments on commit 59ab6af

Please sign in to comment.