diff --git a/owncloudApp/build.gradle b/owncloudApp/build.gradle index c257f2183f4..6a468240df5 100644 --- a/owncloudApp/build.gradle +++ b/owncloudApp/build.gradle @@ -37,9 +37,10 @@ dependencies { implementation "androidx.sqlite:sqlite:$sqliteVersion" implementation "androidx.biometric:biometric:$biometricVersion" - implementation 'com.github.hannesa2:CVScanner:0.9' + implementation 'com.github.hannesa2:CVScanner:1.0' + implementation 'com.github.hannesa2:LiveEdgeDetection:1.3.1' - // Tests +// Tests testImplementation project(':owncloudTestUtil') testImplementation "junit:junit:$junitVersion" testImplementation "androidx.arch.core:core-testing:$archLifecycleVersion" diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt index 0705c20a105..ea79f7efcf0 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt @@ -104,6 +104,7 @@ import com.owncloud.android.utils.PermissionUtil import com.owncloud.android.utils.PreferenceUtils import info.hannes.cvscanner.CVScanner import info.hannes.github.AppUpdateHelper +import info.hannes.liveedgedetection.ScanConstants import kotlinx.android.synthetic.main.nav_coordinator_layout.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -228,7 +229,12 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn AppRater.appLaunched(this, packageName) } - AppUpdateHelper.checkForNewVersion(this, BuildConfig.GIT_USER, BuildConfig.GIT_REPOSITORY, BuildConfig.VERSION_NAME) + AppUpdateHelper.checkForNewVersion( + this, + BuildConfig.GIT_USER, + BuildConfig.GIT_REPOSITORY, + BuildConfig.VERSION_NAME + ) } override fun onPostCreate(savedInstanceState: Bundle?) { @@ -648,19 +654,48 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn // requestUploadOfFilesFromFileSystem(data,resultCode); } else if (requestCode == REQUEST_CODE__UPLOAD_SCANNED_DOCUMENT) { - if(resultCode == RESULT_OK) { - val scannedDocumentPath = data?.getStringExtra (CVScanner.RESULT_IMAGE_PATH); + if (resultCode == RESULT_OK) { + val scannedDocumentPath = data?.getStringExtra(CVScanner.RESULT_IMAGE_PATH) - filesUploadHelper!!.onActivityResult(scannedDocumentPath, object : FilesUploadHelper.OnCheckAvailableSpaceListener { + filesUploadHelper!!.onActivityResult( + scannedDocumentPath, + object : FilesUploadHelper.OnCheckAvailableSpaceListener { - override fun onCheckAvailableSpaceStart() = Unit + override fun onCheckAvailableSpaceStart() = Unit - override fun onCheckAvailableSpaceFinished(hasEnoughSpace: Boolean, capturedFilePaths: Array) { - if (hasEnoughSpace) { - requestUploadOfFilesFromFileSystem(capturedFilePaths, FileUploader.LOCAL_BEHAVIOUR_MOVE) + override fun onCheckAvailableSpaceFinished( + hasEnoughSpace: Boolean, + capturedFilePaths: Array + ) { + if (hasEnoughSpace) { + requestUploadOfFilesFromFileSystem(capturedFilePaths, FileUploader.LOCAL_BEHAVIOUR_MOVE) + } } - } - }) + }) + } + } else if (requestCode == REQUEST_CODE__UPLOAD_LIVEDGE_DOCUMENT) { + if (resultCode == RESULT_OK) { + data?.extras?.let { bundle -> + val scannedDocumentPath = bundle.getString(ScanConstants.SCANNED_RESULT) + + filesUploadHelper!!.onActivityResult(scannedDocumentPath, + object : FilesUploadHelper.OnCheckAvailableSpaceListener { + + override fun onCheckAvailableSpaceStart() = Unit + + override fun onCheckAvailableSpaceFinished( + hasEnoughSpace: Boolean, + capturedFilePaths: Array + ) { + if (hasEnoughSpace) { + requestUploadOfFilesFromFileSystem( + capturedFilePaths, + FileUploader.LOCAL_BEHAVIOUR_MOVE + ) + } + } + }) + } } } else if (requestCode == REQUEST_CODE__MOVE_FILES && resultCode == Activity.RESULT_OK) { handler.postDelayed( @@ -1836,7 +1871,8 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn const val REQUEST_CODE__MOVE_FILES = REQUEST_CODE__LAST_SHARED + 2 const val REQUEST_CODE__COPY_FILES = REQUEST_CODE__LAST_SHARED + 3 const val REQUEST_CODE__UPLOAD_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 4 - const val REQUEST_CODE__UPLOAD_SCANNED_DOCUMENT = REQUEST_CODE__LAST_SHARED + 5; + const val REQUEST_CODE__UPLOAD_SCANNED_DOCUMENT = REQUEST_CODE__LAST_SHARED + 5 + const val REQUEST_CODE__UPLOAD_LIVEDGE_DOCUMENT = REQUEST_CODE__LAST_SHARED + 6 const val RESULT_OK_AND_MOVE = Activity.RESULT_FIRST_USER } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java index bedb3441f42..0f0dd632833 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -78,6 +78,7 @@ public class ExtendedListFragment extends Fragment private FloatingActionButton mFabUpload; private FloatingActionButton mFabMkdir; private FloatingActionButton mFabScan; + private FloatingActionButton mFabEdge; // Save the state of the scroll in browsing private ArrayList mIndexes; @@ -117,6 +118,10 @@ public FloatingActionButton getFabScan() { return mFabScan; } + public FloatingActionButton getFabEdge() { + return mFabEdge; + } + public FloatingActionsMenu getFabMain() { return mFabMain; } @@ -188,6 +193,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mFabUpload = v.findViewById(R.id.fab_upload); mFabMkdir = v.findViewById(R.id.fab_mkdir); mFabScan = v.findViewById(R.id.fab_scan); + mFabEdge = v.findViewById(R.id.fab_edge); mCurrentListView = mListView; // list by default if (savedInstanceState != null) { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 58d469cb784..dd120a33b0f 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -29,6 +29,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.os.PowerManager; import android.preference.PreferenceManager; @@ -80,6 +81,8 @@ import com.owncloud.android.ui.preview.PreviewVideoFragment; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.PreferenceUtils; +import info.hannes.liveedgedetection.ScanConstants; +import info.hannes.liveedgedetection.activity.ScanActivity; import timber.log.Timber; import info.hannes.cvscanner.CVScanner; @@ -310,6 +313,7 @@ private void setFabLabels() { getFabUpload().setTitle(getResources().getString(R.string.actionbar_upload)); getFabMkdir().setTitle(getResources().getString(R.string.actionbar_mkdir)); getFabScan().setTitle(getResources().getString(R.string.scan_document)); + getFabEdge().setTitle(getResources().getString(R.string.scan_edge)); } /** @@ -334,6 +338,8 @@ public void onClick(View v) { final LinearLayout uploadFilesLinearLayout = uploadBottomSheet.findViewById(R.id.files_linear_layout); final LinearLayout scan_document_upload_linear_layout = uploadBottomSheet.findViewById(R.id.scan_document_upload_linear_layout); + final LinearLayout scan_edge_upload_linear_layout = + uploadBottomSheet.findViewById(R.id.scan_edge_upload_linear_layout); LinearLayout uploadFromCameraLinearLayout = uploadBottomSheet.findViewById(R.id.upload_from_camera_linear_layout); TextView uploadToTextView = uploadBottomSheet.findViewById(R.id.upload_to_text_view); @@ -359,6 +365,14 @@ public void onClick(View v) { dialog.hide(); return false; }); + scan_edge_upload_linear_layout.setOnTouchListener((v1, event) -> { + Intent intent = new Intent(getActivity(), ScanActivity.class); + intent.putExtra(ScanConstants.IMAGE_PATH, getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES).toString()); + getActivity().startActivityForResult(intent, FileDisplayActivity.REQUEST_CODE__UPLOAD_LIVEDGE_DOCUMENT); + + dialog.hide(); + return false; + }); uploadToTextView.setText(String.format(getResources().getString(R.string.upload_to), getResources().getString(R.string.app_name))); final BottomSheetBehavior uploadBottomSheetBehavior = @@ -383,6 +397,15 @@ public void onClick(View v) { FileDisplayActivity.REQUEST_CODE__UPLOAD_SCANNED_DOCUMENT); } }); + + getFabEdge().setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(getActivity(), ScanActivity.class); + intent.putExtra(ScanConstants.IMAGE_PATH, getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES).toString()); + getActivity().startActivityForResult(intent, FileDisplayActivity.REQUEST_CODE__UPLOAD_LIVEDGE_DOCUMENT); + } + }); } /** @@ -409,6 +432,14 @@ public boolean onLongClick(View v) { return true; } }); + + getFabEdge().setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + showSnackMessage(R.string.scan_edge); + return true; + } + }); } /** @@ -434,9 +465,11 @@ private void removeFabLabels() { getFabUpload().setTitle(null); getFabMkdir().setTitle(null); getFabScan().setTitle(null); + getFabEdge().setTitle(null); ((TextView) getFabUpload().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE); ((TextView) getFabMkdir().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE); ((TextView) getFabScan().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE); + ((TextView) getFabEdge().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE); } @Override diff --git a/owncloudApp/src/main/res/layout/list_fragment.xml b/owncloudApp/src/main/res/layout/list_fragment.xml index 8babed236d2..5b17502de55 100644 --- a/owncloudApp/src/main/res/layout/list_fragment.xml +++ b/owncloudApp/src/main/res/layout/list_fragment.xml @@ -119,6 +119,16 @@ fab:fab_size="mini" fab:fab_title="" /> + + + android:layout_marginBottom="20dp" + android:orientation="horizontal"> + + + + + + + + android:src="@drawable/ic_bottom_sheets_scanner" /> + android:text="@string/scan_edge" /> diff --git a/owncloudApp/src/main/res/values/strings.xml b/owncloudApp/src/main/res/values/strings.xml index 9e6c73ea0a3..fc1a5c812d1 100644 --- a/owncloudApp/src/main/res/values/strings.xml +++ b/owncloudApp/src/main/res/values/strings.xml @@ -606,6 +606,7 @@ No browser installed. Please install a Browser in order to allow a secure login. it was not found Scan document + Scan edge document It was not possible to know if OAuth2 is supported It was not possible to know the server base url