MerginMaps / mobile

Mobile app for Mergin Maps 📲. Open QGIS projects and manage vector data on your phone, even offline 📶 (Android/iOS/Windows app)
https://merginmaps.com
GNU General Public License v2.0
294 stars 64 forks source link

PDF Viewing Feature #3353

Closed VitorVieiraZ closed 4 months ago

VitorVieiraZ commented 5 months ago

This feature can be used to open PDF files using the user’s system default application viewer, and can open formats such as links, PDFs, Docx, etc.

  1. In a form that allows multiline entries, add text to the "Form Layout" widgets. This can be done in the "Default Value" section, or within the "HtmlWidget" field.

  2. To embed a PDF file in the project, use the following HTML format:

    • For the "Default Value" section, enter:
    • '<a href="project://dummy.pdf">Open File</a>' (include the HTML code inside single quotes).
    • For direct entry in the "HtmlWidget", use:
    • <a href="project://dummy.pdf">Open File</a> (able to enter the HTML code without quotes).
  3. After synchronizing the project, check the app to ensure that the fields display the link reference correctly.

  4. HTML Link Invalid File
  5. When clicking into the HTML button, the PDF file will be opened using the default application of the system.

  6. Additional Note:

tomasMizera commented 5 months ago

Please merge master branch here to make CI working. We can then proceed with testing

github-actions[bot] commented 5 months ago

Pull Request Test Coverage Report for Build 9207444860

Details


Files with Coverage Reduction New Missed Lines %
input/app/ios/iosutils.cpp 2 17.24%
input/app/androidutils.cpp 12 4.76%
input/app/inpututils.cpp 261 50.74%
<!-- Total: 275 -->
Totals Coverage Status
Change from base Build 9161804447: -0.03%
Covered Lines: 7668
Relevant Lines: 12790

💛 - Coveralls
tomasMizera commented 5 months ago

Windows build is failing here @VitorVieiraZ, please check the error log

tomasMizera commented 5 months ago

Let's merge to master and then test from there

jozef-budac commented 5 months ago

I just tried this feature on the APK from this ticket and I always get an error message, that the file does not exist. Can you please check it?

My project is tc05_forms_derived and there is a tab called Files

VitorVieiraZ commented 4 months ago

I just tried this feature on the APK from this ticket and I always get an error message, that the file does not exist. Can you please check it?

My project is tc05_forms_derived and there is a tab called Files

Tests successfully conducted. In the case of a file inside a folder in the project directory, use the following format:

<a href="project://files/sample.pdf">Open PDF File inside folder "files"</a>

sample.pdf file inside 'files' folder

jozef-budac commented 4 months ago

@VitorVieiraZ I checked the project and I don't see a problem in the configuration. Do you see it? I tried it again and I was able to open TXT and DOCX files, but the PDF file was still unavailable. The configuration for it is '<a href="project://sample.pdf">Open PDF File</a>' and the sample.pdf file it is located in the root directory of the project. Am I doing something wrong?

https://github.com/MerginMaps/mobile/assets/83582181/7252006a-940b-4d14-80d1-c91b846c8c8e

jozef-budac commented 4 months ago

Now it looks great! I didn't find any more problems.

jozef-budac commented 4 months ago

Unfortunately, the files in sub-directories stopped working

https://github.com/MerginMaps/mobile/assets/83582181/dc0b2893-349c-443d-89cc-1459e166f010

tomasMizera commented 4 months ago

@VitorVieiraZ please merge master branch here - it will upload the build to iOS then too :)

tomasMizera commented 4 months ago

@jozef-budac Can you please retest this PR? We are mainly interested in PDFs so if they work we can merge it and fix other file types later. This is the build to test it with: https://github.com/MerginMaps/mobile/actions/runs/9158230910?pr=3353

jozef-budac commented 4 months ago

Right now I can't install the package

image

tomasMizera commented 4 months ago

@jozef-budac you can now test it on iOS too :)

tomasMizera commented 4 months ago

@jozef-budac you can now test it on iOS too :)

24.5.622711

tomasMizera commented 4 months ago

I can confirm that the apk is now invalid @VitorVieiraZ

tomasMizera commented 4 months ago

It says Failure, intent tag may have at most one action

tomasMizera commented 4 months ago

After removing these two lines https://github.com/MerginMaps/mobile/blob/d3293dbe25074d9b0f19d6f3796bdb13e5f4ef5a/cmake_templates/AndroidManifest.xml.in#L110-L111

the code works as expected for me in the tc05_forms_derived

jozef-budac commented 4 months ago

PDF files are working now of both Android and iOS> The docx and xlsx are not working on Android. But if only PDF is mandatory, we can go with this to production

tomasMizera commented 4 months ago

For me all of them worked :)

On Thu, 23 May 2024 at 14:39, Jozef Budáč @.***> wrote:

PDF files are working now. The docx and xlsx are not. But if only PDF is mandatory, we can go with this to production

— Reply to this email directly, view it on GitHub https://github.com/MerginMaps/mobile/pull/3353#issuecomment-2127005267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFLI4IRKLZ744SVUKYZLMCDZDXPONAVCNFSM6AAAAABGUMKYDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRXGAYDKMRWG4 . You are receiving this because your review was requested.Message ID: @.***>

jozef-budac commented 4 months ago

Here is a video from Android 14

https://github.com/MerginMaps/mobile/assets/83582181/e9d59326-429a-4827-9fe4-dd8d3a4a3ea5

tomasMizera commented 4 months ago

@jozef-budac do you have some app to open xls installed? If yes, we can debug then. Anyways,let's merge it as pdfs are working now :)

jozef-budac commented 4 months ago

@tomasMizera Yes I have programs to open such files. In some of the previous APKs I was able to open the files. I wrote a note "Now it looks great! I didn't find any more problems." But then it doesn't work anymore.