Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Export / Import #227

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Export / Import #227

wants to merge 6 commits into from

Conversation

Cook-I-T
Copy link

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.

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.
@clach04
Copy link

clach04 commented Mar 19, 2022

@Cook-I-T Just stumbled across this (in-progress PR), thanks for working on this! 👍

@Cook-I-T
Copy link
Author

@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.
I probably should have specified that in the PR description, sorry.

@kripper
Copy link

kripper commented Nov 22, 2022

Please release.

@Cook-I-T
Copy link
Author

@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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants