From b43bf4af8998767c8f9d0187494b0a4accebd51c Mon Sep 17 00:00:00 2001 From: areteruhiro <108941410+areteruhiro@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:47:40 +0900 Subject: [PATCH] Update EmbedOptions.java --- .../lime/hooks/EmbedOptions.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/EmbedOptions.java b/app/src/main/java/io/github/chipppppppppp/lime/hooks/EmbedOptions.java index 5f6370dd..6dadc872 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/hooks/EmbedOptions.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/EmbedOptions.java @@ -146,6 +146,20 @@ 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(pasteButton); @@ -160,6 +174,8 @@ public void onClick(View v) { builder.setView(scrollView); + + builder.setPositiveButton(R.string.positive_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -394,4 +410,64 @@ 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()); + } + } + + 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()); + } + } + }); + + + 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(); + } + }