-
Notifications
You must be signed in to change notification settings - Fork 65
Export / Import #227
base: master
Are you sure you want to change the base?
Export / Import #227
Conversation
Added the buttons to the settings, added a modified startFileChooser method for selecting directories and a ExportSettings class (which currently causes "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference" to occur, still have to figure out why)
Finally figured out what caused all the problems and an ugly workaround for a part of it. When creating the class the constructor doesn't set some important variables regarding context, threads and probably some more. For the context I found the workaround of just passing the context of SettingsActivity to ExportSettings and using that instead of 'this' or 'getBaseContext()'. While that works for the Shared Preferences, it does not work for the FileChooser as that gets into problems with the aforementioned threads. But exporting works now, it saves the testFile.json to the Downloads folder. The JSON includes the settings and all devices but not the keyfiles themself. Also added JSON.simple to dependencies and changed Copyright notice in ExportSettings.java from 2019 to 2022.
The exporting and importing of the settings and devices works now, although there is still a lot to do, especially regarding validation during the import. The "created_at" and "modified_at" dates are no longer in exports as they can't be imported through the DeviceDbHelper's create method. I still have no clue on how to fix the exportSettings and importSettings problems regarding them not getting context/other important stuff, thus I still can't use the file/directory selection and have to use the "passing the context" and "hardcoding the filepath" workarounds.
Changed all hardcoded text to string values with default and German translations. Forgot to export/import commands, that's fully added now. Validation is also fully finished now, tested it with 2 devices and 2 commands and lot's of errors in the JSON and it seems to catch everything properly. Tested it on an emulator and on a real phone. Although more testing would definitely be nice. Fixed ExportSettings by actually reading the DB instead of assuming device IDs always start at 1. Also it now appends a number to the filename if the file already exists and I added better error feedback. Now all that's left is getting the filepicker to work, especially as it's needed to get file read/write permissions.
@Cook-I-T Just stumbled across this (in-progress PR), thanks for working on this! 👍 |
@clach04 I'm glad I can help with this great project, adding these features was a great way to learn Java and Android development. Sadly I can't fix the file/directory-picker problems myself due to having virtually no experience on how android apps work, so someone who actually knows what their doing would have to fix it. |
Please release. |
@kripper What do you mean by release? It is not fully functional now (as it uses hardcoded file paths for creating/restoring backups) and even if someone is nice enough and fixes it the whole rpicheck project is currently in limbo until someone else adopts it, so even if it gets finished and magically merged I doubt that there will be a new release with it anytime soon sadly (unless you compile it yourself). |
Adds requested feature #203
Exporting and importing all settings, devices and commands to/from JSON is fully functional, only the file/directory picker isn't working yet.