Skip to content

Conversation

@PhilLab
Copy link
Contributor

@PhilLab PhilLab commented Feb 1, 2026

  • Tests written, or not not needed

Built-in scanning is not available for all build variants - e.g. not for "generic", which is the flavor for the F-Droid release. It doesn't allow the non-reproducible TinyOpenCV build.

If this is the case, we are checking whether the open source scanning app FairScan is available (https://github.com/pynicolas/FairScan) and open that one for scanning.

This approach was selected based on the discussion here: #12624 (comment)

Result

Screen_recording_20260201_143916.webm
  1. I thought about giving this menu entry a dedicated title, e.g. "Scan document from FairScan", but I decided against it - it's just more code to maintain and at the same time doesn't provide value to the user. Also it is not scalable: what if we add fallbacks to other scanner apps as well? So let's stick to the standard menu entry text.
  2. I also had in mind to make this menu entry an "Install FairScan" button, in case there is no appscan and FairScan also is not installed. But that felt too intrusive.

Behind the scenes

  1. To simplify the detection of the appscan project, a reflection-based approach was implemented. See the messages of the first two commits for why I am proposing this. If you don't agree with this approach, I can remove the commits from the PR, they don't impact the feature itself
  2. FairScan delivers a short-lived URI which we then use to upload the file. Originally, the filename is an "ugly" unix timestamp - you can also see this in above recording, from a prior attempt: 1769952395766.pdf.
  3. Notably, FairScan's Intent feature is still experimental (see their README) but I'd still propose to include it, because:
    • For Non-F-Droid users, all stays the same and uses the built-in scanner
    • For F-Droid users, the menu entry will only appear if FairScan is installed, so the area of impact is quite small.
    • The intent integration is very basic so it is not very likely that FairScan's next iteration will change it in a way which is incompatible with this.
    • If it breaks by changing the intent URI - the button will simply not show anymore so we are not worse off than the status-quo.
    • If it breaks otherwise, then we are still not worse off than having no scanner in the F-Droid variant at all.

To enable the document scanning feature for a specific build variant,
previously two places had to be adjusted:
- The build.gradle.kts, in the "region AppScan"
- A variant-specific implementation for VariantModule.kt

Now, only the first one is required and the VariantModule.kt handles it
automatically.
Benefits: Only a single place to change. And no code duplication
Drawback: Reflection is a bit more brittle - it all depends on the package
          and class name to not change

Signed-off-by: Philipp Hasper <[email protected]>
Testing two main variants, one without appscan, and one with it. However,
as of now the automated test for the gplay flavor does not run
automatically in the CI, as we only test the generic flavor. So the test's
purpose was just to verify the reflection approach locally.

Signed-off-by: Philipp Hasper <[email protected]>
Built-in scanning is not available for all build variants - e.g. not for
"generic", which is the flavor for the F-Droid release. It doesn't allow
the non-reproducible TinyOpenCV build.

If this is the case, we are checking whether the open source scanning app
FairScan is available (https://github.com/pynicolas/FairScan) and open
that one for scanning.

The declaration in the AndroidManifest is required since
Android 11 (API level 30), otherwise the Intent would always be null.
See https://developer.android.com/training/package-visibility

Signed-off-by: Philipp Hasper <[email protected]>
Before, the filename from FairScan just was <unixTimestamp>.pdf. Now,
we are giving it our own timestamped name, just like we do for images and
videos captured via the camera intent.

This uses the same fileDisplayNameTransformer as PR #16298

Signed-off-by: Philipp Hasper <[email protected]>
@PhilLab PhilLab changed the title If built-in scanning is not available, check for FairScan Use FairScan, if built-in document scanning is not available Feb 1, 2026
@github-actions
Copy link

github-actions bot commented Feb 1, 2026

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16427.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@PhilLab PhilLab changed the title Use FairScan, if built-in document scanning is not available feat(doc-scan): Query for FairScan, if built-in scanning not available Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants