capacitor-dex-editor 0.0.37 → 0.0.39
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.
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/assets/availableSyntax.json +54 -0
- package/android/src/main/assets/c.json +42 -0
- package/android/src/main/assets/colors.json +21 -0
- package/android/src/main/assets/cpp.json +79 -0
- package/android/src/main/assets/dart.json +108 -0
- package/android/src/main/assets/java.json +46 -0
- package/android/src/main/assets/js.json +54 -0
- package/android/src/main/assets/json.json +33 -0
- package/android/src/main/assets/kotlin.json +53 -0
- package/android/src/main/assets/lua.json +54 -0
- package/android/src/main/assets/php.json +69 -0
- package/android/src/main/assets/python.json +87 -0
- package/android/src/main/assets/rust.json +139 -0
- package/android/src/main/assets/smali.json +131 -0
- package/android/src/main/assets/xml.json +96 -0
- package/android/src/main/java/com/aetherlink/dexeditor/DexEditorPluginPlugin.java +67 -0
- package/android/src/main/java/com/aetherlink/dexeditor/DexManager.java +165 -0
- package/android/src/main/java/com/aetherlink/dexeditor/SmaliEditorActivity.java +205 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/EditView.java +4022 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/WordWrapLayout.java +275 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/buffer/BufferCache.java +113 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/buffer/GapBuffer.java +685 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/component/ClipboardPanel.java +1380 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/component/Magnifier.java +363 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/highlight/Candidate.java +52 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/highlight/CommentDef.java +47 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/highlight/LineResult.java +49 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/highlight/MHSyntaxHighlightEngine.java +841 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/highlight/Rule.java +53 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/highlight/Token.java +48 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/listener/OnTextChangedListener.java +6 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/utils/Pair.java +80 -0
- package/android/src/main/java/com/aetherlink/dexeditor/editor/utils/ScreenUtils.java +63 -0
- package/android/src/main/res/drawable/abc_text_cursor_material.xml +9 -0
- package/android/src/main/res/drawable/abc_text_select_handle_left_mtrl.png +0 -0
- package/android/src/main/res/drawable/abc_text_select_handle_middle_mtrl.png +0 -0
- package/android/src/main/res/drawable/abc_text_select_handle_right_mtrl.png +0 -0
- package/android/src/main/res/drawable/ic_arrow_back.xml +12 -0
- package/android/src/main/res/drawable/ic_copy.xml +11 -0
- package/android/src/main/res/drawable/ic_cut.xml +10 -0
- package/android/src/main/res/drawable/ic_delete.xml +12 -0
- package/android/src/main/res/drawable/ic_edit_white_24dp.xml +10 -0
- package/android/src/main/res/drawable/ic_goto.xml +10 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +186 -0
- package/android/src/main/res/drawable/ic_look_white_24dp.xml +11 -0
- package/android/src/main/res/drawable/ic_more.xml +10 -0
- package/android/src/main/res/drawable/ic_open_link.xml +11 -0
- package/android/src/main/res/drawable/ic_paste.xml +11 -0
- package/android/src/main/res/drawable/ic_redo_white_24dp.xml +10 -0
- package/android/src/main/res/drawable/ic_select.xml +11 -0
- package/android/src/main/res/drawable/ic_select_all.xml +10 -0
- package/android/src/main/res/drawable/ic_share.xml +11 -0
- package/android/src/main/res/drawable/ic_toggle_comment.xml +12 -0
- package/android/src/main/res/drawable/ic_translate.xml +10 -0
- package/android/src/main/res/drawable/ic_undo_white_24dp.xml +11 -0
- package/android/src/main/res/drawable/magnifier_bg.xml +5 -0
- package/android/src/main/res/drawable/popup_background.xml +8 -0
- package/android/src/main/res/drawable/ripple_effect.xml +9 -0
- package/android/src/main/res/drawable/selection_menu_background.xml +5 -0
- package/android/src/main/res/layout/custom_selection_menu.xml +44 -0
- package/android/src/main/res/layout/expand_button.xml +23 -0
- package/android/src/main/res/layout/item_autocomplete.xml +25 -0
- package/android/src/main/res/layout/magnifier_popup.xml +17 -0
- package/android/src/main/res/layout/menu_item.xml +30 -0
- package/android/src/main/res/layout/text_selection_menu.xml +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MH-TextEditor - An Advanced and optimized TextEditor for android
|
|
3
|
+
* Copyright 2025, developer-krushna
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are
|
|
7
|
+
* met:
|
|
8
|
+
*
|
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* * Redistributions in binary form must reproduce the above
|
|
12
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
* in the documentation and/or other materials provided with the
|
|
14
|
+
* distribution.
|
|
15
|
+
* * Neither the name of developer-krushna nor the names of its
|
|
16
|
+
* contributors may be used to endorse or promote products derived from
|
|
17
|
+
* this software without specific prior written permission.
|
|
18
|
+
*
|
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
* Please contact Krushna by email modder-hub@zohomail.in if you need
|
|
33
|
+
* additional information or have any questions
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
package com.aetherlink.dexeditor.editor.component;
|
|
37
|
+
|
|
38
|
+
import android.annotation.SuppressLint;
|
|
39
|
+
import android.graphics.Bitmap;
|
|
40
|
+
import android.graphics.Canvas;
|
|
41
|
+
import android.graphics.Paint;
|
|
42
|
+
import android.graphics.PorterDuff;
|
|
43
|
+
import android.graphics.PorterDuffXfermode;
|
|
44
|
+
import android.util.DisplayMetrics;
|
|
45
|
+
import android.util.TypedValue;
|
|
46
|
+
import android.view.Gravity;
|
|
47
|
+
import android.view.LayoutInflater;
|
|
48
|
+
import android.view.View;
|
|
49
|
+
import android.widget.ImageView;
|
|
50
|
+
import android.widget.PopupWindow;
|
|
51
|
+
import com.aetherlink.dexeditor.editor.EditView;
|
|
52
|
+
import com.aetherlink.dexeditor.R;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Magnifier specially designed for EditView Provides a popup magnifying glass effect for text
|
|
56
|
+
* editing Originally replicated from Sora Code Editor for Android
|
|
57
|
+
*/
|
|
58
|
+
public class Magnifier {
|
|
59
|
+
|
|
60
|
+
private final EditView editor;
|
|
61
|
+
private final PopupWindow popup;
|
|
62
|
+
private final ImageView image;
|
|
63
|
+
private final Paint paint;
|
|
64
|
+
private final float maxTextSize;
|
|
65
|
+
|
|
66
|
+
private int viewX, viewY; // View-relative coordinates for positioning
|
|
67
|
+
private int contentX, contentY; // Content-relative coordinates for capture
|
|
68
|
+
private boolean enabled = true;
|
|
69
|
+
private View parentView;
|
|
70
|
+
private float scaleFactor;
|
|
71
|
+
|
|
72
|
+
public Magnifier(EditView editor) {
|
|
73
|
+
this.editor = editor;
|
|
74
|
+
this.parentView = editor;
|
|
75
|
+
|
|
76
|
+
// Initialize popup window
|
|
77
|
+
popup = new PopupWindow();
|
|
78
|
+
popup.setElevation(dpToPx(4));
|
|
79
|
+
|
|
80
|
+
@SuppressLint("InflateParams")
|
|
81
|
+
View view = LayoutInflater.from(editor.getContext()).inflate(R.layout.magnifier_popup, null);
|
|
82
|
+
image = view.findViewById(R.id.magnifier_image_view);
|
|
83
|
+
|
|
84
|
+
// Set popup dimensions
|
|
85
|
+
popup.setHeight((int) dpToPx(60)); // Slightly reduced height for compactness
|
|
86
|
+
popup.setWidth((int) dpToPx(80)); // Reduced initial width
|
|
87
|
+
popup.setContentView(view);
|
|
88
|
+
|
|
89
|
+
// Initialize text size limits and scaling
|
|
90
|
+
maxTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 28,
|
|
91
|
+
editor.getResources().getDisplayMetrics());
|
|
92
|
+
scaleFactor = 1.25f;
|
|
93
|
+
paint = new Paint();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ==================== PUBLIC METHODS ====================
|
|
97
|
+
|
|
98
|
+
/** Show magnifier at specified view coordinates */
|
|
99
|
+
public void show(int viewX, int viewY) {
|
|
100
|
+
if (!enabled) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (Math.abs(viewX - this.viewX) < 2 && Math.abs(viewY - this.viewY) < 2) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (getEditorTextSize() > maxTextSize) {
|
|
108
|
+
if (isShowing()) {
|
|
109
|
+
dismiss();
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
popup.setWidth(Math.min(editor.getWidth() * 2 / 5, (int) dpToPx(150))); // Reduced dynamic
|
|
115
|
+
// width (2/5 and
|
|
116
|
+
// 150dp max)
|
|
117
|
+
this.viewX = viewX;
|
|
118
|
+
this.viewY = viewY;
|
|
119
|
+
|
|
120
|
+
int scrollX = editor.getScrollX();
|
|
121
|
+
int scrollY = editor.getScrollY();
|
|
122
|
+
this.contentX = viewX + scrollX;
|
|
123
|
+
this.contentY = viewY + scrollY;
|
|
124
|
+
|
|
125
|
+
// Get screen coordinates
|
|
126
|
+
int[] pos = new int[2];
|
|
127
|
+
editor.getLocationOnScreen(pos);
|
|
128
|
+
|
|
129
|
+
// Calculate popup position in screen coordinates using view-relative
|
|
130
|
+
int screenX = pos[0] + viewX;
|
|
131
|
+
int screenY = pos[1] + viewY;
|
|
132
|
+
|
|
133
|
+
// Position magnifier above the cursor with proper offset
|
|
134
|
+
int popupLeft = screenX - popup.getWidth() / 2;
|
|
135
|
+
int popupTop = screenY - popup.getHeight() - getEditorLineHeight();
|
|
136
|
+
|
|
137
|
+
// Ensure popup stays within screen bounds
|
|
138
|
+
DisplayMetrics metrics = editor.getResources().getDisplayMetrics();
|
|
139
|
+
int screenWidth = metrics.widthPixels;
|
|
140
|
+
int screenHeight = metrics.heightPixels;
|
|
141
|
+
|
|
142
|
+
popupLeft = Math.max(0, Math.min(popupLeft, screenWidth - popup.getWidth()));
|
|
143
|
+
popupTop = Math.max(0, Math.min(popupTop, screenHeight - popup.getHeight()));
|
|
144
|
+
|
|
145
|
+
// If there's not enough space above, put it below
|
|
146
|
+
if (popupTop < 0) {
|
|
147
|
+
popupTop = screenY + getEditorLineHeight();
|
|
148
|
+
popupTop = Math.min(popupTop, screenHeight - popup.getHeight());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (popup.isShowing()) {
|
|
152
|
+
popup.update(popupLeft, popupTop, popup.getWidth(), popup.getHeight());
|
|
153
|
+
} else {
|
|
154
|
+
popup.showAtLocation(parentView, Gravity.NO_GRAVITY, popupLeft, popupTop);
|
|
155
|
+
}
|
|
156
|
+
updateDisplay();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Check if magnifier is currently showing */
|
|
160
|
+
public boolean isShowing() {
|
|
161
|
+
return popup.isShowing();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Dismiss the magnifier */
|
|
165
|
+
public void dismiss() {
|
|
166
|
+
popup.dismiss();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Update the magnifier display */
|
|
170
|
+
public void updateDisplay() {
|
|
171
|
+
if (!isShowing()) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
updateDisplayWithinEditor();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Enable or disable the magnifier */
|
|
178
|
+
public void setEnabled(boolean enabled) {
|
|
179
|
+
this.enabled = enabled;
|
|
180
|
+
if (!enabled) {
|
|
181
|
+
dismiss();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Check if magnifier is enabled */
|
|
186
|
+
public boolean isEnabled() {
|
|
187
|
+
return enabled;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ==================== PRIVATE METHODS ====================
|
|
191
|
+
|
|
192
|
+
/** Convert dp to pixels */
|
|
193
|
+
private float dpToPx(float dp) {
|
|
194
|
+
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
|
|
195
|
+
editor.getResources().getDisplayMetrics());
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Get current editor text size */
|
|
199
|
+
private float getEditorTextSize() {
|
|
200
|
+
return editor.getTextSize();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Get current editor line height */
|
|
204
|
+
private int getEditorLineHeight() {
|
|
205
|
+
return editor.getLineHeight();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Update the magnifier content by capturing and scaling editor content */
|
|
209
|
+
private void updateDisplayWithinEditor() {
|
|
210
|
+
if (popup.getWidth() <= 0 || popup.getHeight() <= 0) {
|
|
211
|
+
dismiss();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
int totalContentHeight = editor.getLineCount() * getEditorLineHeight();
|
|
216
|
+
int totalContentWidth = editor.getLeftSpace() + editor.getLineWidth() + editor.getSpaceWidth() * 4; // Full content width based on max line
|
|
217
|
+
int scrollX = editor.getScrollX();
|
|
218
|
+
int scrollY = editor.getScrollY();
|
|
219
|
+
|
|
220
|
+
// Recompute content in case of scroll during magnifier (rare)
|
|
221
|
+
int contentX = viewX + scrollX;
|
|
222
|
+
int contentY = viewY + scrollY;
|
|
223
|
+
|
|
224
|
+
Bitmap dest = Bitmap.createBitmap(popup.getWidth(), popup.getHeight(), Bitmap.Config.ARGB_8888);
|
|
225
|
+
int requiredWidth = (int) (popup.getWidth() / scaleFactor);
|
|
226
|
+
int requiredHeight = (int) (popup.getHeight() / scaleFactor);
|
|
227
|
+
|
|
228
|
+
// Calculate capture area in content coordinates
|
|
229
|
+
int left = Math.max(contentX - requiredWidth / 2, 0);
|
|
230
|
+
int top = Math.max(contentY - requiredHeight / 2, 0);
|
|
231
|
+
int right = Math.min(left + requiredWidth, totalContentWidth);
|
|
232
|
+
int bottom = Math.min(top + requiredHeight, totalContentHeight);
|
|
233
|
+
|
|
234
|
+
// Adjust for edges
|
|
235
|
+
if (right - left < requiredWidth) {
|
|
236
|
+
left = Math.max(0, right - requiredWidth);
|
|
237
|
+
}
|
|
238
|
+
if (bottom - top < requiredHeight) {
|
|
239
|
+
top = Math.max(0, bottom - requiredHeight);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Special handling for bottom of document
|
|
243
|
+
if (contentY > totalContentHeight - getEditorLineHeight() * 3) {
|
|
244
|
+
// Near bottom of content - show area above cursor
|
|
245
|
+
top = Math.max(0, contentY - requiredHeight);
|
|
246
|
+
bottom = Math.min(top + requiredHeight, totalContentHeight);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (right - left <= 0 || bottom - top <= 0) {
|
|
250
|
+
dismiss();
|
|
251
|
+
dest.recycle();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
int actualWidth = right - left;
|
|
256
|
+
int actualHeight = bottom - top;
|
|
257
|
+
|
|
258
|
+
Bitmap clip = Bitmap.createBitmap(actualWidth, actualHeight, Bitmap.Config.ARGB_8888);
|
|
259
|
+
Canvas viewCanvas = new Canvas(clip);
|
|
260
|
+
// Translate to align content area to clip
|
|
261
|
+
viewCanvas.translate(-left, -top);
|
|
262
|
+
// Clip to the content area in post-translate coordinates
|
|
263
|
+
viewCanvas.clipRect(left, top, right, bottom);
|
|
264
|
+
|
|
265
|
+
// Draw editor content without scroll translation
|
|
266
|
+
editor.drawMatchText(viewCanvas);
|
|
267
|
+
editor.drawLineBackground(viewCanvas);
|
|
268
|
+
editor.drawEditableText(viewCanvas);
|
|
269
|
+
editor.drawSelectHandle(viewCanvas);
|
|
270
|
+
editor.drawCursor(viewCanvas);
|
|
271
|
+
|
|
272
|
+
Bitmap scaled = Bitmap.createScaledBitmap(clip, popup.getWidth(), popup.getHeight(), true);
|
|
273
|
+
clip.recycle();
|
|
274
|
+
|
|
275
|
+
Canvas canvas = new Canvas(dest);
|
|
276
|
+
paint.reset();
|
|
277
|
+
paint.setAntiAlias(true);
|
|
278
|
+
canvas.drawARGB(0, 0, 0, 0);
|
|
279
|
+
final int roundFactor = 6;
|
|
280
|
+
canvas.drawRoundRect(0, 0, popup.getWidth(), popup.getHeight(), dpToPx(roundFactor), dpToPx(roundFactor), paint);
|
|
281
|
+
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
|
282
|
+
canvas.drawBitmap(scaled, 0, 0, paint);
|
|
283
|
+
scaled.recycle();
|
|
284
|
+
|
|
285
|
+
image.setImageBitmap(dest);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Calculate the capture area bounds with edge protection */
|
|
289
|
+
private Rect calculateCaptureBounds(int contentX, int contentY, int requiredWidth,
|
|
290
|
+
int requiredHeight, int totalContentWidth, int totalContentHeight) {
|
|
291
|
+
int left = Math.max(contentX - requiredWidth / 2, 0);
|
|
292
|
+
int top = Math.max(contentY - requiredHeight / 2, 0);
|
|
293
|
+
int right = Math.min(left + requiredWidth, totalContentWidth);
|
|
294
|
+
int bottom = Math.min(top + requiredHeight, totalContentHeight);
|
|
295
|
+
|
|
296
|
+
// Adjust for edges
|
|
297
|
+
if (right - left < requiredWidth) {
|
|
298
|
+
left = Math.max(0, right - requiredWidth);
|
|
299
|
+
}
|
|
300
|
+
if (bottom - top < requiredHeight) {
|
|
301
|
+
top = Math.max(0, bottom - requiredHeight);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Special handling for bottom of document
|
|
305
|
+
if (contentY > totalContentHeight - getEditorLineHeight() * 3) {
|
|
306
|
+
// Near bottom of content - show area above cursor
|
|
307
|
+
top = Math.max(0, contentY - requiredHeight);
|
|
308
|
+
bottom = Math.min(top + requiredHeight, totalContentHeight);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return new Rect(left, top, right - left, bottom - top);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Capture, scale and display the magnified content */
|
|
315
|
+
private void displayMagnifiedContent(Bitmap dest, Rect captureBounds, int scrollX, int scrollY) {
|
|
316
|
+
// Create clip bitmap from capture area
|
|
317
|
+
Bitmap clip = Bitmap.createBitmap(captureBounds.width, captureBounds.height, Bitmap.Config.ARGB_8888);
|
|
318
|
+
Canvas viewCanvas = new Canvas(clip);
|
|
319
|
+
|
|
320
|
+
// Translate to align content area to clip
|
|
321
|
+
viewCanvas.translate(-(captureBounds.left + scrollX), -(captureBounds.top + scrollY));
|
|
322
|
+
|
|
323
|
+
// Draw editor content to clip
|
|
324
|
+
editor.drawEditorContent(viewCanvas, captureBounds.top, captureBounds.bottom);
|
|
325
|
+
|
|
326
|
+
// Scale clip to popup size
|
|
327
|
+
Bitmap scaled = Bitmap.createScaledBitmap(clip, popup.getWidth(), popup.getHeight(), true);
|
|
328
|
+
clip.recycle();
|
|
329
|
+
|
|
330
|
+
// Apply rounded corners to destination
|
|
331
|
+
Canvas canvas = new Canvas(dest);
|
|
332
|
+
paint.reset();
|
|
333
|
+
paint.setAntiAlias(true);
|
|
334
|
+
canvas.drawARGB(0, 0, 0, 0);
|
|
335
|
+
|
|
336
|
+
final int roundFactor = 6;
|
|
337
|
+
canvas.drawRoundRect(0, 0, popup.getWidth(), popup.getHeight(),
|
|
338
|
+
dpToPx(roundFactor), dpToPx(roundFactor), paint);
|
|
339
|
+
|
|
340
|
+
// Apply source-in mode for rounded corners
|
|
341
|
+
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
|
342
|
+
canvas.drawBitmap(scaled, 0, 0, paint);
|
|
343
|
+
scaled.recycle();
|
|
344
|
+
|
|
345
|
+
// Set the final bitmap to image view
|
|
346
|
+
image.setImageBitmap(dest);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** Simple rectangle helper class */
|
|
350
|
+
private static class Rect {
|
|
351
|
+
final int left, top, width, height;
|
|
352
|
+
final int right, bottom;
|
|
353
|
+
|
|
354
|
+
Rect(int left, int top, int width, int height) {
|
|
355
|
+
this.left = left;
|
|
356
|
+
this.top = top;
|
|
357
|
+
this.width = width;
|
|
358
|
+
this.height = height;
|
|
359
|
+
this.right = left + width;
|
|
360
|
+
this.bottom = top + height;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MH-TextEditor - An Advanced and optimized TextEditor for android
|
|
3
|
+
* Copyright 2025, developer-krushna
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are
|
|
7
|
+
* met:
|
|
8
|
+
*
|
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* * Redistributions in binary form must reproduce the above
|
|
12
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
* in the documentation and/or other materials provided with the
|
|
14
|
+
* distribution.
|
|
15
|
+
* * Neither the name of developer-krushna nor the names of its
|
|
16
|
+
* contributors may be used to endorse or promote products derived from
|
|
17
|
+
* this software without specific prior written permission.
|
|
18
|
+
*
|
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
* Please contact Krushna by email modder-hub@zohomail.in if you need
|
|
33
|
+
* additional information or have any questions
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
package com.aetherlink.dexeditor.editor.highlight;
|
|
37
|
+
|
|
38
|
+
/** Candidate: Represents a potential styled text region before overlap filtering. */
|
|
39
|
+
public class Candidate {
|
|
40
|
+
int start, end; // Character range
|
|
41
|
+
String style; // Style name
|
|
42
|
+
int priority; // Rule priority
|
|
43
|
+
int length; // Computed length for sorting
|
|
44
|
+
|
|
45
|
+
public Candidate(int s, int e, String st, int p) {
|
|
46
|
+
start = s;
|
|
47
|
+
end = e;
|
|
48
|
+
style = st;
|
|
49
|
+
priority = p;
|
|
50
|
+
length = e - s;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MH-TextEditor - An Advanced and optimized TextEditor for android
|
|
3
|
+
* Copyright 2025, developer-krushna
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are
|
|
7
|
+
* met:
|
|
8
|
+
*
|
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* * Redistributions in binary form must reproduce the above
|
|
12
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
* in the documentation and/or other materials provided with the
|
|
14
|
+
* distribution.
|
|
15
|
+
* * Neither the name of developer-krushna nor the names of its
|
|
16
|
+
* contributors may be used to endorse or promote products derived from
|
|
17
|
+
* this software without specific prior written permission.
|
|
18
|
+
*
|
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
* Please contact Krushna by email modder-hub@zohomail.in if you need
|
|
33
|
+
* additional information or have any questions
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
package com.aetherlink.dexeditor.editor.highlight;
|
|
37
|
+
|
|
38
|
+
// Comment detection token
|
|
39
|
+
public class CommentDef {
|
|
40
|
+
final String startsWith; // token that starts comment
|
|
41
|
+
final String endsWith; // optional end token (for block comments on same line)
|
|
42
|
+
|
|
43
|
+
CommentDef(String s, String e) {
|
|
44
|
+
this.startsWith = s;
|
|
45
|
+
this.endsWith = e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MH-TextEditor - An Advanced and optimized TextEditor for android
|
|
3
|
+
* Copyright 2025, developer-krushna
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are
|
|
7
|
+
* met:
|
|
8
|
+
*
|
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* * Redistributions in binary form must reproduce the above
|
|
12
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
* in the documentation and/or other materials provided with the
|
|
14
|
+
* distribution.
|
|
15
|
+
* * Neither the name of developer-krushna nor the names of its
|
|
16
|
+
* contributors may be used to endorse or promote products derived from
|
|
17
|
+
* this software without specific prior written permission.
|
|
18
|
+
*
|
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
* Please contact Krushna by email modder-hub@zohomail.in if you need
|
|
33
|
+
* additional information or have any questions
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
package com.aetherlink.dexeditor.editor.highlight;
|
|
37
|
+
|
|
38
|
+
import java.util.List;
|
|
39
|
+
|
|
40
|
+
/** LineResult: tokens + optional full-line background color */
|
|
41
|
+
public class LineResult {
|
|
42
|
+
public List<Token> tokens;
|
|
43
|
+
public Integer backgroundColor; // null if none
|
|
44
|
+
|
|
45
|
+
public LineResult(List<Token> t, Integer bg) {
|
|
46
|
+
tokens = t;
|
|
47
|
+
backgroundColor = bg;
|
|
48
|
+
}
|
|
49
|
+
}
|