-
-
Notifications
You must be signed in to change notification settings - Fork 472
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
Fixed: In Samsung tablet of Android 14, downloaded files can not be opened via file picker or deep linking in non-PS variant. #4015
Conversation
91b906b
to
710272f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4015 +/- ##
============================================
+ Coverage 57.90% 57.99% +0.09%
- Complexity 1499 1513 +14
============================================
Files 315 315
Lines 13066 13125 +59
Branches 1660 1671 +11
============================================
+ Hits 7566 7612 +46
- Misses 4408 4415 +7
- Partials 1092 1098 +6 ☔ View full report in Codecov by Sentry. |
Why do we have to handle the files from the "Download" differently? Your code implies that with the information given in the ContentUri, you can neither open nor copy the file! This seems not normal at all! What will happen if this fallback is triggered for a file which is not in the |
@kelson42 We are using this fallback method to handle ZIM files opened directly from browsers and file pickers. While we can open files using the provided Uri, we need the actual file path for libkiwix. On Android 11 and above, file managers return a Uri with the In contrast, when opening files from locations outside the "Download" folder, either through the file picker or directly in the file manager, the returned Uri usually comes with the com.android.externalstorage.documents authority, which includes the correct file path. For example: However, when clicking on ZIM files directly from browsers, they use their own content provider to return a Uri, and the files are placed in the "Download" folder. That's why our fallback method specifically handles this case.
Our method was not designed to properly open the ZIM files when we directly click on the browsers since browsers give the Uris with their own file provider(Maybe this is a reason for scanning feature is there). Since Firefox can save files in other places like, in its own data directory and "Download" folders, on other places any browser does not put their files. Also, all browsers download their files in the Download directory since this directory is specially designed for downloading the files(And it is recommended, user-friendly, and perfect to work with SAF). So that's why Firefox will not save the downloaded files in other places. Here we are fixing two scenarios:
This is why our fallback method is focused on handling files from the "Download" folder. In my current testing, now this method is working fine with all Android 11 and above devices including all the phones and tablets. But I was testing with the older devices in those devices, there is also now all our functionality is working fine with browsers like it is working in the Android 11 and above. But there is some issue when we are opening directly from the file manager. Since below Android 11, most of the file managers are working fine. But in some devices when we clicks on the file in file manager they provide the ZIM file with their own file provider(e.g. in huawei phones). For this issue, I have placed a fix in this PR. Also, refactored the code to handle those cases, where the user selects the file from other folders, and the |
b68bcc1
to
7b273c0
Compare
Why do you talk about libkiwix here? We have to move/copy the ZIM file to the app directory, this is not done via libkiwix!
We don't open ZIM file file with libkiwix outside the app folders... so what is the point here? |
@kelson42 I think you misunderstood this PR, it is for the non-ps variant where we open the file from file path directly. In PS-variant the copy/move functionality is working fine which we have fixed in #4006.
This point is valid for PS variant, but here we are fixing the non-PS variant issue where we can open the files directly from storage with the file path as we have the |
…pened via file picker or deep linking. * When we open a file from different browsers, they provide a URI through their own file provider, and the content resolver cannot retrieve the file path for these types of URIs. To fix this issue, we have introduced a fallback method that returns the exact path of the file located in the Downloads folder. * Another issue we encountered on tablets is that the URIs are different from those on regular mobile devices, and our `documentProviderContentQuery` method could not return the path for these types of URIs from the Downloads folder. To fix this issue, we used our fallback method to retrieve the file path for these URIs.
…ctly accessed from the file manager. * Improved the method for resolving content type URIs to properly return the file path of the selected URI. * Refined the code and methods for improved clarity in their operations.
…ilePath for null fileNames.
…FilePath` methods to properly resolve the other folders uri.
Fixes #4008
documentProviderContentQuery
method could not return the path for these types of URIs from the Downloads folder. To fix this issue, we used our fallback method to retrieve the file path for these URIs.**Before Fix **
BeforeFix.mp4
After Fix
AfterFix.mp4
File opening issue from the file manager in Huawei phones:
Before fix:
BeforeFix.mp4
After Fix:
XRecorder_04102024_163619.mp4