Skip to content

Commit

Permalink
Move /sdcard/lovegame directory.
Browse files Browse the repository at this point in the history
See love2d#194

This also mean that external storage permission is only requested only when running Marshmallow or earlier.
  • Loading branch information
MikuAuahDark committed Oct 2, 2020
1 parent be561b9 commit 98c2df2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ android {
buildToolsVersion '30.0.2'
ndkVersion '21.3.6528147'
defaultConfig {
applicationId "org.love2d.android"
applicationId 'org.love2d.android'
versionCode 29
versionName "11.3a"
versionName '11.3a'
minSdkVersion 14
targetSdkVersion 30
}
Expand All @@ -27,7 +27,7 @@ android {
}
embed {
dimension 'mode'
applicationIdSuffix "embed"
applicationIdSuffix '.embed'
}
}
lintOptions {
Expand Down
6 changes: 1 addition & 5 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@
# public *;
#}

-keep class br.com.tapps.love.LoveActivity { *; }

-keepclassmembers class br.com.tapps.love.LoveActivity {
public com.naef.jnlua.LuaState createLuaState();
}
-keep class org.love2d.android.GameActivity { *; }
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

<!-- OpenGL ES 2.0 -->
Expand Down
11 changes: 6 additions & 5 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#Thu Oct 01 16:43:18 SGT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
6 changes: 3 additions & 3 deletions love/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
minSdkVersion 14
resValue "bool", "embed", "false"
resValue 'bool', 'embed', 'false'
externalNativeBuild {
ndkBuild {
arguments "-j4"
Expand Down Expand Up @@ -43,7 +43,7 @@ android {
}
embed {
dimension 'mode'
resValue "bool", "embed", "true"
resValue 'bool', 'embed', 'true'
}
}
sourceSets {
Expand All @@ -61,7 +61,7 @@ android {
}
externalNativeBuild {
ndkBuild {
path "src/jni/Android.mk"
path 'src/jni/Android.mk'
}
}
lintOptions {
Expand Down
15 changes: 5 additions & 10 deletions love/src/main/java/org/love2d/android/GameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,13 @@ public void onClick(DialogInterface dialog, int id) {
}

protected void checkLovegameFolder() {
// If no game.love was found fall back to the game in <external storage>/lovegame
// if using normal or playstore build
// If no game.love was found and embed flavor is not used, fall back to the game in
// <external storage>/Android/data/<package name>/games/lovegame
if (!embed) {
Log.d("GameActivity", "fallback to lovegame folder");
if (hasExternalStoragePermission()) {
File ext = Environment.getExternalStorageDirectory();
if ((new File(ext, "/lovegame/main.lua")).exists()) {
gamePath = ext.getPath() + "/lovegame/";
}
} else {
Log.d("GameActivity", "Cannot load game from /sdcard/lovegame: permission not granted");
File ext = getExternalFilesDir("games");
if ((new File(ext, "/lovegame/main.lua")).exists()) {
gamePath = ext.getPath() + "/lovegame/";
}
}
}
Expand Down Expand Up @@ -295,7 +291,6 @@ public static String getGamePath() {
} else {
Log.d("GameActivity", "cannot open game " + gamePath + ": no external storage permission given!");
}

} else {
self.checkLovegameFolder();
if (gamePath.length() > 0)
Expand Down

0 comments on commit 98c2df2

Please sign in to comment.