frida-ui-runtime 2.0.0
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/README.md +181 -0
- package/lib/android-listener.d.ts +20 -0
- package/lib/android-listener.js +92 -0
- package/lib/android-runtime.d.ts +25 -0
- package/lib/android-runtime.js +310 -0
- package/lib/api.d.ts +1 -0
- package/lib/api.js +156 -0
- package/lib/component/button.d.ts +11 -0
- package/lib/component/button.js +61 -0
- package/lib/component/category.d.ts +9 -0
- package/lib/component/category.js +57 -0
- package/lib/component/checkBox.d.ts +33 -0
- package/lib/component/checkBox.js +276 -0
- package/lib/component/collapsible.d.ts +19 -0
- package/lib/component/collapsible.js +197 -0
- package/lib/component/image.d.ts +18 -0
- package/lib/component/image.js +85 -0
- package/lib/component/infoCardBox.d.ts +13 -0
- package/lib/component/infoCardBox.js +68 -0
- package/lib/component/input.d.ts +41 -0
- package/lib/component/input.js +342 -0
- package/lib/component/selector.d.ts +31 -0
- package/lib/component/selector.js +246 -0
- package/lib/component/slider.d.ts +18 -0
- package/lib/component/slider.js +156 -0
- package/lib/component/style/style.d.ts +4 -0
- package/lib/component/style/style.js +325 -0
- package/lib/component/style/theme.d.ts +33 -0
- package/lib/component/style/theme.js +24 -0
- package/lib/component/switch.d.ts +12 -0
- package/lib/component/switch.js +117 -0
- package/lib/component/text.d.ts +9 -0
- package/lib/component/text.js +36 -0
- package/lib/component/ui-components.d.ts +34 -0
- package/lib/component/ui-components.js +108 -0
- package/lib/component/views/header-view.d.ts +20 -0
- package/lib/component/views/header-view.js +198 -0
- package/lib/component/views/log-view.d.ts +41 -0
- package/lib/component/views/log-view.js +511 -0
- package/lib/component/views/tabs-view.d.ts +41 -0
- package/lib/component/views/tabs-view.js +334 -0
- package/lib/constant-config.d.ts +5 -0
- package/lib/constant-config.js +3 -0
- package/lib/event-emitter.d.ts +10 -0
- package/lib/event-emitter.js +52 -0
- package/lib/float-menu.d.ts +103 -0
- package/lib/float-menu.js +648 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +16 -0
- package/lib/java-runtime.d.ts +2 -0
- package/lib/java-runtime.js +2 -0
- package/lib/logger.d.ts +43 -0
- package/lib/logger.js +200 -0
- package/lib/runtime/component-registry.d.ts +24 -0
- package/lib/runtime/component-registry.js +48 -0
- package/lib/runtime/launch-sequence.d.ts +5 -0
- package/lib/runtime/launch-sequence.js +20 -0
- package/lib/runtime/lifecycle-controller.d.ts +9 -0
- package/lib/runtime/lifecycle-controller.js +31 -0
- package/lib/runtime/listener-registry.d.ts +7 -0
- package/lib/runtime/listener-registry.js +40 -0
- package/lib/runtime/overlay-options.d.ts +9 -0
- package/lib/runtime/overlay-options.js +42 -0
- package/lib/runtime/safe-runtime.d.ts +3 -0
- package/lib/runtime/safe-runtime.js +20 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +13 -0
- package/package.json +43 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { API } from "../api.js";
|
|
2
|
+
import { UIComponent } from "./ui-components.js";
|
|
3
|
+
import { applyStyle, dp } from "./style/style.js";
|
|
4
|
+
import { Logger } from "../logger.js";
|
|
5
|
+
import Java from "../java-runtime.js";
|
|
6
|
+
import { createJavaListener } from "../android-listener.js";
|
|
7
|
+
export class Collapsible extends UIComponent {
|
|
8
|
+
constructor(id, title, expanded = false) {
|
|
9
|
+
super(id);
|
|
10
|
+
this.pendingChildren = [];
|
|
11
|
+
this.title = title;
|
|
12
|
+
this.expanded = expanded;
|
|
13
|
+
this.value = expanded;
|
|
14
|
+
}
|
|
15
|
+
createView(context) {
|
|
16
|
+
const LinearLayout = API.LinearLayout;
|
|
17
|
+
const TextView = API.TextView;
|
|
18
|
+
const String = API.JString;
|
|
19
|
+
const ViewGroupLayoutParams = API.ViewGroupLayoutParams;
|
|
20
|
+
const LinearLayoutParams = API.LinearLayoutParams;
|
|
21
|
+
const View = API.View;
|
|
22
|
+
const Gravity = API.Gravity;
|
|
23
|
+
const GradientDrawable = Java.use("android.graphics.drawable.GradientDrawable");
|
|
24
|
+
const createRoundedCard = (bgColor, cornerDp, strokeColor, strokeDp) => {
|
|
25
|
+
const drawable = GradientDrawable.$new();
|
|
26
|
+
drawable.setShape(GradientDrawable.RECTANGLE.value);
|
|
27
|
+
drawable.setColor(bgColor | 0);
|
|
28
|
+
drawable.setCornerRadius(dp(context, cornerDp));
|
|
29
|
+
drawable.setStroke(dp(context, strokeDp), strokeColor | 0);
|
|
30
|
+
return drawable;
|
|
31
|
+
};
|
|
32
|
+
const container = LinearLayout.$new(context);
|
|
33
|
+
container.setOrientation(LinearLayout.VERTICAL.value);
|
|
34
|
+
container.setLayoutParams(LinearLayoutParams.$new(ViewGroupLayoutParams.MATCH_PARENT.value, ViewGroupLayoutParams.WRAP_CONTENT.value));
|
|
35
|
+
const theme = this.menu.options.theme;
|
|
36
|
+
const borderColor = theme.colors.divider;
|
|
37
|
+
const cardBg = theme.colors.rowBg ?? theme.colors.cardBg;
|
|
38
|
+
container.setBackground(createRoundedCard(cardBg, 10, borderColor, 1));
|
|
39
|
+
container.setPadding(0, 0, 0, 0);
|
|
40
|
+
container.setElevation(dp(context, 2));
|
|
41
|
+
const titleRow = LinearLayout.$new(context);
|
|
42
|
+
titleRow.setOrientation(LinearLayout.HORIZONTAL.value);
|
|
43
|
+
titleRow.setGravity(Gravity.CENTER_VERTICAL.value);
|
|
44
|
+
titleRow.setLayoutParams(LinearLayoutParams.$new(ViewGroupLayoutParams.MATCH_PARENT.value, ViewGroupLayoutParams.WRAP_CONTENT.value));
|
|
45
|
+
titleRow.setPadding(dp(context, 14), dp(context, 12), dp(context, 14), dp(context, 12));
|
|
46
|
+
titleRow.setMinimumHeight(dp(context, 48));
|
|
47
|
+
const arrowText = this.expanded ? "⌃" : "›";
|
|
48
|
+
const arrowTextView = TextView.$new(context);
|
|
49
|
+
arrowTextView.setText.overload('java.lang.CharSequence').call(arrowTextView, arrowText);
|
|
50
|
+
arrowTextView.setSingleLine(true);
|
|
51
|
+
arrowTextView.setTextColor(theme.colors.subText);
|
|
52
|
+
arrowTextView.setTextSize(2, 20);
|
|
53
|
+
arrowTextView.setGravity(Gravity.CENTER.value);
|
|
54
|
+
arrowTextView.setPadding(dp(context, 12), 0, 0, 0);
|
|
55
|
+
this.arrowView = arrowTextView;
|
|
56
|
+
const titleView = TextView.$new(context);
|
|
57
|
+
titleView.setText.overload('java.lang.CharSequence').call(titleView, this.title);
|
|
58
|
+
titleView.setSingleLine(true);
|
|
59
|
+
applyStyle(titleView, "text", this.menu.options.theme);
|
|
60
|
+
titleView.setTypeface(null, 1);
|
|
61
|
+
titleView.setTextSize(2, 16);
|
|
62
|
+
titleView.setLayoutParams(LinearLayoutParams.$new(0, ViewGroupLayoutParams.WRAP_CONTENT.value, 1.0));
|
|
63
|
+
titleRow.addView(titleView);
|
|
64
|
+
titleRow.addView(this.arrowView);
|
|
65
|
+
const divider = View.$new(context);
|
|
66
|
+
divider.setLayoutParams(LinearLayoutParams.$new(ViewGroupLayoutParams.MATCH_PARENT.value, dp(context, 1)));
|
|
67
|
+
divider.setBackgroundColor(borderColor);
|
|
68
|
+
if (!this.expanded) {
|
|
69
|
+
divider.setVisibility(View.GONE.value);
|
|
70
|
+
}
|
|
71
|
+
this.contentContainer = LinearLayout.$new(context);
|
|
72
|
+
this.contentContainer.setOrientation(LinearLayout.VERTICAL.value);
|
|
73
|
+
const lp = LinearLayoutParams.$new(ViewGroupLayoutParams.MATCH_PARENT.value, ViewGroupLayoutParams.WRAP_CONTENT.value);
|
|
74
|
+
this.contentContainer.setLayoutParams(lp);
|
|
75
|
+
this.contentContainer.setPadding(dp(context, 10), dp(context, 10), dp(context, 10), dp(context, 10));
|
|
76
|
+
if (this.expanded) {
|
|
77
|
+
this.contentContainer.setVisibility(View.VISIBLE.value);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.contentContainer.setVisibility(View.GONE.value);
|
|
81
|
+
}
|
|
82
|
+
container.addView(titleRow);
|
|
83
|
+
container.addView(divider);
|
|
84
|
+
container.addView(this.contentContainer);
|
|
85
|
+
this.view = container;
|
|
86
|
+
if (this.pendingChildren.length > 0) {
|
|
87
|
+
for (const c of this.pendingChildren) {
|
|
88
|
+
try {
|
|
89
|
+
this.menu.attachNestedComponent(this.id, c, this.contentContainer);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
Logger.instance.error(`[Collapsible:${this.id}] addChild: ${c.getId()} - ${error}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
this.pendingChildren = [];
|
|
96
|
+
}
|
|
97
|
+
this.view.titleRow = titleRow;
|
|
98
|
+
this.view.titleView = titleView;
|
|
99
|
+
this.view.contentContainer = this.contentContainer;
|
|
100
|
+
this.view.divider = divider;
|
|
101
|
+
const OnClickListener = API.OnClickListener;
|
|
102
|
+
const self = this;
|
|
103
|
+
const clickListener = createJavaListener({
|
|
104
|
+
key: "view-click",
|
|
105
|
+
interfaceClass: OnClickListener,
|
|
106
|
+
callbacks: {
|
|
107
|
+
onClick: () => {
|
|
108
|
+
self.toggle();
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
this.own(() => clickListener.dispose());
|
|
113
|
+
titleRow.setOnClickListener(clickListener.instance);
|
|
114
|
+
}
|
|
115
|
+
updateView() {
|
|
116
|
+
if (!this.view) {
|
|
117
|
+
Logger.instance.warn(`[Collapsible:${this.id}] Cannot update view - view not initialized`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.expanded = this.value;
|
|
121
|
+
Java.scheduleOnMainThread(() => {
|
|
122
|
+
const View = API.View;
|
|
123
|
+
const String = API.JString;
|
|
124
|
+
const contentContainer = this.view.contentContainer;
|
|
125
|
+
const divider = this.view.divider;
|
|
126
|
+
if (contentContainer) {
|
|
127
|
+
contentContainer.setVisibility(this.expanded ? View.VISIBLE.value : View.GONE.value);
|
|
128
|
+
}
|
|
129
|
+
if (divider) {
|
|
130
|
+
divider.setVisibility(this.expanded ? View.VISIBLE.value : View.GONE.value);
|
|
131
|
+
}
|
|
132
|
+
if (this.arrowView) {
|
|
133
|
+
const arrowText = this.expanded ? "⌃" : "›";
|
|
134
|
+
this.arrowView.setText.overload('java.lang.CharSequence').call(this.arrowView, arrowText);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
toggle() {
|
|
139
|
+
this.value = !this.value;
|
|
140
|
+
this.updateView();
|
|
141
|
+
this.emit("toggle", this.value);
|
|
142
|
+
}
|
|
143
|
+
expand() {
|
|
144
|
+
this.value = true;
|
|
145
|
+
this.updateView();
|
|
146
|
+
this.emit("expand");
|
|
147
|
+
}
|
|
148
|
+
collapse() {
|
|
149
|
+
this.value = false;
|
|
150
|
+
this.updateView();
|
|
151
|
+
this.emit("collapse");
|
|
152
|
+
}
|
|
153
|
+
setTitle(title) {
|
|
154
|
+
this.title = title;
|
|
155
|
+
if (!this.view) {
|
|
156
|
+
Logger.instance.warn(`[Collapsible:${this.id}] Cannot set title - view not initialized`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
Java.scheduleOnMainThread(() => {
|
|
160
|
+
const titleView = this.view.titleView;
|
|
161
|
+
if (titleView) {
|
|
162
|
+
const String = API.JString;
|
|
163
|
+
titleView.setText.overload('java.lang.CharSequence').call(titleView, title);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
addChild(component) {
|
|
168
|
+
if (!this.contentContainer || !this.view) {
|
|
169
|
+
this.pendingChildren.push(component);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
void this.menu
|
|
173
|
+
.addNestedComponent(this.id, component, this.contentContainer)
|
|
174
|
+
.catch((error) => Logger.instance.error(`[Collapsible:${this.id}] addChild error: ${error}`));
|
|
175
|
+
}
|
|
176
|
+
addChildren(components) {
|
|
177
|
+
for (const c of components)
|
|
178
|
+
this.addChild(c);
|
|
179
|
+
}
|
|
180
|
+
removeChildView(view) {
|
|
181
|
+
if (!this.contentContainer)
|
|
182
|
+
return;
|
|
183
|
+
Java.scheduleOnMainThread(() => {
|
|
184
|
+
try {
|
|
185
|
+
this.contentContainer.removeView(view);
|
|
186
|
+
}
|
|
187
|
+
catch (_e) { }
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
clearChildren() {
|
|
191
|
+
if (!this.contentContainer)
|
|
192
|
+
return;
|
|
193
|
+
Java.scheduleOnMainThread(() => {
|
|
194
|
+
this.contentContainer.removeAllViews();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { UIComponent } from "./ui-components.js";
|
|
2
|
+
export declare class ImageView extends UIComponent {
|
|
3
|
+
private source;
|
|
4
|
+
private width;
|
|
5
|
+
private height;
|
|
6
|
+
static LayoutParamsEnum: {
|
|
7
|
+
readonly WRAP_CONTENT: number;
|
|
8
|
+
readonly MATCH_PARENT: number;
|
|
9
|
+
};
|
|
10
|
+
constructor(id: string, source: string | number, width: (typeof ImageView.LayoutParamsEnum)[keyof typeof ImageView.LayoutParamsEnum] | number, height: (typeof ImageView.LayoutParamsEnum)[keyof typeof ImageView.LayoutParamsEnum] | number);
|
|
11
|
+
protected createView(context: any): void;
|
|
12
|
+
private loadImage;
|
|
13
|
+
protected updateView(): void;
|
|
14
|
+
private updateSize;
|
|
15
|
+
setImage(source: string | number): void;
|
|
16
|
+
setScaleType(scaleType: any): void;
|
|
17
|
+
setSize(width: number, height: number): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import Java from "../java-runtime.js";
|
|
2
|
+
import { API } from "../api.js";
|
|
3
|
+
import { Logger } from "../logger.js";
|
|
4
|
+
import { UIComponent } from "./ui-components.js";
|
|
5
|
+
export class ImageView extends UIComponent {
|
|
6
|
+
constructor(id, source, width, height) {
|
|
7
|
+
super(id);
|
|
8
|
+
this.source = source;
|
|
9
|
+
this.width = width;
|
|
10
|
+
this.height = height;
|
|
11
|
+
this.value = source;
|
|
12
|
+
}
|
|
13
|
+
createView(context) {
|
|
14
|
+
const imageView = API.ImageView;
|
|
15
|
+
const imageViewScaleType = API.ImageViewScaleType;
|
|
16
|
+
const Color = API.Color;
|
|
17
|
+
const ViewGroupLayoutParams = API.ViewGroupLayoutParams;
|
|
18
|
+
this.view = imageView.$new(context);
|
|
19
|
+
this.view.setScaleType(imageViewScaleType.FIT_CENTER.value);
|
|
20
|
+
this.view.setBackgroundColor(Color.TRANSPARENT.value);
|
|
21
|
+
const layoutParams = ViewGroupLayoutParams.$new(this.width, this.height);
|
|
22
|
+
this.view.setLayoutParams(layoutParams);
|
|
23
|
+
this.loadImage(this.source);
|
|
24
|
+
}
|
|
25
|
+
loadImage(source) {
|
|
26
|
+
Java.scheduleOnMainThread(() => {
|
|
27
|
+
try {
|
|
28
|
+
const Base64 = API.Base64;
|
|
29
|
+
const BitmapFactory = API.BitmapFactory;
|
|
30
|
+
const decoded = Base64.decode(source, Base64.DEFAULT.value);
|
|
31
|
+
const bitmap = BitmapFactory.decodeByteArray(decoded, 0, decoded.length);
|
|
32
|
+
this.view.setImageBitmap(bitmap);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
Logger.instance.error(`[Image:${this.id}] Failed to load image:`, error);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
updateView() {
|
|
40
|
+
if (!this.view) {
|
|
41
|
+
Logger.instance.warn(`[Image:${this.id}] Cannot update view - view not initialized`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.loadImage(this.source);
|
|
45
|
+
this.updateSize();
|
|
46
|
+
}
|
|
47
|
+
updateSize() {
|
|
48
|
+
const ViewGroupLayoutParams = API.ViewGroupLayoutParams;
|
|
49
|
+
const layoutParams = this.view.getLayoutParams();
|
|
50
|
+
if (layoutParams) {
|
|
51
|
+
layoutParams.width = this.width;
|
|
52
|
+
layoutParams.height = this.height;
|
|
53
|
+
this.view.setLayoutParams(layoutParams);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const newParams = ViewGroupLayoutParams.$new(this.width, this.height);
|
|
57
|
+
this.view.setLayoutParams(newParams);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
setImage(source) {
|
|
61
|
+
this.source = source;
|
|
62
|
+
this.value = source;
|
|
63
|
+
this.updateView();
|
|
64
|
+
}
|
|
65
|
+
setScaleType(scaleType) {
|
|
66
|
+
if (this.view) {
|
|
67
|
+
Java.scheduleOnMainThread(() => {
|
|
68
|
+
this.view.setScaleType(scaleType);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
setSize(width, height) {
|
|
73
|
+
this.width = width;
|
|
74
|
+
this.height = height;
|
|
75
|
+
if (this.view) {
|
|
76
|
+
Java.scheduleOnMainThread(() => {
|
|
77
|
+
this.updateSize();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
ImageView.LayoutParamsEnum = {
|
|
83
|
+
WRAP_CONTENT: API.ViewGroupLayoutParams.WRAP_CONTENT.value,
|
|
84
|
+
MATCH_PARENT: API.ViewGroupLayoutParams.MATCH_PARENT.value,
|
|
85
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIComponent } from "./ui-components.js";
|
|
2
|
+
export declare class InfoCardText extends UIComponent {
|
|
3
|
+
private content;
|
|
4
|
+
private kind;
|
|
5
|
+
private textView;
|
|
6
|
+
private containerView;
|
|
7
|
+
private size?;
|
|
8
|
+
constructor(id: string, content: string, kind?: "normal" | "note", size?: number);
|
|
9
|
+
protected createView(context: any): void;
|
|
10
|
+
protected updateView(): void;
|
|
11
|
+
setText(content: string): void;
|
|
12
|
+
setKind(kind: "normal" | "note"): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Java from "../java-runtime.js";
|
|
2
|
+
import { API } from "../api.js";
|
|
3
|
+
import { applyStyle } from "./style/style.js";
|
|
4
|
+
import { UIComponent } from "./ui-components.js";
|
|
5
|
+
export class InfoCardText extends UIComponent {
|
|
6
|
+
constructor(id, content, kind = "normal", size) {
|
|
7
|
+
super(id);
|
|
8
|
+
this.content = content;
|
|
9
|
+
this.kind = kind;
|
|
10
|
+
this.size = size;
|
|
11
|
+
this.value = content;
|
|
12
|
+
}
|
|
13
|
+
createView(context) {
|
|
14
|
+
const LinearLayout = API.LinearLayout;
|
|
15
|
+
const LinearLayoutParams = API.LinearLayoutParams;
|
|
16
|
+
const ViewGroupLayoutParams = API.ViewGroupLayoutParams;
|
|
17
|
+
const TextView = API.TextView;
|
|
18
|
+
const Html = API.Html;
|
|
19
|
+
const Gravity = API.Gravity;
|
|
20
|
+
const root = LinearLayout.$new(context);
|
|
21
|
+
root.setOrientation(LinearLayout.VERTICAL.value);
|
|
22
|
+
const rootLp = LinearLayoutParams.$new(ViewGroupLayoutParams.MATCH_PARENT.value, ViewGroupLayoutParams.WRAP_CONTENT.value);
|
|
23
|
+
rootLp.setMargins(0, 0, 0, dp(context, 12));
|
|
24
|
+
root.setLayoutParams(rootLp);
|
|
25
|
+
applyStyle(root, this.kind === "note" ? "noteCard" : "infoCard", this.menu.options.theme);
|
|
26
|
+
const tv = TextView.$new(context);
|
|
27
|
+
tv.setLayoutParams(LinearLayoutParams.$new(ViewGroupLayoutParams.MATCH_PARENT.value, ViewGroupLayoutParams.WRAP_CONTENT.value));
|
|
28
|
+
applyStyle(tv, this.kind === "note" ? "noteText" : "text", this.menu.options.theme);
|
|
29
|
+
if (this.size != null) {
|
|
30
|
+
tv.setTextSize(2, this.size);
|
|
31
|
+
}
|
|
32
|
+
tv.setGravity(Gravity.LEFT.value);
|
|
33
|
+
tv.setText(Html.fromHtml(this.content));
|
|
34
|
+
root.addView(tv);
|
|
35
|
+
this.textView = tv;
|
|
36
|
+
this.containerView = root;
|
|
37
|
+
this.view = root;
|
|
38
|
+
}
|
|
39
|
+
updateView() {
|
|
40
|
+
if (!this.textView)
|
|
41
|
+
return;
|
|
42
|
+
Java.scheduleOnMainThread(() => {
|
|
43
|
+
const Html = API.Html;
|
|
44
|
+
this.textView.setText(Html.fromHtml(this.content));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
setText(content) {
|
|
48
|
+
this.content = content;
|
|
49
|
+
this.value = content;
|
|
50
|
+
this.updateView();
|
|
51
|
+
}
|
|
52
|
+
setKind(kind) {
|
|
53
|
+
this.kind = kind;
|
|
54
|
+
if (!this.containerView || !this.textView)
|
|
55
|
+
return;
|
|
56
|
+
Java.scheduleOnMainThread(() => {
|
|
57
|
+
applyStyle(this.containerView, this.kind === "note" ? "noteCard" : "infoCard", this.menu.options.theme);
|
|
58
|
+
applyStyle(this.textView, this.kind === "note" ? "noteText" : "text", this.menu.options.theme);
|
|
59
|
+
if (this.size != null) {
|
|
60
|
+
this.textView.setTextSize(2, this.size);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function dp(context, v) {
|
|
66
|
+
const dm = context.getResources().getDisplayMetrics();
|
|
67
|
+
return Math.floor(v * dm.density.value + 0.5);
|
|
68
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UIComponent } from "./ui-components.js";
|
|
2
|
+
declare abstract class BaseInputButton extends UIComponent {
|
|
3
|
+
protected title: string;
|
|
4
|
+
protected hint: string;
|
|
5
|
+
protected isShowDialog: boolean;
|
|
6
|
+
protected buttonView: any;
|
|
7
|
+
protected buttonLabelView: any;
|
|
8
|
+
protected buttonIconView: any;
|
|
9
|
+
constructor(id: string, title: string, hint: string);
|
|
10
|
+
protected createBaseView(context: any): void;
|
|
11
|
+
protected refreshButtonText(): void;
|
|
12
|
+
protected abstract buildDisplayText(): string;
|
|
13
|
+
}
|
|
14
|
+
export declare class NumberInput extends BaseInputButton {
|
|
15
|
+
private min;
|
|
16
|
+
private max;
|
|
17
|
+
private handler?;
|
|
18
|
+
constructor(id: string, initialValue?: number, title?: string, hint?: string);
|
|
19
|
+
protected buildDisplayText(): string;
|
|
20
|
+
protected createView(context: any): void;
|
|
21
|
+
protected updateView(): void;
|
|
22
|
+
private showDialog;
|
|
23
|
+
onValueChange(handler: (value: number) => void): void;
|
|
24
|
+
private applyConstraints;
|
|
25
|
+
setHint(hint: string): void;
|
|
26
|
+
setConstraints(min: number | null, max: number | null): void;
|
|
27
|
+
getNumber(): number;
|
|
28
|
+
setNumber(value: number): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class TextInput extends BaseInputButton {
|
|
31
|
+
private handler?;
|
|
32
|
+
constructor(id: string, initialValue?: string, title?: string, hint?: string);
|
|
33
|
+
protected buildDisplayText(): string;
|
|
34
|
+
protected createView(context: any): void;
|
|
35
|
+
protected updateView(): void;
|
|
36
|
+
protected emitValue(value: any): void;
|
|
37
|
+
onValueChange(handler: (value: string) => void): void;
|
|
38
|
+
private showDialog;
|
|
39
|
+
setText(text: string): void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|