This commit is contained in:
Yair Morgenstern
2021-04-21 22:12:46 +03:00
parent 2b6c9e7ec0
commit 55ef131fb2
34 changed files with 161 additions and 39 deletions

View File

@ -22,12 +22,12 @@ open class AndroidLauncher : AndroidApplication() {
}
MultiplayerTurnCheckWorker.createNotificationChannels(applicationContext)
// Only allow mods on KK+, to avoid READ_EXTERNAL_STORAGE permission earlier versions need
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
copyMods()
// Only allow mods on KK+, to avoid READ_EXTERNAL_STORAGE permission earlier versions need
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
copyMods()
val externalfilesDir = getExternalFilesDir(null)
if(externalfilesDir!=null) GameSaver.externalFilesDirForAndroid = externalfilesDir.path
}
if (externalfilesDir != null) GameSaver.externalFilesDirForAndroid = externalfilesDir.path
}
val config = AndroidApplicationConfiguration().apply { useImmersiveMode = true; }
val androidParameters = UncivGameParameters(
@ -36,16 +36,16 @@ open class AndroidLauncher : AndroidApplication() {
fontImplementation = NativeFontAndroid(ORIGINAL_FONT_SIZE.toInt()),
customSaveLocationHelper = customSaveLocationHelper
)
val game = UncivGame ( androidParameters )
val game = UncivGame(androidParameters)
initialize(game, config)
}
/**
* Copies mods from external data directory (where users can access) to the private one (where
* libGDX reads from). Note: deletes all files currently in the private mod directory and
* replaces them with the ones in the external folder!)
*/
private fun copyMods() {
/**
* Copies mods from external data directory (where users can access) to the private one (where
* libGDX reads from). Note: deletes all files currently in the private mod directory and
* replaces them with the ones in the external folder!)
*/
private fun copyMods() {
// Mod directory in the internal app data (where Gdx.files.local looks)
val internalModsDir = File("${filesDir.path}/mods")
@ -74,8 +74,8 @@ open class AndroidLauncher : AndroidApplication() {
cancel(MultiplayerTurnCheckWorker.NOTIFICATION_ID_INFO)
cancel(MultiplayerTurnCheckWorker.NOTIFICATION_ID_SERVICE)
}
} catch (ex: Exception) {
}
catch (ex:Exception){}
super.onResume()
}