Skip to content

Commit eef77e9

Browse files
committed
Fix for Android expansion files (.obb).
1 parent 1d5c9d0 commit eef77e9

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [4.0.1-SNAPSHOT]
6-
- Fix error serializing cb when not Ink library is used.
5+
## [4.0.1]
6+
- Fix error serializing cb when Ink library is not used.
7+
- Fix error creating resolution when there are atlases with subfolders.
8+
- Fix Android launcher to make expansion files (.obb) works again.
79

810
## [4.0.0]
911
- Fix error when android keystore path had spaces.

adventure-editor/src/main/resources/projectTmpl/android/src/AndroidLauncher

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,20 @@ public class AndroidLauncher extends AndroidApplication {
5454
if (Build.VERSION.SDK_INT >= 23) {
5555
if (checkSelfPermission(
5656
Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
57-
Log.v(TAG, "Permission is granted but .obb was not found.");
57+
Log.e(TAG, "Permission is granted but .obb was not found.");
5858
// TODO Download .obb
5959
exit();
6060
} else {
6161
Log.v(TAG, "Permission is revoked, requesting...");
62+
bladeEngine.setWaitingForPermissions(true);
6263
ActivityCompat.requestPermissions(AndroidLauncher.this,
6364
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 2);
6465
}
6566
} else { // permission is automatically granted on sdk<23 upon installation
66-
Log.v(TAG, "Permission is granted in Manifest (sdk<23) but .obb was not found.");
67+
Log.e(TAG, "Permission is granted in Manifest (sdk<23) but .obb was not found.");
6768
// TODO Download .obb
6869
exit();
6970
}
70-
} else {
71-
bladeEngine.createWithExpansion();
7271
}
7372
}
7473
}
@@ -85,15 +84,13 @@ public class AndroidLauncher extends AndroidApplication {
8584
boolean success = ((AndroidFiles) Gdx.files).setAPKExpansion(BuildConfig.EXPANSION_FILE_VERSION, 0);
8685

8786
if (!success) {
88-
Log.v(TAG, "Permission accepted but .obb was not found.");
87+
Log.e(TAG, "Permission accepted but .obb was not found.");
8988

9089
// TODO Download .obb
9190
exit();
92-
} else {
93-
bladeEngine.createWithExpansion();
94-
}
91+
}
9592
} else {
96-
Log.v(TAG, "Permission denied by user.");
93+
Log.e(TAG, "Permission denied by user.");
9794
exit();
9895
}
9996
break;
@@ -112,17 +109,40 @@ public class AndroidLauncher extends AndroidApplication {
112109
}
113110

114111
class AndroidEngine extends BladeEngine {
112+
private boolean waitingForPermissions = false;
113+
115114
@Override
116115
public void create() {
117-
if (BuildConfig.EXPANSION_FILE_VERSION == 0) {
118-
super.create();
116+
if(waitingForPermissions)
117+
return;
118+
119+
if (BuildConfig.EXPANSION_FILE_VERSION > 0) {
120+
boolean success = ((AndroidFiles) Gdx.files).setAPKExpansion(BuildConfig.EXPANSION_FILE_VERSION, 0);
121+
122+
if(!success) {
123+
Log.e(TAG, "Can not set APK expansion.");
124+
Gdx.app.exit();
125+
} else {
126+
Log.d(TAG, "Expansion file stablish successfully!");
127+
}
119128
}
129+
130+
super.create();
120131
}
121132

122-
public void createWithExpansion() {
123-
((AndroidFiles) Gdx.files).setAPKExpansion(BuildConfig.EXPANSION_FILE_VERSION, 0);
133+
@Override
134+
public void resume() {
135+
if(waitingForPermissions) {
136+
// returns from querying permissions
137+
bladeEngine.setWaitingForPermissions(false);
138+
bladeEngine.create();
139+
}
140+
141+
super.resume();
142+
}
124143

125-
super.create();
144+
public void setWaitingForPermissions(boolean v) {
145+
waitingForPermissions = v;
126146
}
127147
}
128148
}

adventure-editor/src/main/resources/projectTmpl/assets/BladeEngine.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ title=Blade Engine Adventure
22
ui_mode=two_buttons
33
inventory_pos=down
44
debug=false
5-
#load_gamestate=
6-
#play_recording=full
7-
#force_res=1920
5+
resolutions=1
6+
87

adventure-editor/src/main/resources/versions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ buildToolsVersion=29.0.2
55
libgdxVersion=1.9.10
66
roboVMGradlePluginVersion=2.3.8
77
roboVMVersion=2.3.8
8-
version=4.0.1-SNAPSHOT
8+
version=4.0.1

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=4.0.1-SNAPSHOT
1+
version=4.0.1
22
libgdxVersion=1.9.10
33
roboVMVersion=2.3.8
44
roboVMGradlePluginVersion=2.3.8

0 commit comments

Comments
 (0)