Skip to content

Commit

Permalink
Fix for Android expansion files (.obb).
Browse files Browse the repository at this point in the history
  • Loading branch information
bladecoder committed May 28, 2020
1 parent 1d5c9d0 commit eef77e9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

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

## [4.0.0]
- Fix error when android keystore path had spaces.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,20 @@ public class AndroidLauncher extends AndroidApplication {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(
Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
Log.v(TAG, "Permission is granted but .obb was not found.");
Log.e(TAG, "Permission is granted but .obb was not found.");
// TODO Download .obb
exit();
} else {
Log.v(TAG, "Permission is revoked, requesting...");
bladeEngine.setWaitingForPermissions(true);
ActivityCompat.requestPermissions(AndroidLauncher.this,
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 2);
}
} else { // permission is automatically granted on sdk<23 upon installation
Log.v(TAG, "Permission is granted in Manifest (sdk<23) but .obb was not found.");
Log.e(TAG, "Permission is granted in Manifest (sdk<23) but .obb was not found.");
// TODO Download .obb
exit();
}
} else {
bladeEngine.createWithExpansion();
}
}
}
Expand All @@ -85,15 +84,13 @@ public class AndroidLauncher extends AndroidApplication {
boolean success = ((AndroidFiles) Gdx.files).setAPKExpansion(BuildConfig.EXPANSION_FILE_VERSION, 0);

if (!success) {
Log.v(TAG, "Permission accepted but .obb was not found.");
Log.e(TAG, "Permission accepted but .obb was not found.");

// TODO Download .obb
exit();
} else {
bladeEngine.createWithExpansion();
}
}
} else {
Log.v(TAG, "Permission denied by user.");
Log.e(TAG, "Permission denied by user.");
exit();
}
break;
Expand All @@ -112,17 +109,40 @@ public class AndroidLauncher extends AndroidApplication {
}

class AndroidEngine extends BladeEngine {
private boolean waitingForPermissions = false;

@Override
public void create() {
if (BuildConfig.EXPANSION_FILE_VERSION == 0) {
super.create();
if(waitingForPermissions)
return;

if (BuildConfig.EXPANSION_FILE_VERSION > 0) {
boolean success = ((AndroidFiles) Gdx.files).setAPKExpansion(BuildConfig.EXPANSION_FILE_VERSION, 0);

if(!success) {
Log.e(TAG, "Can not set APK expansion.");
Gdx.app.exit();
} else {
Log.d(TAG, "Expansion file stablish successfully!");
}
}

super.create();
}

public void createWithExpansion() {
((AndroidFiles) Gdx.files).setAPKExpansion(BuildConfig.EXPANSION_FILE_VERSION, 0);
@Override
public void resume() {
if(waitingForPermissions) {
// returns from querying permissions
bladeEngine.setWaitingForPermissions(false);
bladeEngine.create();
}

super.resume();
}

super.create();
public void setWaitingForPermissions(boolean v) {
waitingForPermissions = v;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ title=Blade Engine Adventure
ui_mode=two_buttons
inventory_pos=down
debug=false
#load_gamestate=
#play_recording=full
#force_res=1920
resolutions=1


2 changes: 1 addition & 1 deletion adventure-editor/src/main/resources/versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ buildToolsVersion=29.0.2
libgdxVersion=1.9.10
roboVMGradlePluginVersion=2.3.8
roboVMVersion=2.3.8
version=4.0.1-SNAPSHOT
version=4.0.1
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=4.0.1-SNAPSHOT
version=4.0.1
libgdxVersion=1.9.10
roboVMVersion=2.3.8
roboVMGradlePluginVersion=2.3.8
Expand Down

0 comments on commit eef77e9

Please sign in to comment.