通知機能のバグの修正
ボタン設定のスクロールを可能に ボタンを変更可能に ボタンの大きさを変更可能に
@ -466,8 +466,9 @@ public class EmbedOptions implements IHook {
|
||||
int read_button_verticalMarginDp = 60;
|
||||
float read_checker_horizontalMarginFactor = 0.5f;
|
||||
int read_checker_verticalMarginDp = 60;
|
||||
float keep_unread_size = 60.0f; // 新しい項目の初期値
|
||||
|
||||
float keep_unread_size = 60.0f;
|
||||
float chat_unread_size = 60.0f;
|
||||
float chat_read_check_size = 60.0f;
|
||||
// ファイルの内容を読み込む
|
||||
if (file.exists()) {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
@ -496,6 +497,12 @@ public class EmbedOptions implements IHook {
|
||||
break;
|
||||
case "keep_unread_size":
|
||||
keep_unread_size = Float.parseFloat(parts[1].trim());
|
||||
break;
|
||||
case "Chat_Unread_Size":
|
||||
chat_unread_size = Float.parseFloat(parts[1].trim());
|
||||
case "Chat_read_check_size":
|
||||
chat_unread_size = Float.parseFloat(parts[1].trim());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -511,7 +518,11 @@ public class EmbedOptions implements IHook {
|
||||
"Read_buttom_Chat_verticalMarginDp=60\n" +
|
||||
"Read_checker_horizontalMarginFactor=0.5\n" +
|
||||
"Read_checker_verticalMarginDp=60\n" +
|
||||
"keep_unread_size=60";
|
||||
"keep_unread_size=60\n"+
|
||||
"Chat_Unread_Size=60\n"+
|
||||
"Chat_read_check_size=60\n"
|
||||
;
|
||||
|
||||
writer.write(defaultSettings);
|
||||
} catch (IOException ignored) {
|
||||
return;
|
||||
@ -554,6 +565,26 @@ public class EmbedOptions implements IHook {
|
||||
verticalInput.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
verticalInput.setLayoutParams(layoutParams);
|
||||
|
||||
// "keep_unread_size" 入力フィールド
|
||||
TextView ChatUnreadLabel = new TextView(context);
|
||||
ChatUnreadLabel.setText(moduleContext.getResources().getString(R.string.chat_unread_size));
|
||||
ChatUnreadLabel.setLayoutParams(layoutParams);
|
||||
|
||||
final EditText ChatUnreadSizeInput = new EditText(context);
|
||||
ChatUnreadSizeInput.setText(String.valueOf(chat_unread_size));
|
||||
ChatUnreadSizeInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
ChatUnreadSizeInput.setLayoutParams(layoutParams);
|
||||
|
||||
// Read_buttom_Chat_size の入力フィールド
|
||||
TextView ChatReadCheckSizeLabel = new TextView(context);
|
||||
ChatReadCheckSizeLabel.setText(moduleContext.getResources().getString(R.string.chat_read_check_size));
|
||||
ChatReadCheckSizeLabel.setLayoutParams(layoutParams);
|
||||
|
||||
final EditText ChatReadCheckSizeInput = new EditText(context);
|
||||
ChatReadCheckSizeInput.setText(String.valueOf(chat_read_check_size));
|
||||
ChatReadCheckSizeInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
ChatReadCheckSizeInput.setLayoutParams(layoutParams);
|
||||
|
||||
// Read_buttom_Chat_horizontalMarginFactor の入力フィールド
|
||||
TextView readButtonHorizontalLabel = new TextView(context);
|
||||
readButtonHorizontalLabel.setText(moduleContext.getResources().getString(R.string.Read_buttom_Chat_horizontalMarginFactor));
|
||||
@ -604,6 +635,8 @@ public class EmbedOptions implements IHook {
|
||||
int newKeepUnreadSize = Integer.parseInt(keepUnreadSizeInput.getText().toString().trim());
|
||||
float newKeepUnreadHorizontalMarginFactor = Float.parseFloat(horizontalInput.getText().toString().trim());
|
||||
int newKeepUnreadVerticalMarginDp = Integer.parseInt(verticalInput.getText().toString().trim());
|
||||
int newChatUnreadSize = Integer.parseInt(ChatUnreadSizeInput.getText().toString().trim());
|
||||
int new_chat_read_check_sizeInput = Integer.parseInt(ChatReadCheckSizeInput.getText().toString().trim());
|
||||
float newReadButtonHorizontalMarginFactor = Float.parseFloat(readButtonHorizontalInput.getText().toString().trim());
|
||||
int newReadButtonVerticalMarginDp = Integer.parseInt(readButtonVerticalInput.getText().toString().trim());
|
||||
float newReadCheckerHorizontalMarginFactor = Float.parseFloat(readCheckerHorizontalInput.getText().toString().trim());
|
||||
@ -615,6 +648,8 @@ public class EmbedOptions implements IHook {
|
||||
writer.write("keep_unread_size=" + newKeepUnreadSize + "\n");
|
||||
writer.write("keep_unread_horizontalMarginFactor=" + newKeepUnreadHorizontalMarginFactor + "\n");
|
||||
writer.write("keep_unread_verticalMarginDp=" + newKeepUnreadVerticalMarginDp + "\n");
|
||||
writer.write("Chat_Unread_Size=" + newChatUnreadSize + "\n");
|
||||
writer.write("Chat_read_check_size=" + new_chat_read_check_sizeInput + "\n");
|
||||
writer.write("Read_buttom_Chat_horizontalMarginFactor=" + newReadButtonHorizontalMarginFactor + "\n");
|
||||
writer.write("Read_buttom_Chat_verticalMarginDp=" + newReadButtonVerticalMarginDp + "\n");
|
||||
writer.write("Read_checker_horizontalMarginFactor=" + newReadCheckerHorizontalMarginFactor + "\n");
|
||||
@ -636,18 +671,31 @@ public class EmbedOptions implements IHook {
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.addView(keepUnreadSizeLabel);
|
||||
layout.addView(keepUnreadSizeInput);
|
||||
|
||||
layout.addView(horizontalLabel);
|
||||
layout.addView(horizontalInput);
|
||||
|
||||
layout.addView(verticalLabel);
|
||||
layout.addView(verticalInput);
|
||||
|
||||
layout.addView(ChatUnreadLabel);
|
||||
layout.addView(ChatUnreadSizeInput);
|
||||
|
||||
layout.addView(ChatReadCheckSizeLabel);
|
||||
layout.addView(ChatReadCheckSizeInput);
|
||||
|
||||
layout.addView(readButtonHorizontalLabel);
|
||||
layout.addView(readButtonHorizontalInput);
|
||||
|
||||
layout.addView(readButtonVerticalLabel);
|
||||
layout.addView(readButtonVerticalInput);
|
||||
|
||||
layout.addView(readCheckerHorizontalLabel);
|
||||
layout.addView(readCheckerHorizontalInput);
|
||||
|
||||
layout.addView(readCheckerVerticalLabel);
|
||||
layout.addView(readCheckerVerticalInput);
|
||||
|
||||
layout.addView(saveButton);
|
||||
|
||||
// ScrollView を作成
|
||||
|
@ -175,7 +175,7 @@ public class KeepUnread implements IHook {
|
||||
}
|
||||
|
||||
private void updateSwitchImage(ImageView imageView, boolean isOn, Context moduleContext) {
|
||||
String imageName = isOn ? "switch_on.png" : "switch_off.png"; // 拡張子を追加
|
||||
String imageName = isOn ? "keep_switch_on.png" : "keep_switch_off.png"; // 拡張子を追加
|
||||
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
|
||||
|
||||
// ディレクトリが存在しない場合は作成
|
||||
@ -205,8 +205,8 @@ public class KeepUnread implements IHook {
|
||||
Drawable drawable = Drawable.createFromPath(imageFile.getAbsolutePath());
|
||||
if (drawable != null) {
|
||||
Map<String, String> settings = readSettingsFromExternalFile(moduleContext);
|
||||
float sizeInDp = Float.parseFloat(settings.getOrDefault("keep_unread_size", "60")); // 既定値 38dp
|
||||
int sizeInPx = dpToPx(moduleContext, sizeInDp); // dp を px に変換
|
||||
float sizeInDp = Float.parseFloat(settings.getOrDefault("keep_unread_size", "60"));
|
||||
int sizeInPx = dpToPx(moduleContext, sizeInDp);
|
||||
drawable = scaleDrawable(drawable, sizeInPx, sizeInPx);
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -130,33 +132,47 @@ public class PreventMarkAsRead implements IHook {
|
||||
return settings;
|
||||
}
|
||||
|
||||
private Map<String, String> readSettingsFromFile(File file) {
|
||||
Map<String, String> settings = new HashMap<>();
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] parts = line.split("=", 2);
|
||||
if (parts.length == 2) {
|
||||
settings.put(parts[0].trim(), parts[1].trim());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e("FileError", "Error reading file: " + e.getMessage());
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
private void updateSwitchImage(ImageView imageView, boolean isOn, Context moduleContext) {
|
||||
String imageName = isOn ? "switch_off" : "switch_on";
|
||||
int imageResource = moduleContext.getResources().getIdentifier(imageName, "drawable", "io.github.hiro.lime");
|
||||
String imageName = isOn ? "read_switch_on.png" : "read_switch_off.png"; // 拡張子を追加
|
||||
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LimeBackup");
|
||||
|
||||
if (imageResource != 0) {
|
||||
Drawable drawable = moduleContext.getResources().getDrawable(imageResource, null);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File imageFile = new File(dir, imageName);
|
||||
|
||||
|
||||
if (!imageFile.exists()) {
|
||||
try (InputStream in = moduleContext.getResources().openRawResource(
|
||||
moduleContext.getResources().getIdentifier(imageName.replace(".png", ""), "drawable", "io.github.hiro.lime"));
|
||||
OutputStream out = new FileOutputStream(imageFile)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (imageFile.exists()) {
|
||||
Drawable drawable = Drawable.createFromPath(imageFile.getAbsolutePath());
|
||||
if (drawable != null) {
|
||||
drawable = scaleDrawable(drawable, 86, 86); // サイズを調整
|
||||
Map<String, String> settings = readSettingsFromExternalFile(moduleContext);
|
||||
float sizeInDp = Float.parseFloat(settings.getOrDefault("chat_unread_size", "60"));
|
||||
int sizeInPx = dpToPx(moduleContext, sizeInDp);
|
||||
drawable = scaleDrawable(drawable, sizeInPx, sizeInPx);
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int dpToPx(Context context, float dp) {
|
||||
float density = context.getResources().getDisplayMetrics().density;
|
||||
return Math.round(dp * density);
|
||||
}
|
||||
private Drawable scaleDrawable(Drawable drawable, int width, int height) {
|
||||
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
|
||||
|
@ -12,7 +12,10 @@ import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
@ -21,15 +24,19 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -194,6 +201,7 @@ public class ReadChecker implements IHook {
|
||||
// デフォルト値
|
||||
float readCheckerHorizontalMarginFactor = 0.5f; // デフォルト値
|
||||
int readCheckerVerticalMarginDp = 100; // デフォルト値
|
||||
float readCheckerSizeDp = 60; // デフォルト値
|
||||
|
||||
// ファイルの内容を読み込む
|
||||
if (file.exists()) {
|
||||
@ -206,6 +214,8 @@ public class ReadChecker implements IHook {
|
||||
readCheckerHorizontalMarginFactor = Float.parseFloat(parts[1].trim());
|
||||
} else if (parts[0].trim().equals("Read_checker_verticalMarginDp")) {
|
||||
readCheckerVerticalMarginDp = Integer.parseInt(parts[1].trim());
|
||||
} else if (parts[0].trim().equals("Chat_read_check_size")) {
|
||||
readCheckerSizeDp = Float.parseFloat(parts[1].trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,26 +223,45 @@ public class ReadChecker implements IHook {
|
||||
}
|
||||
}
|
||||
|
||||
// ボタンを作成
|
||||
Button button = new Button(activity);
|
||||
button.setText("R");
|
||||
button.setBackgroundColor(Color.BLACK);
|
||||
button.setTextColor(Color.WHITE);
|
||||
ImageView imageButton = new ImageView(activity);
|
||||
String imageName = "read_checker.png";
|
||||
File imageFile = new File(dir, imageName);
|
||||
|
||||
if (!imageFile.exists()) {
|
||||
try (InputStream in = moduleContext.getResources().openRawResource(
|
||||
moduleContext.getResources().getIdentifier(imageName.replace(".png", ""), "drawable", "io.github.hiro.lime"));
|
||||
OutputStream out = new FileOutputStream(imageFile)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (imageFile.exists()) {
|
||||
Drawable drawable = Drawable.createFromPath(imageFile.getAbsolutePath());
|
||||
if (drawable != null) {
|
||||
int sizeInPx = dpToPx(moduleContext, readCheckerSizeDp);
|
||||
drawable = scaleDrawable(drawable, sizeInPx, sizeInPx);
|
||||
imageButton.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
// ボタンのレイアウトパラメータを設定
|
||||
FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
|
||||
// マージンを設定
|
||||
int horizontalMarginPx = (int) (readCheckerHorizontalMarginFactor * activity.getResources().getDisplayMetrics().widthPixels);
|
||||
int verticalMarginPx = (int) (readCheckerVerticalMarginDp * activity.getResources().getDisplayMetrics().density);
|
||||
frameParams.setMargins(horizontalMarginPx, verticalMarginPx, 0, 0);
|
||||
|
||||
button.setLayoutParams(frameParams);
|
||||
imageButton.setLayoutParams(frameParams);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
imageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (currentGroupId != null) {
|
||||
@ -242,7 +271,18 @@ public class ReadChecker implements IHook {
|
||||
});
|
||||
|
||||
ViewGroup layout = activity.findViewById(android.R.id.content);
|
||||
layout.addView(button);
|
||||
layout.addView(imageButton);
|
||||
}
|
||||
|
||||
private int dpToPx(Context context, float dp) {
|
||||
float density = context.getResources().getDisplayMetrics().density;
|
||||
return Math.round(dp * density);
|
||||
}
|
||||
|
||||
private Drawable scaleDrawable(Drawable drawable, int width, int height) {
|
||||
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
|
||||
return new BitmapDrawable(scaledBitmap);
|
||||
}
|
||||
|
||||
|
||||
@ -394,7 +434,6 @@ public class ReadChecker implements IHook {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void catchNotification(XC_LoadPackage.LoadPackageParam loadPackageParam, SQLiteDatabase db3, SQLiteDatabase db4, Context appContext, Context moduleContext) {
|
||||
try {
|
||||
XposedBridge.hookAllMethods(
|
||||
@ -453,6 +492,7 @@ public class ReadChecker implements IHook {
|
||||
private void fetchDataAndSave(SQLiteDatabase db3, SQLiteDatabase db4, String paramValue, Context context, Context moduleContext) {
|
||||
File dbFile = new File(context.getFilesDir(), "data_log.txt");
|
||||
|
||||
|
||||
try {
|
||||
String serverId = extractServerId(paramValue, context);
|
||||
String SentUser = extractSentUser(paramValue);
|
||||
@ -463,12 +503,6 @@ public class ReadChecker implements IHook {
|
||||
String SendUser = queryDatabase(db3, "SELECT from_mid FROM chat_history WHERE server_id=?", serverId);
|
||||
String groupId = queryDatabase(db3, "SELECT chat_id FROM chat_history WHERE server_id=?", serverId);
|
||||
String groupName = queryDatabase(db3, "SELECT name FROM groups WHERE id=?", groupId);
|
||||
|
||||
// groupNameがnullまたは空の場合、SentUserのプロファイル名を取得
|
||||
if (groupName == null || groupName.isEmpty()) {
|
||||
groupName = queryDatabase(db4, "SELECT profile_name FROM contacts WHERE mid=?", SentUser);
|
||||
}
|
||||
|
||||
String content = queryDatabase(db3, "SELECT content FROM chat_history WHERE server_id=?", serverId);
|
||||
String user_name = queryDatabase(db4, "SELECT profile_name FROM contacts WHERE mid=?", SentUser);
|
||||
String timeEpochStr = queryDatabase(db3, "SELECT created_time FROM chat_history WHERE server_id=?", serverId);
|
||||
@ -492,15 +526,13 @@ public class ReadChecker implements IHook {
|
||||
}
|
||||
}
|
||||
String finalContent = (content != null && !content.isEmpty()) ? content : (!mediaDescription.isEmpty() ? mediaDescription : "No content:" + serverId);
|
||||
|
||||
// groupNameがnullまたは空の場合user_nameを使用
|
||||
String finalGroupName = (groupName != null && !groupName.isEmpty()) ? groupName : user_name;
|
||||
saveData(SendUser, groupId, serverId, SentUser, finalGroupName, finalContent, user_name, timeFormatted, context);
|
||||
saveData(SendUser, groupId, serverId, SentUser, groupName, finalContent, user_name, timeFormatted, context);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void writeToFile(File file, String text) {
|
||||
try (FileWriter writer = new FileWriter(file, true)) {
|
||||
writer.write(text + "\n");
|
||||
@ -605,113 +637,95 @@ public class ReadChecker implements IHook {
|
||||
limeDatabase.execSQL(createGroupTable);
|
||||
//XposedBridge.log("Database initialized and read_message table created.");
|
||||
}
|
||||
private void saveData(String SendUser, String groupId, String serverId, String SentUser, String groupName, String content, String user_name, String createdTime, Context context) {
|
||||
|
||||
|
||||
private void saveData( String SendUser, String groupId, String serverId, String SentUser, String groupName, String content, String user_name, String createdTime, Context context) {
|
||||
if (groupName == null) {
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String checkQuery = "SELECT COUNT(*), user_name FROM read_message WHERE server_id=?";
|
||||
String checkQuery = "SELECT COUNT(*), user_name FROM group_messages WHERE server_id=? AND Sent_User=?";
|
||||
cursor = limeDatabase.rawQuery(checkQuery, new String[]{serverId});
|
||||
if (cursor.moveToFirst()) {
|
||||
int count = cursor.getInt(0);
|
||||
String existingUserName = cursor.getString(1);
|
||||
String currentTime = getCurrentTime();
|
||||
|
||||
|
||||
if (count > 0) {
|
||||
if (!existingUserName.contains(user_name)) {
|
||||
String updatedUserName = existingUserName + (existingUserName.isEmpty() ? "" : "\n") + "-" + user_name + " [" + currentTime + "]";
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("user_name", updatedUserName);
|
||||
limeDatabase.update("read_message", values, "server_id=?", new String[]{serverId});
|
||||
//XposedBridge.log("User name updated for server_id: " + serverId + ", Sent_User: " + SentUser );
|
||||
limeDatabase.update("group_messages", values, "server_id=? AND Sent_User=?", new String[]{serverId});
|
||||
//XposedBridge.log("User name updated for server_id: " + serverId + ", Sent_User: " + SentUser);
|
||||
}
|
||||
} else {
|
||||
insertNewRecord(SendUser, groupId, serverId, SentUser, groupName, content, "-" + user_name + " [" + currentTime + "]", createdTime);
|
||||
}
|
||||
updateOtherRecordsUserNames(groupId, user_name, currentTime);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateOtherRecordsUserNames(String groupId, String user_name, String currentTime) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String selectOtherQuery = "SELECT server_id, user_name FROM group_messages WHERE group_id=? AND user_name NOT LIKE ?";
|
||||
cursor = limeDatabase.rawQuery(selectOtherQuery, new String[]{groupId, "%-" + user_name + "%"});
|
||||
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
String serverId = cursor.getString(cursor.getColumnIndexOrThrow("server_id"));
|
||||
String existingUserName = cursor.getString(cursor.getColumnIndexOrThrow("user_name"));
|
||||
|
||||
|
||||
if (!existingUserName.contains(user_name)) {
|
||||
String updatedUserName = existingUserName + (existingUserName.isEmpty() ? "" : "\n") + "-" + user_name + " [" + currentTime + "]";
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("user_name", updatedUserName);
|
||||
limeDatabase.update("group_messages", values, "group_id=? AND server_id=?", new String[]{groupId, serverId});
|
||||
//XposedBridge.log("Updated user_name for other records in group_id: " + groupId + ", server_id: " + serverId);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("updateOtherRecordsUserNames", "Error updating other records' user names:", e);
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getCurrentTime() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
|
||||
private void insertNewRecord(String sendUser, String groupId, String serverId, String sentUser, String groupName, String content, String userName, String createdTime) {
|
||||
String selectQuery = "SELECT COUNT(*) FROM read_message WHERE group_id=? AND server_id=?";
|
||||
String insertQuery = "INSERT INTO read_message(group_id, server_id, Sent_User, group_name, content, user_name, created_time, Send_User) " +
|
||||
"VALUES(?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
String updateQuery = "UPDATE read_message SET user_name = ? WHERE group_id = ? AND user_name NOT LIKE ?";
|
||||
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
// 新しいレコードを挿入
|
||||
cursor = limeDatabase.rawQuery(selectQuery, new String[]{groupId, serverId});
|
||||
if (cursor.moveToFirst()) {
|
||||
int count = cursor.getInt(0);
|
||||
if (count == 0) {
|
||||
// 新しいレコードを挿入
|
||||
limeDatabase.execSQL(insertQuery, new Object[]{groupId, serverId, sentUser, groupName, content, userName, createdTime, sendUser});
|
||||
XposedBridge.log("Inserted new record for groupId: " + groupId + ", serverId: " + serverId);
|
||||
} else {
|
||||
XposedBridge.log("Record already exists for groupId: " + groupId + ", serverId: " + serverId);
|
||||
}
|
||||
private void insertNewRecord(String SendUser, String groupId, String serverId, String SentUser, String groupName, String content, String user_name, String createdTime) {
|
||||
String insertQuery = "INSERT INTO group_messages(group_id, server_id, Sent_User,Send_User, group_name, content, user_name, created_time)" +
|
||||
" VALUES(?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
|
||||
try {
|
||||
limeDatabase.execSQL(insertQuery, new Object[]{groupId, serverId, SentUser,SendUser, groupName, content, user_name, createdTime});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
limeDatabase.endTransaction();
|
||||
}
|
||||
|
||||
// 同じ groupId の過去のレコードを更新
|
||||
String existingUserNameQuery = "SELECT user_name FROM read_message WHERE group_id=? AND user_name NOT LIKE ?";
|
||||
Cursor existingCursor = limeDatabase.rawQuery(existingUserNameQuery, new String[]{groupId, "%-" + userName + "%"});
|
||||
|
||||
if (existingCursor.moveToFirst()) {
|
||||
do {
|
||||
String existingUserName = existingCursor.getString(existingCursor.getColumnIndexOrThrow("user_name"));
|
||||
// "-" を除いた名前を比較
|
||||
String cleanedUserName = userName.replace("-", "").trim();
|
||||
// 時間部分を正規表現で削除
|
||||
cleanedUserName = cleanedUserName.replaceAll("\\[.*?\\]", "").trim();
|
||||
|
||||
// user_name を改行で分割して、すべての名前をチェック
|
||||
String[] existingNames = existingUserName.split("\n");
|
||||
boolean alreadyContains = false;
|
||||
|
||||
XposedBridge.log("Checking user_name for groupId: " + groupId);
|
||||
XposedBridge.log("Existing user_names: " + existingUserName);
|
||||
XposedBridge.log("Checking for userName: " + userName);
|
||||
|
||||
for (String existingName : existingNames) {
|
||||
// "-" を除いた名前を比較し、時間部分を削除
|
||||
String cleanedExistingName = existingName.replace("-", "").trim();
|
||||
cleanedExistingName = cleanedExistingName.replaceAll("\\[.*?\\]", "").trim();
|
||||
XposedBridge.log("Comparing cleanedExistingName: " + cleanedExistingName + " with cleanedUserName: " + cleanedUserName);
|
||||
if (cleanedExistingName.equals(cleanedUserName)) {
|
||||
alreadyContains = true;
|
||||
XposedBridge.log("user_name already contains: " + cleanedUserName + " for groupId: " + groupId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// すべての改行で名前を確認して、含まれていない場合のみ更新する
|
||||
if (!alreadyContains) {
|
||||
String updatedUserName = existingUserName + (existingUserName.isEmpty() ? "" : "\n") + userName;
|
||||
limeDatabase.execSQL(updateQuery, new Object[]{updatedUserName, groupId, "%-" + userName + "%"});
|
||||
XposedBridge.log("Updated user_name for groupId: " + groupId + " to include: " + userName);
|
||||
} else {
|
||||
XposedBridge.log("Skipping update, user_name already contains: " + userName + " for groupId: " + groupId);
|
||||
}
|
||||
} while (existingCursor.moveToNext());
|
||||
}
|
||||
existingCursor.close();
|
||||
} catch (Exception e) {
|
||||
Log.e("insertNewRecord", "Error inserting or updating record:", e);
|
||||
XposedBridge.log("Error inserting or updating record: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
BIN
app/src/main/res/drawable/keep_switch_off.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/drawable/keep_switch_on.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 438 KiB |
BIN
app/src/main/res/drawable/read_checker.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 403 KiB |
@ -141,6 +141,8 @@
|
||||
<string name="Read_checker_horizontalMarginFactor">既読者確認ボタン(横マージン)</string>
|
||||
<string name="Read_checker_verticalMarginDp">既読者確認ボタン(縦マージン)</string>
|
||||
<string name="Read_buttom_Chat_verticalMarginDp">チャット内の既読ボタン(縦マージン)</string>
|
||||
<string name="chat_unread_size">常に既読をつけないボタンの大きさ</string>
|
||||
<string name="chat_read_check_sizeLabel">既読ボタンのサイズ</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
@ -148,4 +148,5 @@
|
||||
<string name="MySendMessage">(Read function) Do not display messages other than your own</string>
|
||||
|
||||
<string name="keep_unread_size">keep unread button size</string>
|
||||
<string name="chat_read_check_size">既読ボタンのサイズ</string>
|
||||
</resources>
|
||||
|