Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#172) Storage Access Framework Integration #292

Merged
merged 200 commits into from
Oct 31, 2019

Conversation

K1rakishou
Copy link

@K1rakishou K1rakishou commented Aug 10, 2019

Closes #172

UPDATE:
It's pretty much done, but not tested yet.

UPDATE 2 (9/7/19):
So I thought it was done but then I have found out that this shit is really fucking slow (like dozens of times slower than the regular Java File API) so I decided to try to figure out how to make this shit faster. And I have actually came up with a good idea. So now I'm rewriting some parts of this shit then I'm gonna write tests (I still have to figure out how to test SAF, apparently it's not that easy) and then release it.

UPDATE 3 (10/27/19):
It's fucking done!!!!!

I have fucked up and merged a wrong dev branch so now there are 200 commits. Rebase is impossible since it forces me to resolve conflicts for like 30 times in a row. Maybe you can use squash and merge?

This shit is done and tested a little bit on emulator with emulated sd-card. I don't have a real sd-card so I can't test it on a real device. If you want to help then here is a dev apk:

Kuroba-dev.zip

Things that should be tested:

  • Files/thread albums downloading.
  • Settings importing/exporting.
  • Local threads.
  • Moving saved files/local threads from one base directory to another.

Maybe I forgot something.
And please do not change these files (SavedThreadLoaderManager, ImportExportRepository, SavedThreadLoaderRepository) before this shit is merged otherwise the merge conflicts will be really hard to fix for me because those files were converted into kotlin.

- [x] Settings importing/exporting
- [x] Album images downloading
- [x] Threads downloading
- [x] Optimizing/Refactoring
- [x] Merging with dev
- [x] Testing

@K1rakishou K1rakishou changed the title (#172) WIP: SAF base API implementation (#172) WIP: Storage Access Framework Integration Aug 10, 2019
Now ExternalFiles uses DocumentFile().listFiles() to find a file inside a directory. It's implemented this way because, apparently, it's the only way to get a fully working DocumentFile that supports such operations as exists(), getName(), canRead()/canWrite(), delete() etc and which getParent() returns an actual file and not the null. This slow, but I don't know another way to do this so that everything works as expected.
Add more tests for AbstractFile
…a SAF)

Bring back SaveLocationController so that people can choose whether they want to use SAF or not (or in case of a bug)
… sub directories (site name/board code/boar

AbstractFile.findFile() now returns a new AbstractFile instead of DocumentFile
Fix RawFile.createNew() which would create a file when it should create directory
Implement RawFile.findFile()
Fix file/directory choosers would not remove the callback from the callback map when we have no activity to handle our intent. Also no message would have been shown in such case.
Give the use a choice when exporting settings whether he wants to open an existing settings file to overwrite it or create a new separate file.
Add ability to delete old base directory after moving files into the new one
Small fixes for thread album downloading where folder and file names would not be sanitized
…to (#172)-storage-access-framework

# Conflicts:
#	Kuroba/app/build.gradle
#	README.md
…n the paths thus resulting in losing the sub directories

Fix shared_prefs importing/exporting for dev builds (wrong appId was used)
Extract MediaSettingsControllerCallbacks into it's own class to avoid compilation errors
Additional active local threads checks before allowing the user to change base dir for local threads
Some strings that were forgotten about were moved to resources
…tempts to export a directory path that is located in a directory using SAF
@K1rakishou
Copy link
Author

It's done.

@K1rakishou K1rakishou changed the title (#172) WIP: Storage Access Framework Integration (#172) Storage Access Framework Integration Oct 27, 2019
});
// String[] paths = {destination.getFullPath()};

// FIXME: does not work. Who in their right mind even wants their downloaded images
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MediaScanner is a system level service that doesn't necessarily get touched by any Google program, assuming you have a ROM with all the Google stuff removed. It's used for interop between different apps and a computer, assuming you're connected using MTP. Basically, it's not useless and should be reimplemented at some point in time.

@@ -39,4 +39,20 @@ public static String extractFileExtensionFromImageUrl(String url) {
return url.substring(index + 1);
}

public static String dirNameRemoveBadCharacters(String dirName) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces should be allowed, see #43 and #101.

@Adamantcheese Adamantcheese merged commit 8e90850 into multi-feature Oct 31, 2019
@Adamantcheese
Copy link
Owner

I couldn't rebase it either (not that I have any fucking clue how rebasing works, but I couldn't even get it to the right commit to rebase from on my end). I don't mind the lack of squashing honestly. Debug APK should be building and ready for testing on your server soon.

@K1rakishou K1rakishou deleted the (#172)-storage-access-framework branch October 31, 2019 10:10
@K1rakishou
Copy link
Author

Oh shit, it's in!
Did you change the spaces filtering in the file paths? Because it may actually break when using SAF path because SAF encodes them with %20 that's why I have added filtering (well not filtering, it's changing them to "_").
And the setSubFolder should be tested too, because when I changed that behavior I tested it myself and it worked as expected. And after moving it app it may now start crashing. I will check it on the weekends.

@Adamantcheese
Copy link
Owner

I didn't change the space filtering or the MediaScanner stuff.

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

Successfully merging this pull request may close these issues.

[IMPROVEMENT] Introduce Storage Access Framework
3 participants