Skip to content

Commit 257dd0c

Browse files
committed
v17.5.5
- Replaced moment.js with day.js for improved performance. - Switched from Jimp to HTML5 OffscreenCanvas for image processing to enhance performance. - Added scripts to assist with project preparation and building. - Improved the busy indicator, adjusted the default font size calculation and minimized interference with scrolling to provide a smoother user experience.
1 parent 919a88e commit 257dd0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1743
-2471
lines changed

android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ static def getVersionCodeFromVersionName(String versionName) {
1111
android {
1212
namespace "tv.megacubo.app"
1313
compileSdk rootProject.ext.compileSdkVersion
14+
compileSdkVersion 34
1415
defaultConfig {
1516
applicationId "tv.megacubo.app"
1617
minSdkVersion 24
17-
targetSdkVersion 33
18-
versionName '17.5.4'
18+
targetSdkVersion 34
19+
versionName '17.5.5'
1920
versionCode getVersionCodeFromVersionName(versionName)
2021
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2122
aaptOptions {
@@ -35,7 +36,6 @@ android {
3536
abi {
3637
enable true
3738
reset()
38-
//include 'armeabi-v7a'_64'
3939
include 'armeabi-v7a'
4040
universalApk false
4141
}

android/app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33
<application
4-
android:extractNativeLibs="true"
5-
android:allowBackup="true"
4+
android:allowBackup="true"
65
android:icon="@mipmap/ic_launcher"
76
android:label="@string/app_name"
87
android:roundIcon="@mipmap/ic_launcher_round"
@@ -21,7 +20,8 @@
2120
android:exported="true"
2221
android:supportsPictureInPicture="true"
2322
android:resizeableActivity="true"
24-
android:windowSoftInputMode="adjustResize">
23+
android:windowSoftInputMode="adjustResize"
24+
android:windowLayoutInDisplayCutoutMode="always">
2525
<intent-filter android:label="Megacubo">
2626
<action android:name="android.intent.action.MAIN" />
2727
<category android:name="android.intent.category.LAUNCHER" />
@@ -50,23 +50,32 @@
5050
android:grantUriPermissions="true">
5151
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
5252
</provider>
53-
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
53+
<service
54+
android:name="de.appplant.cordova.plugin.background.ForegroundService"
55+
android:foregroundServiceType="dataSync" android:exported="false" />
56+
<receiver
57+
android:name="de.appplant.cordova.plugin.background.BackgroundMode"
58+
android:enabled="true" android:exported="false">
59+
<intent-filter>
60+
<action android:name="com.backgroundmode.closetv.megacubo.app" />
61+
</intent-filter>
62+
</receiver>
5463
</application>
5564
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
5665
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
5766
<uses-permission android:name="android.permission.WAKE_LOCK" />
5867
<uses-permission android:name="android.permission.VIBRATE" />
5968
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
69+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
6070
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
6171
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6272
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
6373
<uses-permission android:name="android.permission.INTERNET" />
64-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
6574
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
6675
<uses-feature android:name="android.hardware.microphone" android:required="false" />
6776
<uses-feature android:name="android.software.leanback" android:required="false" />
6877
<uses-feature android:name="android.hardware.faketouch" android:required="false" />
69-
<uses-sdk android:minSdkVersion="24" />
78+
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="34" />
7079
<supports-screens
7180
android:anyDensity="true"
7281
android:largeScreens="true"

android/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ org.gradle.jvmargs=-Xmx1536m
2020
# Android operating system, and which are packaged with your app's APK
2121
# https://developer.android.com/topic/libraries/support-library/androidx-rn
2222
android.useAndroidX=true
23-
android.enableJetifier=true
23+
android.enableJetifier=false
24+
org.gradle.configuration-cache=true

android/variables.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ext {
2-
minSdkVersion = 22
2+
minSdkVersion = 24
33
compileSdkVersion = 34
44
targetSdkVersion = 34
55
androidxActivityVersion = '1.8.0'

bin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ findElectronExecutable().then(electronPath => {
6060
stdio: 'ignore',
6161
};
6262
const child = spawn(electronPath, params, opts);
63-
console.log({electronPath, params, opts})
6463
if(debug) {
6564
child.stdout.on('data', (data) => {
6665
process.stdout.write(data);

build.mjs

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { execSync } from 'child_process';
4+
import { fileURLToPath } from 'url';
5+
6+
console.log('This script will build the Megacubo APKs for ARM and ARM64 architectures, building PC installers is not covered yet. Remember to run \'npm run prepare\' before running this script.');
7+
8+
// Get __dirname in ESM
9+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
10+
11+
// Constants
12+
const RELEASE_DIRECTORY = path.join(__dirname, "releases");
13+
const APK_OUTPUT_DIRECTORY = path.join(__dirname, "android", "app", "build", "outputs", "apk", "release");
14+
const BUILD_GRADLE_FILE_PATH = path.join(__dirname, "android", "app", "build.gradle");
15+
const DISTRIBUTION_DIRECTORY = path.join(__dirname, "android", "app", "src", "main", "assets", "public", "nodejs", "dist");
16+
const PACKAGE_JSON_PATH = path.join(__dirname, "package.json");
17+
const SIGNING_PROPERTIES_PATH = path.join(__dirname, "release-signing.properties");
18+
19+
// Function to retrieve the application version from package.json
20+
const getApplicationVersion = async () => {
21+
const { default: { version } } = await import("file://" + PACKAGE_JSON_PATH, { assert: { type: "json" } });
22+
return version || "";
23+
};
24+
25+
// Function to read signing properties from the properties file
26+
const readSigningProperties = () => {
27+
const properties = {};
28+
if (fs.existsSync(SIGNING_PROPERTIES_PATH)) {
29+
const content = fs.readFileSync(SIGNING_PROPERTIES_PATH, "utf-8").split("\n");
30+
content.forEach(line => {
31+
const [key, value] = line.split("=");
32+
if (key && value) {
33+
properties[key.trim()] = value.trim();
34+
}
35+
});
36+
}
37+
if(properties.storeFile && (properties.storeFile.startsWith(".") || !(properties.storeFile.includes("/") || properties.storeFile.includes("\\")))) {
38+
properties.storeFile = path.join(__dirname, properties.storeFile);
39+
}
40+
return properties;
41+
};
42+
43+
// Update build.gradle file to include specified ABI
44+
const updateBuildGradleWithABI = (abi) => {
45+
let gradleContent = fs.readFileSync(BUILD_GRADLE_FILE_PATH, "utf-8");
46+
gradleContent = gradleContent.replace(/include \x27[a-z0-9\- ,\x27]+/g, `include '${abi}'`);
47+
fs.writeFileSync(BUILD_GRADLE_FILE_PATH, gradleContent);
48+
};
49+
50+
// Execute shell command with error handling
51+
const executeCommand = (command) => {
52+
try {
53+
execSync(command, { stdio: "inherit" });
54+
} catch (error) {
55+
console.error(`Command failed: ${command}`);
56+
process.exit(error.status);
57+
}
58+
};
59+
60+
// Main build process
61+
const buildApplication = async () => {
62+
const applicationVersion = await getApplicationVersion();
63+
const signingProperties = readSigningProperties();
64+
65+
if (!applicationVersion || !/^[0-9]+(\.[0-9]+)*$/.test(applicationVersion)) {
66+
console.error(`Application version is invalid or empty: ${applicationVersion}`);
67+
process.exit(1);
68+
}
69+
70+
console.log(`Application Version: ${applicationVersion}`);
71+
72+
const signedApkPath = path.join(APK_OUTPUT_DIRECTORY, "app-release-signed.apk");
73+
const unsignedApkPath = path.join(APK_OUTPUT_DIRECTORY, "app-release-unsigned.apk");
74+
75+
if (fs.existsSync(signedApkPath)) {
76+
fs.unlinkSync(signedApkPath);
77+
}
78+
79+
if (fs.existsSync(unsignedApkPath)) {
80+
fs.unlinkSync(unsignedApkPath);
81+
}
82+
83+
// ARM64 build process
84+
updateBuildGradleWithABI("arm64-v8a");
85+
if (fs.existsSync(path.join(DISTRIBUTION_DIRECTORY, "premium.js"))) {
86+
fs.unlinkSync(path.join(DISTRIBUTION_DIRECTORY, "premium.js"));
87+
}
88+
89+
const arm64PremiumFilePath = path.join(__dirname, "compiled_premium", "premium-arm64.jsc");
90+
const destinationPremiumFilePath = path.join(DISTRIBUTION_DIRECTORY, "premium.jsc");
91+
92+
// Copy ARM64 premium file if it exists
93+
if (fs.existsSync(arm64PremiumFilePath)) {
94+
fs.copyFileSync(arm64PremiumFilePath, destinationPremiumFilePath);
95+
}
96+
97+
// Build command
98+
let buildCommand = `npx cap build android`;
99+
100+
if (signingProperties.storeFile && signingProperties.storePassword && signingProperties.keyAlias && signingProperties.keyPassword) {
101+
console.log("Signing properties found. Signing APK...");
102+
buildCommand += ` --keystorepath ${signingProperties.storeFile} --keystorepass ${signingProperties.storePassword} --keystorealias ${signingProperties.keyAlias} --keystorealiaspass ${signingProperties.keyPassword}`;
103+
} else {
104+
console.log("Signing properties not found. Building unsigned APK...");
105+
}
106+
107+
buildCommand += ` --androidreleasetype APK --signing-type apksigner`;
108+
executeCommand(buildCommand);
109+
110+
const signedApkMtime = fs.existsSync(signedApkPath) ? fs.statSync(signedApkPath).mtime : 0;
111+
const unsignedApkMtime = fs.existsSync(unsignedApkPath) ? fs.statSync(unsignedApkPath).mtime : 0;
112+
113+
const outputApkPath = signedApkMtime > unsignedApkMtime ? signedApkPath : unsignedApkPath;
114+
fs.renameSync(outputApkPath, path.join(RELEASE_DIRECTORY, `Megacubo_${applicationVersion}_android_arm64-v8a.apk`));
115+
116+
// ARM build process
117+
updateBuildGradleWithABI("armeabi-v7a");
118+
119+
const armPremiumFilePath = path.join(__dirname, "compiled_premium", "premium-arm.jsc");
120+
121+
// Copy ARM premium file if it exists
122+
if (fs.existsSync(armPremiumFilePath)) {
123+
fs.copyFileSync(armPremiumFilePath, destinationPremiumFilePath);
124+
}
125+
126+
console.log("Building ARM as last to keep project files with ARM as default instead of ARM64...");
127+
128+
// Resetting buildCommand for ARM build
129+
buildCommand = `npx cap build android`;
130+
131+
if (signingProperties.storeFile && signingProperties.storePassword && signingProperties.keyAlias && signingProperties.keyPassword) {
132+
buildCommand += ` --keystorepath ${signingProperties.storeFile} --keystorepass ${signingProperties.storePassword} --keystorealias ${signingProperties.keyAlias} --keystorealiaspass ${signingProperties.keyPassword}`;
133+
}
134+
135+
buildCommand += ` --androidreleasetype APK --signing-type apksigner`;
136+
executeCommand(buildCommand);
137+
138+
fs.renameSync(
139+
outputApkPath,
140+
path.join(RELEASE_DIRECTORY, `Megacubo_${applicationVersion}_android_armeabi-v7a.apk`)
141+
);
142+
143+
console.log(`Finished: ${new Date().toLocaleString()}`);
144+
};
145+
146+
buildApplication().catch(error => console.error("Build failed:", error));

0 commit comments

Comments
 (0)