capacitor-dex-editor 0.0.42 → 0.0.44
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.
|
@@ -12,8 +12,11 @@ import com.getcapacitor.JSObject;
|
|
|
12
12
|
import com.getcapacitor.Plugin;
|
|
13
13
|
import com.getcapacitor.PluginCall;
|
|
14
14
|
import com.getcapacitor.PluginMethod;
|
|
15
|
+
import com.getcapacitor.annotation.ActivityCallback;
|
|
15
16
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
16
17
|
|
|
18
|
+
import androidx.activity.result.ActivityResult;
|
|
19
|
+
|
|
17
20
|
import org.json.JSONObject;
|
|
18
21
|
|
|
19
22
|
/**
|
|
@@ -24,10 +27,8 @@ import org.json.JSONObject;
|
|
|
24
27
|
public class DexEditorPluginPlugin extends Plugin {
|
|
25
28
|
|
|
26
29
|
private static final String TAG = "DexEditorPlugin";
|
|
27
|
-
private static final int REQUEST_SMALI_EDITOR = 1001;
|
|
28
30
|
private final DexManager dexManager = new DexManager();
|
|
29
31
|
private final ApkManager apkManager = new ApkManager();
|
|
30
|
-
private PluginCall pendingEditorCall;
|
|
31
32
|
|
|
32
33
|
@Override
|
|
33
34
|
public void load() {
|
|
@@ -583,8 +584,6 @@ public class DexEditorPluginPlugin extends Plugin {
|
|
|
583
584
|
String className = call.getString("className", "");
|
|
584
585
|
boolean readOnly = call.getBoolean("readOnly", false);
|
|
585
586
|
|
|
586
|
-
pendingEditorCall = call;
|
|
587
|
-
|
|
588
587
|
Intent intent = new Intent(getContext(), SmaliEditorActivity.class);
|
|
589
588
|
intent.putExtra(SmaliEditorActivity.EXTRA_CONTENT, content);
|
|
590
589
|
intent.putExtra(SmaliEditorActivity.EXTRA_TITLE, title);
|
|
@@ -594,13 +593,16 @@ public class DexEditorPluginPlugin extends Plugin {
|
|
|
594
593
|
startActivityForResult(call, intent, "handleEditorResult");
|
|
595
594
|
}
|
|
596
595
|
|
|
597
|
-
@
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
596
|
+
@ActivityCallback
|
|
597
|
+
private void handleEditorResult(PluginCall call, ActivityResult activityResult) {
|
|
598
|
+
if (call == null) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
JSObject result = new JSObject();
|
|
603
|
+
if (activityResult.getResultCode() == Activity.RESULT_OK) {
|
|
604
|
+
Intent data = activityResult.getData();
|
|
605
|
+
if (data != null) {
|
|
604
606
|
result.put("success", true);
|
|
605
607
|
result.put("content", data.getStringExtra(SmaliEditorActivity.RESULT_CONTENT));
|
|
606
608
|
result.put("modified", data.getBooleanExtra(SmaliEditorActivity.RESULT_MODIFIED, false));
|
|
@@ -608,8 +610,10 @@ public class DexEditorPluginPlugin extends Plugin {
|
|
|
608
610
|
result.put("success", false);
|
|
609
611
|
result.put("cancelled", true);
|
|
610
612
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
+
} else {
|
|
614
|
+
result.put("success", false);
|
|
615
|
+
result.put("cancelled", true);
|
|
613
616
|
}
|
|
617
|
+
call.resolve(result);
|
|
614
618
|
}
|
|
615
619
|
}
|
|
@@ -4,6 +4,7 @@ import android.app.Activity;
|
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.graphics.Color;
|
|
6
6
|
import android.graphics.Typeface;
|
|
7
|
+
import android.os.Build;
|
|
7
8
|
import android.os.Bundle;
|
|
8
9
|
import android.view.View;
|
|
9
10
|
import android.view.ViewGroup;
|
|
@@ -15,6 +16,11 @@ import android.widget.LinearLayout;
|
|
|
15
16
|
import android.widget.TextView;
|
|
16
17
|
import android.widget.Toast;
|
|
17
18
|
|
|
19
|
+
import androidx.core.graphics.Insets;
|
|
20
|
+
import androidx.core.view.ViewCompat;
|
|
21
|
+
import androidx.core.view.WindowCompat;
|
|
22
|
+
import androidx.core.view.WindowInsetsCompat;
|
|
23
|
+
|
|
18
24
|
import com.aetherlink.dexeditor.editor.EditView;
|
|
19
25
|
|
|
20
26
|
public class SmaliEditorActivity extends Activity {
|
|
@@ -29,17 +35,28 @@ public class SmaliEditorActivity extends Activity {
|
|
|
29
35
|
private EditView editView;
|
|
30
36
|
private String originalContent;
|
|
31
37
|
private boolean readOnly = false;
|
|
38
|
+
private LinearLayout root;
|
|
39
|
+
private View topSpacer;
|
|
40
|
+
private View bottomSpacer;
|
|
32
41
|
|
|
33
42
|
@Override
|
|
34
43
|
protected void onCreate(Bundle savedInstanceState) {
|
|
35
44
|
super.onCreate(savedInstanceState);
|
|
36
45
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
46
|
+
// Edge-to-Edge 模式
|
|
47
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
48
|
+
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
|
49
|
+
getWindow().setNavigationBarColor(Color.TRANSPARENT);
|
|
50
|
+
}
|
|
51
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
52
|
+
getWindow().setDecorFitsSystemWindows(false);
|
|
53
|
+
} else {
|
|
54
|
+
getWindow().getDecorView().setSystemUiVisibility(
|
|
55
|
+
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
56
|
+
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
57
|
+
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
58
|
+
);
|
|
59
|
+
}
|
|
43
60
|
|
|
44
61
|
// 获取参数
|
|
45
62
|
Intent intent = getIntent();
|
|
@@ -52,10 +69,16 @@ public class SmaliEditorActivity extends Activity {
|
|
|
52
69
|
if (title == null) title = "Smali Editor";
|
|
53
70
|
|
|
54
71
|
// 创建布局
|
|
55
|
-
|
|
72
|
+
root = new LinearLayout(this);
|
|
56
73
|
root.setOrientation(LinearLayout.VERTICAL);
|
|
57
74
|
root.setBackgroundColor(Color.parseColor("#1E1E1E"));
|
|
58
75
|
|
|
76
|
+
// 顶部安全区域占位
|
|
77
|
+
topSpacer = new View(this);
|
|
78
|
+
topSpacer.setBackgroundColor(Color.parseColor("#2D2D2D"));
|
|
79
|
+
root.addView(topSpacer, new LinearLayout.LayoutParams(
|
|
80
|
+
ViewGroup.LayoutParams.MATCH_PARENT, 0));
|
|
81
|
+
|
|
59
82
|
// 工具栏
|
|
60
83
|
LinearLayout toolbar = createToolbar(title, className);
|
|
61
84
|
root.addView(toolbar);
|
|
@@ -63,17 +86,39 @@ public class SmaliEditorActivity extends Activity {
|
|
|
63
86
|
// 编辑器
|
|
64
87
|
editView = new EditView(this);
|
|
65
88
|
editView.setLayoutParams(new LinearLayout.LayoutParams(
|
|
66
|
-
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
67
|
-
ViewGroup.LayoutParams.MATCH_PARENT
|
|
89
|
+
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1
|
|
68
90
|
));
|
|
69
91
|
editView.setText(originalContent);
|
|
70
92
|
editView.setSyntaxLanguageFileName("smali.json");
|
|
71
93
|
editView.setEditedMode(!readOnly);
|
|
72
94
|
editView.setTypeface(Typeface.MONOSPACE);
|
|
73
95
|
editView.setTextSize(14);
|
|
74
|
-
|
|
75
96
|
root.addView(editView);
|
|
97
|
+
|
|
98
|
+
// 底部安全区域占位
|
|
99
|
+
bottomSpacer = new View(this);
|
|
100
|
+
bottomSpacer.setBackgroundColor(Color.parseColor("#1E1E1E"));
|
|
101
|
+
root.addView(bottomSpacer, new LinearLayout.LayoutParams(
|
|
102
|
+
ViewGroup.LayoutParams.MATCH_PARENT, 0));
|
|
103
|
+
|
|
76
104
|
setContentView(root);
|
|
105
|
+
|
|
106
|
+
// 处理安全区域
|
|
107
|
+
ViewCompat.setOnApplyWindowInsetsListener(root, (v, windowInsets) -> {
|
|
108
|
+
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
|
109
|
+
|
|
110
|
+
// 更新顶部占位高度
|
|
111
|
+
ViewGroup.LayoutParams topParams = topSpacer.getLayoutParams();
|
|
112
|
+
topParams.height = insets.top;
|
|
113
|
+
topSpacer.setLayoutParams(topParams);
|
|
114
|
+
|
|
115
|
+
// 更新底部占位高度
|
|
116
|
+
ViewGroup.LayoutParams bottomParams = bottomSpacer.getLayoutParams();
|
|
117
|
+
bottomParams.height = insets.bottom;
|
|
118
|
+
bottomSpacer.setLayoutParams(bottomParams);
|
|
119
|
+
|
|
120
|
+
return WindowInsetsCompat.CONSUMED;
|
|
121
|
+
});
|
|
77
122
|
}
|
|
78
123
|
|
|
79
124
|
private LinearLayout createToolbar(String title, String className) {
|