Skip to content

Commit a148951

Browse files
feat: improve launchApp (#1987)
* feat: improve launchApp * feat: added jsdoc * format * fix: compile * feat: definition
1 parent 69c0803 commit a148951

File tree

12 files changed

+213
-165
lines changed

12 files changed

+213
-165
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.1.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
33
"formatter": {
44
"enabled": true,
55
"indentStyle": "tab"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@babel/preset-typescript": "^7.28.5",
6464
"@babel/runtime": "^7.28.4",
6565
"@babel/runtime-corejs3": "^7.28.4",
66-
"@biomejs/biome": "2.1.4",
66+
"@biomejs/biome": "2.4.6",
6767
"@rspack/cli": "^1.7.0",
6868
"@rspack/core": "^1.7.0",
6969
"@types/ace": "^0.0.52",

src/components/lspInfoDialog/index.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -634,22 +634,24 @@ function showLspInfoDialog() {
634634
</div>
635635
</div>
636636
<div className="lsp-logs-container">
637-
{logs.length === 0
638-
? <div className="lsp-logs-empty">No logs yet</div>
639-
: logs.slice(-50).map((log) => {
640-
const time = log.timestamp.toLocaleTimeString("en-US", {
641-
hour12: false,
642-
hour: "2-digit",
643-
minute: "2-digit",
644-
second: "2-digit",
645-
});
646-
return (
647-
<div className={`lsp-log ${log.level}`}>
648-
<span className="lsp-log-time">{time}</span>
649-
<span className="lsp-log-text">{log.message}</span>
650-
</div>
651-
);
652-
})}
637+
{logs.length === 0 ? (
638+
<div className="lsp-logs-empty">No logs yet</div>
639+
) : (
640+
logs.slice(-50).map((log) => {
641+
const time = log.timestamp.toLocaleTimeString("en-US", {
642+
hour12: false,
643+
hour: "2-digit",
644+
minute: "2-digit",
645+
second: "2-digit",
646+
});
647+
return (
648+
<div className={`lsp-log ${log.level}`}>
649+
<span className="lsp-log-time">{time}</span>
650+
<span className="lsp-log-text">{log.message}</span>
651+
</div>
652+
);
653+
})
654+
)}
653655
</div>
654656
</div>
655657
);

src/components/settingsPage.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ function createTrailingValueDisplay(item) {
435435
return (
436436
<div className={`setting-value-display ${item.select ? "is-select" : ""}`}>
437437
{$trailingValueText}
438-
{item.select
439-
? <span className="icon keyboard_arrow_down setting-value-icon"></span>
440-
: null}
438+
{item.select ? (
439+
<span className="icon keyboard_arrow_down setting-value-icon"></span>
440+
) : null}
441441
</div>
442442
);
443443
}
@@ -491,9 +491,9 @@ function buildListContent(renderedItems, options) {
491491

492492
function createSectionElements(category) {
493493
const shouldShowLabel = category !== "__default__";
494-
const $label = shouldShowLabel
495-
? <div className="settings-section-label">{category}</div>
496-
: null;
494+
const $label = shouldShowLabel ? (
495+
<div className="settings-section-label">{category}</div>
496+
) : null;
497497
const $card = <div className="settings-section-card"></div>;
498498
return {
499499
$card,

src/components/toast/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ export default function toast(message, duration = 0, bgColor, color) {
1919
style={{ backgroundColor: bgColor, color }}
2020
>
2121
<span className="message">{message}</span>
22-
{duration === false
23-
? <button
24-
className="icon clearclose"
25-
onclick={() => $toast.hide()}
26-
></button>
27-
: ""}
22+
{duration === false ? (
23+
<button
24+
className="icon clearclose"
25+
onclick={() => $toast.hide()}
26+
></button>
27+
) : (
28+
""
29+
)}
2830
</div>
2931
);
3032

src/dialogs/select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ function select(title, items, options = {}) {
4848
const $list = tag("ul", {
4949
className: `scroll${!textTransform ? " no-text-transform" : ""}`,
5050
});
51-
const $titleSpan = title
52-
? <strong className="title">{title}</strong>
53-
: null;
51+
const $titleSpan = title ? (
52+
<strong className="title">{title}</strong>
53+
) : null;
5454
const $select = (
5555
<div className="prompt select">
5656
{$titleSpan ? [$titleSpan, $list] : $list}

src/pages/fontManager/fontManager.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,20 @@ export default function fontManager() {
307307
<div className="text">{name}</div>
308308
<small className="value">{subtitle}</small>
309309
</div>
310-
{isCurrent || !isDefault
311-
? <div className="setting-tail">
312-
{isCurrent
313-
? <span className="font-manager-current">Current</span>
314-
: null}
315-
{!isDefault
316-
? <span
317-
className="icon delete font-manager-action"
318-
data-action="delete"
319-
title="Delete font"
320-
></span>
321-
: null}
322-
</div>
323-
: null}
310+
{isCurrent || !isDefault ? (
311+
<div className="setting-tail">
312+
{isCurrent ? (
313+
<span className="font-manager-current">Current</span>
314+
) : null}
315+
{!isDefault ? (
316+
<span
317+
className="icon delete font-manager-action"
318+
data-action="delete"
319+
title="Delete font"
320+
></span>
321+
) : null}
322+
</div>
323+
) : null}
324324
</div>
325325
);
326326

src/pages/plugin/plugin.view.js

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ export default (props) => {
100100
<div className="plugin-info">
101101
<div className="title-wrapper">
102102
<h1 className="plugin-name">{name}</h1>
103-
{repository
104-
? <a href={repository} className="source-indicator">
105-
<i className="icon github"></i>
106-
<span>{strings.open_source}</span>
107-
</a>
108-
: null}
103+
{repository ? (
104+
<a href={repository} className="source-indicator">
105+
<i className="icon github"></i>
106+
<span>{strings.open_source}</span>
107+
</a>
108+
) : null}
109109
</div>
110110
<div className="plugin-meta">
111111
<span className="meta-item">
@@ -121,14 +121,16 @@ export default (props) => {
121121
<a href={`https://github.com/${authorGithub}`} className="">
122122
{author}
123123
</a>
124-
{authorVerified
125-
? <i
126-
on:click={() => {
127-
toast(strings["verified publisher"]);
128-
}}
129-
className="licons verified verified-tick"
130-
></i>
131-
: ""}
124+
{authorVerified ? (
125+
<i
126+
on:click={() => {
127+
toast(strings["verified publisher"]);
128+
}}
129+
className="licons verified verified-tick"
130+
></i>
131+
) : (
132+
""
133+
)}
132134
</span>
133135
<span className="meta-item">
134136
<span
@@ -138,44 +140,44 @@ export default (props) => {
138140
{license || "Unknown"}
139141
</span>
140142
</div>
141-
{votesUp !== undefined
142-
? <div className="metrics-row">
143-
<div className="metric">
144-
<span className="icon save_alt"></span>
145-
<span className="metric-value">
146-
{helpers.formatDownloadCount(
147-
typeof downloads === "string"
148-
? Number.parseInt(downloads)
149-
: downloads,
150-
)}
151-
</span>
152-
<span>{strings.downloads}</span>
153-
</div>
154-
<div className="metric">
155-
<i className="icon favorite"></i>
156-
<span
157-
className={`rating-value ${rating === "unrated" ? "" : rating.replace("%", "") >= 80 ? "rating-high" : rating.replace("%", "") >= 50 ? "rating-medium" : "rating-low"}`}
158-
>
159-
{rating}
160-
</span>
161-
</div>
162-
<div
163-
className="metric"
164-
onclick={showReviews.bind(null, id, author)}
143+
{votesUp !== undefined ? (
144+
<div className="metrics-row">
145+
<div className="metric">
146+
<span className="icon save_alt"></span>
147+
<span className="metric-value">
148+
{helpers.formatDownloadCount(
149+
typeof downloads === "string"
150+
? Number.parseInt(downloads)
151+
: downloads,
152+
)}
153+
</span>
154+
<span>{strings.downloads}</span>
155+
</div>
156+
<div className="metric">
157+
<i className="icon favorite"></i>
158+
<span
159+
className={`rating-value ${rating === "unrated" ? "" : rating.replace("%", "") >= 80 ? "rating-high" : rating.replace("%", "") >= 50 ? "rating-medium" : "rating-low"}`}
165160
>
166-
<i className="icon chat_bubble"></i>
167-
<span className="metric-value">{commentCount}</span>
168-
<span>{strings.reviews}</span>
169-
</div>
161+
{rating}
162+
</span>
170163
</div>
171-
: null}
172-
{Array.isArray(keywords) && keywords.length
173-
? <div className="keywords">
174-
{keywords.map((keyword) => (
175-
<span className="keyword">{keyword}</span>
176-
))}
164+
<div
165+
className="metric"
166+
onclick={showReviews.bind(null, id, author)}
167+
>
168+
<i className="icon chat_bubble"></i>
169+
<span className="metric-value">{commentCount}</span>
170+
<span>{strings.reviews}</span>
177171
</div>
178-
: null}
172+
</div>
173+
) : null}
174+
{Array.isArray(keywords) && keywords.length ? (
175+
<div className="keywords">
176+
{keywords.map((keyword) => (
177+
<span className="keyword">{keyword}</span>
178+
))}
179+
</div>
180+
) : null}
179181
</div>
180182
<div className="action-buttons">
181183
<Buttons {...props} />

src/plugins/system/android/com/foxdebug/system/System.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public void run() {
546546
openInBrowser(arg1, callbackContext);
547547
break;
548548
case "launch-app":
549-
launchApp(arg1, arg2, arg3, callbackContext);
549+
launchApp(arg1, arg2, args.optJSONObject(2), callbackContext);
550550
break;
551551
case "get-global-setting":
552552
getGlobalSetting(arg1, callbackContext);
@@ -1564,7 +1564,7 @@ private void openInBrowser(String src, CallbackContext callback) {
15641564
private void launchApp(
15651565
String appId,
15661566
String className,
1567-
String data,
1567+
JSONObject extras,
15681568
CallbackContext callback
15691569
) {
15701570
if (appId == null || appId.equals("")) {
@@ -1582,21 +1582,38 @@ private void launchApp(
15821582
intent.addCategory(Intent.CATEGORY_LAUNCHER);
15831583
intent.setPackage(appId);
15841584
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
1585+
intent.setClassName(appId, className);
1586+
1587+
if (extras != null) {
1588+
Iterator<String> keys = extras.keys();
1589+
1590+
while (keys.hasNext()) {
1591+
String key = keys.next();
1592+
Object value = extras.get(key);
15851593

1586-
if (data != null && !data.equals("")) {
1587-
intent.putExtra("acode_data", data);
1594+
if (value instanceof Integer) {
1595+
intent.putExtra(key, (Integer) value);
1596+
} else if (value instanceof Boolean) {
1597+
intent.putExtra(key, (Boolean) value);
1598+
} else if (value instanceof Double) {
1599+
intent.putExtra(key, (Double) value);
1600+
} else if (value instanceof Long) {
1601+
intent.putExtra(key, (Long) value);
1602+
} else if (value instanceof String) {
1603+
intent.putExtra(key, (String) value);
1604+
} else {
1605+
intent.putExtra(key, value.toString());
1606+
}
1607+
}
15881608
}
15891609

1590-
intent.setClassName(appId, className);
15911610
activity.startActivity(intent);
15921611
callback.success("Launched " + appId);
1612+
15931613
} catch (Exception e) {
15941614
callback.error(e.toString());
1595-
return;
15961615
}
15971616

1598-
1599-
16001617
}
16011618

16021619

0 commit comments

Comments
 (0)