Skip to content

Commit 173ed91

Browse files
author
Ajit Kumar
committed
fix(theme, browser activity, sponsor)
1 parent 64224f6 commit 173ed91

File tree

15 files changed

+300
-175
lines changed

15 files changed

+300
-175
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
},
3636
"cordova-plugin-websocket": {},
3737
"cordova-plugin-buildinfo": {},
38-
"cordova-plugin-system": {},
3938
"com.foxdebug.acode.rk.exec.terminal": {},
4039
"com.foxdebug.acode.rk.exec.proot": {},
41-
"cordova-plugin-browser": {}
40+
"cordova-plugin-browser": {},
41+
"cordova-plugin-system": {}
4242
},
4343
"platforms": [
4444
"android"

res/android/values/themes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
<item name="postSplashScreenTheme">@style/Theme.AppCompat.DayNight.NoActionBar</item>
88
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
99
</style>
10+
<style name="Theme.App.Activity" parent="Theme.AppCompat.DayNight.NoActionBar">
11+
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
12+
</style>
1013
</resources>

src/lib/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ export default {
2121
},
2222
API_BASE: "https://acode.app/api",
2323
// API_BASE: 'https://192.168.0.102:3001/api', // test api
24-
SKU_LIST: ["basic", "bronze", "silver", "gold", "platinum", "titanium"],
24+
SKU_LIST: ["crystal", "bronze", "silver", "gold", "platinum", "titanium"],
2525
LOG_FILE_NAME: "Acode.log",
2626
};

src/pages/sponsor/sponsor.js

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default function Sponsor(onclose) {
161161
<span className={`tier-icon ${product.productId}`}></span>
162162
{onlyTitle(product.title)}
163163
</div>
164-
<div className="tier-price">{product.price}</div>
164+
<div className="tier-price">{product.price}/Month</div>
165165
</div>
166166
<div
167167
className="tier-description"
@@ -183,24 +183,28 @@ export default function Sponsor(onclose) {
183183

184184
async function handlePurchase(productId, title) {
185185
let image;
186-
const result = await multiPrompt(onlyTitle(title), [
187-
{
188-
placeholder: "Name",
189-
required: true,
190-
id: "name",
191-
},
192-
{
193-
placeholder: "Email",
194-
required: false,
195-
id: "email",
196-
},
197-
{
186+
const extraFields = [];
187+
188+
if (["silver", "gold", "platinum", "titanium"].includes(productId)) {
189+
extraFields.push({
198190
placeholder: "Website",
199191
required: false,
200192
id: "website",
201193
type: "url",
202-
},
203-
{
194+
});
195+
}
196+
197+
if (productId === "titanium") {
198+
extraFields.push({
199+
placeholder: "Tagline",
200+
required: false,
201+
id: "tagline",
202+
type: "text",
203+
});
204+
}
205+
206+
if (["gold", "platinum", "titanium"].includes(productId)) {
207+
extraFields.push({
204208
placeholder: "Logo/Image (500KB max)",
205209
required: false,
206210
type: "text",
@@ -231,7 +235,22 @@ async function handlePurchase(productId, title) {
231235
reader.readAsDataURL(blob);
232236
}, "image/*");
233237
},
238+
});
239+
}
240+
241+
const result = await multiPrompt(onlyTitle(title), [
242+
{
243+
placeholder: "Name",
244+
required: true,
245+
id: "name",
246+
},
247+
{
248+
placeholder: "Email",
249+
required: false,
250+
id: "email",
251+
type: "email",
234252
},
253+
...extraFields,
235254
{
236255
placeholder: "Show in sponsors list",
237256
required: false,

src/pages/sponsor/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
margin-right: 8px;
99
border-radius: 50%;
1010

11-
&.basic {
11+
&.crystal {
1212
background: linear-gradient(45deg, #95a5a6, #bdc3c7);
1313
}
1414

src/pages/sponsors/sponsors.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default function Sponsors() {
9393
</div>
9494
<div className="tier">
9595
<div className="tier-name">
96-
<span className="tier-icon basic"></span>Crystal
96+
<span className="tier-icon crystal"></span>Crystal
9797
</div>
9898
<div
9999
className="sponsors"
@@ -140,7 +140,7 @@ export default function Sponsors() {
140140
case "bronze":
141141
bronzeSponsors.append(<SponsorCard {...sponsor} />);
142142
break;
143-
case "basic":
143+
case "crystal":
144144
crystalSponsors.append(<SponsorCard {...sponsor} />);
145145
break;
146146
}
@@ -152,17 +152,27 @@ export default function Sponsors() {
152152
}
153153
}
154154

155-
function SponsorCard({ name, image, website }) {
155+
function SponsorCard({ name, image, website, tier, tagline }) {
156+
// for crystal tier only text, for bronze slightly bigger text, for silver bigger clickable text,
157+
// for gold text with image, for platinum and titanium text with big image
158+
156159
return (
157160
<div
158161
attr-role="button"
159-
className="sponsor-card"
160-
onclick={() => website && system.openInBrowser(website)}
162+
className={`sponsor-card ${tier}`}
163+
onclick={() => {
164+
if (!website.startsWith("http")) {
165+
website = "http://" + website;
166+
}
167+
system.openInBrowser(website);
168+
}}
161169
>
162170
<div className="sponsor-avatar">
163171
<img src={`https://acode.app/sponsor/image/${image}`} />
164172
</div>
165173
<div className="sponsor-name">{name}</div>
174+
<div className="sponsor-tagline">{tagline}</div>
175+
{website && <small className="sponsor-website">{website}</small>}
166176
</div>
167177
);
168178
}

src/pages/sponsors/style.scss

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
border-radius: 50%;
77
margin-right: 8px;
88

9-
&.basic {
9+
&.crystal {
1010
background: linear-gradient(45deg, #95a5a6, #bdc3c7);
1111
}
1212

@@ -103,36 +103,76 @@
103103
.sponsor-card {
104104
flex-grow: 1;
105105
min-width: 150px;
106-
background: rgba(255, 255, 255, 0.1);
106+
background: var(--popup-background-color);
107+
color: var(--popup-text-color);
107108
border-radius: 12px;
108109
padding: 15px;
109110
text-align: center;
110111
backdrop-filter: blur(10px);
111-
border: 1px solid rgba(255, 255, 255, 0.2);
112+
border: 1px solid var(--border-color);
112113
transition: all 0.3s ease;
113-
}
114114

115-
.sponsor-avatar {
116-
width: 50px;
117-
height: 50px;
118-
display: flex;
119-
margin: 0 auto 10px;
120-
align-items: center;
121-
justify-content: center;
122-
font-weight: bold;
123-
font-size: 18px;
115+
.sponsor-avatar {
116+
width: 50px;
117+
height: 50px;
118+
border-radius: 50%;
119+
display: flex;
120+
margin: 0 auto 10px;
121+
align-items: center;
122+
justify-content: center;
123+
font-weight: bold;
124+
font-size: 18px;
125+
overflow: hidden;
126+
background-color: currentColor;
127+
128+
img {
129+
max-width: 100%;
130+
max-height: 100%;
131+
object-fit: cover;
132+
}
133+
}
124134

125-
img {
126-
max-width: 100%;
127-
max-height: 100%;
128-
object-fit: contain;
135+
.sponsor-name {
136+
font-size: 14px;
137+
font-weight: 500;
138+
margin-bottom: 5px;
139+
}
140+
141+
.sponsor-website {
142+
opacity: 0.6;
143+
font-size: 12px;
129144
}
130-
}
131145

132-
.sponsor-name {
133-
font-size: 14px;
134-
font-weight: 500;
135-
margin-bottom: 5px;
146+
&.crystal,
147+
&.bronze,
148+
&.silver {
149+
.sponsor-avatar {
150+
display: none;
151+
}
152+
}
153+
154+
&.bronze,
155+
&.crystal {
156+
pointer-events: none;
157+
}
158+
159+
&.silver,
160+
&.bronze,
161+
&.gold,
162+
&.platinum,
163+
&.titanium {
164+
.sponsor-name {
165+
font-size: 16px;
166+
}
167+
}
168+
169+
&.platinum,
170+
&.titanium {
171+
.sponsor-avatar {
172+
width: 100px;
173+
height: 100px;
174+
}
175+
}
136176
}
137177
}
138178
}

src/plugins/browser/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
<config-file parent="./application" target="AndroidManifest.xml">
18-
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:name="com.foxdebug.browser.BrowserActivity" android:theme="@style/Theme.AppCompat.NoActionBar" android:windowSoftInputMode="adjustResize" android:resizeableActivity="true">
18+
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:name="com.foxdebug.browser.BrowserActivity" android:theme="@style/Theme.App.Activity" android:windowSoftInputMode="adjustResize" android:resizeableActivity="true">
1919
</activity>
2020
</config-file>
2121

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

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.foxdebug.system;
22

3+
import static android.os.Build.VERSION.SDK_INT;
34

45
import java.nio.file.Files;
56
import java.nio.file.Paths;
@@ -57,6 +58,7 @@
5758
import java.nio.file.Path;
5859
import android.content.Context;
5960
import android.net.Uri;
61+
import android.util.Log;
6062

6163
import java.io.File;
6264
import java.io.FileInputStream;
@@ -1038,11 +1040,11 @@ private void removeShortcut(String id, CallbackContext callback) {
10381040

10391041
private void setUiTheme(
10401042
final String systemBarColor,
1041-
final JSONObject schema,
1043+
final JSONObject scheme,
10421044
final CallbackContext callback
10431045
) {
10441046
this.systemBarColor = Color.parseColor(systemBarColor);
1045-
this.theme = new Theme(schema);
1047+
this.theme = new Theme(scheme);
10461048

10471049
final Window window = activity.getWindow();
10481050
// Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
@@ -1088,34 +1090,73 @@ private void setUiTheme(
10881090
}
10891091

10901092
private void setStatusBarStyle(final Window window) {
1091-
View decorView = window.getDecorView();
1092-
int uiOptions = decorView.getSystemUiVisibility();
10931093
String themeType = theme.getType();
1094+
View decorView = window.getDecorView();
1095+
int uiOptions;
1096+
int lightStatusBar;
1097+
1098+
if (SDK_INT <= 30) {
1099+
uiOptions = getDeprecatedSystemUiVisibility(decorView);
1100+
lightStatusBar = deprecatedFlagUiLightStatusBar();
1101+
1102+
if (themeType.equals("light")) {
1103+
setDeprecatedSystemUiVisibility(decorView, uiOptions | lightStatusBar);
1104+
return;
1105+
}
1106+
setDeprecatedSystemUiVisibility(decorView, uiOptions & ~lightStatusBar);
1107+
return;
1108+
}
1109+
1110+
uiOptions = Objects.requireNonNull(decorView.getWindowInsetsController()).getSystemBarsAppearance();
1111+
lightStatusBar = WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
10941112

10951113
if (themeType.equals("light")) {
1096-
decorView.setSystemUiVisibility(
1097-
uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
1098-
);
1114+
decorView.getWindowInsetsController().setSystemBarsAppearance(uiOptions | lightStatusBar, lightStatusBar);
10991115
return;
11001116
}
1101-
decorView.setSystemUiVisibility(
1102-
uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
1103-
);
1117+
1118+
decorView.getWindowInsetsController().setSystemBarsAppearance(uiOptions & ~lightStatusBar, lightStatusBar);
11041119
}
11051120

11061121
private void setNavigationBarStyle(final Window window) {
1107-
View decorView = window.getDecorView();
1108-
int uiOptions = decorView.getSystemUiVisibility();
11091122
String themeType = theme.getType();
1123+
View decorView = window.getDecorView();
1124+
int uiOptions;
11101125

1111-
// 0x80000000 FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
1112-
// 0x00000010 SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
1126+
if (SDK_INT <= 30) {
1127+
uiOptions = getDeprecatedSystemUiVisibility(decorView);
1128+
// 0x80000000 FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
1129+
// 0x00000010 SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
1130+
1131+
if (themeType.equals("light")) {
1132+
setDeprecatedSystemUiVisibility(decorView, uiOptions | 0x80000000 | 0x00000010);
1133+
return;
1134+
}
1135+
setDeprecatedSystemUiVisibility(decorView, uiOptions | (0x80000000 & ~0x00000010));
1136+
return;
1137+
}
1138+
1139+
uiOptions = Objects.requireNonNull(decorView.getWindowInsetsController()).getSystemBarsAppearance();
1140+
int lightNavigationBar = WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
11131141

11141142
if (themeType.equals("light")) {
1115-
decorView.setSystemUiVisibility(uiOptions | 0x80000000 | 0x00000010);
1143+
decorView.getWindowInsetsController().setSystemBarsAppearance(uiOptions | lightNavigationBar, lightNavigationBar);
11161144
return;
11171145
}
1118-
decorView.setSystemUiVisibility(uiOptions | (0x80000000 & ~0x00000010));
1146+
1147+
decorView.getWindowInsetsController().setSystemBarsAppearance(uiOptions & ~lightNavigationBar, lightNavigationBar);
1148+
}
1149+
1150+
private int deprecatedFlagUiLightStatusBar() {
1151+
return View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
1152+
}
1153+
1154+
private int getDeprecatedSystemUiVisibility(View decorView) {
1155+
return decorView.getSystemUiVisibility();
1156+
}
1157+
1158+
private void setDeprecatedSystemUiVisibility(View decorView, int visibility) {
1159+
decorView.setSystemUiVisibility(visibility);
11191160
}
11201161

11211162
private void getCordovaIntent(CallbackContext callback) {

0 commit comments

Comments
 (0)