capacitor-dex-editor 0.0.43 → 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.
@@ -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
- requestWindowFeature(Window.FEATURE_NO_TITLE);
39
- getWindow().setFlags(
40
- WindowManager.LayoutParams.FLAG_FULLSCREEN,
41
- WindowManager.LayoutParams.FLAG_FULLSCREEN
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
- LinearLayout root = new LinearLayout(this);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-dex-editor",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
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",