Compare commits

...
Author SHA1 Message Date
tobiasKaminsky 54fd22ffa3 Catch RejectedExecutionException
Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-15 09:34:48 +02:00
Álvaro Brey 31c84d57e9 Merge pull request #10385 from nextcloud/account-culling
Migrate Account to User in some APIs
2022-06-14 21:32:49 +02:00
Álvaro Brey 84aa239c9a Merge pull request #10391 from nextcloud/updateSharIcon
Update share icon when sharing link directly
2022-06-14 21:24:11 +02:00
Álvaro Brey 64998aca10 Merge pull request #10386 from nextcloud/dependabot/gradle/com.github.spotbugs.snom-spotbugs-gradle-plugin-5.0.8
Bump spotbugs-gradle-plugin from 5.0.7 to 5.0.8
2022-06-14 21:20:20 +02:00
Álvaro Brey 17ebc23621 Merge pull request #10377 from nextcloud/groupfolderCannotBeEncrypted
Groupfolders cannot be encrypted
2022-06-14 16:00:36 +02:00
tobiasKaminsky d971bc849c Update share icon when sharing link directly
Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-14 08:46:20 +02:00
Tobias Kaminsky 8db4536941 Merge pull request #10382 from nextcloud/changelog-master-stable-3.20.3
Add changelog for 3.20.3
2022-06-14 07:23:59 +02:00
Nextcloud bot 9a1158d5a0 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-14 04:18:12 +00:00
dependabot[bot] 9de14a7fbd Bump spotbugs-gradle-plugin from 5.0.7 to 5.0.8
Bumps [spotbugs-gradle-plugin](https://github.com/spotbugs/spotbugs-gradle-plugin) from 5.0.7 to 5.0.8.
- [Release notes](https://github.com/spotbugs/spotbugs-gradle-plugin/releases)
- [Commits](https://github.com/spotbugs/spotbugs-gradle-plugin/compare/5.0.7...5.0.8)

---
updated-dependencies:
- dependency-name: com.github.spotbugs.snom:spotbugs-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-14 01:09:42 +00:00
Chris Narkiewicz edc8149c1f Migrate Account to User in some APIs
Migrate remaining Account uses to User model when it was
possible without wider refactoring.

Signed-off-by: Chris Narkiewicz <[email protected]>
2022-06-13 23:37:16 +01:00
Álvaro Brey 24ab566d3b Add changelog for 3.20.3
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-13 16:18:02 +02:00
tobiasKaminsky 60757a1853 Groupfolders cannot be encrypted
added test showing folder types

Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-13 16:17:28 +02:00
Tobias Kaminsky 7854d48559 Merge pull request #10367 from nextcloud/moveMD5
move md5 function to tests, as md5 should never be used is production
2022-06-13 14:38:10 +02:00
Álvaro Brey 42e79cb176 Merge pull request #10313 from nextcloud/chore/detekt-cleanup-again
Fix last remaining unsuppressed detekt issues
2022-06-13 14:31:07 +02:00
Tobias Kaminsky fcbbd45ec7 Merge pull request #10379 from nextcloud/repo-sync/android-common/master
🔄 Synced file(s) with nextcloud/android-common
2022-06-13 13:40:44 +02:00
Álvaro Brey e2ea977288 Lower detekt maxIssues to 0
Finally no more issues!

Signed-off-by: Álvaro Brey <[email protected]>
2022-06-13 10:51:38 +00:00
Álvaro Brey 43215a0833 FileDetailsSharingProcessFragment: clean up last detekt issues
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-13 10:51:38 +00:00
Álvaro Brey 29bf03a4e4 Merge pull request #10376 from nextcloud/feat/workflow-auto-update-command-rebase.yml
Updating command-rebase.yml workflow from template
2022-06-13 12:27:17 +02:00
Álvaro Brey 1917729598 Remove duplicated codeql analysis workflow
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-13 12:06:42 +02:00
nextcloud-android-bot aa40ba3d5c 🔄 Synced local '.github/workflows/' with remote 'config/workflows/' 2022-06-13 10:03:55 +00:00
Nextcloud bot c56ccc8363 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-12 04:18:20 +00:00
Nextcloud bot 14ca116b86 Updating command-rebase.yml workflow from template
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-11 15:15:00 +00:00
Álvaro Brey d432c8e46f Merge pull request #10359 from nextcloud/enterCreatedFolder
When copy/move a file and creating a new folder we now go directly into this freshly created folder
2022-06-10 15:58:52 +02:00
Álvaro Brey 0f8a5b1bf3 Merge pull request #10353 from nextcloud/fix/invalid-folder-no-mediascan
FileDataStorageManager: don't add files to media scan in android 11+
2022-06-10 15:56:40 +02:00
Álvaro Brey ede4790927 Merge pull request #10352 from nextcloud/fix/oob-gallery-scroll
GalleryFastScrollViewHelper: fix index out of bounds in getScrollOffset
2022-06-10 13:59:59 +02:00
tobiasKaminsky ffdb26b4be move md5 function to tests, as md5 should never be used is production
Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-10 07:57:44 +02:00
Tobias Kaminsky 8b79aa17f4 Merge pull request #10364 from nextcloud/changelog-master-stable-3.20.2
Add changelog for 3.20.2
2022-06-10 07:10:52 +02:00
Tobias Kaminsky c8e720a4d9 Merge pull request #9356 from nextcloud/tobiasKaminsky-patch-2
Create codeql-analysis.yml
2022-06-10 06:51:53 +02:00
tobiasKaminsky d536b9fea7 Add changelog for 3.20.2
Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-09 15:55:26 +02:00
Tobias KaminskyandÁlvaro Brey 451694d0fb Update .github/workflows/codeql-analysis.yml
Co-authored-by: Álvaro Brey <[email protected]>
2022-06-09 12:48:30 +02:00
Álvaro Brey e644b12aee Merge pull request #10355 from nextcloud/fix/synced-folders-adapter-performance
SyncedFoldersActivity: don't refresh entire adapter when toggling a folder from dialog
2022-06-09 11:44:07 +02:00
Álvaro Brey Vilas b94c776d6e CodeQL: format file and remove extra comments
[skip ci]

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-06-09 08:35:21 +00:00
Álvaro Brey Vilas 81d8cafa02 CodeQL: setup JDK for build
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-06-09 08:35:21 +00:00
Álvaro Brey Vilas 9bc615a287 CodeQL: do not use autobuild
Fails for android projects

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-06-09 08:35:21 +00:00
Tobias Kaminsky 51dc293fab Update codeql-analysis.yml 2022-06-09 08:35:21 +00:00
Tobias Kaminsky 9684b0172d Create codeql-analysis.yml 2022-06-09 08:35:21 +00:00
Tobias Kaminsky 266e45b098 Merge pull request #10343 from nextcloud/fix/community-report
Use different link for automated bugreport and manual report
2022-06-09 09:50:52 +02:00
tobiasKaminsky 67cb25a603 When copy/move a file and creating a new folder we now go directly into this freshly created folder
Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-09 09:12:32 +02:00
Nextcloud bot 5538a5e734 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-09 04:22:28 +00:00
github-actions bf0a884e54 Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: github-actions <[email protected]>
2022-06-08 15:35:45 +00:00
Álvaro Brey fb4eaf11ff SyncedFoldersActivity: don't refresh entire adapter when toggling a folder from dialog
It's enough to refresh its header, and it doesn't have to refresh all pictures

Signed-off-by: Álvaro Brey <[email protected]>
2022-06-08 16:54:20 +02:00
Álvaro Brey affe52e49a Merge pull request #10315 from nextcloud/dependabot/gradle/com.google.android.material-material-1.6.1
Bump material from 1.6.0 to 1.6.1
2022-06-08 13:18:22 +02:00
Álvaro Brey 306bcb09ef Merge pull request #10348 from nextcloud/file-uploader-downloader-migration-to-user
Migrate some FileUploader and FileDownloader APIs to User
2022-06-08 09:38:50 +02:00
Nextcloud bot f6bb42141e [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-08 04:24:38 +00:00
dependabot[bot] 4d0db55318 Bump material from 1.6.0 to 1.6.1
Bumps [material](https://github.com/material-components/material-components-android) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/material-components/material-components-android/releases)
- [Commits](https://github.com/material-components/material-components-android/compare/1.6.0...1.6.1)

---
updated-dependencies:
- dependency-name: com.google.android.material:material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-08 01:05:20 +00:00
Chris Narkiewicz 1d81a705bf Migrate some FileUploader and FileDownloader APIs to User
Signed-off-by: Chris Narkiewicz <[email protected]>
2022-06-07 20:56:43 +01:00
Álvaro Brey c9933d558e FileDataStorageManager: don't add files to media scan in android 11+
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-07 10:20:17 +02:00
Álvaro Brey 301d9ae9a9 GalleryFastScrollViewHelper: fix index out of bounds in getScrollOffset
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-07 10:03:12 +02:00
Álvaro Brey 5944bfabdd Merge pull request #10209 from nextcloud/migrate-remote-operation-execute-to-user
Migrate RemoteOperation.execute calls to User
2022-06-06 13:10:37 +02:00
Álvaro Brey 6f6bed084c Use different link for automated bugreport and manual report
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-06 10:02:55 +02:00
Nextcloud bot 721f63971a [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-06 04:25:53 +00:00
Chris Narkiewicz 35e164fa2d Migrate RemoteOperation.execute calls to User
Signed-off-by: Chris Narkiewicz <[email protected]>
2022-06-04 23:59:50 +01:00
Nextcloud bot bd5a99a10e [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-04 04:22:45 +00:00
Álvaro Brey 5a3ad05b0e Merge pull request #10328 from nextcloud/dependabot/gradle/mockitoVersion-4.6.1
Bump mockitoVersion from 4.6.0 to 4.6.1
2022-06-03 13:55:00 +02:00
Álvaro Brey 03964f4342 Merge pull request #10319 from nextcloud/dependabot/gradle/androidx.appcompat-appcompat-1.4.2
Bump appcompat from 1.4.1 to 1.4.2
2022-06-03 09:56:00 +02:00
Tobias Kaminsky 3fd8928327 Merge pull request #10307 from nextcloud/fix/choosetemplate-button-nullpointer
Fix NPE in ChooseTemplateDialogFragment
2022-06-03 07:29:32 +02:00
Álvaro Brey 4011fa7b7d Exclude all activities except AuthenticatorActivity from security key listener (#10311)
Signed-off-by: Álvaro Brey <[email protected]>
2022-06-03 07:28:27 +02:00
dependabot[bot] cfc34942b0 Bump mockitoVersion from 4.6.0 to 4.6.1
Bumps `mockitoVersion` from 4.6.0 to 4.6.1.

Updates `mockito-core` from 4.6.0 to 4.6.1
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v4.6.0...v4.6.1)

Updates `mockito-android` from 4.6.0 to 4.6.1
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.mockito:mockito-android
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-03 04:44:13 +00:00
dependabot[bot] bddbc4ff9d Bump appcompat from 1.4.1 to 1.4.2
Bumps appcompat from 1.4.1 to 1.4.2.

---
updated-dependencies:
- dependency-name: androidx.appcompat:appcompat
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-02 01:06:48 +00:00
Álvaro Brey f6f8b91d25 Merge pull request #10317 from nextcloud/chore/remove-powermock
build: Remove powermock
2022-06-01 12:56:32 +02:00
Álvaro Brey 5b85fb95d6 build: Remove powermock
Unused, bad practice, and incompatible with mockito 4 anyway.

Signed-off-by: Álvaro Brey <[email protected]>
2022-06-01 11:15:01 +02:00
Álvaro Brey 15f6cea189 Merge pull request #10253 from nextcloud/thumbnailFolderBug
Harden thumbnail generation
2022-06-01 10:49:38 +02:00
Álvaro Brey c707e19797 Merge pull request #10298 from nextcloud/dependabot/gradle/mockitoVersion-4.6.0
Bump mockitoVersion from 4.5.1 to 4.6.0
2022-06-01 10:48:21 +02:00
Álvaro Brey 313a9da7df Merge pull request #10268 from nextcloud/dependabot/gradle/com.google.firebase-firebase-messaging-23.0.5
Bump firebase-messaging from 23.0.4 to 23.0.5
2022-06-01 10:47:10 +02:00
Álvaro Brey 0767e4fe43 GalleryAdapter: cleanup index out of bounds 2022-06-01 07:28:17 +00:00
nextcloud-android-bot 89c712d39c Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-06-01 07:28:17 +00:00
tobiasKaminsky 0748ba19af Harden thumbnail generation
Signed-off-by: tobiasKaminsky <[email protected]>
2022-06-01 07:28:17 +00:00
dependabot[bot] 4141a52617 Bump mockitoVersion from 4.5.1 to 4.6.0
Bumps `mockitoVersion` from 4.5.1 to 4.6.0.

Updates `mockito-core` from 4.5.1 to 4.6.0
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v4.5.1...v4.6.0)

Updates `mockito-android` from 4.5.1 to 4.6.0
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v4.5.1...v4.6.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.mockito:mockito-android
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-01 07:27:02 +00:00
dependabot[bot] ef642a2f0d Bump firebase-messaging from 23.0.4 to 23.0.5
Bumps firebase-messaging from 23.0.4 to 23.0.5.

---
updated-dependencies:
- dependency-name: com.google.firebase:firebase-messaging
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-06-01 07:27:01 +00:00
Álvaro Brey 749a7e7f04 Merge pull request #10225 from nextcloud/sectionedRecyclerview
Use our own version of sectioned-recyclerview
2022-06-01 09:21:03 +02:00
Álvaro Brey 86ea4d55a9 Merge pull request #10300 from nextcloud/dependabot/gradle/com.vanniktech-emoji-google-0.15.0
Bump emoji-google from 0.12.0 to 0.15.0
2022-06-01 08:53:48 +02:00
Nextcloud bot d971d0a619 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-06-01 04:24:28 +00:00
dependabot[bot] 0830799292 Bump emoji-google from 0.12.0 to 0.15.0
Bumps [emoji-google](https://github.com/vanniktech/Emoji) from 0.12.0 to 0.15.0.
- [Release notes](https://github.com/vanniktech/Emoji/releases)
- [Changelog](https://github.com/vanniktech/Emoji/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vanniktech/Emoji/compare/0.12.0...0.15.0)

---
updated-dependencies:
- dependency-name: com.vanniktech:emoji-google
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-31 15:34:32 +00:00
Álvaro Brey 51aa8cbd35 ChooseTemplateDialogFragment: convert to Kotlin
Since I'm here...

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-31 09:34:18 +00:00
Álvaro Brey 3ce883466b Fix NPE in ChooseTemplateDialogFragment.checkEnablingCreateButton
This method can be called before positiveButton is initialized

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-31 09:34:18 +00:00
Álvaro Brey 82daff8797 Merge pull request #10310 from nextcloud/lintUnusedQuantity
Since newest Transifex update we have many translations with not need…
2022-05-31 11:31:31 +02:00
Álvaro Brey 713350f8d0 Merge pull request #10280 from nextcloud/dependabot/github_actions/actions/upload-artifact-3.1.0
Bump actions/upload-artifact from 3 to 3.1.0
2022-05-31 11:28:07 +02:00
tobiasKaminsky ee57fa0732 Since newest Transifex update we have many translations with not needed translations, e.g. "many" in spanish.
To not have lint warnings all the time, and as it does not harm Android, we can ignore it.

Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-31 10:17:15 +02:00
dependabot[bot] da98a8a980 Bump actions/upload-artifact from 3 to 3.1.0
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 3.1.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...3cea5372237819ed00197afe530f5a7ea3e805c8)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-31 08:07:54 +00:00
Álvaro Brey f54d234626 Merge pull request #10279 from nextcloud/chore/analysis-github-token
workflows/analysis: Use GITHUB_TOKEN instead of GIT_TOKEN, and some cleanup
2022-05-31 10:07:03 +02:00
Nextcloud bot d51a9426d4 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-27 04:16:05 +00:00
Nextcloud bot a13c4c1906 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-26 04:16:47 +00:00
Tobias Kaminsky c1cf416872 Merge pull request #10148 from nextcloud/proseMirror
Test proseMirror with custom user agent
2022-05-25 15:40:54 +02:00
Nextcloud bot 78e689b2f1 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-25 04:51:04 +00:00
Nextcloud bot 2a3bc3b0dc [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-24 04:30:55 +00:00
Álvaro Brey fa3d92009d Update workflows/qa
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-23 10:15:29 +02:00
Álvaro Brey e74e12c293 Update some workflows
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-23 10:11:36 +02:00
Nextcloud bot ea16420d37 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-23 04:15:15 +00:00
Nextcloud bot 748f2ac903 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-22 04:17:24 +00:00
tobiasKaminsky 8bd3243238 Do not set custom user agent for Text/ProseMirror
Use EditorUtils

Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-20 11:39:38 +02:00
Álvaro Brey b1c747b333 Merge pull request #10267 from nextcloud/dependabot/gradle/androidx.constraintlayout-constraintlayout-2.1.4
Bump constraintlayout from 2.1.3 to 2.1.4
2022-05-20 09:27:04 +02:00
dependabot[bot] 94d2e1998e Bump constraintlayout from 2.1.3 to 2.1.4
Bumps [constraintlayout](https://github.com/androidx/constraintlayout) from 2.1.3 to 2.1.4.
- [Release notes](https://github.com/androidx/constraintlayout/releases)
- [Commits](https://github.com/androidx/constraintlayout/commits)

---
updated-dependencies:
- dependency-name: androidx.constraintlayout:constraintlayout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-20 01:05:41 +00:00
Tobias Kaminsky 5f465c0d2d Merge pull request #10241 from nextcloud/projectId
Project_id is needed
2022-05-19 12:12:41 +02:00
tobiasKaminsky 6a4c4c0b28 Project_id is needed
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-19 09:54:03 +02:00
Álvaro Brey 0b0b49b266 Merge pull request #10251 from nextcloud/dependabot/gradle/com.karumi-shot-5.14.1
Bump shot from 5.14.0 to 5.14.1
2022-05-19 09:34:18 +02:00
dependabot[bot] 1cce3be464 Bump shot from 5.14.0 to 5.14.1
Bumps [shot](https://github.com/pedrovgs/shot) from 5.14.0 to 5.14.1.
- [Release notes](https://github.com/pedrovgs/shot/releases)
- [Commits](https://github.com/pedrovgs/shot/compare/5.14.0...5.14.1)

---
updated-dependencies:
- dependency-name: com.karumi:shot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-18 09:40:46 +00:00
Álvaro Brey 54b68b049c Merge pull request #10256 from nextcloud/dependabot/gradle/com.vanniktech-emoji-google-0.12.0
Bump emoji-google from 0.11.0 to 0.12.0
2022-05-18 11:24:16 +02:00
dependabot[bot] 8f46bd6275 Bump emoji-google from 0.11.0 to 0.12.0
Bumps [emoji-google](https://github.com/vanniktech/Emoji) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/vanniktech/Emoji/releases)
- [Changelog](https://github.com/vanniktech/Emoji/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vanniktech/Emoji/compare/0.11.0...0.12.0)

---
updated-dependencies:
- dependency-name: com.vanniktech:emoji-google
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-17 01:04:56 +00:00
Álvaro Brey f0aa754b32 Merge pull request #10252 from nextcloud/dependabot/github_actions/cirrus-actions/rebase-1.7
Bump cirrus-actions/rebase from 1.6 to 1.7
2022-05-16 17:39:07 +02:00
dependabot[bot] 2cac6f916a Bump cirrus-actions/rebase from 1.6 to 1.7
Bumps [cirrus-actions/rebase](https://github.com/cirrus-actions/rebase) from 1.6 to 1.7.
- [Release notes](https://github.com/cirrus-actions/rebase/releases)
- [Commits](https://github.com/cirrus-actions/rebase/compare/1.6...1.7)

---
updated-dependencies:
- dependency-name: cirrus-actions/rebase
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-16 11:16:25 +00:00
Nextcloud bot 294db08117 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-16 04:11:57 +00:00
Nextcloud bot f3b80053f6 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-15 04:11:12 +00:00
Álvaro Brey f56b926f25 Merge pull request #10239 from nextcloud/dependabot/gradle/com.github.spotbugs.snom-spotbugs-gradle-plugin-5.0.7
Bump spotbugs-gradle-plugin from 5.0.6 to 5.0.7
2022-05-13 10:33:33 +02:00
dependabot[bot] f589c7b949 Bump spotbugs-gradle-plugin from 5.0.6 to 5.0.7
Bumps [spotbugs-gradle-plugin](https://github.com/spotbugs/spotbugs-gradle-plugin) from 5.0.6 to 5.0.7.
- [Release notes](https://github.com/spotbugs/spotbugs-gradle-plugin/releases)
- [Commits](https://github.com/spotbugs/spotbugs-gradle-plugin/compare/5.0.6...5.0.7)

---
updated-dependencies:
- dependency-name: com.github.spotbugs.snom:spotbugs-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-13 01:04:27 +00:00
Tobias Kaminsky bd4b35d41b Merge pull request #10228 from nextcloud/fix/getpopuptext-crash
OCFileListAdapter: skip popup text generation if no sortOrder is present
2022-05-12 12:22:27 +02:00
Álvaro Brey f5849f6af7 Merge pull request #10231 from nextcloud/dependabot/gradle/com.vanniktech-emoji-google-0.11.0
Bump emoji-google from 0.9.0 to 0.11.0
2022-05-12 09:56:46 +02:00
Álvaro Brey 573b5085fe Merge pull request #10230 from nextcloud/dependabot/gradle/mockkVersion-1.12.4
Bump mockkVersion from 1.12.3 to 1.12.4
2022-05-12 09:38:17 +02:00
Álvaro Brey b2630f532a SetStatusDialogFragment: fix EmojiPopup after API changes
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-12 09:29:12 +02:00
Álvaro Brey bad754b74d Merge pull request #10229 from nextcloud/qrCodeScanner
Moved repo for qrcodescanner
2022-05-12 09:10:24 +02:00
dependabot[bot] 1c0a189511 Bump emoji-google from 0.9.0 to 0.11.0
Bumps [emoji-google](https://github.com/vanniktech/Emoji) from 0.9.0 to 0.11.0.
- [Release notes](https://github.com/vanniktech/Emoji/releases)
- [Changelog](https://github.com/vanniktech/Emoji/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vanniktech/Emoji/compare/0.9.0...0.11.0)

---
updated-dependencies:
- dependency-name: com.vanniktech:emoji-google
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-12 01:07:12 +00:00
dependabot[bot] 95f1e1066f Bump mockkVersion from 1.12.3 to 1.12.4
Bumps `mockkVersion` from 1.12.3 to 1.12.4.

Updates `mockk` from 1.12.3 to 1.12.4
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.12.3...1.12.4)

Updates `mockk-android` from 1.12.3 to 1.12.4
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.12.3...1.12.4)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: io.mockk:mockk-android
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-12 01:07:11 +00:00
Álvaro Brey 0a1736dc75 OCFileListAdapter: skip popup text generation if no sortOrder is present
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-11 15:28:29 +02:00
tobiasKaminsky 7e3bfffd67 Moved repo for qrcodescanner
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-11 15:24:27 +02:00
tobiasKaminsky d496001a01 Use our own version of sectioned-recyclerview
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-11 15:23:03 +02:00
Álvaro Brey 258af3c465 Merge pull request #10222 from nextcloud/dependabot/gradle/daggerVersion-2.42
Bump daggerVersion from 2.41 to 2.42
2022-05-10 11:21:18 +02:00
Nextcloud bot 4cab92f48e [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-10 04:24:14 +00:00
dependabot[bot] d9897ec1a6 Bump daggerVersion from 2.41 to 2.42
Bumps `daggerVersion` from 2.41 to 2.42.

Updates `dagger` from 2.41 to 2.42
- [Release notes](https://github.com/google/dagger/releases)
- [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/dagger/compare/dagger-2.41...dagger-2.42)

Updates `dagger-android` from 2.41 to 2.42
- [Release notes](https://github.com/google/dagger/releases)
- [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/dagger/compare/dagger-2.41...dagger-2.42)

Updates `dagger-android-support` from 2.41 to 2.42
- [Release notes](https://github.com/google/dagger/releases)
- [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/dagger/compare/dagger-2.41...dagger-2.42)

Updates `dagger-compiler` from 2.41 to 2.42
- [Release notes](https://github.com/google/dagger/releases)
- [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/dagger/compare/dagger-2.41...dagger-2.42)

Updates `dagger-android-processor` from 2.41 to 2.42
- [Release notes](https://github.com/google/dagger/releases)
- [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/dagger/compare/dagger-2.41...dagger-2.42)

---
updated-dependencies:
- dependency-name: com.google.dagger:dagger
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.google.dagger:dagger-android
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.google.dagger:dagger-android-support
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.google.dagger:dagger-compiler
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.google.dagger:dagger-android-processor
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-10 01:06:46 +00:00
Álvaro Brey e7ea566bb6 Merge pull request #10217 from nextcloud/fix/on-device-crash
Fix crash when navigating from Gallery to On device
2022-05-09 15:03:34 +02:00
Álvaro Brey 1955e46a10 Fix crash when navigating from Gallery to On device
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-09 13:15:36 +02:00
134 changed files with 1394 additions and 1073 deletions

No files matched your search

+8 -8
View File
@@ -14,18 +14,18 @@ steps:
from_secret: LOG_PASSWORD
GIT_USERNAME:
from_secret: GIT_USERNAME
GIT_TOKEN:
GITHUB_TOKEN:
from_secret: GIT_TOKEN
commands:
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
- scripts/checkIfRunDrone.sh $DRONE_PULL_REQUEST || exit 0
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
- ./gradlew assembleGplayDebugAndroidTest
- scripts/wait_for_emulator.sh
- ./gradlew installGplayDebugAndroidTest
- scripts/wait_for_server.sh "server"
- scripts/deleteOldComments.sh "stable" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN
- ./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN
- scripts/deleteOldComments.sh "stable" "IT" $DRONE_PULL_REQUEST
- ./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST
services:
- name: server
@@ -74,13 +74,13 @@ steps:
from_secret: LOG_PASSWORD
GIT_USERNAME:
from_secret: GIT_USERNAME
GIT_TOKEN:
GITHUB_TOKEN:
from_secret: GIT_TOKEN
commands:
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
- scripts/checkIfRunDrone.sh $DRONE_PULL_REQUEST || exit 0
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
- scripts/runCombinedTest.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER
- scripts/runCombinedTest.sh $DRONE_PULL_REQUEST $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER
services:
- name: server
@@ -125,7 +125,7 @@ steps:
environment:
GIT_USERNAME:
from_secret: GIT_USERNAME
GIT_TOKEN:
GITHUB_TOKEN:
from_secret: GIT_TOKEN
LOG_USERNAME:
from_secret: LOG_USERNAME
+4 -11
View File
@@ -1,7 +1,7 @@
name: "Analysis"
on:
pull_request_target:
pull_request:
branches: [ master, stable-* ]
push:
branches: [ master, stable-* ]
@@ -17,22 +17,13 @@ jobs:
# push
echo "::set-output name=branch::$GITHUB_REF_NAME"
echo "::set-output name=pr::$GITHUB_RUN_ID"
echo "::set-output name=repo::${{ github.repository }}"
else
# pull request
echo "::set-output name=branch::$GITHUB_HEAD_REF"
echo "::set-output name=pr::${{ github.event.pull_request.number }}"
echo "::set-output name=repo::${{ github.event.pull_request.head.repo.full_name }}"
fi
- name: Show variables
run: |
echo "REPO: ${{ steps.get-vars.outputs.repo }}"
echo "BRANCH: ${{ steps.get-vars.outputs.branch }}"
echo "PR: ${{ steps.get-vars.outputs.pr }}"
echo "RUN NUMBER: $GITHUB_RUN_NUMBER"
- uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
repository: ${{ steps.get-vars.outputs.repo }}
ref: ${{ steps.get-vars.outputs.branch }}
- name: Set up JDK 11
@@ -44,7 +35,9 @@ jobs:
run: |
python3 -m pip install defusedxml
- name: Run analysis wrapper
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
scripts/analysis/analysis-wrapper.sh ${{ secrets.GIT_USERNAME }} ${{ secrets.GIT_TOKEN }} ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ steps.get-vars.outputs.pr }}
scripts/analysis/analysis-wrapper.sh ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ steps.get-vars.outputs.pr }}
+41
View File
@@ -0,0 +1,41 @@
name: "CodeQL"
on:
push:
branches: [ "master", "stable-*" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '24 18 * * 3'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: 11
- name: Assemble
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
./gradlew assembleDebug
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+6 -1
View File
@@ -9,9 +9,14 @@ on:
issue_comment:
types: created
permissions:
contents: read
jobs:
rebase:
runs-on: ubuntu-latest
permissions:
contents: none
# On pull requests and if the comment starts with `/rebase`
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase')
@@ -32,7 +37,7 @@ jobs:
token: ${{ secrets.COMMAND_BOT_PAT }}
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.6
uses: cirrus-actions/rebase@1.7
env:
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
+10 -5
View File
@@ -1,32 +1,37 @@
name: "QA"
on:
pull_request_target:
pull_request:
branches: [ master, stable-* ]
jobs:
qa:
runs-on: ubuntu-latest
steps:
- name: Check if secrets are available
run: echo "::set-output name=ok::${{ secrets.KS_PASS != '' }}"
id: check-secrets
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
- name: set up JDK 11
uses: actions/setup-java@v3
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
with:
distribution: "temurin"
java-version: 11
- name: Install NDK and cmake
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
run: |
source ndk.env
/usr/local/lib/android/sdk/tools/bin/sdkmanager "ndk;${NDK_VERSION}" "cmake;${CMAKE_VERSION}"
- name: Build QA
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
env:
KS_PASS: ${{ secrets.KS_PASS }}
KEY_PASS: ${{ secrets.KEY_PASS }}
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
@@ -34,4 +39,4 @@ jobs:
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" app/build.gradle
./gradlew assembleQaDebug
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks app/build/outputs/apk/qa/debug/qa-debug-*.apk
sudo scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD ${{github.event.number}} ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
sudo scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD ${{github.event.number}} ${{github.event.number}}
+1 -1
View File
@@ -42,7 +42,7 @@ jobs:
# Upload the results as artifacts (optional).
- name: "Upload artifact"
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v2.3.1
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v2.3.1
with:
name: SARIF file
path: results.sarif
+7 -3
View File
@@ -59,8 +59,10 @@ jobs:
run: ./gradlew assembleGplayDebug
- name: Delete old comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ always() }}
run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
- name: Run screenshot tests
uses: reactivecircus/android-emulator-runner@v2
@@ -74,10 +76,12 @@ jobs:
script: ./gradlew uninstallAll gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
- name: upload failing results
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
- name: Archive Espresso results
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
if: ${{ always() }}
with:
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
+7 -3
View File
@@ -17,16 +17,20 @@ jobs:
distribution: "temurin"
java-version: 11
- name: Delete old comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ always() }}
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
- name: Run unit tests with coverage
uses: gradle/gradle-build-action@v2
with:
arguments: jacocoTestGplayDebugUnitTest
- name: Upload failing results
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
@@ -35,7 +39,7 @@ jobs:
fail_ci_if_error: true
- name: Upload jacoco artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
with:
name: test-results
path: app/build/reports/tests/testGplayDebugUnitTest/
+16
View File
@@ -1,3 +1,19 @@
## 3.20.3 (June 13th, 2022)
- Minor bug fixes
Minimum: NC 16 Server, Android 6.0 Marshmallow
For a full list, please see https://github.com/nextcloud/android/milestone/69
## 3.20.2 (June 9th, 2022)
- Several minor bugfixes
Minimum: NC 16 Server, Android 6.0 Marshmallow
For a full list, please see https://github.com/nextcloud/android/milestone/68
## 3.20.1 (May 6th, 2022)
- Several minor bugfixes
+9 -12
View File
@@ -5,11 +5,11 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.hiya:jacoco-android:0.2'
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.6'
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.20.0"
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
classpath 'com.karumi:shot:5.14.0'
classpath 'com.karumi:shot:5.14.1'
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
@@ -217,11 +217,11 @@ dependencies {
compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.6.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
@@ -237,17 +237,17 @@ dependencies {
implementation 'org.lukhnos:nnio:0.2'
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.70'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
implementation 'com.github.nextcloud:sectioned-recyclerview:0.6.1'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'
implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.4' // 'com.github.blikoon:QRCodeScanner:0.1.2'
implementation 'com.github.nextcloud:qrcodescanner:0.1.2.4' // 'com.github.blikoon:QRCodeScanner:0.1.2'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation('com.github.bumptech.glide:glide:3.8.0') {
exclude group: "com.android.support"
}
implementation 'com.caverock:androidsvg:1.4'
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'com.vanniktech:emoji-google:0.9.0'
implementation 'com.vanniktech:emoji-google:0.15.0'
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido:$fidoVersion"
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido2:$fidoVersion"
@@ -302,9 +302,6 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "androidx.test:core:$androidxTestVersion"
testImplementation "org.powermock:powermock-core:$powermockVersion"
testImplementation "org.powermock:powermock-module-junit4:$powermockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
testImplementation 'org.json:json:20220320'
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation 'androidx.arch.core:core-testing:2.1.0'
@@ -350,7 +347,7 @@ dependencies {
implementation "com.github.stateless4j:stateless4j:2.6.0"
// upon each update first test: new registration, receive push
gplayImplementation "com.google.firebase:firebase-messaging:23.0.4"
gplayImplementation "com.google.firebase:firebase-messaging:23.0.5"
}
configurations.all {
+1 -1
View File
@@ -1,5 +1,5 @@
build:
maxIssues: 3
maxIssues: 0
weights:
# complexity: 2
# LongParameterList: 1
+2 -3
View File
@@ -23,9 +23,7 @@
</issue>
<issue id="UnusedQuantity">
<ignore path="**/values-sk-rSK/strings.xml"/>
<ignore path="**/values-cs-rCZ/strings.xml"/>
<ignore path="**/values-lt-rLT/strings.xml"/>
<ignore path="**/values-**/strings.xml" />
</issue>
<issue id="ExtraTranslation">
@@ -35,6 +33,7 @@
<issue id="UnusedResources">
<ignore path="**/values-**/strings.xml" />
<ignore path="**/values/setup.xml" />
</issue>
<issue id="TypographyEllipsis">
Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

@@ -468,7 +468,7 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
assertTrue(new RemoveFileOperation(fileToDelete,
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -621,7 +621,7 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
Log_OC.d(this, "Remove file: " + child.getDecryptedRemotePath());
}
assertTrue(new RemoveFileOperation(child, false, account, false, targetContext, getStorageManager())
assertTrue(new RemoveFileOperation(child, false, user, false, targetContext, getStorageManager())
.execute(client)
.isSuccess()
);
@@ -121,7 +121,7 @@ public abstract class AbstractIT {
user = optionalUser.orElseThrow(IllegalAccessError::new);
client = OwnCloudClientFactory.createOwnCloudClient(account, targetContext);
nextcloudClient = OwnCloudClientFactory.createNextcloudClient(account, targetContext);
nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user, targetContext);
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (AuthenticatorException e) {
@@ -63,7 +63,7 @@ public class DownloadIT extends AbstractOnServerIT {
if (result.isSuccess() && getStorageManager().getFileByDecryptedRemotePath(FOLDER) != null) {
new RemoveFileOperation(getStorageManager().getFileByDecryptedRemotePath(FOLDER),
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -38,7 +38,7 @@ public class FileIT extends AbstractOnServerIT {
assertTrue(file.isFolder());
// cleanup
new RemoveFileOperation(file, false, account, false, targetContext, getStorageManager()).execute(client);
new RemoveFileOperation(file, false, user, false, targetContext, getStorageManager()).execute(client);
}
@Test
@@ -58,7 +58,7 @@ public class FileIT extends AbstractOnServerIT {
// cleanup
new RemoveFileOperation(file,
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -116,7 +116,7 @@ public class UploadIT extends AbstractOnServerIT {
if (result.isSuccess() && getStorageManager().getFileByDecryptedRemotePath(FOLDER) != null) {
new RemoveFileOperation(getStorageManager().getFileByDecryptedRemotePath(FOLDER),
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -371,7 +371,7 @@ public class UploadIT extends AbstractOnServerIT {
// cleanup
new RemoveFileOperation(getStorageManager().getFileByDecryptedRemotePath(FOLDER),
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -136,7 +136,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadNewFile(
targetContext,
account,
user,
file.absolutePath,
"/testFile.txt",
FileUploader.LOCAL_BEHAVIOUR_COPY,
@@ -160,7 +160,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadUpdateFile(
targetContext,
account,
user,
ocFile2,
FileUploader.LOCAL_BEHAVIOUR_COPY,
NameCollisionPolicy.OVERWRITE
@@ -255,7 +255,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadNewFile(
targetContext,
account,
user,
file.absolutePath,
"/testFile.txt",
FileUploader.LOCAL_BEHAVIOUR_COPY,
@@ -279,7 +279,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadUpdateFile(
targetContext,
account,
user,
ocFile2,
FileUploader.LOCAL_BEHAVIOUR_COPY,
NameCollisionPolicy.RENAME
@@ -366,7 +366,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadNewFile(
targetContext,
account,
user,
file.absolutePath,
"/testFile.txt",
FileUploader.LOCAL_BEHAVIOUR_COPY,
@@ -390,7 +390,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadUpdateFile(
targetContext,
account,
user,
ocFile2,
FileUploader.LOCAL_BEHAVIOUR_COPY,
NameCollisionPolicy.CANCEL
@@ -473,7 +473,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadNewFile(
targetContext,
account,
user,
file.absolutePath,
"/testFile.txt",
FileUploader.LOCAL_BEHAVIOUR_COPY,
@@ -497,7 +497,7 @@ class FileUploaderIT : AbstractOnServerIT() {
FileUploader.uploadUpdateFile(
targetContext,
account,
user,
ocFile2,
FileUploader.LOCAL_BEHAVIOUR_COPY,
NameCollisionPolicy.CANCEL
@@ -47,7 +47,7 @@ public class RemoveFileOperationIT extends AbstractOnServerIT {
assertTrue(new RemoveFileOperation(folder,
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -59,7 +59,7 @@ public class RemoveFileOperationIT extends AbstractOnServerIT {
assertNotNull(parentFolder);
assertTrue(new RemoveFileOperation(parentFolder,
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -81,7 +81,7 @@ public class RemoveFileOperationIT extends AbstractOnServerIT {
assertTrue(new RemoveFileOperation(file,
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -93,7 +93,7 @@ public class RemoveFileOperationIT extends AbstractOnServerIT {
assertNotNull(parentFolder);
assertTrue(new RemoveFileOperation(parentFolder,
false,
account,
user,
false,
targetContext,
getStorageManager())
@@ -29,6 +29,7 @@ import com.owncloud.android.AbstractIT
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.resources.shares.ShareType
import com.owncloud.android.lib.resources.shares.ShareeUser
import com.owncloud.android.utils.MimeType
import com.owncloud.android.utils.ScreenshotTest
import org.junit.After
import org.junit.Assert
@@ -80,90 +81,103 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
/**
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
*/
@Test
@ScreenshotTest
fun showSharedFiles() {
val sut = testActivityRule.launchActivity(null)
val fragment = OCFileListFragment()
val userShare = OCFile("/sharedToUser.jpg").apply {
OCFile("/sharedToUser.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(ShareeUser("Admin", "Server Admin", ShareType.USER))
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(userShare)
val groupShare = OCFile("/sharedToGroup.jpg").apply {
OCFile("/sharedToGroup.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(ShareeUser("group", "Group", ShareType.GROUP))
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(groupShare)
val emailShare = OCFile("/sharedToEmail.jpg").apply {
OCFile("/sharedToEmail.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(ShareeUser("[email protected]", "[email protected]", ShareType.EMAIL))
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(emailShare)
val publicLink = OCFile("/publicLink.jpg").apply {
OCFile("/publicLink.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedViaLink = true
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(publicLink)
val federatedUserShare = OCFile("/sharedToFederatedUser.jpg").apply {
OCFile("/sharedToFederatedUser.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(
ShareeUser("[email protected]", "[email protected] (remote)", ShareType.FEDERATED)
)
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(federatedUserShare)
val personalCircleShare = OCFile("/sharedToPersonalCircle.jpg").apply {
OCFile("/sharedToPersonalCircle.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(ShareeUser("circle", "Circle (Personal circle)", ShareType.CIRCLE))
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(personalCircleShare)
// as we cannot distinguish circle types, we do not need them right now
// val publicCircleShare = OCFile("/sharedToPublicCircle.jpg").apply {
// OCFile("/sharedToPublicCircle.jpg").apply {
// parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
// isSharedWithSharee = true
// sharees = listOf(ShareeUser("circle", "Circle (Public circle)", ShareType.CIRCLE))
// modificationTimestamp = 1000
// sut.storageManager.saveFile(this)
// }
// sut.storageManager.saveFile(publicCircleShare)
//
// val closedCircleShare = OCFile("/sharedToClosedCircle.jpg").apply {
// OCFile("/sharedToClosedCircle.jpg").apply {
// parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
// isSharedWithSharee = true
// sharees = listOf(ShareeUser("circle", "Circle (Closed circle)", ShareType.CIRCLE))
// modificationTimestamp = 1000
// sut.storageManager.saveFile(this)
// }
// sut.storageManager.saveFile(closedCircleShare)
//
// val secretCircleShare = OCFile("/sharedToSecretCircle.jpg").apply {
// OCFile("/sharedToSecretCircle.jpg").apply {
// parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
// isSharedWithSharee = true
// sharees = listOf(ShareeUser("circle", "Circle (Secret circle)", ShareType.CIRCLE))
// modificationTimestamp = 1000
// sut.storageManager.saveFile(this)
// }
// sut.storageManager.saveFile(secretCircleShare)
val userRoomShare = OCFile("/sharedToUserRoom.jpg").apply {
OCFile("/sharedToUserRoom.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(ShareeUser("Conversation", "Admin", ShareType.ROOM))
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(userRoomShare)
val groupRoomShare = OCFile("/sharedToGroupRoom.jpg").apply {
OCFile("/sharedToGroupRoom.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(ShareeUser("Conversation", "Meeting", ShareType.ROOM))
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(groupRoomShare)
val usersShare = OCFile("/sharedToUsers.jpg").apply {
OCFile("/sharedToUsers.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
isSharedWithSharee = true
sharees = listOf(
@@ -171,13 +185,67 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
ShareeUser("User", "User", ShareType.USER),
ShareeUser("Christine", "Christine Scott", ShareType.USER)
)
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(usersShare)
val noShare = OCFile("/notShared.jpg").apply {
OCFile("/notShared.jpg").apply {
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
modificationTimestamp = 1000
sut.storageManager.saveFile(this)
}
sut.addFragment(fragment)
shortSleep()
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
sut.runOnUiThread {
fragment.listDirectory(root, false, false)
fragment.adapter.setShowShareAvatar(true)
}
waitForIdleSync()
shortSleep()
shortSleep()
shortSleep()
screenshot(sut)
}
/**
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
*/
@Test
@ScreenshotTest
fun showFolderTypes() {
val sut = testActivityRule.launchActivity(null)
val fragment = OCFileListFragment()
OCFile("/normal/").apply {
mimeType = MimeType.DIRECTORY
modificationTimestamp = 1624003571000
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
sut.storageManager.saveFile(this)
}
OCFile("/groupFolder/").apply {
mimeType = MimeType.DIRECTORY
modificationTimestamp = 1615003571000
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
permissions += "M"
sut.storageManager.saveFile(this)
}
OCFile("/encrypted/").apply {
mimeType = MimeType.DIRECTORY
isEncrypted = true
decryptedRemotePath = "/encrypted/"
modificationTimestamp = 1614003571000
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
sut.storageManager.saveFile(this)
}
sut.storageManager.saveFile(noShare)
sut.addFragment(fragment)
@@ -35,17 +35,20 @@ import com.owncloud.android.utils.EncryptionUtils;
import net.bytebuddy.utility.RandomString;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.util.Arrays;
@@ -72,7 +75,6 @@ import static com.owncloud.android.utils.EncryptionUtils.encryptFile;
import static com.owncloud.android.utils.EncryptionUtils.encryptFolderMetadata;
import static com.owncloud.android.utils.EncryptionUtils.generateKey;
import static com.owncloud.android.utils.EncryptionUtils.generateSHA512;
import static com.owncloud.android.utils.EncryptionUtils.getMD5Sum;
import static com.owncloud.android.utils.EncryptionUtils.ivDelimiter;
import static com.owncloud.android.utils.EncryptionUtils.ivDelimiterOld;
import static com.owncloud.android.utils.EncryptionUtils.ivLength;
@@ -566,4 +568,33 @@ public class EncryptionTestIT {
return temp;
}
private String getMD5Sum(File file) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] bytes = new byte[2048];
int readBytes;
while ((readBytes = fileInputStream.read(bytes)) != -1) {
md5.update(bytes, 0, readBytes);
}
return new String(Hex.encodeHex(md5.digest()));
} catch (Exception e) {
Log_OC.e(this, e.getMessage());
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
Log_OC.e(this, "Error getting MD5 checksum for file", e);
}
}
}
return "";
}
}
@@ -58,7 +58,7 @@ public class ErrorMessageAdapterIT {
new RemoteOperationResult(RemoteOperationResult.ResultCode.FORBIDDEN),
new RemoveFileOperation(new OCFile(PATH_TO_DELETE),
false,
user.toPlatformAccount(),
user,
false,
context,
new FileDataStorageManager(user, context.getContentResolver())),
+1
View File
@@ -10,6 +10,7 @@
<string name="google_app_id" translatable="false">1:829118773643:android:512449826e931d0e</string>
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyAWIyOcLafaFp8PFL61h64cy1NNZW2cU_s</string>
<string name="google_storage_bucket" translatable="false">nextcloud-a7dea.appspot.com</string>
<string name="project_id" translatable="false">nextcloud-a7dea</string>
</resources>
@@ -24,8 +24,8 @@ import android.accounts.Account
import android.os.Parcelable
import com.owncloud.android.lib.common.OwnCloudAccount
interface User : Parcelable {
val accountName: String
interface User : Parcelable, com.nextcloud.common.User {
override val accountName: String
val server: Server
val isAnonymous: Boolean
@@ -39,7 +39,7 @@ interface User : Parcelable {
* @return Account instance that is associated with this User object.
*/
@Deprecated("Temporary workaround")
fun toPlatformAccount(): Account
override fun toPlatformAccount(): Account
/**
* This is temporary helper method created to facilitate incremental refactoring.
@@ -147,21 +147,17 @@ public interface UserAccountManager extends CurrentAccountProvider {
* <p>
* Full account name is in form of "[email protected]".
*
* @param account Account instance
* @param user user instance
* @return User name (without domain) or null, if name cannot be extracted.
*/
static @Nullable
String getUsername(Account account) {
if (account != null && account.name != null) {
return account.name.substring(0, account.name.lastIndexOf('@'));
} else {
return null;
}
static String getUsername(User user) {
final String name = user.getAccountName();
return name.substring(0, name.lastIndexOf('@'));
}
static @Nullable
String getDisplayName(Account account) {
return AccountManager.get(MainApp.getAppContext()).getUserData(account,
@Nullable
static String getDisplayName(User user) {
return AccountManager.get(MainApp.getAppContext()).getUserData(user.toPlatformAccount(),
AccountUtils.Constants.KEY_DISPLAY_NAME);
}
@@ -23,7 +23,6 @@
*/
package com.nextcloud.client.jobs
import android.accounts.Account
import android.content.Context
import android.text.TextUtils
import androidx.work.Worker
@@ -110,7 +109,7 @@ class AccountRemovalWork(
arbitraryDataProvider.deleteKeyForAccount(user.accountName, ManageAccountsActivity.PENDING_FOR_REMOVAL)
// remove synced folders set for account
removeSyncedFolders(context, user.toPlatformAccount(), clock)
removeSyncedFolders(context, user, clock)
// delete all uploads for account
uploadsStorageManager.removeUserUploads(user)
@@ -182,7 +181,7 @@ class AccountRemovalWork(
}
}
private fun removeSyncedFolders(context: Context, account: Account, clock: Clock) {
private fun removeSyncedFolders(context: Context, user: User, clock: Clock) {
val syncedFolderProvider = SyncedFolderProvider(
context.contentResolver,
AppPreferencesImpl.fromContext(context),
@@ -191,11 +190,11 @@ class AccountRemovalWork(
val syncedFolders = syncedFolderProvider.syncedFolders
val syncedFolderIds: MutableList<Long> = ArrayList()
for (syncedFolder in syncedFolders) {
if (syncedFolder.account == account.name) {
if (syncedFolder.account == user.accountName) {
syncedFolderIds.add(syncedFolder.id)
}
}
syncedFolderProvider.deleteSyncFoldersForAccount(account)
syncedFolderProvider.deleteSyncFoldersForAccount(user)
val filesystemDataProvider = FilesystemDataProvider(context.contentResolver)
for (syncedFolderId in syncedFolderIds) {
filesystemDataProvider.deleteAllEntriesForSyncedFolder(syncedFolderId.toString())
@@ -173,7 +173,7 @@ class FilesSyncWork(
}
FileUploader.uploadNewFile(
context,
user.toPlatformAccount(),
user,
file.absolutePath,
FileStorageUtils.getInstantUploadFilePath(
file,
@@ -149,7 +149,7 @@ class MediaFoldersDetectionWork constructor(
for (imageMediaFolder in imageMediaFolderPaths) {
val folder = syncedFolderProvider.findByLocalPathAndAccount(
imageMediaFolder,
user.toPlatformAccount()
user
)
if (folder == null &&
SyncedFolderUtils.isQualifyingMediaFolder(imageMediaFolder, MediaFolderType.IMAGE)
@@ -170,7 +170,7 @@ class MediaFoldersDetectionWork constructor(
for (videoMediaFolder in videoMediaFolderPaths) {
val folder = syncedFolderProvider.findByLocalPathAndAccount(
videoMediaFolder,
user.toPlatformAccount()
user
)
if (folder == null) {
val contentTitle = String.format(
@@ -88,7 +88,7 @@ class OfflineSyncWork constructor(
ocFolder.remotePath,
ocFolder.etagOnServer
)
val result = checkEtagOperation.execute(user.toPlatformAccount(), context)
val result = checkEtagOperation.execute(user, context)
when (result.code) {
ResultCode.ETAG_UNCHANGED -> {
Log_OC.d(TAG, "$folderName: eTag unchanged")
@@ -59,7 +59,7 @@ class ClientFactoryImpl implements ClientFactory {
@Override
public NextcloudClient createNextcloudClient(User user) throws CreationException {
try {
return OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), context);
return OwnCloudClientFactory.createNextcloudClient(user, context);
} catch (AccountUtils.AccountNotFoundException e) {
throw new CreationException(e);
}
@@ -29,7 +29,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.lib.resources.users.SetPredefinedCustomStatusMessageRemoteOperation
public class SetPredefinedCustomStatusTask(
class SetPredefinedCustomStatusTask(
val messageId: String,
val clearAt: Long?,
val account: Account?,
@@ -59,6 +59,8 @@ import com.owncloud.android.utils.theme.ThemeTextInputUtils
import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.EmojiPopup
import com.vanniktech.emoji.google.GoogleEmojiProvider
import com.vanniktech.emoji.installDisableKeyboardInput
import com.vanniktech.emoji.installForceSingleEmoji
import java.util.Calendar
import java.util.Locale
import javax.inject.Inject
@@ -169,18 +171,18 @@ class SetStatusDialogFragment :
binding.setStatus.setOnClickListener { setStatusMessage() }
binding.emoji.setOnClickListener { popup.show() }
popup = EmojiPopup.Builder
.fromRootView(view)
.setOnEmojiClickListener { _, _ ->
popup = EmojiPopup(
view, binding.emoji,
onEmojiClickListener = {
popup.dismiss()
binding.emoji.clearFocus()
val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as
InputMethodManager
imm.hideSoftInputFromWindow(binding.emoji.windowToken, 0)
}
.build(binding.emoji)
binding.emoji.disableKeyboardInput(popup)
binding.emoji.forceSingleEmoji()
)
binding.emoji.installDisableKeyboardInput(popup)
binding.emoji.installForceSingleEmoji()
val adapter = ArrayAdapter<String>(requireContext(), android.R.layout.simple_spinner_item)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
@@ -30,6 +30,7 @@ import android.app.NotificationManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
@@ -57,6 +58,7 @@ import com.nextcloud.client.onboarding.OnboardingService;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.nextcloud.client.preferences.DarkMode;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.authentication.PassCodeManager;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.MediaFolder;
@@ -370,12 +372,33 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
});
}
@SuppressWarnings("unchecked")
private void initSecurityKeyManager() {
SecurityKeyManager securityKeyManager = SecurityKeyManager.getInstance();
SecurityKeyManagerConfig config = new SecurityKeyManagerConfig.Builder()
.setEnableDebugLogging(BuildConfig.DEBUG)
.build();
securityKeyManager.init(this, config);
final SecurityKeyManagerConfig.Builder configBuilder = new SecurityKeyManagerConfig.Builder()
.setEnableDebugLogging(BuildConfig.DEBUG);
try {
// exclude all activities except AuthenticatorActivity
final PackageManager pm = this.getPackageManager();
final PackageInfo info = pm.getPackageInfo(this.getPackageName(), PackageManager.GET_ACTIVITIES);
final ActivityInfo[] activities = info.activities;
for (ActivityInfo activityInfo : activities) {
try {
final Class<? extends Activity> aClass = (Class<? extends Activity>) Class.forName(activityInfo.name);
if (aClass != AuthenticatorActivity.class) {
configBuilder.addExcludedActivityClass(aClass);
}
} catch (ClassNotFoundException | ClassCastException e) {
Log_OC.e(TAG, "Couldn't disable activity for security key listener", e);
}
}
} catch (PackageManager.NameNotFoundException e) {
Log_OC.e(TAG, "Couldn't disable activities for security key listener", e);
}
securityKeyManager.init(this, configBuilder.build());
}
public static void initContactsBackup(UserAccountManager accountManager, BackgroundJobManager backgroundJobManager) {
@@ -278,7 +278,7 @@ public class FileDataStorageManager {
// remote request
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(parentPath);
// TODO Deprecated
RemoteOperationResult result = operation.execute(getUser().toPlatformAccount(), context);
RemoteOperationResult result = operation.execute(getUser(), context);
if (result.isSuccess()) {
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
@@ -506,6 +506,7 @@ public class FileDataStorageManager {
cv.put(ProviderTableMeta.FILE_LOCK_TIMESTAMP, file.getLockTimestamp());
cv.put(ProviderTableMeta.FILE_LOCK_TIMEOUT, file.getLockTimeout());
cv.put(ProviderTableMeta.FILE_LOCK_TOKEN, file.getLockToken());
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
return cv;
}
@@ -1626,25 +1627,29 @@ public class FileDataStorageManager {
if (path != null && !TextUtils.isEmpty(path)) {
ContentValues values = new ContentValues();
ContentResolver contentResolver = MainApp.getAppContext().getContentResolver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ) {
if (file != null) {
values.put(MediaStore.Images.Media.MIME_TYPE, file.getMimeType());
values.put(MediaStore.Images.Media.TITLE, file.getFileName());
values.put(MediaStore.Images.Media.DISPLAY_NAME, file.getFileName());
}
values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis() / 1000);
values.put(MediaStore.Images.Media.RELATIVE_PATH, path);
values.put(MediaStore.Images.Media.IS_PENDING, 0);
try {
contentResolver.insert(MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
values);
} catch (IllegalArgumentException e) {
Log_OC.e("MediaScanner", "Adding image to media scanner failed: " + e);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
if (file != null) {
values.put(MediaStore.Images.Media.MIME_TYPE, file.getMimeType());
values.put(MediaStore.Images.Media.TITLE, file.getFileName());
values.put(MediaStore.Images.Media.DISPLAY_NAME, file.getFileName());
}
values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis() / 1000);
values.put(MediaStore.Images.Media.RELATIVE_PATH, path);
values.put(MediaStore.Images.Media.IS_PENDING, 0);
try {
contentResolver.insert(MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
values);
} catch (IllegalArgumentException e) {
Log_OC.e("MediaScanner", "Adding image to media scanner failed: " + e);
}
} else {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(new File(path)));
MainApp.getAppContext().sendBroadcast(intent);
}
} else {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(new File(path)));
MainApp.getAppContext().sendBroadcast(intent);
Log_OC.d(TAG, "SDK > 29, skipping media scan");
}
}
}
@@ -52,6 +52,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
@VisibleForTesting
public final static String PERMISSION_CAN_RESHARE = "R";
private final static String PERMISSION_CAN_WRITE = "CK";
private final static String PERMISSION_GROUPFOLDER = "M";
public static final String PATH_SEPARATOR = "/";
public static final String ROOT_PATH = PATH_SEPARATOR;
@@ -618,6 +619,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
}
public boolean isGroupFolder() {
String permissions = getPermissions();
return permissions != null && permissions.contains(PERMISSION_GROUPFOLDER);
}
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
@Override
@@ -20,13 +20,13 @@
*/
package com.owncloud.android.datamodel;
import android.accounts.Account;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import com.nextcloud.client.account.User;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
@@ -187,14 +187,14 @@ public class SyncedFolderProvider extends Observable {
return result;
}
public SyncedFolder findByLocalPathAndAccount(String localPath, Account account) {
public SyncedFolder findByLocalPathAndAccount(String localPath, User user) {
SyncedFolder result = null;
Cursor cursor = mContentResolver.query(
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
null,
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + " LIKE ? AND " +
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " =? ",
new String[]{localPath + "%", account.name},
new String[]{localPath + "%", user.getAccountName()},
null
);
@@ -220,13 +220,13 @@ public class SyncedFolderProvider extends Observable {
/**
* Delete all synced folders for an account
*
* @param account whose synced folders should be deleted
* @param user whose synced folders should be deleted
*/
public int deleteSyncFoldersForAccount(Account account) {
public int deleteSyncFoldersForAccount(User user) {
return mContentResolver.delete(
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " = ?",
new String[]{String.valueOf(account.name)}
new String[]{String.valueOf(user.getAccountName())}
);
}
@@ -560,7 +560,7 @@ public class UploadsStorageManager extends Observable {
if (uploadResult.isCancelled()) {
removeUpload(
upload.getAccount().name,
upload.getUser().getAccountName(),
upload.getRemotePath()
);
} else {
@@ -22,24 +22,20 @@
package com.owncloud.android.files;
import android.accounts.AccountManager;
import android.content.ContentResolver;
import android.content.Context;
import android.view.Menu;
import android.view.MenuItem;
import com.google.gson.Gson;
import com.nextcloud.android.files.FileLockingHelper;
import com.nextcloud.client.account.User;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.lib.common.DirectEditing;
import com.owncloud.android.lib.common.Editor;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
import com.owncloud.android.ui.activity.ComponentsGetter;
import com.owncloud.android.utils.EditorUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.NextcloudServer;
@@ -49,8 +45,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import androidx.annotation.Nullable;
/**
* Filters out the file actions available in a given {@link Menu} for a given {@link OCFile}
* according to the current state of the latest.
@@ -316,7 +310,7 @@ public class FileMenuFilter {
}
private void filterEncrypt(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) {
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || isEncryptedFolder()
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || isEncryptedFolder() || isGroupFolder()
|| !endToEndEncryptionEnabled) {
toHide.add(R.id.action_encrypted);
} else {
@@ -352,44 +346,16 @@ public class FileMenuFilter {
String mimeType = files.iterator().next().getMimeType();
if (isRichDocumentEditingSupported(capability, mimeType) || isEditorAvailable(context.getContentResolver(),
user,
mimeType)) {
if (isRichDocumentEditingSupported(capability, mimeType) ||
EditorUtils.isEditorAvailable(context.getContentResolver(),
user,
mimeType)) {
toShow.add(R.id.action_edit);
} else {
toHide.add(R.id.action_edit);
}
}
public static boolean isEditorAvailable(ContentResolver contentResolver, User user, String mimeType) {
return getEditor(contentResolver, user, mimeType) != null;
}
@Nullable
public static Editor getEditor(ContentResolver contentResolver, User user, String mimeType) {
String json = new ArbitraryDataProvider(contentResolver).getValue(user, ArbitraryDataProvider.DIRECT_EDITING);
if (json.isEmpty()) {
return null;
}
DirectEditing directEditing = new Gson().fromJson(json, DirectEditing.class);
for (Editor editor : directEditing.getEditors().values()) {
if (editor.getMimetypes().contains(mimeType)) {
return editor;
}
}
for (Editor editor : directEditing.getEditors().values()) {
if (editor.getOptionalMimetypes().contains(mimeType)) {
return editor;
}
}
return null;
}
/**
* This will be replaced by unified editor and can be removed once EOL of corresponding server version.
*/
@@ -580,6 +546,10 @@ public class FileMenuFilter {
}
}
private boolean isGroupFolder() {
return files.iterator().next().isGroupFolder();
}
private boolean isSingleImage() {
return isSingleSelection() && MimeTypeUtil.isImage(files.iterator().next());
}
@@ -269,7 +269,7 @@ public class FileDownloader extends Service
@Override
public void onAccountsUpdated(Account[] accounts) {
//review the current download and cancel it if its account doesn't exist
if (mCurrentDownload != null && !accountManager.exists(mCurrentDownload.getAccount())) {
if (mCurrentDownload != null && !accountManager.exists(mCurrentDownload.getUser().toPlatformAccount())) {
mCurrentDownload.cancel();
}
// The rest of downloads are cancelled when they try to start
@@ -443,15 +443,12 @@ public class FileDownloader extends Service
if (mCurrentDownload != null) {
// Detect if the account exists
if (accountManager.exists(mCurrentDownload.getAccount())) {
Log_OC.d(TAG, "Account " + mCurrentDownload.getAccount().name + " exists");
if (accountManager.exists(mCurrentDownload.getUser().toPlatformAccount())) {
notifyDownloadStart(mCurrentDownload);
RemoteOperationResult downloadResult = null;
try {
/// prepare client object to send the request to the ownCloud server
Account currentDownloadAccount = mCurrentDownload.getAccount();
Account currentDownloadAccount = mCurrentDownload.getUser().toPlatformAccount();
Optional<User> currentDownloadUser = accountManager.getUser(currentDownloadAccount.name);
if (!currentUser.equals(currentDownloadUser)) {
currentUser = currentDownloadUser;
@@ -641,7 +638,7 @@ public class FileDownloader extends Service
.setProgress(0, 0, false);
if (needsToUpdateCredentials) {
configureUpdateCredentialsNotification(download.getAccount());
configureUpdateCredentialsNotification(download.getUser());
} else {
// TODO put something smart in showDetailsIntent
@@ -666,10 +663,10 @@ public class FileDownloader extends Service
}
}
private void configureUpdateCredentialsNotification(Account account) {
private void configureUpdateCredentialsNotification(User user) {
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
updateAccountCredentials.putExtra(
AuthenticatorActivity.EXTRA_ACTION,
AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN
@@ -701,7 +698,7 @@ public class FileDownloader extends Service
Intent end = new Intent(getDownloadFinishMessage());
end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess());
end.putExtra(ACCOUNT_NAME, download.getAccount().name);
end.putExtra(ACCOUNT_NAME, download.getUser().getAccountName());
end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
end.putExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR, download.getBehaviour());
end.putExtra(SendShareDialog.ACTIVITY_NAME, download.getActivityName());
@@ -723,7 +720,7 @@ public class FileDownloader extends Service
private void sendBroadcastNewDownload(DownloadFileOperation download,
String linkedToRemotePath) {
Intent added = new Intent(getDownloadAddedMessage());
added.putExtra(ACCOUNT_NAME, download.getAccount().name);
added.putExtra(ACCOUNT_NAME, download.getUser().getAccountName());
added.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
added.putExtra(EXTRA_LINKED_TO_PATH, linkedToRemotePath);
added.setPackage(getPackageName());
@@ -142,11 +142,18 @@ public class FileUploader extends Service
* Call this Service with KEY_RETRY and KEY_RETRY_UPLOAD to retry upload of file identified by KEY_RETRY_UPLOAD.
*/
private static final String KEY_RETRY_UPLOAD = "KEY_RETRY_UPLOAD";
/**
* {@link Account} to which file is to be uploaded.
*/
public static final String KEY_ACCOUNT = "ACCOUNT";
/**
* {@link User} for which file is to be uploaded.
*/
public static final String KEY_USER = "USER";
/**
* What {@link NameCollisionPolicy} to do when the file already exists on the remote.
*/
@@ -584,7 +591,7 @@ public class FileUploader extends Service
@Override
public void onAccountsUpdated(Account[] accounts) {
// Review current upload, and cancel it if its account doesn't exist
if (mCurrentUpload != null && !accountManager.exists(mCurrentUpload.getAccount())) {
if (mCurrentUpload != null && !accountManager.exists(mCurrentUpload.getUser().toPlatformAccount())) {
mCurrentUpload.cancel(ResultCode.ACCOUNT_NOT_FOUND);
}
// The rest of uploads are cancelled when they try to start
@@ -600,8 +607,8 @@ public class FileUploader extends Service
if (mCurrentUpload != null) {
/// Check account existence
if (!accountManager.exists(mCurrentUpload.getAccount())) {
Log_OC.w(TAG, "Account " + mCurrentUpload.getAccount().name +
if (!accountManager.exists(mCurrentUpload.getUser().toPlatformAccount())) {
Log_OC.w(TAG, "Account " + mCurrentUpload.getUser().getAccountName() +
" does not exist anymore -> cancelling all its uploads");
cancelPendingUploads(mCurrentUpload.getUser().getAccountName());
return;
@@ -618,28 +625,14 @@ public class FileUploader extends Service
try {
/// prepare client object to send the request to the ownCloud server
if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentUpload.getAccount())) {
mCurrentAccount = mCurrentUpload.getAccount();
if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentUpload.getUser().toPlatformAccount())) {
mCurrentAccount = mCurrentUpload.getUser().toPlatformAccount();
mStorageManager = new FileDataStorageManager(getCurrentUser().get(), getContentResolver());
} // else, reuse storage manager from previous operation
// always get client from client manager, to get fresh credentials in case of update
OwnCloudAccount ocAccount = new OwnCloudAccount(mCurrentAccount, this);
mUploadClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this);
// // If parent folder is encrypted, upload file encrypted
// OCFile parent = mStorageManager.getFileByPath(mCurrentUpload.getFile().getParentRemotePath());
// if (parent.isEncrypted()) {
// UploadEncryptedFileOperation uploadEncryptedFileOperation =
// new UploadEncryptedFileOperation(parent, mCurrentUpload);
//
// uploadResult = uploadEncryptedFileOperation.execute(mUploadClient, mStorageManager);
// } else {
/// perform the regular upload
uploadResult = mCurrentUpload.execute(mUploadClient);
// }
} catch (Exception e) {
Log_OC.e(TAG, "Error uploading", e);
uploadResult = new RemoteOperationResult(e);
@@ -810,7 +803,7 @@ public class FileUploader extends Service
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
updateAccountCredentials.putExtra(
AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount()
AuthenticatorActivity.EXTRA_ACCOUNT, upload.getUser().toPlatformAccount()
);
updateAccountCredentials.putExtra(
AuthenticatorActivity.EXTRA_ACTION,
@@ -878,7 +871,7 @@ public class FileUploader extends Service
Intent start = new Intent(getUploadStartMessage());
start.putExtra(EXTRA_REMOTE_PATH, upload.getRemotePath()); // real remote
start.putExtra(EXTRA_OLD_FILE_PATH, upload.getOriginalStoragePath());
start.putExtra(ACCOUNT_NAME, upload.getAccount().name);
start.putExtra(ACCOUNT_NAME, upload.getUser().getAccountName());
start.setPackage(getPackageName());
localBroadcastManager.sendBroadcast(start);
@@ -908,7 +901,7 @@ public class FileUploader extends Service
end.putExtra(EXTRA_OLD_REMOTE_PATH, upload.getOldFile().getRemotePath());
}
end.putExtra(EXTRA_OLD_FILE_PATH, upload.getOriginalStoragePath());
end.putExtra(ACCOUNT_NAME, upload.getAccount().name);
end.putExtra(ACCOUNT_NAME, upload.getUser().getAccountName());
end.putExtra(EXTRA_UPLOAD_RESULT, uploadResult.isSuccess());
if (unlinkedFromRemotePath != null) {
end.putExtra(EXTRA_LINKED_TO_PATH, unlinkedFromRemotePath);
@@ -932,7 +925,7 @@ public class FileUploader extends Service
*/
public static void uploadNewFile(
Context context,
Account account,
User user,
String localPath,
String remotePath,
int behaviour,
@@ -945,7 +938,7 @@ public class FileUploader extends Service
) {
uploadNewFile(
context,
account,
user,
new String[]{localPath},
new String[]{remotePath},
new String[]{mimeType},
@@ -963,7 +956,7 @@ public class FileUploader extends Service
*/
public static void uploadNewFile(
Context context,
Account account,
User user,
String[] localPaths,
String[] remotePaths,
String[] mimeTypes,
@@ -976,7 +969,8 @@ public class FileUploader extends Service
) {
Intent intent = new Intent(context, FileUploader.class);
intent.putExtra(FileUploader.KEY_ACCOUNT, account);
intent.putExtra(FileUploader.KEY_ACCOUNT, user.toPlatformAccount());
intent.putExtra(FileUploader.KEY_USER, user);
intent.putExtra(FileUploader.KEY_LOCAL_FILE, localPaths);
intent.putExtra(FileUploader.KEY_REMOTE_FILE, remotePaths);
intent.putExtra(FileUploader.KEY_MIME_TYPE, mimeTypes);
@@ -999,12 +993,12 @@ public class FileUploader extends Service
*/
public static void uploadUpdateFile(
Context context,
Account account,
User user,
OCFile existingFile,
Integer behaviour,
NameCollisionPolicy nameCollisionPolicy
) {
uploadUpdateFile(context, account, new OCFile[]{existingFile}, behaviour, nameCollisionPolicy, true);
) {
uploadUpdateFile(context, user, new OCFile[]{existingFile}, behaviour, nameCollisionPolicy, true);
}
/**
@@ -1012,13 +1006,13 @@ public class FileUploader extends Service
*/
public static void uploadUpdateFile(
Context context,
Account account,
User user,
OCFile existingFile,
Integer behaviour,
NameCollisionPolicy nameCollisionPolicy,
boolean disableRetries
) {
uploadUpdateFile(context, account, new OCFile[]{existingFile}, behaviour, nameCollisionPolicy, disableRetries);
uploadUpdateFile(context, user, new OCFile[]{existingFile}, behaviour, nameCollisionPolicy, disableRetries);
}
/**
@@ -1026,7 +1020,7 @@ public class FileUploader extends Service
*/
public static void uploadUpdateFile(
Context context,
Account account,
User user,
OCFile[] existingFiles,
Integer behaviour,
NameCollisionPolicy nameCollisionPolicy,
@@ -1034,7 +1028,8 @@ public class FileUploader extends Service
) {
Intent intent = new Intent(context, FileUploader.class);
intent.putExtra(FileUploader.KEY_ACCOUNT, account);
intent.putExtra(FileUploader.KEY_USER, user);
intent.putExtra(FileUploader.KEY_ACCOUNT, user.toPlatformAccount());
intent.putExtra(FileUploader.KEY_FILE, existingFiles);
intent.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, behaviour);
intent.putExtra(FileUploader.KEY_NAME_COLLISION_POLICY, nameCollisionPolicy);
@@ -1053,6 +1048,7 @@ public class FileUploader extends Service
public static void retryUpload(@NonNull Context context, @NonNull User user, @NonNull OCUpload upload) {
Intent i = new Intent(context, FileUploader.class);
i.putExtra(FileUploader.KEY_RETRY, true);
i.putExtra(FileUploader.KEY_USER, user);
i.putExtra(FileUploader.KEY_ACCOUNT, user.toPlatformAccount());
i.putExtra(FileUploader.KEY_RETRY_UPLOAD, upload);
@@ -1323,7 +1319,7 @@ public class FileUploader extends Service
long totalToTransfer,
String fileName
) {
String key = buildRemoteName(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath());
String key = buildRemoteName(mCurrentUpload.getUser().getAccountName(), mCurrentUpload.getFile().getRemotePath());
OnDatatransferProgressListener boundListener = mBoundListeners.get(key);
if (boundListener != null) {
@@ -1344,7 +1340,7 @@ public class FileUploader extends Service
if (cancelReason != null) {
cancel(
mCurrentUpload.getAccount().name,
mCurrentUpload.getUser().getAccountName(),
mCurrentUpload.getFile().getRemotePath(),
cancelReason
);
@@ -202,7 +202,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
if (encryptedRemotePath != null) {
RemoteOperationResult removeResult = new RemoveRemoteEncryptedFileOperation(encryptedRemotePath,
parent.getLocalId(),
user.toPlatformAccount(),
user,
context,
filename).execute(client);
@@ -185,7 +185,7 @@ public class DownloadFileOperation extends RemoteOperation {
DecryptedFolderMetadata metadata = EncryptionUtils.downloadFolderMetadata(parent,
client,
context,
user.toPlatformAccount());
user);
if (metadata == null) {
return new RemoteOperationResult(RemoteOperationResult.ResultCode.METADATA_NOT_FOUND);
@@ -239,11 +239,6 @@ public class DownloadFileOperation extends RemoteOperation {
}
}
@Deprecated
public Account getAccount() {
return this.user.toPlatformAccount();
}
public User getUser() {
return this.user;
}
@@ -273,7 +273,7 @@ public class RefreshFolderOperation extends RemoteOperation {
}
private void updateOCVersion(OwnCloudClient client) {
UpdateOCVersionOperation update = new UpdateOCVersionOperation(user.toPlatformAccount(), mContext);
UpdateOCVersionOperation update = new UpdateOCVersionOperation(user, mContext);
RemoteOperationResult result = update.execute(client);
if (result.isSuccess()) {
// Update Capabilities for this account
@@ -283,7 +283,7 @@ public class RefreshFolderOperation extends RemoteOperation {
private void updateUserProfile() {
try {
NextcloudClient nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), mContext);
NextcloudClient nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user, mContext);
RemoteOperationResult<UserInfo> result = new GetUserProfileOperation(mStorageManager).execute(nextcloudClient);
if (!result.isSuccess()) {
@@ -316,7 +316,7 @@ public class RefreshFolderOperation extends RemoteOperation {
}
private void updateDirectEditing(ArbitraryDataProvider arbitraryDataProvider, String newDirectEditingEtag) {
RemoteOperationResult<DirectEditing> result = new DirectEditingObtainRemoteOperation().execute(user.toPlatformAccount(),
RemoteOperationResult<DirectEditing> result = new DirectEditingObtainRemoteOperation().execute(user,
mContext);
if (result.isSuccess()) {
@@ -336,7 +336,7 @@ public class RefreshFolderOperation extends RemoteOperation {
NextcloudClient client;
try {
client = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), mContext);
client = OwnCloudClientFactory.createNextcloudClient(user, mContext);
} catch (AccountUtils.AccountNotFoundException | NullPointerException e) {
Log_OC.e(this, "Update of predefined status not possible!");
return;
@@ -474,7 +474,7 @@ public class RefreshFolderOperation extends RemoteOperation {
DecryptedFolderMetadata metadata = getDecryptedFolderMetadata(encryptedAncestor,
mLocalFolder,
getClient(),
user.toPlatformAccount(),
user,
mContext);
// get current data about local contents of the folder to synchronize
@@ -539,11 +539,11 @@ public class RefreshFolderOperation extends RemoteOperation {
public static DecryptedFolderMetadata getDecryptedFolderMetadata(boolean encryptedAncestor,
OCFile localFolder,
OwnCloudClient client,
Account account,
User user,
Context context) {
DecryptedFolderMetadata metadata;
if (encryptedAncestor) {
metadata = EncryptionUtils.downloadFolderMetadata(localFolder, client, context, account);
metadata = EncryptionUtils.downloadFolderMetadata(localFolder, client, context, user);
} else {
metadata = null;
}
@@ -22,9 +22,9 @@
package com.owncloud.android.operations;
import android.accounts.Account;
import android.content.Context;
import com.nextcloud.client.account.User;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
@@ -44,7 +44,7 @@ public class RemoveFileOperation extends SyncOperation {
private final OCFile fileToRemove;
private final boolean onlyLocalCopy;
private final Account account;
private final User user;
private final boolean inBackground;
private final Context context;
@@ -57,7 +57,7 @@ public class RemoveFileOperation extends SyncOperation {
*/
public RemoveFileOperation(OCFile fileToRemove,
boolean onlyLocalCopy,
Account account,
User user,
boolean inBackground,
Context context,
FileDataStorageManager storageManager) {
@@ -65,7 +65,7 @@ public class RemoveFileOperation extends SyncOperation {
this.fileToRemove = fileToRemove;
this.onlyLocalCopy = onlyLocalCopy;
this.account = account;
this.user = user;
this.inBackground = inBackground;
this.context = context;
}
@@ -105,7 +105,7 @@ public class RemoveFileOperation extends SyncOperation {
OCFile parent = getStorageManager().getFileByPath(fileToRemove.getParentRemotePath());
operation = new RemoveRemoteEncryptedFileOperation(fileToRemove.getRemotePath(),
parent.getLocalId(),
account,
user,
context,
fileToRemove.getEncryptedFileName());
} else {
@@ -21,10 +21,10 @@
package com.owncloud.android.operations;
import android.accounts.Account;
import android.content.Context;
import com.google.gson.reflect.TypeToken;
import com.nextcloud.client.account.User;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.DecryptedFolderMetadata;
import com.owncloud.android.datamodel.EncryptedFolderMetadata;
@@ -63,7 +63,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
private String remotePath;
private String parentId;
private Account account;
private User user;
private ArbitraryDataProvider arbitraryDataProvider;
private String fileName;
@@ -76,12 +76,12 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
*/
RemoveRemoteEncryptedFileOperation(String remotePath,
String parentId,
Account account,
User user,
Context context,
String fileName) {
this.remotePath = remotePath;
this.parentId = parentId;
this.account = account;
this.user = user;
this.fileName = fileName;
arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
@@ -97,7 +97,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
String token = null;
DecryptedFolderMetadata metadata;
String privateKey = arbitraryDataProvider.getValue(account.name, EncryptionUtils.PRIVATE_KEY);
String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);
try {
// Lock folder
@@ -300,7 +300,7 @@ public class SynchronizeFileOperation extends SyncOperation {
private void requestForUpload(OCFile file) {
FileUploader.uploadUpdateFile(
mContext,
mUser.toPlatformAccount(),
mUser,
file,
FileUploader.LOCAL_BEHAVIOUR_MOVE,
NameCollisionPolicy.OVERWRITE
@@ -283,7 +283,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
DecryptedFolderMetadata metadata = RefreshFolderOperation.getDecryptedFolderMetadata(encryptedAncestor,
mLocalFolder,
getClient(),
user.toPlatformAccount(),
user,
mContext);
// get current data about local contents of the folder to synchronize
@@ -24,6 +24,7 @@ import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import com.nextcloud.client.account.User;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
import com.owncloud.android.lib.common.operations.RemoteOperation;
@@ -47,13 +48,12 @@ public class UpdateOCVersionOperation extends RemoteOperation {
private static final String STATUS_PATH = "/status.php";
private Account mAccount;
private final User user;
private Context mContext;
private OwnCloudVersion mOwnCloudVersion;
public UpdateOCVersionOperation(Account account, Context context) {
mAccount = account;
public UpdateOCVersionOperation(User user, Context context) {
this.user = user;
mContext = context;
mOwnCloudVersion = null;
}
@@ -62,7 +62,7 @@ public class UpdateOCVersionOperation extends RemoteOperation {
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
AccountManager accountMngr = AccountManager.get(mContext);
String statUrl = accountMngr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);
String statUrl = accountMngr.getUserData(user.toPlatformAccount(), Constants.KEY_OC_BASE_URL);
statUrl += STATUS_PATH;
RemoteOperationResult result = null;
GetMethod getMethod = null;
@@ -85,7 +85,7 @@ public class UpdateOCVersionOperation extends RemoteOperation {
String version = json.getString("version");
mOwnCloudVersion = new OwnCloudVersion(version);
if (mOwnCloudVersion.isVersionValid()) {
accountMngr.setUserData(mAccount, Constants.KEY_OC_VERSION, mOwnCloudVersion.getVersion());
accountMngr.setUserData(user.toPlatformAccount(), Constants.KEY_OC_VERSION, mOwnCloudVersion.getVersion());
Log_OC.d(TAG, "Got new OC version " + mOwnCloudVersion);
result = new RemoteOperationResult(ResultCode.OK);
@@ -264,10 +264,6 @@ public class UploadFileOperation extends SyncOperation {
public boolean isIgnoringPowerSaveMode() { return mIgnoringPowerSaveMode; }
public Account getAccount() {
return user.toPlatformAccount();
}
public User getUser() {
return user;
}
@@ -468,8 +464,8 @@ public class UploadFileOperation extends SyncOperation {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());
String privateKey = arbitraryDataProvider.getValue(getAccount().name, EncryptionUtils.PRIVATE_KEY);
String publicKey = arbitraryDataProvider.getValue(getAccount().name, EncryptionUtils.PUBLIC_KEY);
String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);
String publicKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PUBLIC_KEY);
try {
// check conditions
@@ -61,7 +61,7 @@ public abstract class SyncOperation extends RemoteOperation {
throw new IllegalArgumentException("Trying to execute a sync operation with a " +
"storage manager for an anonymous account");
}
return super.execute(this.storageManager.getUser().toPlatformAccount(), context);
return super.execute(this.storageManager.getUser(), context);
}
public RemoteOperationResult execute(@NonNull NextcloudClient client) {
@@ -263,7 +263,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
// upload file with FileUploader service (off main thread)
FileUploader.uploadUpdateFile(
context,
user.toPlatformAccount(),
user,
ocFile,
LOCAL_BEHAVIOUR_DELETE,
NameCollisionPolicy.OVERWRITE,
@@ -284,7 +284,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
Context context = getNonNullContext();
OCFile ocFile = document.getFile();
RemoteOperationResult result = new CheckEtagRemoteOperation(ocFile.getRemotePath(), ocFile.getEtag())
.execute(document.getUser().toPlatformAccount(), context);
.execute(document.getUser(), context);
switch (result.getCode()) {
case ETAG_CHANGED:
return true;
@@ -611,7 +611,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
OCFile file = document.getStorageManager().getFileByPath(document.getRemotePath());
RemoteOperationResult result = new RemoveFileOperation(file,
false,
document.getUser().toPlatformAccount(),
document.getUser(),
true,
context,
document.getStorageManager())
@@ -207,7 +207,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
// request to the OC server about users and groups matching userQuery
GetShareesRemoteOperation searchRequest = new GetShareesRemoteOperation(userQuery, REQUESTED_PAGE,
RESULTS_PER_PAGE);
RemoteOperationResult result = searchRequest.execute(user.toPlatformAccount(), getContext());
RemoteOperationResult result = searchRequest.execute(user, getContext());
List<JSONObject> names = new ArrayList<>();
if (result.isSuccess()) {
@@ -668,7 +668,7 @@ public class OperationsService extends Service {
boolean inBackground = operationIntent.getBooleanExtra(EXTRA_IN_BACKGROUND, false);
operation = new RemoveFileOperation(file,
onlyLocalCopy,
account,
user,
inBackground,
getApplicationContext(),
fileDataStorageManager);
@@ -249,7 +249,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
* Updates the locally stored version value of the ownCloud server
*/
private void updateOCVersion() {
UpdateOCVersionOperation update = new UpdateOCVersionOperation(getAccount(), getContext());
UpdateOCVersionOperation update = new UpdateOCVersionOperation(getUser(), getContext());
RemoteOperationResult result = update.execute(getClient());
if (!result.isSuccess()) {
mLastFailedResult = result;
@@ -101,7 +101,7 @@ public class TextDrawable extends Drawable {
*/
@NonNull
public static TextDrawable createAvatar(User user, float radiusInDp) {
String username = UserAccountManager.getDisplayName(user.toPlatformAccount());
String username = UserAccountManager.getDisplayName(user);
return createNamedAvatar(username, radiusInDp);
}
@@ -28,6 +28,7 @@ import android.accounts.OperationCanceledException;
import android.content.Context;
import android.os.AsyncTask;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.common.NextcloudClient;
import com.owncloud.android.MainApp;
@@ -50,7 +51,7 @@ import java.util.List;
public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
private static final String TAG = ActivitiesServiceApiImpl.class.getSimpleName();
private UserAccountManager accountManager;
private final UserAccountManager accountManager;
public ActivitiesServiceApiImpl(UserAccountManager accountManager) {
this.accountManager = accountManager;
@@ -58,7 +59,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
@Override
public void getAllActivities(int lastGiven, ActivitiesServiceCallback<List<Object>> callback) {
GetActivityListTask getActivityListTask = new GetActivityListTask(accountManager.getUser().toPlatformAccount(),
GetActivityListTask getActivityListTask = new GetActivityListTask(accountManager.getUser(),
lastGiven,
callback);
getActivityListTask.execute();
@@ -68,15 +69,15 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
private final ActivitiesServiceCallback<List<Object>> callback;
private List<Object> activities;
private Account account;
private final User user;
private int lastGiven;
private String errorMessage;
private NextcloudClient client;
private GetActivityListTask(Account account,
private GetActivityListTask(User user,
int lastGiven,
ActivitiesServiceCallback<List<Object>> callback) {
this.account = account;
this.user = user;
this.lastGiven = lastGiven;
this.callback = callback;
activities = new ArrayList<>();
@@ -86,9 +87,8 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
@Override
protected Boolean doInBackground(Void... voids) {
final Context context = MainApp.getAppContext();
OwnCloudAccount ocAccount;
try {
ocAccount = new OwnCloudAccount(account, context);
final OwnCloudAccount ocAccount = user.toOwnCloudAccount();
client = OwnCloudClientManagerFactory.getDefaultSingleton().
getNextcloudClientFor(ocAccount, MainApp.getAppContext());
@@ -117,9 +117,6 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
return Boolean.FALSE;
}
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Account not found", e);
errorMessage = "Account not found";
} catch (IOException e) {
Log_OC.e(TAG, "IO error", e);
errorMessage = "IO error";
@@ -87,7 +87,7 @@ public class CommunityActivity extends DrawerActivity {
MaterialButton reportButton = binding.communityTestingReport;
themeButtonUtils.colorPrimaryButton(reportButton, this, themeColorUtils);
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_empty_link));
binding.communityBetaFdroid.setOnClickListener(
l -> DisplayUtils.startLinkIntent(this, R.string.fdroid_beta_link));
@@ -113,7 +113,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
listener = decision -> {
OCFile file = newFile; // local file got changed, so either upload it or replace it again by server
// version
User user = getUser().orElseThrow(RuntimeException::new);
switch (decision) {
case CANCEL:
// nothing to do
@@ -121,7 +121,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
case KEEP_LOCAL: // Upload
FileUploader.uploadUpdateFile(
getBaseContext(),
getAccount(),
user,
file,
localBehaviour,
NameCollisionPolicy.OVERWRITE
@@ -132,7 +132,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
case KEEP_BOTH: // Upload
FileUploader.uploadUpdateFile(
getBaseContext(),
getAccount(),
user,
file,
localBehaviour,
NameCollisionPolicy.RENAME
@@ -1165,7 +1165,7 @@ public abstract class DrawerActivity extends ToolbarActivity
Log_OC.d("ExternalLinks", "update via api");
RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
RemoteOperationResult result = getExternalLinksOperation.execute(user.toPlatformAccount(), this);
RemoteOperationResult result = getExternalLinksOperation.execute(user, this);
if (result.isSuccess() && result.getData() != null) {
externalLinksProvider.deleteAllExternalLinks();
@@ -156,6 +156,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
file.isSharedWithSharee(),
file.isSharedViaLink(),
file.isEncrypted(),
file.isGroupFolder(),
file.getMountType(),
this,
themeColorUtils,
@@ -179,7 +179,7 @@ public class ExternalSiteWebView extends FileActivity {
webSettings.setLoadWithOverviewMode(true);
// user agent
webSettings.setUserAgentString(MainApp.getUserAgent());
setUserAgentString(webSettings);
// no private data storing
webSettings.setSavePassword(false);
@@ -199,6 +199,10 @@ public class ExternalSiteWebView extends FileActivity {
}
}
protected void setUserAgentString(WebSettings webSettings) {
webSettings.setUserAgentString(MainApp.getUserAgent());
}
private void setupActionBar(String title) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
@@ -87,6 +87,7 @@ import com.owncloud.android.ui.dialog.ShareLinkToDialog;
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
import com.owncloud.android.ui.fragment.FileDetailFragment;
import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.helpers.FileOperationsHelper;
import com.owncloud.android.utils.ClipboardUtil;
import com.owncloud.android.utils.DisplayUtils;
@@ -781,6 +782,7 @@ public abstract class FileActivity extends DrawerActivity
private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
RemoteOperationResult result) {
FileDetailSharingFragment sharingFragment = getShareFileFragment();
OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES);
if (result.isSuccess()) {
updateFileFromDB();
@@ -803,6 +805,10 @@ public abstract class FileActivity extends DrawerActivity
if (sharingFragment != null) {
sharingFragment.onUpdateShareInformation(result, file);
}
if (fileListFragment != null && file != null) {
fileListFragment.updateOCFile(file);
}
} else {
// Detect Failure (403) --> maybe needs password
String password = operation.getPassword();
@@ -907,7 +907,7 @@ public class FileDisplayActivity extends FileActivity
FileUploader.uploadNewFile(
this,
getAccount(),
getUser().orElseThrow(RuntimeException::new),
filePaths,
remotePaths,
null, // MIME type will be detected from file name
@@ -2282,8 +2282,10 @@ public class FileDisplayActivity extends FileActivity
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_on_device));
}
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
if (ocFileListFragment != null) {
if (ocFileListFragment != null && !(ocFileListFragment instanceof GalleryFragment) && !(ocFileListFragment instanceof SharedListFragment)) {
ocFileListFragment.refreshDirectory();
} else {
setLeftFragment(new OCFileListFragment());
}
}
@@ -449,7 +449,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
) {
if (result.isSuccess()) {
refreshListOfFilesFragment(false);
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.onItemClicked(getStorageManager().getFileByPath(operation.getRemotePath()));
}
} else {
try {
DisplayUtils.showSnackMessage(
@@ -63,6 +63,7 @@ import android.widget.Toast;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.nextcloud.client.account.User;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.MainApp;
@@ -898,7 +899,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
public void uploadFile(String tmpName, String filename) {
FileUploader.uploadNewFile(
getBaseContext(),
getAccount(),
getUser().orElseThrow(RuntimeException::new),
tmpName,
mFile.getRemotePath() + filename,
FileUploader.LOCAL_BEHAVIOUR_COPY,
@@ -176,7 +176,7 @@ public class RichDocumentsEditorWebView extends EditorWebView {
new Thread(() -> {
User user = currentAccountProvider.getUser();
RichDocumentsCreateAssetOperation operation = new RichDocumentsCreateAssetOperation(file.getRemotePath());
RemoteOperationResult result = operation.execute(user.toPlatformAccount(), this);
RemoteOperationResult result = operation.execute(user, this);
if (result.isSuccess()) {
String asset = (String) result.getSingleData();
@@ -785,7 +785,7 @@ public class SettingsActivity extends ThemedPreferenceActivity
davDroidLoginIntent.setData(Uri.parse(serverBaseUri.toString() + AuthenticatorActivity.WEB_LOGIN));
davDroidLoginIntent.putExtra("davPath", DAV_PATH);
}
davDroidLoginIntent.putExtra("username", UserAccountManager.getUsername(user.toPlatformAccount()));
davDroidLoginIntent.putExtra("username", UserAccountManager.getUsername(user));
startActivityForResult(davDroidLoginIntent, ACTION_REQUEST_CODE_DAVDROID_SETUP);
} else {
@@ -76,6 +76,7 @@ public class ShareActivity extends FileActivity {
file.isSharedWithSharee(),
file.isSharedViaLink(),
file.isEncrypted(),
file.isGroupFolder(),
file.getMountType(),
this,
themeColorUtils,
@@ -108,7 +109,7 @@ public class ShareActivity extends FileActivity {
Activity activity = this;
new Thread(() -> {
RemoteOperationResult result = new ReadFileRemoteOperation(getFile().getRemotePath())
.execute(optionalUser.get().toPlatformAccount(),
.execute(optionalUser.get(),
activity);
if (result.isSuccess()) {
@@ -672,8 +672,7 @@ class SyncedFoldersActivity :
)
saveOrUpdateSyncedFolder(item)
// TODO test if notifyItemChanged is sufficient (should improve performance)
adapter.notifyDataSetChanged()
adapter.notifyItemChanged(adapter.getSectionHeaderIndex(syncedFolder.section))
}
syncedFolderPreferencesDialogFragment = null
if (syncedFolder.isEnabled) {
@@ -23,14 +23,15 @@ package com.owncloud.android.ui.activity
import android.annotation.SuppressLint
import android.net.Uri
import android.webkit.WebSettings
import android.widget.Toast
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import com.nextcloud.client.appinfo.AppInfo
import com.nextcloud.client.device.DeviceInfo
import com.owncloud.android.R
import com.owncloud.android.files.FileMenuFilter
import com.owncloud.android.ui.asynctasks.TextEditorLoadUrlTask
import com.owncloud.android.utils.EditorUtils
import com.owncloud.android.utils.theme.ThemeUtils
import javax.inject.Inject
@@ -53,29 +54,33 @@ class TextEditorWebView : EditorWebView() {
finish()
}
val editor = FileMenuFilter.getEditor(contentResolver, user.get(), file.mimeType)
if (editor != null && editor.id == "onlyoffice") {
getWebView().settings.userAgentString = generateOnlyOfficeUserAgent()
}
getWebView().addJavascriptInterface(MobileInterface(), "DirectEditingMobileInterface")
webView.addJavascriptInterface(MobileInterface(), "DirectEditingMobileInterface")
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
WebSettingsCompat.setForceDarkStrategy(
getWebView().settings,
webView.settings,
WebSettingsCompat.DARK_STRATEGY_WEB_THEME_DARKENING_ONLY
)
}
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK) && themeUtils.isDarkModeActive(this)) {
WebSettingsCompat.setForceDark(getWebView().settings, WebSettingsCompat.FORCE_DARK_ON)
WebSettingsCompat.setForceDark(webView.settings, WebSettingsCompat.FORCE_DARK_ON)
}
getWebView().setDownloadListener { url, _, _, _, _ -> downloadFile(Uri.parse(url)) }
webView.setDownloadListener { url, _, _, _, _ -> downloadFile(Uri.parse(url)) }
loadUrl(intent.getStringExtra(ExternalSiteWebView.EXTRA_URL))
}
override fun setUserAgentString(webSettings: WebSettings?) {
val editor = EditorUtils.getEditor(contentResolver, user.get(), file.mimeType)
if (editor != null && editor.id == ONLYOFFICE) {
webView.settings.userAgentString = generateOnlyOfficeUserAgent()
}
// For Text/prosemirror we keep default user agent to not mess around with their special treatments
}
override fun loadUrl(url: String?) {
if (url.isNullOrEmpty()) {
TextEditorLoadUrlTask(this, user.get(), file).execute()
@@ -87,4 +92,8 @@ class TextEditorWebView : EditorWebView() {
return String.format(userAgent, deviceInfo.androidVersion, appInfo.getAppVersion(this))
}
companion object {
const val ONLYOFFICE = "onlyoffice"
}
}
@@ -316,7 +316,7 @@ public class UserInfoActivity extends DrawerActivity implements Injectable {
NextcloudClient nextcloudClient;
try {
nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(),
nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user,
this);
} catch (AccountUtils.AccountNotFoundException e) {
Log_OC.e(this, "Error retrieving user info", e);
@@ -178,10 +178,11 @@ class GalleryAdapter(
return files.isEmpty()
}
fun getItem(position: Int): OCFile {
fun getItem(position: Int): OCFile? {
val itemCoord = getRelativePosition(position)
return files[itemCoord.section()].files[itemCoord.relativePos()]
return files
.getOrNull(itemCoord.section())?.files
?.getOrNull(itemCoord.relativePos())
}
override fun isMultiSelect(): Boolean {
@@ -770,7 +770,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
mStorageManager,
user,
activity);
refreshFolderOperation.execute(user.toPlatformAccount(), activity);
refreshFolderOperation.execute(user, activity);
}
}
@@ -911,19 +911,22 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public String getPopupText(int position) {
OCFile file = getItem(position);
if (file == null) {
if (file == null || sortOrder == null) {
return "";
}
if (sortOrder.getType() == FileSortOrder.SortType.ALPHABET) {
return String.valueOf(file.getFileName().charAt(0)).toUpperCase(Locale.getDefault());
} else if (sortOrder.getType() == FileSortOrder.SortType.DATE) {
long milliseconds = file.getModificationTimestamp();
Date date = new Date(milliseconds);
return dateFormat.format(date);
} else {
// Size
return DisplayUtils.bytesToHumanReadable(file.getFileLength());
switch (sortOrder.getType()) {
case ALPHABET:
return String.valueOf(file.getFileName().charAt(0)).toUpperCase(Locale.getDefault());
case DATE:
long milliseconds = file.getModificationTimestamp();
Date date = new Date(milliseconds);
return dateFormat.format(date);
case SIZE:
return DisplayUtils.bytesToHumanReadable(file.getFileLength());
default:
Log_OC.d(TAG, "getPopupText: Unsupported sort order: " + sortOrder.getType());
return "";
}
}
@@ -367,9 +367,9 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
final UploadResult uploadResult = item.getLastResult();
itemViewHolder.binding.uploadListItemLayout.setOnClickListener(v -> {
if (uploadResult == UploadResult.CREDENTIAL_ERROR) {
final Optional<User> user = accountManager.getUser(item.getAccountName());
final Account account = user.orElseThrow(RuntimeException::new).toPlatformAccount();
parentActivity.getFileOperationsHelper().checkCurrentCredentials(account);
final Optional<User> optUser = accountManager.getUser(item.getAccountName());
final User user = optUser.orElseThrow(RuntimeException::new);
parentActivity.getFileOperationsHelper().checkCurrentCredentials(user);
return;
} else if (uploadResult == UploadResult.SYNC_CONFLICT && optionalUser.isPresent()) {
User user = optionalUser.get();
@@ -578,7 +578,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
storageManager,
user,
context)
.execute(user.toPlatformAccount(), context, (caller, result) -> {
.execute(user, context, (caller, result) -> {
view.binding.uploadListItemLayout.setClickable(true);
listener.onRemoteOperationFinish(caller, result);
}, parentActivity.getHandler());
@@ -108,6 +108,7 @@ public class UploaderAdapter extends SimpleAdapter {
final Drawable icon = MimeTypeUtil.getFolderTypeIcon(isShared,
file.isSharedViaLink(),
file.isEncrypted(),
file.isGroupFolder(),
user,
file.getMountType(),
mContext,
@@ -303,7 +303,7 @@ public class UserListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
binding.userName.setText(oca.getDisplayName());
} catch (Exception e) {
Log_OC.w(TAG, "Account not found right after being read; using account name instead");
binding.userName.setText(UserAccountManager.getUsername(user.toPlatformAccount()));
binding.userName.setText(UserAccountManager.getUsername(user));
}
binding.userName.setTag(user.getAccountName());
}
@@ -191,7 +191,7 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
}
requestUpload(
user.toPlatformAccount(),
user,
fullTempPath,
currentRemotePath,
behaviour,
@@ -249,10 +249,10 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
return result;
}
private void requestUpload(Account account, String localPath, String remotePath, int behaviour, String mimeType) {
private void requestUpload(User user, String localPath, String remotePath, int behaviour, String mimeType) {
FileUploader.uploadNewFile(
mAppContext,
account,
user,
localPath,
remotePath,
behaviour,
@@ -60,8 +60,7 @@ public class FetchRemoteFileTask extends AsyncTask<Void, Void, String> {
FILE_ID_SEARCH,
false,
fileDisplayActivity.getCapabilities());
RemoteOperationResult remoteOperationResult = searchRemoteOperation.execute(user.toPlatformAccount(),
fileDisplayActivity);
RemoteOperationResult remoteOperationResult = searchRemoteOperation.execute(user, fileDisplayActivity);
if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
if (remoteOperationResult.getData().isEmpty()) {
@@ -70,7 +69,7 @@ public class FetchRemoteFileTask extends AsyncTask<Void, Void, String> {
String remotePath = ((RemoteFile) remoteOperationResult.getData().get(0)).getRemotePath();
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(remotePath);
RemoteOperationResult result = operation.execute(user.toPlatformAccount(), fileDisplayActivity);
RemoteOperationResult result = operation.execute(user, fileDisplayActivity);
if (!result.isSuccess()) {
Exception exception = result.getException();
@@ -105,7 +104,7 @@ public class FetchRemoteFileTask extends AsyncTask<Void, Void, String> {
storageManager,
user,
fileDisplayActivity);
refreshFolderOperation.execute(user.toPlatformAccount(), fileDisplayActivity);
refreshFolderOperation.execute(user, fileDisplayActivity);
fileDisplayActivity.setFile(ocFile);
} else {
@@ -96,8 +96,7 @@ public class GallerySearchTask extends AsyncTask<Void, Void, GallerySearchTask.R
" - " + new Date(endDate * 1000L) +
" with limit: " + limit);
RemoteOperationResult result = searchRemoteOperation.execute(user.toPlatformAccount(),
photoFragment.getContext());
RemoteOperationResult result = searchRemoteOperation.execute(user, photoFragment.getContext());
if (result.isSuccess()) {
boolean emptySearch = parseMedia(startDate, endDate, result.getData());
@@ -34,12 +34,12 @@ import java.lang.ref.WeakReference;
public class RichDocumentsLoadUrlTask extends AsyncTask<Void, Void, String> {
private Account account;
private final User user;
private WeakReference<EditorWebView> editorWebViewWeakReference;
private OCFile file;
public RichDocumentsLoadUrlTask(EditorWebView editorWebView, User user, OCFile file) {
this.account = user.toPlatformAccount();
this.user = user;
this.editorWebViewWeakReference = new WeakReference<>(editorWebView);
this.file = file;
}
@@ -52,7 +52,7 @@ public class RichDocumentsLoadUrlTask extends AsyncTask<Void, Void, String> {
return "";
}
RemoteOperationResult result = new RichDocumentsUrlOperation(file.getLocalId()).execute(account, editorWebView);
RemoteOperationResult result = new RichDocumentsUrlOperation(file.getLocalId()).execute(user, editorWebView);
if (!result.isSuccess()) {
return "";
@@ -26,23 +26,21 @@ import android.os.AsyncTask;
import com.nextcloud.android.lib.resources.directediting.DirectEditingOpenFileRemoteOperation;
import com.nextcloud.client.account.User;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.lib.common.Editor;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.ui.activity.EditorWebView;
import com.owncloud.android.utils.EditorUtils;
import java.lang.ref.WeakReference;
public class TextEditorLoadUrlTask extends AsyncTask<Void, Void, String> {
private Account account;
private WeakReference<EditorWebView> editorWebViewWeakReference;
private OCFile file;
private User user;
public TextEditorLoadUrlTask(EditorWebView editorWebView, User user, OCFile file) {
this.user = user;
this.account = user.toPlatformAccount();
this.editorWebViewWeakReference = new WeakReference<>(editorWebView);
this.file = file;
}
@@ -55,14 +53,14 @@ public class TextEditorLoadUrlTask extends AsyncTask<Void, Void, String> {
return "";
}
Editor editor = FileMenuFilter.getEditor(editorWebView.getContentResolver(), user, file.getMimeType());
Editor editor = EditorUtils.getEditor(editorWebView.getContentResolver(), user, file.getMimeType());
if (editor == null) {
return "";
}
RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(file.getRemotePath(), editor.getId())
.execute(account, editorWebViewWeakReference.get());
.execute(user, editorWebViewWeakReference.get());
if (!result.isSuccess()) {
@@ -1,451 +0,0 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* @author Chris Narkiewicz
*
* Copyright (C) 2018 Tobias Kaminsky
* Copyright (C) 2018 Nextcloud GmbH.
* Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import com.nextcloud.android.lib.resources.directediting.DirectEditingCreateFileRemoteOperation;
import com.nextcloud.android.lib.resources.directediting.DirectEditingObtainListOfTemplatesRemoteOperation;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.account.User;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.databinding.ChooseTemplateBinding;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.Creator;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.Template;
import com.owncloud.android.lib.common.TemplateList;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.ui.activity.ExternalSiteWebView;
import com.owncloud.android.ui.activity.TextEditorWebView;
import com.owncloud.android.ui.adapter.TemplateAdapter;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.ThemeTextInputUtils;
import java.lang.ref.WeakReference;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.GridLayoutManager;
/**
* Dialog to show templates for new documents/spreadsheets/presentations.
*/
public class ChooseTemplateDialogFragment extends DialogFragment implements View.OnClickListener,
TemplateAdapter.ClickListener, Injectable {
private static final String ARG_PARENT_FOLDER = "PARENT_FOLDER";
private static final String ARG_CREATOR = "CREATOR";
private static final String ARG_HEADLINE = "HEADLINE";
private static final String TAG = ChooseTemplateDialogFragment.class.getSimpleName();
private static final String DOT = ".";
public static final int SINGLE_TEMPLATE = 1;
@Inject ClientFactory clientFactory;
@Inject CurrentAccountProvider currentAccount;
@Inject ThemeColorUtils themeColorUtils;
@Inject ThemeDrawableUtils themeDrawableUtils;
@Inject ThemeButtonUtils themeButtonUtils;
@Inject ThemeTextInputUtils themeTextInputUtils;
private TemplateAdapter adapter;
private OCFile parentFolder;
private String title;
private Button positiveButton;
private Creator creator;
public enum Type {
DOCUMENT,
SPREADSHEET,
PRESENTATION
}
ChooseTemplateBinding binding;
public static ChooseTemplateDialogFragment newInstance(OCFile parentFolder, Creator creator, String headline) {
ChooseTemplateDialogFragment frag = new ChooseTemplateDialogFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_PARENT_FOLDER, parentFolder);
args.putParcelable(ARG_CREATOR, creator);
args.putString(ARG_HEADLINE, headline);
frag.setArguments(args);
return frag;
}
@Override
public void onStart() {
super.onStart();
AlertDialog alertDialog = (AlertDialog) getDialog();
positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
themeButtonUtils.themeBorderlessButton(themeColorUtils,
positiveButton,
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
positiveButton.setOnClickListener(this);
positiveButton.setEnabled(false);
checkEnablingCreateButton();
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments == null) {
throw new IllegalArgumentException("Arguments may not be null");
}
Activity activity = getActivity();
if (activity == null) {
throw new IllegalArgumentException("Activity may not be null");
}
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER);
creator = arguments.getParcelable(ARG_CREATOR);
title = arguments.getString(ARG_HEADLINE, getString(R.string.select_template));
if (savedInstanceState == null) {
title = arguments.getString(ARG_HEADLINE);
} else {
title = savedInstanceState.getString(ARG_HEADLINE);
}
// Inflate the layout for the dialog
LayoutInflater inflater = requireActivity().getLayoutInflater();
binding = ChooseTemplateBinding.inflate(inflater, null, false);
View view = binding.getRoot();
binding.filename.requestFocus();
themeTextInputUtils.colorTextInput(binding.filenameContainer,
binding.filename,
themeColorUtils.primaryColor(getContext()));
binding.filename.setOnKeyListener((v, keyCode, event) -> {
checkEnablingCreateButton();
return false;
});
binding.filename.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// generated method stub
}
@Override
public void afterTextChanged(Editable s) {
checkEnablingCreateButton();
}
});
try {
User user = currentAccount.getUser();
new FetchTemplateTask(this, clientFactory, user, creator).execute();
} catch (Exception e) {
Log_OC.e(TAG, "Loading stream url not possible: " + e);
}
binding.list.setHasFixedSize(true);
binding.list.setLayoutManager(new GridLayoutManager(activity, 2));
adapter = new TemplateAdapter(creator.getMimetype(),
this,
getContext(),
currentAccount,
clientFactory,
themeColorUtils,
themeDrawableUtils);
binding.list.setAdapter(adapter);
// Build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(view)
.setPositiveButton(R.string.create, null)
.setNeutralButton(R.string.common_cancel, null)
.setTitle(title);
Dialog dialog = builder.create();
Window window = dialog.getWindow();
if (window != null) {
window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
return dialog;
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
@Override
public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putString(ARG_HEADLINE, title);
}
private void createFromTemplate(Template template, String path) {
new CreateFileFromTemplateTask(this, clientFactory, currentAccount.getUser(), template, path, creator).execute();
}
public void setTemplateList(TemplateList templateList) {
adapter.setTemplateList(templateList);
adapter.notifyDataSetChanged();
}
@Override
public void onClick(Template template) {
onTemplateChosen(template);
}
private void onTemplateChosen(Template template) {
adapter.setTemplateAsActive(template);
prefillFilenameIfEmpty(template);
checkEnablingCreateButton();
}
private void prefillFilenameIfEmpty(Template template) {
String name = binding.filename.getText().toString();
if (name.isEmpty() || name.equalsIgnoreCase(DOT + template.getExtension())) {
binding.filename.setText(String.format("%s.%s", template.getTitle(), template.getExtension()));
name = binding.filename.getText().toString();
int dotPos = name.lastIndexOf('.');
binding.filename.setSelection((dotPos != -1) ? dotPos : name.length());
}
}
@Override
public void onClick(View v) {
String name = binding.filename.getText().toString();
String path = parentFolder.getRemotePath() + name;
Template selectedTemplate = adapter.getSelectedTemplate();
if (selectedTemplate == null) {
DisplayUtils.showSnackMessage(binding.list, R.string.select_one_template);
} else if (name.isEmpty() || name.equalsIgnoreCase(DOT + selectedTemplate.getExtension())) {
DisplayUtils.showSnackMessage(binding.list, R.string.enter_filename);
} else if (!name.endsWith(selectedTemplate.getExtension())) {
createFromTemplate(selectedTemplate, path + DOT + selectedTemplate.getExtension());
} else {
createFromTemplate(selectedTemplate, path);
}
}
private void checkEnablingCreateButton() {
Template selectedTemplate = adapter.getSelectedTemplate();
String name = binding.filename.getText().toString();
positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() &&
!name.equalsIgnoreCase(DOT + selectedTemplate.getExtension()));
}
private static class CreateFileFromTemplateTask extends AsyncTask<Void, Void, String> {
private ClientFactory clientFactory;
private WeakReference<ChooseTemplateDialogFragment> chooseTemplateDialogFragmentWeakReference;
private Template template;
private String path;
private Creator creator;
private User user;
private OCFile file;
CreateFileFromTemplateTask(ChooseTemplateDialogFragment chooseTemplateDialogFragment,
ClientFactory clientFactory,
User user,
Template template,
String path,
Creator creator
) {
this.clientFactory = clientFactory;
this.chooseTemplateDialogFragmentWeakReference = new WeakReference<>(chooseTemplateDialogFragment);
this.template = template;
this.path = path;
this.creator = creator;
this.user = user;
}
@Override
protected String doInBackground(Void... voids) {
try {
OwnCloudClient client = clientFactory.create(user);
RemoteOperationResult<String> result =
new DirectEditingCreateFileRemoteOperation(path,
creator.getEditor(),
creator.getId(),
template.getTitle()).execute(client);
if (!result.isSuccess()) {
return "";
}
RemoteOperationResult newFileResult = new ReadFileRemoteOperation(path).execute(client);
if (!newFileResult.isSuccess()) {
return "";
}
final ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get();
if (fragment == null) {
return "";
}
final Context context = fragment.getContext();
if (context == null) {
// fragment has been detached
return "";
}
FileDataStorageManager storageManager = new FileDataStorageManager(user,
context.getContentResolver());
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0));
storageManager.saveFile(temp);
file = storageManager.getFileByPath(path);
return result.getResultData();
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Error creating file from template!", e);
return "";
}
}
@Override
protected void onPostExecute(String url) {
final ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get();
if (fragment != null && fragment.isAdded()) {
if (url.isEmpty()) {
DisplayUtils.showSnackMessage(fragment.binding.list, "Error creating file from template");
} else {
Intent editorWebView = new Intent(MainApp.getAppContext(), TextEditorWebView.class);
editorWebView.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Text");
editorWebView.putExtra(ExternalSiteWebView.EXTRA_URL, url);
editorWebView.putExtra(ExternalSiteWebView.EXTRA_FILE, file);
editorWebView.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
fragment.startActivity(editorWebView);
fragment.dismiss();
}
} else {
Log_OC.e(TAG, "Error creating file from template!");
}
}
}
private static class FetchTemplateTask extends AsyncTask<Void, Void, TemplateList> {
private User user;
private ClientFactory clientFactory;
private WeakReference<ChooseTemplateDialogFragment> chooseTemplateDialogFragmentWeakReference;
private Creator creator;
FetchTemplateTask(ChooseTemplateDialogFragment chooseTemplateDialogFragment,
ClientFactory clientFactory,
User user,
Creator creator) {
this.user = user;
this.clientFactory = clientFactory;
this.chooseTemplateDialogFragmentWeakReference = new WeakReference<>(chooseTemplateDialogFragment);
this.creator = creator;
}
@Override
protected TemplateList doInBackground(Void... voids) {
try {
OwnCloudClient client = clientFactory.create(user);
RemoteOperationResult<TemplateList> result =
new DirectEditingObtainListOfTemplatesRemoteOperation(creator.getEditor(),
creator.getId())
.execute(client);
if (!result.isSuccess()) {
return new TemplateList();
}
return result.getResultData();
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Could not fetch template", e);
return new TemplateList();
}
}
@Override
protected void onPostExecute(TemplateList templateList) {
ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get();
if (fragment != null && fragment.isAdded()) {
if (templateList.getTemplates().isEmpty()) {
DisplayUtils.showSnackMessage(fragment.binding.list, R.string.error_retrieving_templates);
} else {
if (templateList.getTemplates().size() == SINGLE_TEMPLATE) {
fragment.onTemplateChosen(templateList.getTemplates().values().iterator().next());
fragment.binding.list.setVisibility(View.GONE);
} else {
String name = DOT + templateList.getTemplates().values().iterator().next().getExtension();
fragment.binding.filename.setText(name);
fragment.binding.helperText.setVisibility(View.VISIBLE);
}
fragment.setTemplateList(templateList);
}
} else {
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
}
}
}
}
@@ -0,0 +1,411 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* @author Chris Narkiewicz
*
* Copyright (C) 2018 Tobias Kaminsky
* Copyright (C) 2018 Nextcloud GmbH.
* Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.dialog
import android.app.Dialog
import android.content.Intent
import android.os.AsyncTask
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.view.WindowManager
import android.widget.Button
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.GridLayoutManager
import com.nextcloud.android.lib.resources.directediting.DirectEditingCreateFileRemoteOperation
import com.nextcloud.android.lib.resources.directediting.DirectEditingObtainListOfTemplatesRemoteOperation
import com.nextcloud.client.account.CurrentAccountProvider
import com.nextcloud.client.account.User
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.network.ClientFactory
import com.nextcloud.client.network.ClientFactory.CreationException
import com.owncloud.android.MainApp
import com.owncloud.android.R
import com.owncloud.android.databinding.ChooseTemplateBinding
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.Creator
import com.owncloud.android.lib.common.Template
import com.owncloud.android.lib.common.TemplateList
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.owncloud.android.ui.activity.ExternalSiteWebView
import com.owncloud.android.ui.activity.TextEditorWebView
import com.owncloud.android.ui.adapter.TemplateAdapter
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.FileStorageUtils
import com.owncloud.android.utils.theme.ThemeButtonUtils
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.ThemeTextInputUtils
import java.lang.ref.WeakReference
import javax.inject.Inject
/**
* Dialog to show templates for new documents/spreadsheets/presentations.
*/
class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, TemplateAdapter.ClickListener, Injectable {
@Inject
lateinit var clientFactory: ClientFactory
@Inject
lateinit var currentAccount: CurrentAccountProvider
@Inject
lateinit var themeColorUtils: ThemeColorUtils
@Inject
lateinit var themeDrawableUtils: ThemeDrawableUtils
@Inject
lateinit var themeButtonUtils: ThemeButtonUtils
@Inject
lateinit var themeTextInputUtils: ThemeTextInputUtils
private var adapter: TemplateAdapter? = null
private var parentFolder: OCFile? = null
private var title: String? = null
private var positiveButton: Button? = null
private var creator: Creator? = null
enum class Type {
DOCUMENT, SPREADSHEET, PRESENTATION
}
private var _binding: ChooseTemplateBinding? = null
private val binding get() = _binding!!
override fun onStart() {
super.onStart()
val alertDialog = dialog as AlertDialog
val button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
themeButtonUtils.themeBorderlessButton(
themeColorUtils,
button,
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL)
)
button.setOnClickListener(this)
button.isEnabled = false
positiveButton = button
checkEnablingCreateButton()
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val arguments = arguments ?: throw IllegalArgumentException("Arguments may not be null")
val activity = activity ?: throw IllegalArgumentException("Activity may not be null")
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER)
creator = arguments.getParcelable(ARG_CREATOR)
title = arguments.getString(ARG_HEADLINE, getString(R.string.select_template))
title = when (savedInstanceState) {
null -> arguments.getString(ARG_HEADLINE)
else -> savedInstanceState.getString(ARG_HEADLINE)
}
// Inflate the layout for the dialog
val inflater = requireActivity().layoutInflater
_binding = ChooseTemplateBinding.inflate(inflater, null, false)
val view: View = binding.root
binding.filename.requestFocus()
themeTextInputUtils.colorTextInput(
binding.filenameContainer,
binding.filename,
themeColorUtils.primaryColor(context)
)
binding.filename.setOnKeyListener { _, _, _ ->
checkEnablingCreateButton()
false
}
binding.filename.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) = Unit
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) = Unit
override fun afterTextChanged(s: Editable) {
checkEnablingCreateButton()
}
})
fetchTemplate()
binding.list.setHasFixedSize(true)
binding.list.layoutManager = GridLayoutManager(activity, 2)
adapter = TemplateAdapter(
creator!!.mimetype,
this,
context,
currentAccount,
clientFactory,
themeColorUtils,
themeDrawableUtils
)
binding.list.adapter = adapter
// Build the dialog
val builder = AlertDialog.Builder(activity)
builder.setView(view)
.setPositiveButton(R.string.create, null)
.setNeutralButton(R.string.common_cancel, null)
.setTitle(title)
val dialog: Dialog = builder.create()
val window = dialog.window
window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
return dialog
}
@Suppress("TooGenericExceptionCaught") // legacy code
private fun fetchTemplate() {
try {
val user = currentAccount.user
FetchTemplateTask(this, clientFactory, user, creator).execute()
} catch (e: Exception) {
Log_OC.e(TAG, "Loading stream url not possible: $e")
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onSaveInstanceState(savedInstanceState: Bundle) {
super.onSaveInstanceState(savedInstanceState)
savedInstanceState.putString(ARG_HEADLINE, title)
}
private fun createFromTemplate(template: Template, path: String) {
CreateFileFromTemplateTask(this, clientFactory, currentAccount.user, template, path, creator).execute()
}
fun setTemplateList(templateList: TemplateList?) {
adapter!!.setTemplateList(templateList)
adapter!!.notifyDataSetChanged()
}
override fun onClick(template: Template) {
onTemplateChosen(template)
}
private fun onTemplateChosen(template: Template) {
adapter!!.setTemplateAsActive(template)
prefillFilenameIfEmpty(template)
checkEnablingCreateButton()
}
private fun prefillFilenameIfEmpty(template: Template) {
var name = binding.filename.text.toString()
if (name.isEmpty() || name.equals(DOT + template.extension, ignoreCase = true)) {
binding.filename.setText(String.format("%s.%s", template.title, template.extension))
name = binding.filename.text.toString()
val dotPos = name.lastIndexOf('.')
binding.filename.setSelection(if (dotPos != -1) dotPos else name.length)
}
}
override fun onClick(v: View) {
val name = binding.filename.text.toString()
val path = parentFolder!!.remotePath + name
val selectedTemplate = adapter!!.selectedTemplate
if (selectedTemplate == null) {
DisplayUtils.showSnackMessage(binding.list, R.string.select_one_template)
} else if (name.isEmpty() || name.equals(DOT + selectedTemplate.extension, ignoreCase = true)) {
DisplayUtils.showSnackMessage(binding.list, R.string.enter_filename)
} else if (!name.endsWith(selectedTemplate.extension)) {
createFromTemplate(selectedTemplate, path + DOT + selectedTemplate.extension)
} else {
createFromTemplate(selectedTemplate, path)
}
}
private fun checkEnablingCreateButton() {
if (positiveButton != null) {
val selectedTemplate = adapter!!.selectedTemplate
val name = binding.filename.text.toString()
positiveButton!!.isEnabled = selectedTemplate != null && name.isNotEmpty() &&
!name.equals(DOT + selectedTemplate.extension, ignoreCase = true)
}
}
@Suppress("LongParameterList") // legacy code
private class CreateFileFromTemplateTask(
chooseTemplateDialogFragment: ChooseTemplateDialogFragment,
private val clientFactory: ClientFactory?,
user: User,
template: Template,
path: String,
creator: Creator?
) : AsyncTask<Void, Void, String>() {
private val chooseTemplateDialogFragmentWeakReference: WeakReference<ChooseTemplateDialogFragment>
private val template: Template
private val path: String
private val creator: Creator?
private val user: User
private var file: OCFile? = null
@Suppress("ReturnCount") // legacy code
override fun doInBackground(vararg params: Void): String {
return try {
val client = clientFactory!!.create(user)
val result = DirectEditingCreateFileRemoteOperation(
path,
creator!!.editor,
creator.id,
template.title
).execute(client)
if (!result.isSuccess) {
return ""
}
val newFileResult = ReadFileRemoteOperation(path).execute(client)
if (!newFileResult.isSuccess) {
return ""
}
val fragment = chooseTemplateDialogFragmentWeakReference.get() ?: return ""
val context = fragment.context
?: // fragment has been detached
return ""
val storageManager = FileDataStorageManager(
user,
context.contentResolver
)
val temp = FileStorageUtils.fillOCFile(newFileResult.data[0] as RemoteFile)
storageManager.saveFile(temp)
file = storageManager.getFileByPath(path)
result.resultData
} catch (e: CreationException) {
Log_OC.e(TAG, "Error creating file from template!", e)
""
}
}
override fun onPostExecute(url: String) {
val fragment = chooseTemplateDialogFragmentWeakReference.get()
if (fragment != null && fragment.isAdded) {
if (url.isEmpty()) {
DisplayUtils.showSnackMessage(fragment.binding.list, "Error creating file from template")
} else {
val editorWebView = Intent(MainApp.getAppContext(), TextEditorWebView::class.java)
editorWebView.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Text")
editorWebView.putExtra(ExternalSiteWebView.EXTRA_URL, url)
editorWebView.putExtra(ExternalSiteWebView.EXTRA_FILE, file)
editorWebView.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false)
fragment.startActivity(editorWebView)
fragment.dismiss()
}
} else {
Log_OC.e(TAG, "Error creating file from template!")
}
}
init {
chooseTemplateDialogFragmentWeakReference = WeakReference(chooseTemplateDialogFragment)
this.template = template
this.path = path
this.creator = creator
this.user = user
}
}
private class FetchTemplateTask(
chooseTemplateDialogFragment: ChooseTemplateDialogFragment,
private val clientFactory: ClientFactory?,
private val user: User,
creator: Creator?
) : AsyncTask<Void, Void, TemplateList>() {
private val chooseTemplateDialogFragmentWeakReference: WeakReference<ChooseTemplateDialogFragment>
private val creator: Creator?
override fun doInBackground(vararg voids: Void): TemplateList {
return try {
val client = clientFactory!!.create(user)
val result = DirectEditingObtainListOfTemplatesRemoteOperation(
creator!!.editor,
creator.id
)
.execute(client)
if (!result.isSuccess) {
TemplateList()
} else result.resultData
} catch (e: CreationException) {
Log_OC.e(TAG, "Could not fetch template", e)
TemplateList()
}
}
override fun onPostExecute(templateList: TemplateList) {
val fragment = chooseTemplateDialogFragmentWeakReference.get()
if (fragment != null && fragment.isAdded) {
if (templateList.templates.isEmpty()) {
DisplayUtils.showSnackMessage(fragment.binding.list, R.string.error_retrieving_templates)
} else {
if (templateList.templates.size == SINGLE_TEMPLATE) {
fragment.onTemplateChosen(templateList.templates.values.iterator().next())
fragment.binding.list.visibility = View.GONE
} else {
val name = DOT + templateList.templates.values.iterator().next().extension
fragment.binding.filename.setText(name)
fragment.binding.helperText.visibility = View.VISIBLE
}
fragment.setTemplateList(templateList)
}
} else {
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!")
}
}
init {
chooseTemplateDialogFragmentWeakReference = WeakReference(chooseTemplateDialogFragment)
this.creator = creator
}
}
companion object {
private const val ARG_PARENT_FOLDER = "PARENT_FOLDER"
private const val ARG_CREATOR = "CREATOR"
private const val ARG_HEADLINE = "HEADLINE"
private val TAG = ChooseTemplateDialogFragment::class.java.simpleName
private const val DOT = "."
const val SINGLE_TEMPLATE = 1
@JvmStatic
fun newInstance(parentFolder: OCFile?, creator: Creator?, headline: String?): ChooseTemplateDialogFragment {
val frag = ChooseTemplateDialogFragment()
val args = Bundle()
args.putParcelable(ARG_PARENT_FOLDER, parentFolder)
args.putParcelable(ARG_CREATOR, creator)
args.putString(ARG_HEADLINE, headline)
frag.arguments = args
return frag
}
}
}
@@ -283,7 +283,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment implements Inj
// - decrypt private key, store unencrypted private key in database
GetPublicKeyOperation publicKeyOperation = new GetPublicKeyOperation();
RemoteOperationResult publicKeyResult = publicKeyOperation.execute(user.toPlatformAccount(), getContext());
RemoteOperationResult publicKeyResult = publicKeyOperation.execute(user, getContext());
if (publicKeyResult.isSuccess()) {
Log_OC.d(TAG, "public key successful downloaded for " + user.getAccountName());
@@ -297,7 +297,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment implements Inj
}
RemoteOperationResult<com.owncloud.android.lib.ocs.responses.PrivateKey> privateKeyResult =
new GetPrivateKeyOperation().execute(user.toPlatformAccount(), getContext());
new GetPrivateKeyOperation().execute(user, getContext());
if (privateKeyResult.isSuccess()) {
Log_OC.d(TAG, "private key successful downloaded for " + user.getAccountName());
@@ -356,7 +356,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment implements Inj
String urlEncoded = CsrHelper.generateCsrPemEncodedString(keyPair, userId);
SendCSROperation operation = new SendCSROperation(urlEncoded);
RemoteOperationResult result = operation.execute(user.toPlatformAccount(), getContext());
RemoteOperationResult result = operation.execute(user, getContext());
if (result.isSuccess()) {
Log_OC.d(TAG, "public key success");
@@ -374,8 +374,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment implements Inj
// upload encryptedPrivateKey
StorePrivateKeyOperation storePrivateKeyOperation = new StorePrivateKeyOperation(encryptedPrivateKey);
RemoteOperationResult storePrivateKeyResult = storePrivateKeyOperation.execute(user.toPlatformAccount(),
getContext());
RemoteOperationResult storePrivateKeyResult = storePrivateKeyOperation.execute(user, getContext());
if (storePrivateKeyResult.isSuccess()) {
Log_OC.d(TAG, "private key success");
@@ -390,7 +389,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment implements Inj
return (String) storePrivateKeyResult.getData().get(0);
} else {
DeletePublicKeyOperation deletePublicKeyOperation = new DeletePublicKeyOperation();
deletePublicKeyOperation.execute(user.toPlatformAccount(), getContext());
deletePublicKeyOperation.execute(user, getContext());
}
} catch (Exception e) {
Log_OC.e(TAG, e.getMessage());
@@ -181,51 +181,10 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
binding.shareProcessEditShareLink.visibility = View.VISIBLE
binding.shareProcessGroupTwo.visibility = View.GONE
// set up UI for modifying share
if (share != null) {
if (share?.isFolder == true) {
updateViewForFolder()
} else {
updateViewForFile()
}
// read only / allow upload and editing / file drop
if (SharingMenuHelper.isUploadAndEditingAllowed(share)) {
binding.shareProcessPermissionUploadEditing.isChecked = true
} else if (SharingMenuHelper.isFileDrop(share) && share?.isFolder == true) {
binding.shareProcessPermissionFileDrop.isChecked = true
} else if (SharingMenuHelper.isReadOnly(share)) {
binding.shareProcessPermissionReadOnly.isChecked = true
}
shareType = share?.shareType ?: ShareType.NO_SHARED
// show different text for link share and other shares
// because we have link to share in Public Link
if (shareType == ShareType.PUBLIC_LINK) {
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.share_copy_link)
} else {
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.common_confirm)
}
updateViewForShareType()
binding.shareProcessSetPasswordSwitch.isChecked = share?.isPasswordProtected == true
showPasswordInput(binding.shareProcessSetPasswordSwitch.isChecked)
updateExpirationDateView()
showExpirationDateInput(binding.shareProcessSetExpDateSwitch.isChecked)
}
// update UI for creating new share
else {
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.common_next)
file.let {
if (file?.isFolder == true) {
updateViewForFolder()
} else {
updateViewForFile()
}
updateViewForShareType()
}
showPasswordInput(binding.shareProcessSetPasswordSwitch.isChecked)
showExpirationDateInput(binding.shareProcessSetExpDateSwitch.isChecked)
setupModificationUI()
} else {
setupUpdateUI()
}
// show or hide expiry date
@@ -237,6 +196,51 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
shareProcessStep = SCREEN_TYPE_PERMISSION
}
private fun setupModificationUI() {
if (share?.isFolder == true) {
updateViewForFolder()
} else {
updateViewForFile()
}
// read only / allow upload and editing / file drop
if (SharingMenuHelper.isUploadAndEditingAllowed(share)) {
binding.shareProcessPermissionUploadEditing.isChecked = true
} else if (SharingMenuHelper.isFileDrop(share) && share?.isFolder == true) {
binding.shareProcessPermissionFileDrop.isChecked = true
} else if (SharingMenuHelper.isReadOnly(share)) {
binding.shareProcessPermissionReadOnly.isChecked = true
}
shareType = share?.shareType ?: ShareType.NO_SHARED
// show different text for link share and other shares
// because we have link to share in Public Link
if (shareType == ShareType.PUBLIC_LINK) {
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.share_copy_link)
} else {
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.common_confirm)
}
updateViewForShareType()
binding.shareProcessSetPasswordSwitch.isChecked = share?.isPasswordProtected == true
showPasswordInput(binding.shareProcessSetPasswordSwitch.isChecked)
updateExpirationDateView()
showExpirationDateInput(binding.shareProcessSetExpDateSwitch.isChecked)
}
private fun setupUpdateUI() {
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.common_next)
file.let {
if (file?.isFolder == true) {
updateViewForFolder()
} else {
updateViewForFile()
}
updateViewForShareType()
}
showPasswordInput(binding.shareProcessSetPasswordSwitch.isChecked)
showExpirationDateInput(binding.shareProcessSetExpDateSwitch.isChecked)
}
/**
* method to update views on the basis of Share type
*/
@@ -434,54 +438,28 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
*/
@Suppress("ReturnCount")
private fun validateShareProcessFirst() {
// get the permissions on the basis of selection
when {
binding.shareProcessPermissionReadOnly.isChecked -> {
permission = OCShare.READ_PERMISSION_FLAG
}
binding.shareProcessPermissionUploadEditing.isChecked -> {
permission = if (file?.isFolder == true || share?.isFolder == true) {
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER
} else {
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE
}
}
binding.shareProcessPermissionFileDrop.isChecked -> {
permission = OCShare.CREATE_PERMISSION_FLAG
}
}
if (binding.shareProcessAllowResharingCheckbox.isChecked) {
permission = getResharePermission()
}
permission = getSelectedPermission()
if (permission == OCShare.NO_PERMISSION) {
DisplayUtils.showSnackMessage(binding.root, R.string.no_share_permission_selected)
return
}
if (binding.shareProcessSetPasswordSwitch.isChecked && TextUtils.isEmpty(
binding.shareProcessEnterPassword
.text.toString().trim()
)
if (binding.shareProcessSetPasswordSwitch.isChecked &&
binding.shareProcessEnterPassword.text?.trim().isNullOrEmpty()
) {
DisplayUtils.showSnackMessage(binding.root, R.string.share_link_empty_password)
return
}
if (binding.shareProcessSetExpDateSwitch.isChecked && TextUtils.isEmpty(
binding.shareProcessSelectExpDate
.text.toString().trim()
)
if (binding.shareProcessSetExpDateSwitch.isChecked &&
binding.shareProcessSelectExpDate.text?.trim().isNullOrEmpty()
) {
showExpirationDateDialog()
return
}
if (binding.shareProcessChangeNameSwitch.isChecked && TextUtils.isEmpty(
binding.shareProcessChangeNameEt
.text.toString().trim()
)
if (binding.shareProcessChangeNameSwitch.isChecked &&
binding.shareProcessChangeNameEt.text?.trim().isNullOrEmpty()
) {
DisplayUtils.showSnackMessage(binding.root, R.string.label_empty)
return
@@ -489,16 +467,7 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
// if modifying existing share information then execute the process
if (share != null) {
fileOperationsHelper?.updateShareInformation(
share, permission,
binding.shareProcessHideDownloadCheckbox.isChecked,
binding.shareProcessEnterPassword.text.toString().trim(),
chosenExpDateInMills, binding.shareProcessChangeNameEt.text.toString().trim()
)
// copy the share link if available
if (!TextUtils.isEmpty(share?.shareLink)) {
ClipboardUtil.copyToClipboard(activity, share?.shareLink)
}
updateShare()
removeCurrentFragment()
} else {
// else show step 2 (note screen)
@@ -506,6 +475,33 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
}
}
/**
* get the permissions on the basis of selection
*/
private fun getSelectedPermission() = when {
binding.shareProcessAllowResharingCheckbox.isChecked -> getResharePermission()
binding.shareProcessPermissionReadOnly.isChecked -> OCShare.READ_PERMISSION_FLAG
binding.shareProcessPermissionUploadEditing.isChecked -> when {
file?.isFolder == true || share?.isFolder == true -> OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER
else -> OCShare.MAXIMUM_PERMISSIONS_FOR_FILE
}
binding.shareProcessPermissionFileDrop.isChecked -> OCShare.CREATE_PERMISSION_FLAG
else -> permission
}
private fun updateShare() {
fileOperationsHelper?.updateShareInformation(
share, permission,
binding.shareProcessHideDownloadCheckbox.isChecked,
binding.shareProcessEnterPassword.text.toString().trim(),
chosenExpDateInMills, binding.shareProcessChangeNameEt.text.toString().trim()
)
// copy the share link if available
if (!TextUtils.isEmpty(share?.shareLink)) {
ClipboardUtil.copyToClipboard(activity, share?.shareLink)
}
}
/**
* method to validate step 2 (note screen) information
*/
@@ -182,7 +182,6 @@ public class GalleryFragment extends OCFileListFragment {
public void searchCompleted(boolean emptySearch, long lastTimeStamp) {
photoSearchQueryRunning = false;
mAdapter.notifyDataSetChanged();
if (mAdapter.isEmpty()) {
setEmptyListMessage(SearchType.GALLERY_SEARCH);
@@ -35,19 +35,17 @@ import com.owncloud.android.databinding.FileListActionsBottomSheetCreatorBinding
import com.owncloud.android.databinding.FileListActionsBottomSheetFragmentBinding;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.lib.common.Creator;
import com.owncloud.android.lib.common.DirectEditing;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.ui.activity.AppScanActivity;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.utils.EditorUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.ThemeUtils;
import javax.inject.Inject;
/**
* FAB menu {@link android.app.Dialog} styled as a bottom sheet for main actions.
*/
@@ -155,9 +153,9 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
}
// create rich workspace
if (FileMenuFilter.isEditorAvailable(getContext().getContentResolver(),
user,
MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) &&
if (EditorUtils.isEditorAvailable(getContext().getContentResolver(),
user,
MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) &&
file != null && !file.isEncrypted()) {
// richWorkspace
// == "": no info set -> show button
@@ -104,6 +104,7 @@ import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.ui.preview.PreviewTextFileFragment;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.EditorUtils;
import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.FileStorageUtils;
@@ -410,7 +411,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) fragmentActivity;
fileDisplayActivity.updateActionBarTitleAndHomeButton(fileDisplayActivity.getCurrentDir());
}
listDirectory(false, false);
listDirectory(MainApp.isOnlyOnDevice(), false);
}
protected void setAdapter(Bundle args) {
@@ -541,7 +542,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
public void createRichWorkspace() {
new Thread(() -> {
RemoteOperationResult result = new RichWorkspaceDirectEditingRemoteOperation(mFile.getRemotePath())
.execute(accountManager.getUser().toPlatformAccount(), requireContext());
.execute(accountManager.getUser(), requireContext());
if (result.isSuccess()) {
String url = (String) result.getSingleData();
@@ -626,7 +627,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
@Override
public void showTemplate(Creator creator, String headline) {
public void showTemplate(@NonNull Creator creator, @NonNull String headline) {
ChooseTemplateDialogFragment.newInstance(mFile, creator, headline).show(requireActivity().getSupportFragmentManager(),
DIALOG_CREATE_DOCUMENT);
}
@@ -1062,9 +1063,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
setFabVisible(false);
resetHeaderScrollingState();
((FileDisplayActivity) mContainerActivity).startMediaPreview(file, 0, true, true, true);
} else if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
accountManager.getUser(),
file.getMimeType()) &&
} else if (EditorUtils.isEditorAvailable(requireContext().getContentResolver(),
accountManager.getUser(),
file.getMimeType()) &&
!file.isEncrypted()) {
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(file, getContext());
} else if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) &&
@@ -1131,9 +1132,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
return true;
} else if (itemId == R.id.action_edit) {
// should not be necessary, as menu item is filtered, but better play safe
if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
accountManager.getUser(),
singleFile.getMimeType())) {
if (EditorUtils.isEditorAvailable(requireContext().getContentResolver(),
accountManager.getUser(),
singleFile.getMimeType())) {
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, getContext());
} else {
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, getContext());
@@ -1321,6 +1322,12 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
}
public void updateOCFile(OCFile file) {
mAdapter.getFiles().remove(file);
mAdapter.getFiles().add(file);
mAdapter.notifyItemChanged(file);
}
private void updateLayout() {
// decide grid vs list view
if (isGridViewPreferred(mFile)) {
@@ -61,9 +61,7 @@ class OCFileListSearchAsyncTask(
}
fragment.setTitle()
val remoteOperationResult = remoteOperation.execute(
currentUser.toPlatformAccount(), fragment.context
)
val remoteOperationResult = remoteOperation.execute(currentUser, fragment.context)
if (remoteOperationResult.hasSuccessfulResult() && !isCancelled && fragment.searchFragment) {
fragment.searchEvent = event
if (remoteOperationResult.resultData.isNullOrEmpty()) {
@@ -84,8 +84,7 @@ class SharedListFragment : OCFileListFragment(), Injectable {
private suspend fun fetchFileData(partialFile: OCFile): OCFile? {
return withContext(Dispatchers.IO) {
val user = accountManager.user
val fetchResult = ReadFileRemoteOperation(partialFile.remotePath)
.execute(user.toPlatformAccount(), context)
val fetchResult = ReadFileRemoteOperation(partialFile.remotePath).execute(user, context)
if (!fetchResult.isSuccess) {
logger.e(SHARED_TAG, "Error fetching file")
if (fetchResult.isException) {
@@ -260,7 +260,7 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
RefreshFolderOperation operation = new RefreshFolderOperation(folder, System.currentTimeMillis(),
false, false, storageManager, user, context);
RemoteOperationResult result = operation.execute(user.toPlatformAccount(), context);
RemoteOperationResult result = operation.execute(user, context);
return result.isSuccess();
} else {
return Boolean.FALSE;
@@ -41,6 +41,7 @@ import me.zhanghai.android.fastscroll.FastScroller
import me.zhanghai.android.fastscroll.PopupTextProvider
import me.zhanghai.android.fastscroll.Predicate
import kotlin.math.ceil
import kotlin.math.min
/**
* Custom ViewHelper to get fast scroll working on gallery, which has a gridview and variable height (due to headers)
@@ -138,7 +139,7 @@ class GalleryFastScrollViewHelper(
val isHeader = itemCoord.relativePos() == -1
val seenRowsInPreviousSections = adapter.files
.subList(0, itemCoord.section())
.subList(0, min(itemCoord.section(), adapter.files.size))
.sumOf { itemCountToRowCount(it.files.size) }
val seenRowsInThisSection = if (isHeader) 0 else itemCountToRowCount(itemCoord.relativePos())
val totalSeenRows = seenRowsInPreviousSections + seenRowsInThisSection
@@ -55,7 +55,6 @@ import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.files.StreamMediaFileOperation;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
@@ -82,6 +81,7 @@ import com.owncloud.android.ui.events.FavoriteEvent;
import com.owncloud.android.ui.events.FileLockEvent;
import com.owncloud.android.ui.events.SyncEventFinished;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.EditorUtils;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.UriUtils;
@@ -235,7 +235,7 @@ public class FileOperationsHelper {
// check for changed eTag
CheckEtagRemoteOperation checkEtagOperation = new CheckEtagRemoteOperation(file.getRemotePath(),
file.getEtag());
RemoteOperationResult result = checkEtagOperation.execute(user.toPlatformAccount(), fileActivity);
RemoteOperationResult result = checkEtagOperation.execute(user, fileActivity);
// eTag changed, sync file
if (result.getCode() == RemoteOperationResult.ResultCode.ETAG_CHANGED) {
@@ -302,9 +302,9 @@ public class FileOperationsHelper {
if (launchables.isEmpty()) {
Optional<User> optionalUser = fileActivity.getUser();
if (optionalUser.isPresent() && FileMenuFilter.isEditorAvailable(fileActivity.getContentResolver(),
optionalUser.get(),
file.getMimeType())) {
if (optionalUser.isPresent() && EditorUtils.isEditorAvailable(fileActivity.getContentResolver(),
optionalUser.get(),
file.getMimeType())) {
openFileWithTextEditor(file, fileActivity);
} else {
Account account = fileActivity.getAccount();
@@ -454,7 +454,7 @@ public class FileOperationsHelper {
final User user = currentAccount.getUser();
new Thread(() -> {
StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getRemoteId());
RemoteOperationResult result = sfo.execute(user.toPlatformAccount(), fileActivity);
RemoteOperationResult result = sfo.execute(user, fileActivity);
fileActivity.dismissLoadingDialog();
@@ -1049,12 +1049,12 @@ public class FileOperationsHelper {
/**
* Starts a check of the currently stored credentials for the given account.
*
* @param account OC account which credentials will be checked.
* @param user user which credentials will be checked.
*/
public void checkCurrentCredentials(Account account) {
public void checkCurrentCredentials(User user) {
Intent service = new Intent(fileActivity, OperationsService.class);
service.setAction(OperationsService.ACTION_CHECK_CURRENT_CREDENTIALS);
service.putExtra(OperationsService.EXTRA_ACCOUNT, account);
service.putExtra(OperationsService.EXTRA_ACCOUNT, user.toPlatformAccount());
mWaitingForOpId = fileActivity.getOperationsServiceBinder().queueNewOperation(service);
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_checking_credentials));
@@ -157,7 +157,7 @@ public class UriUploader {
private void requestUpload(String localPath, String remotePath) {
FileUploader.uploadNewFile(
mActivity,
user.toPlatformAccount(),
user,
localPath,
remotePath,
mBehaviour,
@@ -136,7 +136,7 @@ public class PreviewTextStringFragment extends PreviewTextFragment {
private void edit() {
new Thread(() -> {
RemoteOperationResult result = new RichWorkspaceDirectEditingRemoteOperation(getFile().getRemotePath())
.execute(accountManager.getUser().toPlatformAccount(), getContext());
.execute(accountManager.getUser(), getContext());
if (result.isSuccess()) {
String url = (String) result.getSingleData();
@@ -104,6 +104,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.RejectedExecutionException;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -858,8 +859,13 @@ public final class DisplayUtils {
stopShimmer(shimmerThumbnail, thumbnailView);
thumbnailView.setImageDrawable(MimeTypeUtil
.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
file.isSharedViaLink(), file.isEncrypted(),
file.getMountType(), context, themeColorUtils, themeDrawableUtils));
file.isSharedViaLink(),
file.isEncrypted(),
file.isGroupFolder(),
file.getMountType(),
context,
themeColorUtils,
themeDrawableUtils));
} else {
if (file.getRemoteId() != null && file.isPreviewAvailable()) {
// Thumbnail in cache?
@@ -936,12 +942,14 @@ public final class DisplayUtils {
});
thumbnailView.setImageDrawable(asyncDrawable);
asyncTasks.add(task);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file,
file.getRemoteId()));
asyncTasks.add(task);
} catch (IllegalArgumentException e) {
Log_OC.d(TAG, "ThumbnailGenerationTask : " + e.getMessage());
} catch (RejectedExecutionException e) {
// Executor queue is full, ignore
}
}
}
@@ -0,0 +1,48 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.owncloud.android.utils
import android.content.ContentResolver
import com.google.gson.Gson
import com.nextcloud.client.account.User
import com.owncloud.android.datamodel.ArbitraryDataProvider
import com.owncloud.android.lib.common.DirectEditing
import com.owncloud.android.lib.common.Editor
object EditorUtils {
@JvmStatic
fun isEditorAvailable(contentResolver: ContentResolver?, user: User?, mimeType: String?): Boolean {
return getEditor(contentResolver, user, mimeType) != null
}
@JvmStatic
fun getEditor(contentResolver: ContentResolver?, user: User?, mimeType: String?): Editor? {
val json = ArbitraryDataProvider(contentResolver).getValue(user, ArbitraryDataProvider.DIRECT_EDITING)
if (json.isEmpty()) {
return null
}
val directEditing = Gson().fromJson(json, DirectEditing::class.java)
val editors = directEditing.editors.values
return editors.firstOrNull { it.mimetypes.contains(mimeType) || it.optionalMimetypes.contains(mimeType) }
}
}
@@ -21,7 +21,6 @@
package com.owncloud.android.utils;
import android.accounts.Account;
import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
@@ -29,6 +28,7 @@ import android.util.Pair;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nextcloud.client.account.User;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.DecryptedFolderMetadata;
import com.owncloud.android.datamodel.EncryptedFolderMetadata;
@@ -43,13 +43,11 @@ import com.owncloud.android.lib.resources.e2ee.UnlockFileRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.UpdateMetadataRemoteOperation;
import com.owncloud.android.operations.UploadException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.httpclient.HttpStatus;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -223,7 +221,7 @@ public final class EncryptionUtils {
*/
public static @Nullable
DecryptedFolderMetadata downloadFolderMetadata(OCFile folder, OwnCloudClient client,
Context context, Account account) {
Context context, User user) {
RemoteOperationResult getMetadataOperationResult = new GetMetadataRemoteOperation(folder.getLocalId())
.execute(client);
@@ -234,7 +232,7 @@ public final class EncryptionUtils {
// decrypt metadata
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
String serializedEncryptedMetadata = (String) getMetadataOperationResult.getData().get(0);
String privateKey = arbitraryDataProvider.getValue(account.name, EncryptionUtils.PRIVATE_KEY);
String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);
EncryptedFolderMetadata encryptedFolderMetadata = EncryptionUtils.deserializeJSON(
serializedEncryptedMetadata, new TypeToken<EncryptedFolderMetadata>() {
@@ -660,35 +658,6 @@ public final class EncryptionUtils {
Helper
*/
public static String getMD5Sum(File file) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] bytes = new byte[2048];
int readBytes;
while ((readBytes = fileInputStream.read(bytes)) != -1) {
md5.update(bytes, 0, readBytes);
}
return new String(Hex.encodeHex(md5.digest()));
} catch (Exception e) {
Log_OC.e(TAG, e.getMessage());
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
Log_OC.e(TAG, "Error getting MD5 checksum for file", e);
}
}
}
return "";
}
public static List<String> getRandomWords(int count, Context context) throws IOException {
InputStream ins = context.getResources().openRawResource(context.getResources()
.getIdentifier("encryption_key_words", "raw", context.getPackageName()));
Loaded 100 of 134 files, more files were not shown because too many files have changed in this diff. Show more