Skip to content

Commit

Permalink
v17.5.5
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
EdenwareApps committed Nov 11, 2024
1 parent 919a88e commit 257dd0c
Show file tree
Hide file tree
Showing 54 changed files with 1,743 additions and 2,471 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ static def getVersionCodeFromVersionName(String versionName) {
android {
namespace "tv.megacubo.app"
compileSdk rootProject.ext.compileSdkVersion
compileSdkVersion 34
defaultConfig {
applicationId "tv.megacubo.app"
minSdkVersion 24
targetSdkVersion 33
versionName '17.5.4'
targetSdkVersion 34
versionName '17.5.5'
versionCode getVersionCodeFromVersionName(versionName)
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
Expand All @@ -35,7 +36,6 @@ android {
abi {
enable true
reset()
//include 'armeabi-v7a'_64'
include 'armeabi-v7a'
universalApk false
}
Expand Down
21 changes: 15 additions & 6 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:extractNativeLibs="true"
android:allowBackup="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand All @@ -21,7 +20,8 @@
android:exported="true"
android:supportsPictureInPicture="true"
android:resizeableActivity="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:windowLayoutInDisplayCutoutMode="always">
<intent-filter android:label="Megacubo">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -50,23 +50,32 @@
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
<service
android:name="de.appplant.cordova.plugin.background.ForegroundService"
android:foregroundServiceType="dataSync" android:exported="false" />
<receiver
android:name="de.appplant.cordova.plugin.background.BackgroundMode"
android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="com.backgroundmode.closetv.megacubo.app" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.faketouch" android:required="false" />
<uses-sdk android:minSdkVersion="24" />
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="34" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
Expand Down
3 changes: 2 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ org.gradle.jvmargs=-Xmx1536m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=false
org.gradle.configuration-cache=true
2 changes: 1 addition & 1 deletion android/variables.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ext {
minSdkVersion = 22
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34
androidxActivityVersion = '1.8.0'
Expand Down
1 change: 0 additions & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ findElectronExecutable().then(electronPath => {
stdio: 'ignore',
};
const child = spawn(electronPath, params, opts);
console.log({electronPath, params, opts})
if(debug) {
child.stdout.on('data', (data) => {
process.stdout.write(data);
Expand Down
146 changes: 146 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import { fileURLToPath } from 'url';

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.');

// Get __dirname in ESM
const __dirname = path.dirname(fileURLToPath(import.meta.url));

// Constants
const RELEASE_DIRECTORY = path.join(__dirname, "releases");
const APK_OUTPUT_DIRECTORY = path.join(__dirname, "android", "app", "build", "outputs", "apk", "release");
const BUILD_GRADLE_FILE_PATH = path.join(__dirname, "android", "app", "build.gradle");
const DISTRIBUTION_DIRECTORY = path.join(__dirname, "android", "app", "src", "main", "assets", "public", "nodejs", "dist");
const PACKAGE_JSON_PATH = path.join(__dirname, "package.json");
const SIGNING_PROPERTIES_PATH = path.join(__dirname, "release-signing.properties");

// Function to retrieve the application version from package.json
const getApplicationVersion = async () => {
const { default: { version } } = await import("file://" + PACKAGE_JSON_PATH, { assert: { type: "json" } });
return version || "";
};

// Function to read signing properties from the properties file
const readSigningProperties = () => {
const properties = {};
if (fs.existsSync(SIGNING_PROPERTIES_PATH)) {
const content = fs.readFileSync(SIGNING_PROPERTIES_PATH, "utf-8").split("\n");
content.forEach(line => {
const [key, value] = line.split("=");
if (key && value) {
properties[key.trim()] = value.trim();
}
});
}
if(properties.storeFile && (properties.storeFile.startsWith(".") || !(properties.storeFile.includes("/") || properties.storeFile.includes("\\")))) {
properties.storeFile = path.join(__dirname, properties.storeFile);
}
return properties;
};

// Update build.gradle file to include specified ABI
const updateBuildGradleWithABI = (abi) => {
let gradleContent = fs.readFileSync(BUILD_GRADLE_FILE_PATH, "utf-8");
gradleContent = gradleContent.replace(/include \x27[a-z0-9\- ,\x27]+/g, `include '${abi}'`);
fs.writeFileSync(BUILD_GRADLE_FILE_PATH, gradleContent);
};

// Execute shell command with error handling
const executeCommand = (command) => {
try {
execSync(command, { stdio: "inherit" });
} catch (error) {
console.error(`Command failed: ${command}`);
process.exit(error.status);
}
};

// Main build process
const buildApplication = async () => {
const applicationVersion = await getApplicationVersion();
const signingProperties = readSigningProperties();

if (!applicationVersion || !/^[0-9]+(\.[0-9]+)*$/.test(applicationVersion)) {
console.error(`Application version is invalid or empty: ${applicationVersion}`);
process.exit(1);
}

console.log(`Application Version: ${applicationVersion}`);

const signedApkPath = path.join(APK_OUTPUT_DIRECTORY, "app-release-signed.apk");
const unsignedApkPath = path.join(APK_OUTPUT_DIRECTORY, "app-release-unsigned.apk");

if (fs.existsSync(signedApkPath)) {
fs.unlinkSync(signedApkPath);
}

if (fs.existsSync(unsignedApkPath)) {
fs.unlinkSync(unsignedApkPath);
}

// ARM64 build process
updateBuildGradleWithABI("arm64-v8a");
if (fs.existsSync(path.join(DISTRIBUTION_DIRECTORY, "premium.js"))) {
fs.unlinkSync(path.join(DISTRIBUTION_DIRECTORY, "premium.js"));
}

const arm64PremiumFilePath = path.join(__dirname, "compiled_premium", "premium-arm64.jsc");
const destinationPremiumFilePath = path.join(DISTRIBUTION_DIRECTORY, "premium.jsc");

// Copy ARM64 premium file if it exists
if (fs.existsSync(arm64PremiumFilePath)) {
fs.copyFileSync(arm64PremiumFilePath, destinationPremiumFilePath);
}

// Build command
let buildCommand = `npx cap build android`;

if (signingProperties.storeFile && signingProperties.storePassword && signingProperties.keyAlias && signingProperties.keyPassword) {
console.log("Signing properties found. Signing APK...");
buildCommand += ` --keystorepath ${signingProperties.storeFile} --keystorepass ${signingProperties.storePassword} --keystorealias ${signingProperties.keyAlias} --keystorealiaspass ${signingProperties.keyPassword}`;
} else {
console.log("Signing properties not found. Building unsigned APK...");
}

buildCommand += ` --androidreleasetype APK --signing-type apksigner`;
executeCommand(buildCommand);

const signedApkMtime = fs.existsSync(signedApkPath) ? fs.statSync(signedApkPath).mtime : 0;
const unsignedApkMtime = fs.existsSync(unsignedApkPath) ? fs.statSync(unsignedApkPath).mtime : 0;

const outputApkPath = signedApkMtime > unsignedApkMtime ? signedApkPath : unsignedApkPath;
fs.renameSync(outputApkPath, path.join(RELEASE_DIRECTORY, `Megacubo_${applicationVersion}_android_arm64-v8a.apk`));

// ARM build process
updateBuildGradleWithABI("armeabi-v7a");

const armPremiumFilePath = path.join(__dirname, "compiled_premium", "premium-arm.jsc");

// Copy ARM premium file if it exists
if (fs.existsSync(armPremiumFilePath)) {
fs.copyFileSync(armPremiumFilePath, destinationPremiumFilePath);
}

console.log("Building ARM as last to keep project files with ARM as default instead of ARM64...");

// Resetting buildCommand for ARM build
buildCommand = `npx cap build android`;

if (signingProperties.storeFile && signingProperties.storePassword && signingProperties.keyAlias && signingProperties.keyPassword) {
buildCommand += ` --keystorepath ${signingProperties.storeFile} --keystorepass ${signingProperties.storePassword} --keystorealias ${signingProperties.keyAlias} --keystorealiaspass ${signingProperties.keyPassword}`;
}

buildCommand += ` --androidreleasetype APK --signing-type apksigner`;
executeCommand(buildCommand);

fs.renameSync(
outputApkPath,
path.join(RELEASE_DIRECTORY, `Megacubo_${applicationVersion}_android_armeabi-v7a.apk`)
);

console.log(`Finished: ${new Date().toLocaleString()}`);
};

buildApplication().catch(error => console.error("Build failed:", error));
Loading

0 comments on commit 257dd0c

Please sign in to comment.