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

Fixed: Opening the zim file with kiwix fails to open(not showing the copy/move dialog). #4006

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Sep 23, 2024

Fixes #3941
Fixes #3997

  • The issue occurred because the logic for opening ZIM files was inside the KiwixReaderFragment, and if the user was on any other screen while using the application, this code was not triggered. As a result, the copy/move dialog was not shown. To resolve this, we moved the functionality to the KiwixMainActivity.
  • Fixed: ZIM file not moving/Copying on Android 14 tablet.
    • When opening the ZIM file via file picker or deep linking, we were obtaining the file path using the getZimFileFromUri() method to perform the renaming for the move functionality. However, on Android 14 tablets, the URI was not resolved correctly by this method, leading to a "ZIM file not found" error(This is a separate issue In Samsung tablet of Android 14, downloaded files can not be opened via file picker or deep linking. #4008).
    • To fix this issue, we removed the dependency on the getZimFileFromUri() method in the Play Store variant, as future Android versions may handle URIs differently. We refactored our code so that the copy/move functionality works independently of this method and now works directly with Android's provided URI.

Reference APK https://drive.google.com/file/d/16uwwoKWdF00rwhvAvR5musunKse4bBwD/view?usp=sharing https://drive.google.com/file/d/16uwwoKWdF00rwhvAvR5musunKse4bBwD/view?usp=sharing you can try this APK and confirms the behaviours of this functionality.

…copy/move dialog).

* The issue occurred because the logic for opening ZIM files was inside the KiwixReaderFragment, and if the user was on any other screen while using the application, this code was not triggered. As a result, the copy/move dialog was not shown. To resolve this, we moved the functionality to the KiwixMainActivity.
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 60.60606% with 13 lines in your changes missing coverage. Please review.

Project coverage is 58.13%. Comparing base (7e6e826) to head (fbb947c).

Files with missing lines Patch % Lines
...va/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt 73.68% 3 Missing and 2 partials ⚠️
...ile/nav/destination/library/CopyMoveFileHandler.kt 33.33% 2 Missing and 2 partials ⚠️
...le/nav/destination/library/LocalLibraryFragment.kt 50.00% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4006      +/-   ##
============================================
+ Coverage     57.81%   58.13%   +0.32%     
- Complexity     1599     1600       +1     
============================================
  Files           314      314              
  Lines         13109    13079      -30     
  Branches       1666     1658       -8     
============================================
+ Hits           7579     7604      +25     
+ Misses         4422     4364      -58     
- Partials       1108     1111       +3     
Flag Coverage Δ
58.13% <60.60%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

* When opening the ZIM file via file picker or deep linking, we were obtaining the file path using the getZimFileFromUri() method to perform the renaming for the move functionality. However, on Android 14 tablets, the URI was not resolved correctly by this method, leading to a "ZIM file not found" error.
* To fix this issue, we removed the dependency on the `getZimFileFromUri()` method in the Play Store variant, as future Android versions may handle URIs differently. We refactored our code so that the copy/move functionality works independently of this method and now works directly with Android's provided URI.
@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review September 24, 2024 18:35
@kelson42
Copy link
Collaborator

@MohitMaliFtechiz It works! But why my tablet behaves differently than other android 14?

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz It works! But why my tablet behave differently than other Android 14?

@kelson42 Tablet Uris are different than normal phones. I have checked with another real tablet and found the same issue there. These download URIs are different in tablets to make them compatible with scoped storage.

In tablets:
For example, if I open a zim file directly from the opera browser then it returns the URI like this: content://com.opera.browser.DownloadProvider/downloads/beer.stackexchange.com_en_all_2023-05.zim?hash=w4A3vMuc7l1FPQwk23rmbgvfPGJfhcj5FujW37NApdA%3D&mt=application%2Foctet-stream which opera gives with its own file provider.

When I directly open the downloaded zim file from the file manager it gives us this URI: content://com.android.providers.downloads.documents/document/msf%3A1000000057.

In phones:

Chrome Uri: content://media/external/downloads/2825

File Manager Uri: content://com.android.providers.downloads.documents/100059.

@kelson42
Copy link
Collaborator

kelson42 commented Sep 25, 2024

@MohitMaliFtechiz Please test this then for both tablet and phone within the CI. This very super basic should 100% work.

3 scenarios:

  • From Browser
  • From file navigator
  • Using the "+"

In mean obviously: testing in CI

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft September 26, 2024 05:35
* Improved the test case to remove the file from the emulator to free up device storage, as we do not have access to this file after running the test case, and it will remain in storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants