Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions engine/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ android {
}

signingConfigs {
debug {
// ... your debug keystore details here ...
// For example, if you have a debug.keystore in your project root
storeFile file('debug.keystore')
storePassword 'android' // Default password for debug keystore
keyAlias 'androiddebugkey' // Default alias
keyPassword 'android' // Default password for alias
}

release {
// only try to find keystore.properties when it's release build
if (project.gradle.startParameter.taskNames.any { it.toLowerCase().contains('release') }) {
/*
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
Expand All @@ -35,7 +44,7 @@ android {
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
*/
}
}

Expand All @@ -46,7 +55,10 @@ android {
outputFileName = "OpenBOR.apk";
}
}

debug {
// Do NOT add 'signingConfig signingConfigs.release' here
// It should inherit the default debug signing or you define 'signingConfig signingConfigs.debug'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand Down
Binary file added engine/android/app/debug.keystore
Binary file not shown.
24 changes: 19 additions & 5 deletions engine/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="preferExternal">

<!-- OpenGL ES 3.0 -->
Expand All @@ -22,24 +23,37 @@
<!-- CRxTRDude - Allows the use of a wake lock -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- Kratus (02-2023) - Added custom a style.xml to show a png image as splash screen -->
<!-- Kratus (03-2023) - Added the "CutoutMode" in the style.xml to adjust both screen/touch automatically -->
<!-- Kratus (03-2023) - Upgraded the icon system to adaptive method -->
<application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:theme="@style/Theme.Custom">

<!--
NEW: LauncherActivity - This will be your app's entry point.
It handles file selection and then starts GameActivity.
-->
<activity android:exported="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:name="org.openbor.engine.GameActivity">
android:name="org.openbor.engine.LauncherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!--
MODIFIED: GameActivity - Now started by LauncherActivity.
The MAIN and LAUNCHER intent filters have been removed from here.
-->
<activity android:exported="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
android:name="org.openbor.engine.GameActivity">
<!-- No intent-filter for MAIN and LAUNCHER here anymore -->
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,22 @@

import org.libsdl.app.SDLActivity;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.File;
import java.io.FileOutputStream;

import android.util.Log;
import android.os.Bundle;
import android.content.Context;
import android.os.Build;
import android.content.pm.PackageManager;
import android.content.pm.ApplicationInfo;
import android.os.PowerManager;
import android.os.PowerManager.*;
import android.os.PowerManager.WakeLock; // Explicitly import WakeLock if you want to be specific, or keep PowerManager.*
import android.view.View;
import android.view.WindowManager;
import android.content.res.*;
import android.Manifest;
//msmalik681 added imports for new pak copy!
import android.os.Environment;
import android.widget.Toast;
//msmalik681 added import for permission check
import androidx.core.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import android.view.WindowManager;
import android.os.Vibrator;
import android.os.VibrationEffect;
import android.view.*;

//needed to fix sdk 34+ crashing
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

/**
Expand Down Expand Up @@ -137,7 +120,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v("OpenBOR", "onCreate called");
//msmalik681 copy pak for custom apk and notify is paks folder empty
CopyPak();
// CopyPak();

//CRxTRDude - Added FLAG_KEEP_SCREEN_ON to prevent screen timeout.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Expand All @@ -151,102 +134,6 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

/**
* Proceed in copying paks files, or just prepare the destination Paks directory depending
* on which type of app it is.
*/
public void CopyPak()
{
try {
Context ctx = getContext();
Context appCtx = getApplicationContext();
String toast = null;

// if package name is literally "org.openbor.engine" then we have no need to copy any .pak files
if (appCtx.getPackageName().equals("org.openbor.engine"))
{
// Default output folder
File outFolderDefault = new File(Environment.getExternalStorageDirectory() + "/OpenBOR/Paks");

if (!outFolderDefault.isDirectory())
{
outFolderDefault.mkdirs();
toast = "Folder: (" + outFolderDefault + ") is empty!";
Toast.makeText(appCtx, toast, Toast.LENGTH_LONG).show();
}
else
{
String[] files = outFolderDefault.list();
if (files.length == 0)
{
// directory is empty
toast = "Paks Folder: (" + outFolderDefault + ") is empty!";
Toast.makeText(appCtx, toast, Toast.LENGTH_LONG).show();
}
}
}
// otherwise it acts like a dedicated app (commercial title, standalone app)
// intend to work with pre-baked single .pak file at build time
else
{
String version = null;
// versionName is "android:versionName" in AndroidManifest.xml
version = appCtx.getPackageManager().getPackageInfo(appCtx.getPackageName(), 0).versionName; // get version number as string
// set local output folder (primary shared/external storage)
File outFolder = new File(ctx.getExternalFilesDir(null) + "/Paks");
// set local output filename as version number
File outFile = new File(outFolder, version + ".pak");

// check if existing pak directory is actually directory, and pak file with matching version
// for this build is there, if not then delete all files residing in such
// directory (old pak files) preparing for updating new one
if (outFolder.isDirectory() && !outFile.exists()) // if local folder true and file does not match version empty folder
{
toast = "Updating please wait!";
String[] children = outFolder.list();
for (int i = 0; i < children.length; i++)
{
new File(outFolder, children[i]).delete();
}
}
else
{
toast = "First time setup, please wait...";
}

if (!outFile.exists())
{
Toast.makeText(appCtx, toast, Toast.LENGTH_LONG).show();
outFolder.mkdirs();

//custom pak should be saved in "app\src\main\assets\bor.pak"
InputStream in = ctx.getAssets().open("bor.pak");
FileOutputStream out = new FileOutputStream(outFile);

copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
}
}
} catch (IOException e) {
// not handled
} catch (Exception e) {
// not handled
}
}

private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1)
{
out.write(buffer, 0, read);
}
}

@Override
public void onLowMemory() {
super.onLowMemory();
Expand Down
Loading