ogarcia / opensudoku

Open Source Sudoku game for Android.
GNU General Public License v3.0
328 stars 144 forks source link

Fix import and export of sudokus #104

Closed autinerd closed 3 years ago

autinerd commented 3 years ago

Fixes #103 partly.

Because Android 11 changes a lot in terms of accessing files in external storage, there have to be some changes in handling import and export.

Export: Uses the Android system file picker to let to user select a path and writes the data into that file. Import: Uses the Android system file picker to let the user select a file to import. Because the file name is not reliable, decides the format based on the first 512 bytes of the file content.

One downside is that the minimum Android version will be KitKat.

autinerd commented 3 years ago

It has now following behavior:

ogarcia commented 3 years ago

This is a great PR and I think that we can drop support to versions prior to kikat, but the import seems not work well if you try to open a file directly from web browser. Steps to reproduce:

  1. Open app in emulator with Kitkat
  2. Go to sudoku lists
  3. Press in Get More Puzzles Online
  4. Press in any file of list, for example in Easy (100 puzzles)
  5. App crash

Can you try to fix this crash?

autinerd commented 3 years ago

I have now removed the http intent filters, because for download a extra background task would be needed. So now the browser downloads the file. The file opening in the File Explorer just stooped working again for me, so I added now OpenSudoku in the Share panel, so that you can share the file you want to import and it will be imported.

The file opening is very horrible, you never know if it will work or not.

ogarcia commented 3 years ago

The problem in File Explorer is caused because it don't send full filename so in some android devices (and versions) works and in others not.

With latest change the import don't work anymore because String action = intent.getAction(); can be null :hankey:

autinerd commented 3 years ago

With latest change the import don't work anymore because String action = intent.getAction(); can be null

Is fixed :)

MrGibbage commented 3 years ago

Worked perfectly on my Pixel 5/Android 11. Thanks!