Repository navigation
feat(scan): New Document Scanning, powered by FairScan #17710
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
Draft
PhilLab
wants to merge
13
commits into
master
Choose a base branch
from
ph/fairscan_integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8e9b0d5
refactor(scan): remove PDF-from-images background job
PhilLab c4f3496
refactor(scan): remove built-in multi-page scan screen
PhilLab 0d583f5
refactor(scan): remove :appscan module and its reflection wiring
PhilLab 89f0af4
WIP feat(scan): Include FairScan via mavenLocal
PhilLab 2e086a5
WIP feat(scan): CI builds Fairscan to local maven
PhilLab 3303a7f
feat(scan): Start onboard FairScan component, if external app not ins…
PhilLab 993a6ae
fix(scan): finish embedded FairScan scan-to-PDF upload
PhilLab 63873dd
Manually added key for dependency sh.calvin.reorderable
PhilLab 9b740a2
Updated dependency verification data
PhilLab e027342
feat(scan): Using library fork of FairScan, available on Jitpack
PhilLab f1dec69
Added verification metadata for fairscan library Jitpack artifact
PhilLab e6f6d2c
test(scan): Made external/internal distinction unit-testable
PhilLab 1ec6dbb
test(scan): Added instrumented test
PhilLab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
app/src/androidTest/java/com/nextcloud/client/documentscan/GeneratePDFUseCaseTest.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
app/src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentScanIT.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| package com.owncloud.android.ui.fragment | ||
|
|
||
| import android.app.Activity | ||
| import android.app.Instrumentation | ||
| import android.content.Intent | ||
| import android.os.SystemClock | ||
| import androidx.test.core.app.launchActivity | ||
| import androidx.test.espresso.intent.Intents | ||
| import androidx.test.espresso.intent.Intents.intending | ||
| import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction | ||
| import com.nextcloud.client.account.UserAccountManagerImpl | ||
| import com.nextcloud.test.TestActivity | ||
| import com.owncloud.android.AbstractIT | ||
| import com.owncloud.android.datamodel.UploadsStorageManager | ||
| import com.owncloud.android.db.OCUpload | ||
| import com.nextcloud.client.jobs.upload.FileUploadWorker | ||
| import org.junit.After | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Assert.fail | ||
| import org.junit.Before | ||
| import org.junit.Test | ||
|
|
||
| class OCFileListFragmentScanIT : AbstractIT() { | ||
|
|
||
| private lateinit var uploadsStorageManager: UploadsStorageManager | ||
|
|
||
| @Before | ||
| fun setUp() { | ||
| Intents.init() | ||
| uploadsStorageManager = UploadsStorageManager( | ||
| UserAccountManagerImpl.fromContext(targetContext), | ||
| targetContext.contentResolver | ||
| ) | ||
| uploadsStorageManager.removeUploads(account.name) | ||
| } | ||
|
|
||
| @After | ||
| fun tearDown() { | ||
| Intents.release() | ||
| uploadsStorageManager.removeUploads(account.name) | ||
| } | ||
|
|
||
| @Test | ||
| fun scanStartsEmbeddedFairScanWithAutoDeletionDisabled() { | ||
| scan(Activity.RESULT_CANCELED, null) | ||
|
|
||
| val scanIntent = Intents.getIntents().single { it.action == FAIRSCAN_ACTION } | ||
| assertEquals(FAIRSCAN_ACTIVITY, scanIntent.component?.className) | ||
| assertEquals(FAIRSCAN_ACTION, scanIntent.action) | ||
| assertTrue(scanIntent.getBooleanExtra(FAIRSCAN_EXTRA_DISABLE_AUTO_DELETION, false)) | ||
| } | ||
|
|
||
| @Test | ||
| fun cancelledScanDoesNotUpload() { | ||
| scan(Activity.RESULT_CANCELED, null) | ||
| SystemClock.sleep(NO_UPLOAD_GRACE_MILLIS) | ||
|
|
||
| assertEquals(0, uploadsStorageManager.getAllStoredUploads().size) | ||
| } | ||
|
|
||
| @Test | ||
| fun embeddedScanResultIsQueuedForUploadWithMoveBehaviour() { | ||
| val pdf = createFile("scan.pdf", 1) | ||
| scan(Activity.RESULT_OK, Intent().putExtra(FAIRSCAN_EXTRA_PDF_PATH, pdf.absolutePath)) | ||
|
|
||
| val upload = waitForUpload() | ||
| assertEquals(pdf.absolutePath, upload.localPath) | ||
| assertTrue(upload.remotePath.startsWith("/")) | ||
| assertTrue(upload.remotePath.endsWith(".pdf")) | ||
| assertEquals(FileUploadWorker.LOCAL_BEHAVIOUR_MOVE, upload.localAction) | ||
| assertEquals(account.name, upload.accountName) | ||
| } | ||
|
|
||
| private fun scan(resultCode: Int, data: Intent?) { | ||
| launchActivity<TestActivity>().use { scenario -> | ||
| intending(hasAction(FAIRSCAN_ACTION)).respondWith(Instrumentation.ActivityResult(resultCode, data)) | ||
| scenario.onActivity { activity -> | ||
| val fragment = OCFileListFragment() | ||
| activity.addFragment(fragment) | ||
| activity.supportFragmentManager.executePendingTransactions() | ||
| fragment.scanDocUploadFromApp() | ||
| } | ||
| SystemClock.sleep(RESULT_DELIVERY_MILLIS) | ||
| } | ||
| } | ||
|
|
||
| private fun waitForUpload(): OCUpload { | ||
| val deadline = SystemClock.elapsedRealtime() + WAIT_TIMEOUT_MILLIS | ||
| while (SystemClock.elapsedRealtime() < deadline) { | ||
| uploadsStorageManager.getAllStoredUploads().firstOrNull()?.let { return it } | ||
| SystemClock.sleep(WAIT_POLL_INTERVAL_MILLIS) | ||
| } | ||
| fail("No upload was queued for the scanned PDF") | ||
| error("unreachable") | ||
| } | ||
|
|
||
| private companion object { | ||
| const val FAIRSCAN_ACTIVITY = "org.fairscan.app.MainActivity" | ||
| const val FAIRSCAN_ACTION = "org.fairscan.app.action.SCAN_TO_PDF" | ||
| const val FAIRSCAN_EXTRA_DISABLE_AUTO_DELETION = "org.fairscan.app.extra.DISABLE_AUTO_DELETION" | ||
| const val FAIRSCAN_EXTRA_PDF_PATH = "org.fairscan.app.extra.PDF_PATH" | ||
| const val RESULT_DELIVERY_MILLIS = 1_000L | ||
| const val NO_UPLOAD_GRACE_MILLIS = 1_000L | ||
| const val WAIT_TIMEOUT_MILLIS = 10_000L | ||
| const val WAIT_POLL_INTERVAL_MILLIS = 200L | ||
| } | ||
| } |
50 changes: 0 additions & 50 deletions
50
app/src/androidTestGeneric/java/com/nextcloud/client/di/VariantModuleTest.kt
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
app/src/androidTestGplay/java/com/nextcloud/client/di/VariantModuleTest.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.