Skip to content

Commit 52921e7

Browse files
authored
Merge pull request #340 from DCurrent/android_upddates_malik
Android Updates
2 parents f71c4fd + 17a3fa1 commit 52921e7

7 files changed

Lines changed: 279 additions & 136 deletions

File tree

engine/android/app/build.gradle

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ android {
2424
}
2525

2626
signingConfigs {
27+
debug {
28+
// ... your debug keystore details here ...
29+
// For example, if you have a debug.keystore in your project root
30+
storeFile file('debug.keystore')
31+
storePassword 'android' // Default password for debug keystore
32+
keyAlias 'androiddebugkey' // Default alias
33+
keyPassword 'android' // Default password for alias
34+
}
35+
2736
release {
2837
// only try to find keystore.properties when it's release build
29-
if (project.gradle.startParameter.taskNames.any { it.toLowerCase().contains('release') }) {
38+
/*
3039
def keystorePropertiesFile = rootProject.file("keystore.properties")
3140
def keystoreProperties = new Properties()
3241
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
@@ -35,7 +44,7 @@ android {
3544
keyPassword keystoreProperties['keyPassword']
3645
storeFile file(keystoreProperties['storeFile'])
3746
storePassword keystoreProperties['storePassword']
38-
}
47+
*/
3948
}
4049
}
4150

@@ -46,7 +55,10 @@ android {
4655
outputFileName = "OpenBOR.apk";
4756
}
4857
}
49-
58+
debug {
59+
// Do NOT add 'signingConfig signingConfigs.release' here
60+
// It should inherit the default debug signing or you define 'signingConfig signingConfigs.debug'
61+
}
5062
release {
5163
minifyEnabled false
5264
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

engine/android/app/debug.keystore

2.7 KB
Binary file not shown.

engine/android/app/src/main/AndroidManifest.xml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
android:installLocation="preferExternal">
45

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

25-
<!-- Kratus (02-2023) - Added custom a style.xml to show a png image as splash screen -->
26-
<!-- Kratus (03-2023) - Added the "CutoutMode" in the style.xml to adjust both screen/touch automatically -->
27-
<!-- Kratus (03-2023) - Upgraded the icon system to adaptive method -->
2826
<application android:label="@string/app_name"
2927
android:icon="@mipmap/ic_launcher"
3028
android:roundIcon="@mipmap/ic_launcher_round"
3129
android:allowBackup="true"
3230
android:hardwareAccelerated="true"
3331
android:theme="@style/Theme.Custom">
32+
33+
<!--
34+
NEW: LauncherActivity - This will be your app's entry point.
35+
It handles file selection and then starts GameActivity.
36+
-->
3437
<activity android:exported="true"
3538
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
3639
android:screenOrientation="landscape"
37-
android:name="org.openbor.engine.GameActivity">
40+
android:name="org.openbor.engine.LauncherActivity">
3841
<intent-filter>
3942
<action android:name="android.intent.action.MAIN" />
4043
<category android:name="android.intent.category.LAUNCHER" />
4144
</intent-filter>
4245
</activity>
46+
47+
<!--
48+
MODIFIED: GameActivity - Now started by LauncherActivity.
49+
The MAIN and LAUNCHER intent filters have been removed from here.
50+
-->
51+
<activity android:exported="true"
52+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
53+
android:screenOrientation="landscape"
54+
android:name="org.openbor.engine.GameActivity">
55+
<!-- No intent-filter for MAIN and LAUNCHER here anymore -->
56+
</activity>
4357
</application>
4458

45-
</manifest>
59+
</manifest>

engine/android/app/src/main/java/org/openbor/engine/GameActivity.java

Lines changed: 3 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,22 @@
2222

2323
import org.libsdl.app.SDLActivity;
2424

25-
import java.io.InputStream;
26-
import java.io.IOException;
27-
import java.io.OutputStream;
28-
import java.io.File;
29-
import java.io.FileOutputStream;
30-
3125
import android.util.Log;
3226
import android.os.Bundle;
3327
import android.content.Context;
3428
import android.os.Build;
35-
import android.content.pm.PackageManager;
3629
import android.content.pm.ApplicationInfo;
3730
import android.os.PowerManager;
38-
import android.os.PowerManager.*;
31+
import android.os.PowerManager.WakeLock; // Explicitly import WakeLock if you want to be specific, or keep PowerManager.*
3932
import android.view.View;
4033
import android.view.WindowManager;
41-
import android.content.res.*;
42-
import android.Manifest;
43-
//msmalik681 added imports for new pak copy!
44-
import android.os.Environment;
45-
import android.widget.Toast;
46-
//msmalik681 added import for permission check
47-
import androidx.core.content.ContextCompat;
48-
import androidx.core.app.ActivityCompat;
34+
import android.view.WindowManager;
4935
import android.os.Vibrator;
5036
import android.os.VibrationEffect;
51-
import android.view.*;
5237

53-
//needed to fix sdk 34+ crashing
5438
import android.content.BroadcastReceiver;
5539
import android.content.Intent;
5640
import android.content.IntentFilter;
57-
import android.os.Build;
5841
import org.jetbrains.annotations.Nullable;
5942

6043
/**
@@ -137,7 +120,7 @@ protected void onCreate(Bundle savedInstanceState) {
137120
super.onCreate(savedInstanceState);
138121
Log.v("OpenBOR", "onCreate called");
139122
//msmalik681 copy pak for custom apk and notify is paks folder empty
140-
CopyPak();
123+
// CopyPak();
141124

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

154-
/**
155-
* Proceed in copying paks files, or just prepare the destination Paks directory depending
156-
* on which type of app it is.
157-
*/
158-
public void CopyPak()
159-
{
160-
try {
161-
Context ctx = getContext();
162-
Context appCtx = getApplicationContext();
163-
String toast = null;
164-
165-
// if package name is literally "org.openbor.engine" then we have no need to copy any .pak files
166-
if (appCtx.getPackageName().equals("org.openbor.engine"))
167-
{
168-
// Default output folder
169-
File outFolderDefault = new File(Environment.getExternalStorageDirectory() + "/OpenBOR/Paks");
170-
171-
if (!outFolderDefault.isDirectory())
172-
{
173-
outFolderDefault.mkdirs();
174-
toast = "Folder: (" + outFolderDefault + ") is empty!";
175-
Toast.makeText(appCtx, toast, Toast.LENGTH_LONG).show();
176-
}
177-
else
178-
{
179-
String[] files = outFolderDefault.list();
180-
if (files.length == 0)
181-
{
182-
// directory is empty
183-
toast = "Paks Folder: (" + outFolderDefault + ") is empty!";
184-
Toast.makeText(appCtx, toast, Toast.LENGTH_LONG).show();
185-
}
186-
}
187-
}
188-
// otherwise it acts like a dedicated app (commercial title, standalone app)
189-
// intend to work with pre-baked single .pak file at build time
190-
else
191-
{
192-
String version = null;
193-
// versionName is "android:versionName" in AndroidManifest.xml
194-
version = appCtx.getPackageManager().getPackageInfo(appCtx.getPackageName(), 0).versionName; // get version number as string
195-
// set local output folder (primary shared/external storage)
196-
File outFolder = new File(ctx.getExternalFilesDir(null) + "/Paks");
197-
// set local output filename as version number
198-
File outFile = new File(outFolder, version + ".pak");
199-
200-
// check if existing pak directory is actually directory, and pak file with matching version
201-
// for this build is there, if not then delete all files residing in such
202-
// directory (old pak files) preparing for updating new one
203-
if (outFolder.isDirectory() && !outFile.exists()) // if local folder true and file does not match version empty folder
204-
{
205-
toast = "Updating please wait!";
206-
String[] children = outFolder.list();
207-
for (int i = 0; i < children.length; i++)
208-
{
209-
new File(outFolder, children[i]).delete();
210-
}
211-
}
212-
else
213-
{
214-
toast = "First time setup, please wait...";
215-
}
216-
217-
if (!outFile.exists())
218-
{
219-
Toast.makeText(appCtx, toast, Toast.LENGTH_LONG).show();
220-
outFolder.mkdirs();
221-
222-
//custom pak should be saved in "app\src\main\assets\bor.pak"
223-
InputStream in = ctx.getAssets().open("bor.pak");
224-
FileOutputStream out = new FileOutputStream(outFile);
225-
226-
copyFile(in, out);
227-
in.close();
228-
in = null;
229-
out.flush();
230-
out.close();
231-
out = null;
232-
}
233-
}
234-
} catch (IOException e) {
235-
// not handled
236-
} catch (Exception e) {
237-
// not handled
238-
}
239-
}
240-
241-
private void copyFile(InputStream in, OutputStream out) throws IOException {
242-
byte[] buffer = new byte[1024];
243-
int read;
244-
while ((read = in.read(buffer)) != -1)
245-
{
246-
out.write(buffer, 0, read);
247-
}
248-
}
249-
250137
@Override
251138
public void onLowMemory() {
252139
super.onLowMemory();

0 commit comments

Comments
 (0)