capacitor-dex-editor 0.0.46 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,18 @@
1
1
  package com.aetherlink.dexeditor;
2
2
 
3
+ import android.app.AlertDialog;
3
4
  import android.content.Intent;
4
5
  import android.graphics.Color;
5
6
  import android.graphics.Typeface;
6
7
  import android.os.Build;
7
8
  import android.os.Bundle;
9
+ import android.text.InputType;
8
10
  import android.view.View;
9
11
  import android.view.ViewGroup;
10
12
  import android.view.Window;
11
13
  import android.view.WindowManager;
14
+ import android.widget.CheckBox;
15
+ import android.widget.EditText;
12
16
  import android.widget.FrameLayout;
13
17
  import android.widget.ImageButton;
14
18
  import android.widget.LinearLayout;
@@ -159,12 +163,15 @@ public class SmaliEditorActivity extends AppCompatActivity {
159
163
  });
160
164
  toolbar.addView(redoBtn);
161
165
 
162
- // 保存按钮
163
- if (!readOnly) {
164
- ImageButton saveBtn = createIconButton("✓");
165
- saveBtn.setOnClickListener(v -> saveAndFinish());
166
- toolbar.addView(saveBtn);
167
- }
166
+ // 查找按钮
167
+ ImageButton searchBtn = createIconButton("🔍");
168
+ searchBtn.setOnClickListener(v -> showSearchDialog());
169
+ toolbar.addView(searchBtn);
170
+
171
+ // 跳转行号按钮
172
+ ImageButton gotoBtn = createIconButton("⤵");
173
+ gotoBtn.setOnClickListener(v -> showGotoLineDialog());
174
+ toolbar.addView(gotoBtn);
168
175
 
169
176
  return toolbar;
170
177
  }
@@ -206,6 +213,118 @@ public class SmaliEditorActivity extends AppCompatActivity {
206
213
  return textBtn;
207
214
  }
208
215
 
216
+ private String lastSearchText = "";
217
+ private String lastReplaceText = "";
218
+
219
+ private void showSearchDialog() {
220
+ LinearLayout layout = new LinearLayout(this);
221
+ layout.setOrientation(LinearLayout.VERTICAL);
222
+ layout.setPadding(48, 32, 48, 16);
223
+
224
+ // 查找输入框
225
+ EditText searchInput = new EditText(this);
226
+ searchInput.setHint("查找内容");
227
+ searchInput.setText(lastSearchText);
228
+ searchInput.setTextColor(Color.WHITE);
229
+ searchInput.setHintTextColor(Color.GRAY);
230
+ layout.addView(searchInput);
231
+
232
+ // 替换输入框
233
+ EditText replaceInput = new EditText(this);
234
+ replaceInput.setHint("替换为 (可选)");
235
+ replaceInput.setText(lastReplaceText);
236
+ replaceInput.setTextColor(Color.WHITE);
237
+ replaceInput.setHintTextColor(Color.GRAY);
238
+ layout.addView(replaceInput);
239
+
240
+ // 正则表达式选项
241
+ CheckBox regexCheckbox = new CheckBox(this);
242
+ regexCheckbox.setText("使用正则表达式");
243
+ regexCheckbox.setTextColor(Color.WHITE);
244
+ layout.addView(regexCheckbox);
245
+
246
+ AlertDialog dialog = new AlertDialog.Builder(this)
247
+ .setTitle("查找与替换")
248
+ .setView(layout)
249
+ .setPositiveButton("查找下一个", null)
250
+ .setNegativeButton("替换", null)
251
+ .setNeutralButton("全部替换", null)
252
+ .create();
253
+
254
+ dialog.setOnShowListener(d -> {
255
+ dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
256
+ String text = searchInput.getText().toString();
257
+ if (!text.isEmpty()) {
258
+ lastSearchText = text;
259
+ if (regexCheckbox.isChecked()) {
260
+ editView.find(text);
261
+ } else {
262
+ editView.find(java.util.regex.Pattern.quote(text));
263
+ }
264
+ }
265
+ });
266
+
267
+ dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> {
268
+ String text = searchInput.getText().toString();
269
+ String replace = replaceInput.getText().toString();
270
+ if (!text.isEmpty()) {
271
+ lastSearchText = text;
272
+ lastReplaceText = replace;
273
+ if (regexCheckbox.isChecked()) {
274
+ editView.find(text);
275
+ } else {
276
+ editView.find(java.util.regex.Pattern.quote(text));
277
+ }
278
+ editView.replaceFirst(replace);
279
+ }
280
+ });
281
+
282
+ dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(v -> {
283
+ String text = searchInput.getText().toString();
284
+ String replace = replaceInput.getText().toString();
285
+ if (!text.isEmpty()) {
286
+ lastSearchText = text;
287
+ lastReplaceText = replace;
288
+ if (regexCheckbox.isChecked()) {
289
+ editView.find(text);
290
+ } else {
291
+ editView.find(java.util.regex.Pattern.quote(text));
292
+ }
293
+ editView.replaceAll(replace);
294
+ Toast.makeText(this, "已替换所有匹配项", Toast.LENGTH_SHORT).show();
295
+ }
296
+ });
297
+ });
298
+
299
+ dialog.show();
300
+ }
301
+
302
+ private void showGotoLineDialog() {
303
+ EditText input = new EditText(this);
304
+ input.setInputType(InputType.TYPE_CLASS_NUMBER);
305
+ input.setHint("输入行号");
306
+ input.setTextColor(Color.WHITE);
307
+ input.setHintTextColor(Color.GRAY);
308
+ input.setPadding(48, 32, 48, 32);
309
+
310
+ new AlertDialog.Builder(this)
311
+ .setTitle("跳转到行")
312
+ .setView(input)
313
+ .setPositiveButton("跳转", (d, w) -> {
314
+ String text = input.getText().toString();
315
+ if (!text.isEmpty()) {
316
+ try {
317
+ int line = Integer.parseInt(text);
318
+ editView.gotoLine(line);
319
+ } catch (NumberFormatException e) {
320
+ Toast.makeText(this, "请输入有效的行号", Toast.LENGTH_SHORT).show();
321
+ }
322
+ }
323
+ })
324
+ .setNegativeButton("取消", null)
325
+ .show();
326
+ }
327
+
209
328
  private void handleBack() {
210
329
  String currentContent = editView.getBuffer().toString();
211
330
  if (!currentContent.equals(originalContent)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-dex-editor",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "Capacitor-plugin-for-editing-DEX-files-in-APK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",