nibuen / SpaceAlertMissionGenerator

Mission Generator For Space Alert Board Game On Android
https://blog.iterary.com/
MIT License
15 stars 9 forks source link

fix external media access #49

Closed MarcusZuber closed 3 years ago

MarcusZuber commented 3 years ago

This seams to fix https://github.com/nibuen/SpaceAlertMissionGenerator/issues/48 at least up to Android 10.

nibuen commented 3 years ago

thanks for this @MarcusZuber ! Since you refactored to kotlin can you help point to line that fixes it so I can help validate?

nibuen commented 3 years ago

pretty sure you are missing permission requests still? This part of the code base is really ugly anyways I will help cleanup and merge the rest, thanks again for help

MarcusZuber commented 3 years ago

The only thing I changed (beside changing to kotlin and then doing some small adjustments due to this) was to change how the File object was created.

I changed this

File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/com.boarbeard");
FileOutputStream(new File(dir.getAbsolutePath() + "/readme.txt"));

to

FileOutputStream(File(context.getExternalFilesDir(null), "readme.txt")) that, which seams the new implementation in java.io.File,. For the other files and the reading of the file list I did it similar.

The permissions are still confusing me a little bit. The app newer asks about the storage permissions, and it even works, when they are never granted or removed. Probably, this is because only the app-related external storage (/sdcard/Android/data/com.boarbeard) is used?

nibuen commented 3 years ago

The only thing I changed (beside changing to kotlin and then doing some small adjustments due to this) was to change how the File object was created.

I changed this

File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/com.boarbeard");
FileOutputStream(new File(dir.getAbsolutePath() + "/readme.txt"));

to

FileOutputStream(File(context.getExternalFilesDir(null), "readme.txt")) that, which seams the new implementation in java.io.File,. For the other files and the reading of the file list I did it similar.

The permissions are still confusing me a little bit. The app newer asks about the storage permissions, and it even works, when they are never granted or removed. Probably, this is because only the app-related external storage (/sdcard/Android/data/com.boarbeard) is used?

Thanks, I checked it is no longer required for checking permissions on external directory, so I think we are good and I will just make this more friendly around it.