Compare commits

...
Author SHA1 Message Date
Álvaro Brey 4d8a530e68 DisplayUtils: fix threading for setThumbnail
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-09 14:43:41 +02:00
Álvaro Brey 940fe90556 Fix threading for DisplayUtils.setAvatar
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-09 14:30:19 +02:00
tobiasKaminsky a8ea93dd14 Get rid of disk read on main thread
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-09 14:16:07 +02:00
Álvaro Brey 54e57dc146 Merge pull request #10135 from nextcloud/fix/fda-screenshot
Fix and enable FDAScreenshotIT.showMediaThenAllFiles
2022-05-09 14:05:30 +02:00
Álvaro Brey Vilas 62d58d0a36 Fix and enable FDAScreenshotIT.showMediaThenAllFiles
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-09 13:24:33 +02:00
Álvaro Brey 03453c787a Merge pull request #10188 from nextcloud/changelog-master-stable-3.20.1
Add changelog for 3.20.1
2022-05-09 10:08:09 +02:00
Álvaro Brey 91efa194c1 Merge pull request #10191 from nextcloud/fix/some-detekt
Fix a bunch of Detekt issues
2022-05-09 10:04:47 +02:00
Álvaro Brey 454f7c6b96 Merge pull request #10168 from pelzvieh/patch-1
Make SAF root IDs stable through server version updates
2022-05-09 10:03:27 +02:00
Álvaro Brey b2b80c031b Merge pull request #10211 from nextcloud/videoInGallery
Play video in gallery
2022-05-09 09:44:41 +02:00
Álvaro Brey d5d64b6f38 Merge pull request #10210 from nextcloud/dependabot/gradle/com.google.firebase-firebase-messaging-23.0.4
Bump firebase-messaging from 23.0.3 to 23.0.4
2022-05-09 09:43:51 +02:00
tobiasKaminsky c0c094c30e Play video in gallery
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-09 08:17:12 +02:00
Nextcloud bot 0649f787b8 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-09 04:12:54 +00:00
dependabot[bot] 6cf85b290d Bump firebase-messaging from 23.0.3 to 23.0.4
Bumps firebase-messaging from 23.0.3 to 23.0.4.

---
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-05-09 02:03:17 +00:00
Nextcloud bot 55cffc80d1 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-08 04:11:49 +00:00
Nextcloud bot 51eb6e8620 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-07 04:09:35 +00:00
Álvaro Brey 8ef80aa105 Fix DocumentsStorageProviderIT for new root ID
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 18:16:11 +02:00
Álvaro Brey 06820a21fd Lower detekt maxIssues to remaining 3
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 18:07:13 +02:00
Álvaro Brey fb1469aeea UriUtils: refactor to keep detekt happy
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 18:06:51 +02:00
Álvaro Brey 6297742f01 SyncedFoldersActivity: suppress detekt warning
This entire class is legacy and should be refactored

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 18:00:01 +02:00
Álvaro Brey a6dc89a8e5 ShareeListAdapterTest: refactor to fix detekt issues
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 17:57:56 +02:00
Álvaro Brey 7adadbb53c SetStatusDialogFragment: some easy & safe cleanups
Make detekt happy

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 17:57:43 +02:00
Álvaro Brey 9cff9725fc HttpStreamFetcher: reduce nesting in loadData
Make detekt happy

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 17:22:18 +02:00
Álvaro Brey a753f4ef03 Merge pull request #10142 from nextcloud/dependabot/github_actions/codecov/codecov-action-3
Bump codecov/codecov-action from 2 to 3
2022-05-06 17:13:40 +02:00
Álvaro Brey 02f23f326d DocumentsStorageProvider: hash the accountName for rootId map
This should handle the fact that accountNames are of arbitrary length

MD5 is fine for this, as it should be quicker than SHA and the chance of collisions here is very low

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 17:05:53 +02:00
Álvaro Brey 3b3d23ff0a DocumentsStorageProvider: fix build error due to missing import
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 17:05:34 +02:00
pelzviehandÁlvaro Brey 43c4876ef3 Update app/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java
Co-authored-by: Álvaro Brey <[email protected]>
2022-05-06 16:11:50 +02:00
Álvaro Brey cd488d38f1 Add changelog for 3.20.1
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 15:44:23 +02:00
Tobias Kaminsky 8d4ed0a862 Merge pull request #10181 from nextcloud/videoFullscreenPause
Correctly obey play/pause state
2022-05-06 14:43:43 +02:00
Álvaro Brey b950be1f7d Merge pull request #10178 from nextcloud/galleryLongRunning
Media search improvement
2022-05-06 13:47:09 +02:00
Álvaro Brey ac208945e8 DocumentsStorageProvider: key can't be parsed into Int, since it's String now
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 13:13:50 +02:00
Álvaro Brey 8a9a9ec66d GallerySearchTask: remove leftover testing code
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 13:04:50 +02:00
Álvaro Brey 27be297146 Merge pull request #10179 from nextcloud/throttleShareOverflowMenu
Throttle click on share icon
2022-05-06 12:55:50 +02:00
Álvaro Brey db85ebba94 Merge pull request #10174 from nextcloud/new-fastscroll-lib
Fast scrolling fixes
2022-05-06 12:08:06 +02:00
Álvaro Brey 84d1ffa546 Merge pull request #10180 from nextcloud/fix/spotbugs-not-failing
Fix spotbugs not failing builds when count increases
2022-05-06 11:22:24 +02:00
Andreas Feldner 04a0ce1e71 Update DocumentsStorageProvider.java
Change root id for an nextcloud account to urlencoded user@uri. This is to avoid issues with unstable hashCodes.
2022-05-06 10:24:45 +02:00
Álvaro Brey 96ee2ee661 Fix spotbugs not failing builds when count increases
spotbugs-up now needs base branch, not target branch

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-06 09:32:15 +02:00
Andreas Feldner 805ec3e61a Revert "Make Server's hashCode stable vs. version changes"
This reverts commit 5627e92619.
2022-05-06 09:17:32 +02:00
tobiasKaminsky d33d5a20fd Throttle click on share icon
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-06 09:11:10 +02:00
tobiasKaminsky f34fff62a8 Fix #10176
Signed-off-by: tobiasKaminsky <[email protected]>
2022-05-06 07:55:29 +02:00
Nextcloud bot 73a18fbf6e [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-06 04:11:46 +00:00
Álvaro Brey be79e3cf37 Merge pull request #10152 from nextcloud/chore/update_fastlane
Update fastlane and fix huawei upload
2022-05-05 16:08:15 +02:00
Álvaro Brey b897f09683 Merge pull request #10156 from nextcloud/bump-master-3.21
Bump master to 3.21.0
2022-05-05 15:57:12 +02:00
Álvaro Brey ea4222a1ae FileDisplayActivity: fix appbar for fast scroll
Adds padding at the bottom if appbar is not collapsed

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-05 15:51:58 +02:00
Álvaro Brey 09b95951c5 Fix fast scroll in gallery
Gallery has a grid layout + variable row height (due to section titles)

This is a no-no in all fastscroll libraries. However, the new one supports writing custom logic
to handle this, which is what this commit is.

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-05 15:51:58 +02:00
Tobias Kaminsky d374d87c24 Merge pull request #10163 from nextcloud/fix/previewmedia-exoplayer-null
PreviewMediaFragment: prevent crash due to onStop called before exoplayer initialization
2022-05-05 15:28:03 +02:00
Tobias Kaminsky 4b0adb1bae Merge pull request #10157 from nextcloud/drone-stable-24
Drone: test on stable 24
2022-05-05 13:42:22 +02:00
Álvaro Brey 12312393b2 Replace fastscroll library
Smoother scrolling

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-05 11:03:00 +02:00
Álvaro Brey 20ec696c99 Merge pull request #10171 from nextcloud/dependabot/gradle/com.google.android.material-material-1.6.0
Bump material from 1.5.0 to 1.6.0
2022-05-05 10:04:20 +02:00
Nextcloud bot d6f6f36d52 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-05 04:12:34 +00:00
dependabot[bot] 362a8286a6 Bump material from 1.5.0 to 1.6.0
Bumps [material](https://github.com/material-components/material-components-android) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/material-components/material-components-android/releases)
- [Commits](https://github.com/material-components/material-components-android/compare/1.5.0...1.6.0)

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

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-05 01:07:03 +00:00
pelzvieh 5627e92619 Make Server's hashCode stable vs. version changes
Bug #9906 seems to be triggered by a version change of the nextcloud server the client is connected to. It appears the most logical solution to make nextcloud object IDs stable against server version changes. These object IDs are derived from the User object using account/anonymous, and the referenced Server object. Providing a hashCode function in Server that ignores the server's version therefore provides stability of object IDs. This seems safe to do, as an URI is already designed to be an identificator.
2022-05-04 17:40:32 +02:00
Álvaro Brey aac4a0cd67 PreviewMediaFragment: prevent crash due to onStop called before exoplayer initialization
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-04 11:23:54 +02:00
Álvaro Brey 323fd34680 Merge pull request #10160 from nextcloud/dependabot/gradle/org.jlleitschuh.gradle-ktlint-gradle-10.3.0
Bump ktlint-gradle from 10.2.1 to 10.3.0
2022-05-04 11:17:59 +02:00
Nextcloud bot 1924041e4b [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-04 04:19:43 +00:00
dependabot[bot] bac992254c Bump ktlint-gradle from 10.2.1 to 10.3.0
Bumps ktlint-gradle from 10.2.1 to 10.3.0.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-04 01:04:41 +00:00
Álvaro Brey 0ae42c892c Drone: test on stable 24
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-03 15:59:44 +02:00
Álvaro Brey 520d17bb8b Bump master to 3.21.0
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-03 15:58:59 +02:00
Álvaro Brey 4be4974c7e Merge pull request #10151 from nextcloud/changelog-master-stable-3.20.0
Add changelog for 3.20.0
2022-05-03 15:04:18 +02:00
Álvaro Brey 1b021a9eb9 fastlane: huawei: Add delay before review
Otherwise we get an error, see https://github.com/shr3jn/fastlane-plugin-huawei_appgallery_connect/issues/34

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-03 12:48:11 +02:00
Álvaro Brey ad5769c98c Update fastlane and plugins
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-03 12:47:45 +02:00
Álvaro Brey 36062f7502 Add changelog for 3.20.0
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-03 12:42:55 +02:00
Nextcloud bot 76ab52499d [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-03 04:11:34 +00:00
Álvaro Brey 3c97b4b619 Merge pull request #10133 from nextcloud/fix/more-scrolling-bugs
Fix contents cut off when scrolling is locked
2022-05-02 18:10:53 +02:00
Álvaro Brey f0b77e5751 Merge pull request #10052 from nextcloud/file_locking
File locking
2022-05-02 17:19:49 +02:00
Álvaro Brey 26aef8e462 Merge pull request #10134 from nextcloud/fix/dagger-mediacontrolview
Fix theme utils injection in custom views
2022-05-02 17:19:30 +02:00
Álvaro Brey d34d3b419a Fix mocking in FileMenuFilterIT
Not sure why this wasn't a compilation error

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-02 15:43:12 +02:00
Álvaro Brey ba7a2192f3 Merge pull request #10140 from nextcloud/fix/directory-does-not-exist
FileDisplayActivity: wait until OCFileListFragment is initialized to trigger browseToRoot()
2022-05-02 14:56:57 +02:00
dependabot[bot] 0cd5f1b9f4 Bump codecov/codecov-action from 2 to 3
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-02 11:18:13 +00:00
Álvaro Brey 49ad952544 Restore library version, since library changes are merged
Signed-off-by: Álvaro Brey <[email protected]>
2022-05-02 12:49:44 +02:00
Álvaro Brey Vilas 81ce812d86 Fix some licenses
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas 3eb3079757 Fix spotbugs
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas f079f030cf Remove unused resources
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas f50d9f8451 Add test for FileMenuFilter that verifies file locking menu items
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas 6d40f25f29 Add unit tests for FileLockingHelper
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas 2cd2e29b86 FileMenuFilter: don't show lock options if there's no locking capability
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas db30142ad3 Fix lock info in actionMode menu when selecting a single, locked, file
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas f8ad9ae413 FileMenuFilter: don't show move, remove or rename options when file is locked
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas d90083fc07 Show file lock info in actions menu instead of separate dialog
Requested by design team

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:43 +02:00
Álvaro Brey Vilas 46ccddcef4 Combine lock indicator with overflow icon
Requested by design

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas a902fb6f84 FileMenuFilter: properly filter lock/unlock depending on lock status
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas a88b03a0c8 Show lock details when tapping on lock indicator
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas 68b2535481 Retrieve and persist more locking attributes from remote files
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas 356db04aa8 Add ability to toggle file lock from file context menu
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas fd2435379a FileDataStorageManager: small cleanup
- Remove two unused methods
- Make some fields final

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas f5ecaf91d1 Show file locking status on list
Also includes a refactor of how ContentValues are created in FileDataStorageManager.

The code for that was triplicated. now it's not.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas 353afb119c build.gradle: temporary library version
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:42 +02:00
Álvaro Brey Vilas b8cf8dade8 Store file locking capability
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 12:49:36 +02:00
Álvaro Brey 123cf4ad65 Merge pull request #10138 from nextcloud/dependabot/gradle/byteBuddyVersion-1.12.10
Bump byteBuddyVersion from 1.12.9 to 1.12.10
2022-05-02 12:10:55 +02:00
Álvaro Brey 9a2cbcbba4 FileDisplayActivity: wait until OCFileListFragment is initialized to trigger browseToRoot()
This solves a bug which caused a "Directory does not exist" popup when coming back from Gallery,
as it tried to call browseToRoot on GalleryFragment due it being executed before the fragment transaction.

Signed-off-by: Álvaro Brey <[email protected]>
2022-05-02 11:02:46 +02:00
Álvaro Brey Vilas 13e061e7d7 PreviewMediaFragment: Remove margin from top bar
Not needed since previous commit fixing scroll bugs, creates unwanted space

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 07:55:34 +00:00
Álvaro Brey Vilas 7a2c735795 Fix contents cut off when scrolling is locked
Don't need to touch the coordinator params, just set scroll flags properly

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-05-02 07:55:34 +00:00
Álvaro Brey 2bb8c91965 Merge pull request #10132 from nextcloud/chore/cleanup-repositories
build: Clean up repository configuration
2022-05-02 09:45:42 +02:00
dependabot[bot] f4546d1ceb Bump byteBuddyVersion from 1.12.9 to 1.12.10
Bumps `byteBuddyVersion` from 1.12.9 to 1.12.10.

Updates `byte-buddy` from 1.12.9 to 1.12.10
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.12.9...byte-buddy-1.12.10)

Updates `byte-buddy-android` from 1.12.9 to 1.12.10
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.12.9...byte-buddy-1.12.10)

---
updated-dependencies:
- dependency-name: net.bytebuddy:byte-buddy
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: net.bytebuddy:byte-buddy-android
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-05-02 01:26:20 +00:00
Nextcloud bot ddb96e7b17 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-05-01 04:10:03 +00:00
Álvaro Brey e33e801bd8 Merge pull request #10128 from nextcloud/fix/calendar-picker-rotation
Fix expiration date picker layout when rotating screen
2022-04-29 17:42:31 +02:00
nextcloud-android-bot 1ea61c6fe6 Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-29 15:07:40 +00:00
Álvaro Brey Vilas 2560d1be3c Inject ThemeColorUtils into ThemeableSwitchPreference too
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 16:56:56 +02:00
Álvaro Brey Vilas b58749d459 Fix ThemeUtils injection for MediaControlView
Inflation of this view was failing as there was no proper constructor

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 16:50:35 +02:00
Álvaro Brey Vilas 2bd8fb4240 build: Update last 2 libraries that used JCenter
Both of these are present in mavenCentral with a different groupId.

For both of them, the version bump is only for the groupId change, there are no breaking changes otherwise.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 16:13:04 +02:00
Álvaro Brey Vilas 9463d2e668 build: Clean up repository configuration
- Put jitpack.io at the bottom, so that it is the last one checked. For libraries that are both in jitpack and elsewhere,
this should prevent a lot of errors especially in CI due to jitpack unreliability.
- Don't use gradle plugin portal as a mirror for JCenter. JCenter is still up as read-only, and using the gradle plugin portal
hides the fact that we have stop using jcenter libraries.
- For buildscripts, use gradlePluginPortal() instead of manual maven config
- Don't have repository configuration in both app/build.gradle and project build.gradle. Use project gradle instead

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 16:07:55 +02:00
Álvaro Brey Vilas 7e31a71ba0 FileDetailsSharing: Preserve selected date when recreating expiration date dialog
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 11:12:07 +00:00
Álvaro Brey Vilas 85dcbe542e FileDetailsSharingProcess: force recreation of date picked on config changes
See added comment for details

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 11:12:07 +00:00
Álvaro Brey Vilas 8c2fc3ee87 ExpirationDatePickerDF: customize buttons on onStart instead of showing dialog on onCreate
That is how DialogFragment is supposed to work

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 11:12:07 +00:00
Álvaro Brey 3148d94262 Merge pull request #10129 from nextcloud/chore/leakcanary-disabled-default
build: Disable LeakCanary unless manually activated with a property
2022-04-29 12:14:34 +02:00
Álvaro Brey Vilas 21ed337184 build: Disable LeakCanary unless manually activated with a property
Use `./gradlew installGplayDebug -P "leakCanary"`, for example, to activate it.

LeakCanary dramatically slows down normal development work due to app freezes for memory dumps.

This way we can avoid that, but still use it when we want to check for leaks. I don't think leaks should be a primary focus right now,
since we have other stuff to work on first.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 11:43:11 +02:00
Álvaro Brey caf89f7908 Merge pull request #9876 from nextcloud/ThemeColorUtilsToDI
Move all Theme classes to DI
2022-04-29 11:22:27 +02:00
Álvaro Brey Vilas 4ff54bb48b Fix and update testBottomSheet screenshot test
We can't edit the capability in FDA directly

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas bdd1daa10e SyncFileNotEnoughSpaceDialogFragment needs injector
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas e023cedd7f Fix GalleryAdapterTest
GalleryAdapter needs theme stuff now

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas 3ff35d46e6 Fix some spotbugs stuff
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas 56584c06e6 Fix detekt
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas 42c28dce70 ThemeModule: convert to Kotlin and fix copyright
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
nextcloud-android-bot e2c3091fc0 Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-29 06:38:14 +00:00
tobiasKaminsky 17828cb3b4 remove some spotbugs warnings
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas f627f3d976 Fix injection ofr RenameFileDialogFragment
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:14 +00:00
Álvaro Brey Vilas 6bd7d808f4 Put OCFileListBottomSheetDialog into a DialogFragment
Can't inject things into a Dialog

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:13 +00:00
tobiasKaminsky 74e17ee7c6 Fixes after rebase
Signed-off-by: tobiasKaminsky <[email protected]>

Fixes after rebase

Signed-off-by: tobiasKaminsky <[email protected]>

Fixes after rebase

Signed-off-by: tobiasKaminsky <[email protected]>

Fix after rebase

Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-29 06:38:13 +00:00
Álvaro Brey Vilas 75cb8a767c Remove SyncedFoldersActivity.java
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-29 06:38:13 +00:00
tobiasKaminsky 349a045b46 Move all Theme classes to DI
Signed-off-by: tobiasKaminsky <[email protected]>

Move all Theme classes to DI

Signed-off-by: tobiasKaminsky <[email protected]>

Move all Theme classes to DI

Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-29 06:38:13 +00:00
Nextcloud bot 0a802b51da [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-29 04:11:37 +00:00
Álvaro Brey c81c1c83aa Merge pull request #10117 from nextcloud/chore/screenshot-test-reliability
Screenshot tests reliability improvements
2022-04-28 14:05:23 +02:00
Álvaro Brey 87ed56f4d9 Merge pull request #10080 from nextcloud/thumbnailFetch
Parallel thumbnail fetching
2022-04-28 11:11:08 +02:00
Álvaro Brey Vilas bc44b2c524 PasscodeActivityIT: add short sleep after closing keyboard
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-28 11:09:19 +02:00
tobiasKaminsky 73bb12f78a Parallel thumbnail fetching
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-28 08:10:54 +00:00
Álvaro Brey Vilas 011d6c3ceb ActivitiesActivityIT.error: more sleep
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-28 09:03:35 +02:00
Álvaro Brey Vilas 236925de99 Screenshot tests reliability improvements
Add more sleeps to SetupEncryptionDialogFragment.error and TrashBinActivity.empty, which fail frequently

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-28 09:03:29 +02:00
Tobias Kaminsky a2d2c1a3c7 Merge pull request #10122 from nextcloud/fix/activity-constructor
Fixes for tests due changes in Activity constructor in library
2022-04-28 08:03:57 +02:00
Álvaro Brey Vilas d79b20dbc5 ActivitiesPresenterTest: Activity no longer has empty constructor
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 19:02:43 +02:00
Álvaro Brey Vilas 98177e3eb3 Fix crash in screenshot test due to changes in library
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 19:02:26 +02:00
Álvaro Brey c20c3e4066 Merge pull request #10014 from nextcloud/spotbugs-improvements
Spotbugs improvements
2022-04-27 11:34:35 +02:00
Álvaro Brey 23dd1f30f1 Merge pull request #10113 from nextcloud/chore/unit-tests-gh-actions
Run unit tests in GH actions
2022-04-27 11:21:49 +02:00
Álvaro Brey 176fb24d5b Merge pull request #10084 from nextcloud/dependabot/gradle/com.google.firebase-firebase-messaging-23.0.3
Bump firebase-messaging from 23.0.2 to 23.0.3
2022-04-27 11:12:02 +02:00
Álvaro Brey Vilas 7073746309 Use defusedxml for xml parsing instead of etree
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 11:03:59 +02:00
Álvaro Brey Vilas 6eff01d735 Fix some codacy warnings
- Quote some strings in analysis-wrapper
 - Cleanup unneeded checks in spotbugs-up

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 10:53:30 +02:00
Álvaro Brey Vilas 79fc8c61d9 codecov: add flag to integration test coverage so the UI is clearer
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 10:19:23 +02:00
dependabot[bot] f93e65872a Bump firebase-messaging from 23.0.2 to 23.0.3
Bumps firebase-messaging from 23.0.2 to 23.0.3.

---
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-04-27 08:09:10 +00:00
Álvaro Brey Vilas 3879d90eec Ditch findbugs-results.txt: use the stable branch XML as single source of truth
Poor man's baseline

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 08:07:32 +00:00
Álvaro Brey Vilas 21a432dc9e Generate spotbugs summary from xml
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 08:07:32 +00:00
Álvaro Brey Vilas c850d14fc0 spotbugs: Use fancy stylesheet
MUCH more readable and easier to find stuff

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 08:07:32 +00:00
Álvaro Brey Vilas 7f00cd6e46 Upload unit test results properly if they fail
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 08:43:51 +02:00
Álvaro Brey Vilas 3b80d4dc1f build: Remove combinedTestReport task
It's not working properly (complains about no classes, empty report), AND codecov should merge unit and integration coverages for us anyway

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 06:13:49 +00:00
Álvaro Brey Vilas 323fdda409 Drone: optimize assemble while waiting for server/emulator
- Don't assemble Gplay separately from gplayDebug. We already have some GH actions to verify that all flavors assemble.
- Assemble the AndroidTest task, so that there's less work to do when installGplayDebug is called

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 06:13:49 +00:00
Álvaro Brey Vilas f572176e4c Drone: don't run unit tests
Done in GH actions now

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 06:13:49 +00:00
Álvaro Brey Vilas 68b2665b09 Run unit tests in GH actions
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-27 06:13:49 +00:00
Tobias Kaminsky d61a8f3444 Merge pull request #10112 from nextcloud/fix/loginIT-master
Fix LoginIT for server master
2022-04-27 07:52:30 +02:00
Álvaro Brey b3b3376c5b Merge pull request #10069 from nextcloud/dependabot/gradle/com.vanniktech-emoji-google-0.9.0
Bump emoji-google from 0.8.0 to 0.9.0
2022-04-26 18:21:06 +02:00
Álvaro Brey Vilas dd4a69d58c LoginIT: convert to Kotlin
While we're at it

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-26 09:51:39 +02:00
Álvaro Brey Vilas 85b5bf6875 Fix LoginIT submit click
In latest Nextcloud version the "submit" button does not have an ID, but we can use the type for selection

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-26 09:45:32 +02:00
Nextcloud bot bd139f1afb [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-26 04:11:10 +00:00
Álvaro Brey d45e12c2b8 Merge pull request #10089 from nextcloud/remove-account-usage-from-manage-acconuts-activity
Remove account use from ManageAccountsActivity
2022-04-25 16:47:34 +02:00
Álvaro Brey 828bef6af7 Merge pull request #10102 from nextcloud/dependabot/gradle/kotlin_version-1.6.21
Bump kotlin_version from 1.6.20 to 1.6.21
2022-04-25 11:59:15 +02:00
Álvaro Brey 1095fd540d Merge pull request #10065 from nextcloud/dependabot/gradle/byteBuddyVersion-1.12.9
Bump byteBuddyVersion from 1.12.8 to 1.12.9
2022-04-25 10:52:09 +02:00
Álvaro Brey cae58daa4c Merge pull request #10111 from nextcloud/dependabot/gradle/com.karumi-shot-5.14.0
Bump shot from 5.13.0 to 5.14.0
2022-04-25 10:42:47 +02:00
dependabot[bot] 93b236ff7c Bump kotlin_version from 1.6.20 to 1.6.21
Bumps `kotlin_version` from 1.6.20 to 1.6.21.

Updates `kotlin-gradle-plugin` from 1.6.20 to 1.6.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-stdlib` from 1.6.20 to 1.6.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-25 07:59:15 +00:00
dependabot[bot] de0bcbb279 Bump shot from 5.13.0 to 5.14.0
Bumps [shot](https://github.com/pedrovgs/shot) from 5.13.0 to 5.14.0.
- [Release notes](https://github.com/pedrovgs/shot/releases)
- [Commits](https://github.com/pedrovgs/shot/compare/5.13.0...5.14.0)

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

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-25 02:12:53 +00:00
Nextcloud bot 98075eba14 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-24 04:13:03 +00:00
Chris Narkiewicz 042c3758ac Remove account use from ManageAccountsActivity
Signed-off-by: Chris Narkiewicz <[email protected]>
2022-04-23 16:49:13 +01:00
Nextcloud bot 14aac48b90 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-23 04:00:20 +00:00
Álvaro Brey 0ad80b89cc Merge pull request #10106 from nextcloud/dependabot/gradle/mockitoVersion-4.5.1
Bump mockitoVersion from 4.4.0 to 4.5.1
2022-04-22 13:01:42 +02:00
Nextcloud bot 7759475728 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-22 04:03:25 +00:00
dependabot[bot] 4086ad36b3 Bump mockitoVersion from 4.4.0 to 4.5.1
Bumps `mockitoVersion` from 4.4.0 to 4.5.1.

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

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

---
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-04-22 01:06:11 +00:00
Álvaro Brey 0c189a77b4 Merge pull request #10104 from nextcloud/dependabot/gradle/com.squareup.leakcanary-leakcanary-android-2.9.1
Bump leakcanary-android from 2.9 to 2.9.1
2022-04-21 09:29:36 +02:00
Nextcloud bot 7cc0d53cff [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-21 04:01:23 +00:00
dependabot[bot] 0b08f95361 Bump leakcanary-android from 2.9 to 2.9.1
Bumps [leakcanary-android](https://github.com/square/leakcanary) from 2.9 to 2.9.1.
- [Release notes](https://github.com/square/leakcanary/releases)
- [Changelog](https://github.com/square/leakcanary/blob/main/docs/changelog.md)
- [Commits](https://github.com/square/leakcanary/compare/v2.9...v2.9.1)

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

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-21 01:05:49 +00:00
Álvaro Brey 4da8fc27e4 Merge pull request #10100 from nextcloud/dependabot/gradle/com.squareup.leakcanary-leakcanary-android-2.9
Bump leakcanary-android from 2.8.1 to 2.9
2022-04-20 14:44:07 +02:00
dependabot[bot] f17cb72f99 Bump leakcanary-android from 2.8.1 to 2.9
Bumps [leakcanary-android](https://github.com/square/leakcanary) from 2.8.1 to 2.9.
- [Release notes](https://github.com/square/leakcanary/releases)
- [Changelog](https://github.com/square/leakcanary/blob/main/docs/changelog.md)
- [Commits](https://github.com/square/leakcanary/compare/v2.8.1...v2.9)

---
updated-dependencies:
- dependency-name: com.squareup.leakcanary:leakcanary-android
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-20 01:05:33 +00:00
Álvaro Brey c944203d93 Merge pull request #10050 from nextcloud/mediaTimeline
Group photos as timeline by month
2022-04-19 15:28:31 +02:00
nextcloud-android-bot d1a3b415d8 Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-19 12:40:36 +00:00
Álvaro Brey Vilas 9e29b5cbc4 Remove FilesFilter, as it is unused
Only created in OCFileListAdapter, and then unused

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-19 14:19:38 +02:00
Álvaro Brey Vilas ca72520d54 MainApp: remove unused variable
Leftover

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-19 11:34:18 +02:00
dependabot[bot] 8610bc7ba3 Bump emoji-google from 0.8.0 to 0.9.0
Bumps [emoji-google](https://github.com/vanniktech/Emoji) from 0.8.0 to 0.9.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.8.0...0.9.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-04-19 09:26:42 +00:00
Álvaro Brey Vilas fb12a65949 Fix unit test for GalleryAdapter
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-19 10:59:14 +02:00
nextcloud-android-bot 997e4c736c Analysis: update Spotbugs results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-18 17:22:02 +00:00
nextcloud-android-bot eddbe5ef28 Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-18 17:20:49 +00:00
Álvaro Brey Vilas a785135b1b GalleryAdapterTest: fix wrong parameter list for GalleryAdapter constructor
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-18 19:14:22 +02:00
Álvaro Brey Vilas ff3833c62f OCFileListDelegate: fix detekt
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-18 18:40:25 +02:00
Álvaro Brey Vilas 0def0a8af8 Format with ktlint
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-18 18:21:35 +02:00
tobiasKaminsky 97d71d0383 Group media by month 2022-04-18 18:18:19 +02:00
Álvaro Brey bb82017448 Merge pull request #10093 from nextcloud/dependabot/github_actions/cirrus-actions/rebase-1.6
Bump cirrus-actions/rebase from 1.5 to 1.6
2022-04-18 17:38:57 +02:00
Álvaro Brey e4a20d1f48 Merge pull request #10094 from nextcloud/dependabot/github_actions/trilom/file-changes-action-1.2.4
Bump trilom/file-changes-action from 1.2.3 to 1.2.4
2022-04-18 13:38:41 +02:00
dependabot[bot] 3ab5f6ea0a Bump trilom/file-changes-action from 1.2.3 to 1.2.4
Bumps [trilom/file-changes-action](https://github.com/trilom/file-changes-action) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/trilom/file-changes-action/releases)
- [Changelog](https://github.com/trilom/file-changes-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/trilom/file-changes-action/compare/v1.2.3...v1.2.4)

---
updated-dependencies:
- dependency-name: trilom/file-changes-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-18 11:18:10 +00:00
dependabot[bot] 75e828cf54 Bump cirrus-actions/rebase from 1.5 to 1.6
Bumps [cirrus-actions/rebase](https://github.com/cirrus-actions/rebase) from 1.5 to 1.6.
- [Release notes](https://github.com/cirrus-actions/rebase/releases)
- [Commits](https://github.com/cirrus-actions/rebase/compare/1.5...1.6)

---
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-04-18 11:18:06 +00:00
Álvaro Brey 0e03400486 Merge pull request #10074 from nextcloud/equals
Replace equals with == on enums
2022-04-18 12:49:14 +02:00
Álvaro Brey 9a899ce3dc Merge pull request #10070 from nextcloud/trashbinNav
Fix trashbin navigation
2022-04-18 12:30:48 +02:00
Álvaro Brey 68b4b6fe56 Merge pull request #10073 from nextcloud/dependabot/github_actions/hmarr/auto-approve-action-2.2.1
Bump hmarr/auto-approve-action from 2.2.0 to 2.2.1
2022-04-18 12:24:06 +02:00
Álvaro Brey 914319c940 Merge pull request #10072 from nextcloud/dependabot/github_actions/actions/setup-java-3
Bump actions/setup-java from 2 to 3
2022-04-18 12:23:41 +02:00
Álvaro Brey 66b500b9dc Merge pull request #10085 from nextcloud/dependabot/gradle/io.gitlab.arturbosch.detekt-detekt-gradle-plugin-1.20.0
Bump detekt-gradle-plugin from 1.19.0 to 1.20.0
2022-04-18 11:42:15 +02:00
Álvaro Brey Vilas 3930633272 Fix detekt.yml for new detekt version
Remove formatting (that is handled by ktlint), update some other properties

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-18 11:14:17 +02:00
Nextcloud bot 58b34c3ee4 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-16 03:59:30 +00:00
Nextcloud bot df887ce4f2 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-15 04:04:35 +00:00
dependabot[bot] 7ed1b84375 Bump detekt-gradle-plugin from 1.19.0 to 1.20.0
Bumps detekt-gradle-plugin from 1.19.0 to 1.20.0.

---
updated-dependencies:
- dependency-name: io.gitlab.arturbosch.detekt:detekt-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-15 01:09:47 +00:00
nextcloud-android-bot e47f97b07e Analysis: update Spotbugs results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-13 10:20:07 +02:00
tobiasKaminsky a9608108ac Replace equals with == on enums
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-13 10:19:30 +02:00
Tobias Kaminsky bce8866961 Merge pull request #10075 from nextcloud/fixDroneCheck
Fix drone check due to app subfolder
2022-04-13 10:18:51 +02:00
tobiasKaminsky a9473d6158 Fix drone check due to app subfolder
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-13 10:18:21 +02:00
Tobias Kaminsky 31dda2e0fb Merge pull request #9985 from nextcloud/fastscrollWithLib
Fastscroll for all lists
2022-04-13 08:30:03 +02:00
tobiasKaminsky ce6bb70415 Merge remote-tracking branch 'origin/fastscrollWithLib' into fastscrollWithLib 2022-04-12 14:30:49 +02:00
tobiasKaminsky b4dc084d65 wip
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 14:30:43 +02:00
nextcloud-android-bot c8cf7bbfe7 Analysis: update Spotbugs results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-04-12 07:23:20 +00:00
tobiasKaminsky 075e91d9ba Replace equals with == on enums
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 09:15:33 +02:00
tobiasKaminsky f57aa2037b wip
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 08:45:10 +02:00
Tobias Kaminsky 2154e4d3ea Merge pull request #10060 from nextcloud/failOnNewJavaFiles
Let us no longer create java files
2022-04-12 08:08:21 +02:00
tobiasKaminsky 3c69ae92bb wip
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 08:05:17 +02:00
tobiasKaminsky e67fc70451 wip
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 08:04:23 +02:00
tobiasKaminsky 930d3e61fd wip
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 08:04:23 +02:00
tobiasKaminsky cf932e69e7 Fastscroll for all lists
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-12 08:04:23 +02:00
dependabot[bot] 7fb9b97e8d Bump hmarr/auto-approve-action from 2.2.0 to 2.2.1
Bumps [hmarr/auto-approve-action](https://github.com/hmarr/auto-approve-action) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/hmarr/auto-approve-action/releases)
- [Commits](https://github.com/hmarr/auto-approve-action/compare/v2.2.0...v2.2.1)

---
updated-dependencies:
- dependency-name: hmarr/auto-approve-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-11 11:20:04 +00:00
dependabot[bot] 5e924a5c4f Bump actions/setup-java from 2 to 3
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2 to 3.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-11 11:20:00 +00:00
tobiasKaminsky abc9f14555 Fix trashbin navigation
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-11 08:33:00 +02:00
tobiasKaminskyandÁlvaro Brey 7817a3b8d5 Let us no longer create java files
Signed-off-by: tobiasKaminsky <[email protected]>
Co-authored-by: Álvaro Brey <[email protected]>
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-08 10:17:44 +02:00
Álvaro Brey 86ee9dff69 Merge pull request #10064 from nextcloud/dependabot/gradle/com.android.tools.build-gradle-7.1.3
Bump gradle from 7.1.2 to 7.1.3
2022-04-08 09:06:31 +02:00
Nextcloud bot 7c6bce5617 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-08 04:05:40 +00:00
dependabot[bot] f2ff5482e9 Bump byteBuddyVersion from 1.12.8 to 1.12.9
Bumps `byteBuddyVersion` from 1.12.8 to 1.12.9.

Updates `byte-buddy` from 1.12.8 to 1.12.9
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.12.8...byte-buddy-1.12.9)

Updates `byte-buddy-android` from 1.12.8 to 1.12.9
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.12.8...byte-buddy-1.12.9)

---
updated-dependencies:
- dependency-name: net.bytebuddy:byte-buddy
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: net.bytebuddy:byte-buddy-android
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-08 01:32:43 +00:00
dependabot[bot] f8f46e62b9 Bump gradle from 7.1.2 to 7.1.3
Bumps gradle from 7.1.2 to 7.1.3.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-08 01:32:06 +00:00
Álvaro Brey d97edf023d Merge pull request #10051 from nextcloud/fdroid-no-scan
Don't include document scanner in FDroid version
2022-04-07 12:46:08 +02:00
Álvaro Brey ace6b49786 Merge pull request #10059 from nextcloud/exceptionHandling
Do not use ExceptionHandler on debug builds
2022-04-07 12:18:50 +02:00
tobiasKaminsky df7e70a3f1 Do not use ExceptionHandler on debug builds
Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-07 11:47:42 +02:00
Tobias Kaminsky b84149ac7c Merge pull request #10034 from nextcloud/fix/details-title-again
Better approach for avoiding state loss in FileDetailFragment
2022-04-07 11:07:11 +02:00
Tobias Kaminsky 69234dec5f Merge pull request #10049 from nextcloud/fix/camera2_not_required
AndroidManifest: set camera2 feature to not required
2022-04-07 10:44:34 +02:00
Álvaro Brey 9d68af7caf Merge pull request #10047 from nextcloud/dependabot/gradle/jacoco_version-0.8.8
Bump jacoco_version from 0.8.7 to 0.8.8
2022-04-07 10:37:27 +02:00
Álvaro Brey d781583c6c Merge pull request #10007 from nextcloud/fixVideoStreaming
Use remoteId to properly fetch streaming video url
2022-04-07 10:36:07 +02:00
Álvaro Brey 568988d891 Merge pull request #10054 from nextcloud/dependabot/gradle/com.h3xstream.findsecbugs-findsecbugs-plugin-1.12.0
Bump findsecbugs-plugin from 1.11.0 to 1.12.0
2022-04-07 10:26:57 +02:00
dependabot[bot] d33a3ce9e4 Bump findsecbugs-plugin from 1.11.0 to 1.12.0
Bumps [findsecbugs-plugin](https://github.com/find-sec-bugs/find-sec-bugs) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/find-sec-bugs/find-sec-bugs/releases)
- [Changelog](https://github.com/find-sec-bugs/find-sec-bugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/find-sec-bugs/find-sec-bugs/commits)

---
updated-dependencies:
- dependency-name: com.h3xstream.findsecbugs:findsecbugs-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-07 01:13:27 +00:00
Álvaro Brey Vilas 9827612010 Don't include document scanner in FDroid version
Not allowed due to binary OpenCV

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-06 14:43:05 +02:00
Álvaro Brey Vilas ba369f22ab AndroidManifest: set camera2 feature to not required
Brought by document scanner lib, but not actually required. If set to required,
devices without this feature will not see the app in Play Store.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-06 09:26:39 +02:00
dependabot[bot] bf1657facb Bump jacoco_version from 0.8.7 to 0.8.8
Bumps `jacoco_version` from 0.8.7 to 0.8.8.

Updates `org.jacoco.core` from 0.8.7 to 0.8.8
- [Release notes](https://github.com/jacoco/jacoco/releases)
- [Commits](https://github.com/jacoco/jacoco/compare/v0.8.7...v0.8.8)

Updates `org.jacoco.report` from 0.8.7 to 0.8.8
- [Release notes](https://github.com/jacoco/jacoco/releases)
- [Commits](https://github.com/jacoco/jacoco/compare/v0.8.7...v0.8.8)

Updates `org.jacoco.agent` from 0.8.7 to 0.8.8
- [Release notes](https://github.com/jacoco/jacoco/releases)
- [Commits](https://github.com/jacoco/jacoco/compare/v0.8.7...v0.8.8)

---
updated-dependencies:
- dependency-name: org.jacoco:org.jacoco.core
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jacoco:org.jacoco.report
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jacoco:org.jacoco.agent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-06 01:06:17 +00:00
Álvaro Brey 5b8d11f738 Optimize loading time for Shared view (#10015)
* Don't load entire OCFiles in the Shared view, as it takes too long

Instead, build partially-filled OCFiles from the OCShares we get

Signed-off-by: Álvaro Brey Vilas <[email protected]>

* Load metadata of shared files only when attempting to interact with them

This was quite a big undertaking and required a whole new fragment

Signed-off-by: Álvaro Brey Vilas <[email protected]>

* Fix wrong usages of deprecaed OCShare shareType setter

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-04-04 18:52:21 +02:00
Álvaro Brey 0736d01f01 Merge pull request #10044 from nextcloud/dependabot/github_actions/hmarr/auto-approve-action-2.2.0
Bump hmarr/auto-approve-action from 2.1.0 to 2.2.0
2022-04-04 17:06:58 +02:00
dependabot[bot] dc15edb6f6 Bump hmarr/auto-approve-action from 2.1.0 to 2.2.0
Bumps [hmarr/auto-approve-action](https://github.com/hmarr/auto-approve-action) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/hmarr/auto-approve-action/releases)
- [Commits](https://github.com/hmarr/auto-approve-action/compare/v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: hmarr/auto-approve-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-04 11:17:51 +00:00
Tobias Kaminsky b324f0d784 - no camera permission (#10042)
- scan document
- approve permission
- see scan document activity, previously it was wrong upload image activity

Signed-off-by: tobiasKaminsky <[email protected]>
2022-04-04 09:13:21 +00:00
Álvaro Brey c84d09f006 Merge pull request #10041 from nextcloud/dependabot/gradle/kotlin_version-1.6.20
Bump kotlin_version from 1.6.10 to 1.6.20
2022-04-04 10:57:43 +02:00
dependabot[bot] 84d7aa5406 Bump kotlin_version from 1.6.10 to 1.6.20
Bumps `kotlin_version` from 1.6.10 to 1.6.20.

Updates `kotlin-gradle-plugin` from 1.6.10 to 1.6.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-stdlib` from 1.6.10 to 1.6.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-04-04 01:26:08 +00:00
Nextcloud bot 77507f9c9b [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-04-03 04:01:33 +00:00
Álvaro Brey Vilas cd895ad2cf Better approach for avoiding state loss in FileDetailFragment
Do not overwrite file when updating share information, instead of holding the file in FDA

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-31 15:04:19 +02:00
Nextcloud bot 7285ddc4cb [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-31 04:08:34 +00:00
Álvaro Brey d9811e1f34 Merge pull request #10013 from nextcloud/fix/login-after-logout
Fix bugs when removing accounts
2022-03-30 18:29:24 +02:00
Álvaro Brey 1666224219 Merge pull request #10025 from nextcloud/fix/fastlane-artifact-number
fastlane: Increase number of expected artifacts to 4
2022-03-30 18:06:18 +02:00
Nextcloud bot 9a94cb1e12 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-30 04:03:28 +00:00
Álvaro Brey Vilas 2dc9ec212a fastlane: Increase number of expected artifacts to 4
3 APKs + 1 AAB

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-28 17:19:35 +02:00
Álvaro Brey 70c605fd78 Merge pull request #10022 from nextcloud/dependabot/github_actions/peter-evans/create-or-update-comment-2
Bump peter-evans/create-or-update-comment from 1 to 2
2022-03-28 13:42:41 +02:00
dependabot[bot] d931d37e91 Bump peter-evans/create-or-update-comment from 1 to 2
Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 1 to 2.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/v1...v2)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-03-28 11:14:54 +00:00
Nextcloud bot 4b8bb8a707 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-28 04:02:23 +00:00
Nextcloud bot ca751d0f71 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-27 04:01:42 +00:00
Nextcloud bot 3753ef361c [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-25 05:41:13 +00:00
Álvaro Brey Vilas a1901ca3e8 ManageAccountsActivity: go back to AuthenticatorActivity after removing last account
Instead of waiting for FileDisplayActivity to make a network request and fail

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 18:23:57 +01:00
Álvaro Brey Vilas 95046c4b5d AccountRemovalWork: remove cached owncloudClient after removing account
Otherwise, the account (which is identified by account name only) will reuse old token, if login is done right after account removal.

Three hours of debugging for one line of code

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 18:22:11 +01:00
Álvaro Brey 23a72722d3 Merge pull request #10009 from nextcloud/fix/dark-mode-scroll
Fix several scrolling bugs
2022-03-23 11:11:09 +01:00
Álvaro Brey Vilas 2e593a034b Fix FileDisplayActivity screenshot tests
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 10:38:08 +01:00
Álvaro Brey Vilas 154755af9b Fix scrolling behaviour when changing dark mode
Also fixes "scrolling on top bar" for empty folders

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 10:38:07 +01:00
Álvaro Brey Vilas b8bb261234 PreviewMediaFragment: fix crash when changing theme with audio fragment
Exoplayer is null when recreating

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 10:38:07 +01:00
Álvaro Brey Vilas 6a527a6e87 FileDisplayActivity: properly lock scrollbar for media preview
This locks the scrolling of the CoordinatorLayout AND removes the scroll flags from the AppbarLayout

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 10:38:07 +01:00
Álvaro Brey Vilas 17b695728e build.gradle: Fix spacing for library version
It's triggering false CI positives

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 10:37:41 +01:00
Álvaro Brey Vilas fb5de078f7 qa: fix head ref
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-23 10:29:31 +01:00
Álvaro Brey d013464320 Merge pull request #9959 from nextcloud/shareFromMediaView
Fix sharing from media view
2022-03-23 09:30:26 +01:00
Tobias Kaminsky 3aad1fc376 Merge pull request #9999 from nextcloud/chore/qa_pr_target
qa: run on pull_request_target, to enable running on fork PRs
2022-03-23 07:50:48 +01:00
Tobias Kaminsky 8f641e8aa2 Merge pull request #10006 from nextcloud/local-library-composite-build
SETUP: update local library linking instructions with composite builds
2022-03-23 07:48:31 +01:00
tobiasKaminsky f522446d13 Correctly show edit share link
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-23 06:50:51 +01:00
Nextcloud bot 0c5a9fd155 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-23 03:59:59 +00:00
tobiasKaminsky e481382c28 Use remoteId to properly fetch streaming video url
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-22 16:36:11 +01:00
Álvaro Brey Vilas f65b99a265 SETUP: update local library linking instructions with composite builds
Reference: https://docs.gradle.org/current/userguide/composite_builds.html

Not only is this the "official" way to do this, but also:
 - It's much simpler (changes only one file)
 - No need for symlinks
 - Android Studio support seems to finally be perfect (understands lombok, knows that there are two Git roots...)

[skip ci][ci skip]

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-22 14:31:59 +01:00
Álvaro Brey Vilas ea27e54d26 build.gradle: Restore library version
Wrongly committed

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-22 14:30:54 +01:00
Álvaro Brey Vilas f6298f7904 FileDetialsSharing...: add minHeight to content instead of scrollview
This still keeps the minimum height, but doesn't center the content vertically which looked odd

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-22 10:10:55 +01:00
Tobias Kaminsky 6c858840cb Merge pull request #10001 from nextcloud/chore/android-app-bundles
Use app bundles for Google Play upload
2022-03-22 08:33:50 +01:00
Tobias Kaminsky 646f857890 daily dev 20220322
Update Nextcloud Android library
2022-03-22 08:03:02 +01:00
Tobias Kaminsky 4cf9b68fab Merge pull request #10004 from nextcloud/fixDevScript
correct location of different build.gradle files
2022-03-22 07:59:13 +01:00
tobiasKaminsky c18bf9983e correct location of different build.gradle files
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-22 07:58:39 +01:00
Álvaro Brey Vilas 5cfa23c14b Update fastlane
command ran: bundle update fastlane

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-21 16:30:23 +01:00
Álvaro Brey Vilas 042b6aa38a fastlane: Sign the app bundle, and use it for google play upload
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-21 16:14:19 +01:00
Álvaro Brey Vilas ae0840e5aa fastlane: Build AAB for gplayRelease in addition to APK
APK is generated from AAB using bundletool, for speed and to ensure contents are the same

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-21 15:25:36 +01:00
tobiasKaminsky d91d2996ab Fix sharing from media view
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-21 15:06:06 +01:00
Álvaro Brey bfccee5d15 Merge pull request #9995 from nextcloud/gradle-clean
build.gradle: Add clean task to root project
2022-03-21 14:30:37 +01:00
Álvaro Brey Vilas eeee70f472 qa: run on pull_request_target, to enable running on fork PRs
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-21 13:24:10 +01:00
Álvaro Brey 380585ea52 Merge pull request #9998 from nextcloud/dependabot/github_actions/actions/cache-3
Bump actions/cache from 2 to 3
2022-03-21 13:14:40 +01:00
dependabot[bot] efd6d88124 Bump actions/cache from 2 to 3
Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-03-21 11:48:58 +00:00
Álvaro Brey a9bc999574 Merge pull request #9991 from nextcloud/dependabot/gradle/org.json-json-20220320
Bump json from 20211205 to 20220320
2022-03-21 10:48:01 +01:00
Álvaro Brey edac6e2870 Merge pull request #9983 from nextcloud/dependabot/gradle/com.google.firebase-firebase-messaging-23.0.2
Bump firebase-messaging from 20.1.3 to 23.0.2
2022-03-21 10:47:04 +01:00
Álvaro Brey Vilas d63d22d066 GooglePlayUtils: convert to Kotlin, fix spotbugs
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-21 09:40:18 +01:00
dependabot[bot] abf14b52cf Bump firebase-messaging from 20.1.3 to 23.0.2
Bumps firebase-messaging from 20.1.3 to 23.0.2.

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

Signed-off-by: dependabot[bot] <[email protected]>
2022-03-21 09:40:09 +01:00
Álvaro Brey Vilas 354047fdce build.gradle: Add clean task to root project
Missed this when restructuring

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-21 09:19:15 +01:00
Nextcloud bot 321a97acf7 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-21 03:59:20 +00:00
dependabot[bot] 5cadf81c43 Bump json from 20211205 to 20220320
Bumps [json](https://github.com/douglascrockford/JSON-java) from 20211205 to 20220320.
- [Release notes](https://github.com/douglascrockford/JSON-java/releases)
- [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md)
- [Commits](https://github.com/douglascrockford/JSON-java/commits)

---
updated-dependencies:
- dependency-name: org.json:json
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-03-21 02:06:05 +00:00
Nextcloud bot 98575bc8ca [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-20 04:00:57 +00:00
Nextcloud bot d7dbef4085 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-19 04:01:55 +00:00
Nextcloud bot 6d1b14785c [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-18 04:00:34 +00:00
Álvaro Brey 138d3a03a9 Merge pull request #9972 from nextcloud/fix/search-loading
Fix search loading animation and display
2022-03-17 13:04:10 +01:00
Álvaro Brey e7e2ab8a96 Merge pull request #9976 from nextcloud/fix/receive-crash-no-account
ReceiveExternalFilesActivity: don't crash if no user present
2022-03-17 10:44:45 +01:00
Álvaro Brey Vilas 769816978a OCFileListFragment: extract seach async task and convert it to kotlin
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-17 10:38:30 +01:00
Nextcloud bot 886400b5e0 [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-17 04:04:03 +00:00
Álvaro Brey b70eeaae3a Merge pull request #9977 from nextcloud/chore/ktlint-gradle
Use ktlint plugin instead of manual ktlint tasks
2022-03-16 13:05:23 +01:00
Álvaro Brey ad13f544ee Merge pull request #9974 from nextcloud/chore/espresso-intents-version
build.gradle: Don't hardcode espresso-intents version, use the same as other espresso libs
2022-03-16 13:00:49 +01:00
nextcloud-android-bot a64986e2e3 Analysis: update lint results to reflect reduced error/warning count
Signed-off-by: nextcloud-android-bot <[email protected]>
2022-03-16 11:40:41 +01:00
Álvaro Brey Vilas 3e2eba34a5 Update FolderPickerActivity screenshot
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-16 11:40:41 +01:00
Álvaro Brey Vilas 0af297735c ExtendedListFragment: Remove ViewTreeObserver on search frame
This was incorrectly setting empty message when switching search types. And it makes no sense: search is only executed when submitted.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-16 11:40:41 +01:00
Álvaro Brey Vilas e8e18609e5 OCFileListFragment: make search async task static, fix loading animation usage
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-16 11:40:41 +01:00
Álvaro Brey e8acc254b8 Merge pull request #9969 from nextcloud/chore/ndk-version
build: Specify NDK version (optional install)
2022-03-16 11:38:15 +01:00
Álvaro Brey Vilas 3597fb0a53 Use ktlint plugin instead of manual ktlint tasks
- Recommended by ktlint
 - Analyzes sources for all sourcesets without extra config
 - Less gradle code to maintain

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-16 11:30:39 +01:00
Tobias Kaminsky eccd9205bd Merge pull request #9970 from nextcloud/fix/share-screen-update
FileDisplayActivity: set file when opening FileDetailsFragment
2022-03-16 11:03:28 +01:00
Álvaro Brey 76d9bbfba3 Merge pull request #9432 from nextcloud/showCorrectNoShared
if no shared files are on server, show correct empty message
2022-03-16 10:45:08 +01:00
Álvaro Brey Vilas 3975839d53 ReceiveExternalFilesActivity: don't crash if no user present
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-16 10:38:37 +01:00
Álvaro Brey Vilas d6f32eb5ce build.gradle: Don't hardcode espresso-intents version, use the same as other espresso libs
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-16 10:01:04 +01:00
tobiasKaminsky d9b8b3baf8 Add NDK to buildDev
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-16 07:56:39 +01:00
Nextcloud bot e82fb2c6da [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-16 04:01:13 +00:00
tobiasKaminsky 080736af30 if no shared files are on server, show correct empty message
Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-15 17:36:20 +01:00
Álvaro Brey Vilas 934953506f FileDisplayActivity: set file when opening FileDetailsFragment
Solves issues when creating or removing shares, at which point the file would be re-set to the root folder

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-15 17:26:35 +01:00
Tobias Kaminsky 91520971cd Merge pull request #9873 from nextcloud/optional-files-permission
Make external storage permission optional
2022-03-15 16:49:54 +01:00
Álvaro Brey Vilas ec98c5db52 Centralize NDK and CMAKE versions
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-15 14:43:05 +01:00
Álvaro Brey Vilas 3b5d9ddabf qa: Ensure NDK and cmake are present
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-15 13:14:57 +01:00
Álvaro Brey Vilas 12ce7c2837 build: Specify NDK version (optional install)
If this + CMake is installed, native libraries are correctly stripped, and then APK size is reduced.
If not installed, everything still works as we don't actually need to compile any native stuff.

If `ndkVersion` is not specified, then the default version for Android Gradle Plugin is expected,
and stripping will not work even if other NDK version is installed. So it's better to use a
specific version, to prevent it from stopping working in the future.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-15 10:29:20 +01:00
Álvaro Brey Vilas 1a9014ee3b FileDisplayActivity: always try to reload folder on onResume
This makes it so that the folder loads even without granting storage permission, which is the expected behaviour now

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 17:39:21 +01:00
Álvaro Brey Vilas 2a4316a298 PermissionUtil: ensure permission choice dialog doesn't overlap itself
(ensure only one instance of it is ever shown at the same time)

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 17:22:17 +01:00
Álvaro Brey Vilas d8811c97a1 StoragePermissionDialogFragment: fix theming of buttons
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 17:18:07 +01:00
Álvaro Brey Vilas db196c68a4 Design updates for storage permission dialog
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 17:04:18 +01:00
Álvaro Brey Vilas ad5b443489 Choice between All Files and read-only external storage in SDK >=30
- Allow users to choose between MANAGE_EXTERNAL_STORAGE (full access) and READ_EXTERNAL_STORAGE (media read-only) in sdk >=30, with a dialog
- If All Files is not available (activity to manage not present, or permission not in manifest), request READ_EXTERNAL_STORAGE instead
- Misc improvements to permission request in UploadFilesActivity and SyncedFoldersActivity

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 17:04:17 +01:00
Álvaro Brey Vilas 7d2f0fa017 Make external storage permission optional
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 17:04:12 +01:00
Álvaro Brey 55c9811db6 Merge pull request #9865 from nextcloud/centralizeThemeUtils
Cache capabilities
2022-03-14 16:32:07 +01:00
Álvaro Brey Vilas 91c46090e8 Increase findbugs-results.txt
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-14 14:09:57 +01:00
tobiasKaminsky 05bd775171 only have one place for capability
update cache entry

Signed-off-by: tobiasKaminsky <[email protected]>
2022-03-14 13:23:14 +01:00
Nextcloud bot d2f670369f [tx-robot] updated from transifex
Signed-off-by: Nextcloud bot <[email protected]>
2022-03-14 11:15:03 +00:00
Álvaro Brey d4d18307b7 Merge pull request #9920 from nextcloud/fix/autoupload-select-folder
Fix folder selection in custom autoupload folders
2022-03-11 15:11:24 +01:00
Álvaro Brey Vilas a860761144 Increase lint and spotbugs
Lint is expected, spotbugs is false positive

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-11 13:22:52 +01:00
Álvaro Brey Vilas 785767ae70 Screenshot tests for UploadFilesActivity
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-11 13:22:50 +01:00
Álvaro Brey Vilas 900145da05 Fix folder selection in custom autoupload folders
Hide checkboxes and keep choose button enabled. The flow to select folders is to navigate into them and tap "Choose", as is typical in file browsers.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-03-11 13:21:31 +01:00
333 changed files with 12025 additions and 3973 deletions

No files matched your search

+6 -10
View File
@@ -20,25 +20,21 @@ steps:
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $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
- sed -i s"#server#server#" gradle.properties
- ./gradlew assembleGplay
- ./gradlew assembleGplayDebug
- ./gradlew assembleGplayDebugAndroidTest
- scripts/wait_for_emulator.sh
- scripts/deleteOldComments.sh "stable" "Unit" $DRONE_PULL_REQUEST $GIT_TOKEN
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_TOKEN
- ./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
- ./gradlew combinedTestReport
services:
- name: server
image: ghcr.io/nextcloud/continuous-integration-server:latest # also change in updateScreenshots.sh
environment:
EVAL: true
SERVER_VERSION: 'stable24'
commands:
- BRANCH='stable23' /usr/local/bin/initnc.sh
- BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh
- echo 127.0.0.1 server >> /etc/hosts
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
@@ -47,11 +43,11 @@ services:
- su www-data -c "php /var/www/html/occ group:add users"
- su www-data -c "php /var/www/html/occ group:adduser users user1"
- su www-data -c "php /var/www/html/occ group:adduser users user2"
- su www-data -c "git clone -b stable23 https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
- su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
- su www-data -c "php /var/www/html/occ app:enable activity"
- su www-data -c "git clone -b stable23 https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "php /var/www/html/occ app:enable text"
- su www-data -c "git clone -b stable23 https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
- /usr/local/bin/run.sh
+4 -1
View File
@@ -36,10 +36,13 @@ jobs:
repository: ${{ steps.get-vars.outputs.repo }}
ref: ${{ steps.get-vars.outputs.branch }}
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
- name: Install dependencies
run: |
python3 -m pip install defusedxml
- name: Run analysis wrapper
run: |
mkdir -p $HOME/.gradle
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
+1 -1
View File
@@ -7,7 +7,7 @@ jobs:
auto-approve:
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2.1.0
- uses: hmarr/auto-approve-action@v2.2.1
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
+2 -2
View File
@@ -10,11 +10,11 @@ jobs:
strategy:
fail-fast: false
matrix:
task: [ detekt, ktlint ]
task: [ detekt, ktlintCheck ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
+3 -3
View File
@@ -18,7 +18,7 @@ jobs:
steps:
- name: Add reaction on start
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
repository: ${{ github.event.repository.full_name }}
@@ -32,12 +32,12 @@ jobs:
token: ${{ secrets.COMMAND_BOT_PAT }}
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.5
uses: cirrus-actions/rebase@1.6
env:
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
- name: Add reaction on failure
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v2
if: failure()
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
+15
View File
@@ -0,0 +1,15 @@
name: "Detect new java files"
on:
pull_request:
branches: [ master, stable-* ]
jobs:
detectNewJavaFiles:
runs-on: ubuntu-latest
steps:
- uses: trilom/[email protected]
- uses: actions/checkout@v2
- name: Detect new java files
run: scripts/analysis/detectNewJavaFiles.sh
+9 -8
View File
@@ -1,26 +1,27 @@
name: "QA"
on:
pull_request:
pull_request_target:
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
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: set up JDK 11
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
- name: Install NDK and cmake
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 }}
+3 -3
View File
@@ -17,14 +17,14 @@ jobs:
- uses: actions/checkout@v3
- name: Gradle cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: AVD cache
uses: actions/cache@v2
uses: actions/cache@v3
id: avd-cache
with:
path: |
@@ -32,7 +32,7 @@ jobs:
~/.android/adb*
key: avd-${{ matrix.api-level }}
- uses: actions/setup-java@v2
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
+41
View File
@@ -0,0 +1,41 @@
name: Unit tests
on:
pull_request:
branches: [ master, stable-* ]
push:
branches: [ master, stable-* ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
- name: Delete old comments
if: ${{ always() }}
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
- name: Run unit tests with coverage
uses: gradle/gradle-build-action@v2
with:
arguments: jacocoTestGplayDebugUnitTest
- name: Upload failing results
if: ${{ failure() }}
run:
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit
fail_ci_if_error: true
- name: Upload jacoco artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: test-results
path: app/build/reports/tests/testGplayDebugUnitTest/
+5 -1
View File
@@ -1,6 +1,7 @@
# built application files
*.apk
*.ap_
*.aab
# files for the dex VM
*.dex
@@ -49,4 +50,7 @@ fastlane/Fastfile
**/fastlane/test_output
/fastlane/vendor/
/.bundle/
/fastlane/.bundle/
/fastlane/.bundle
# python
**/__pycache__/
+19
View File
@@ -1,3 +1,22 @@
## 3.20.1 (May 6th, 2022)
- Several minor bugfixes
Minimum: NC 16 Server, Android 6.0 Marshmallow
For a full list, please see https://github.com/nextcloud/android/milestone/67
## 3.20.0 (May 3rd, 2022)
- Built-in PDF viewer
- Built-in document scanner
- Better choices for storage permissions
- File locking support
- Better UI for media gallery
- Many bugfixes and improvements
Minimum: NC 16 Server, Android 6.0 Marshmallow
For a full list, please see https://github.com/nextcloud/android/milestone/64
## 3.19.1 (March 10, 2022)
- Minor fixes and improvements
+23 -23
View File
@@ -8,20 +8,20 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.549.0)
aws-sdk-core (3.125.5)
aws-partitions (1.582.0)
aws-sdk-core (3.130.2)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.53.0)
aws-sdk-core (~> 3, >= 3.125.0)
aws-sdk-kms (1.56.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.111.2)
aws-sdk-core (~> 3, >= 3.125.0)
aws-sdk-s3 (1.113.2)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.4.0)
aws-sigv4 (1.5.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
@@ -36,8 +36,8 @@ GEM
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
emoji_regex (3.2.3)
excon (0.90.0)
faraday (1.9.3)
excon (0.92.3)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
@@ -66,7 +66,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.201.1)
fastlane (2.205.2)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
@@ -105,9 +105,9 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-huawei_appgallery_connect (1.0.18)
fastlane-plugin-huawei_appgallery_connect (1.0.19)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.15.0)
google-apis-androidpublisher_v3 (0.19.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-core (0.4.2)
addressable (~> 2.5, >= 2.5.1)
@@ -122,15 +122,15 @@ GEM
google-apis-core (>= 0.4, < 2.a)
google-apis-playcustomapp_v1 (0.7.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-storage_v1 (0.11.0)
google-apis-storage_v1 (0.13.0)
google-apis-core (>= 0.4, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.0)
google-cloud-storage (1.36.2)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
@@ -138,8 +138,8 @@ GEM
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.1.0)
faraday (>= 0.17.3, < 2.0)
googleauth (1.1.3)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
@@ -149,7 +149,7 @@ GEM
http-cookie (1.0.4)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.5.0)
jmespath (1.6.1)
json (2.6.1)
jwt (2.3.0)
memoist (0.16.2)
@@ -162,7 +162,7 @@ GEM
optparse (0.1.1)
os (1.1.4)
plist (3.6.0)
public_suffix (4.0.6)
public_suffix (4.0.7)
rake (13.0.6)
representable (3.1.1)
declarative (< 0.1.0)
@@ -174,9 +174,9 @@ GEM
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.16.0)
signet (0.16.1)
addressable (~> 2.8)
faraday (>= 0.17.3, < 2.0)
faraday (>= 0.17.5, < 3.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.8)
@@ -193,7 +193,7 @@ GEM
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unf_ext (0.0.8.1)
unicode-display_width (1.8.0)
webrick (1.7.0)
word_wrap (1.0.0)
+5 -12
View File
@@ -89,22 +89,15 @@ The app is currently equipped to be built with three flavours:
#### 1. Direct usage of library project
This is handy if one wants to make changes both to files app and library:
- In the repository root: `ln -s [path to library clone] nextcloud-android-library`
- Add the following to `settings.gradle`:
```groovy
include ':nextcloud-android-library'
```
- In `app/build.gradle`, replace the following:
```groovy
implementation ("com.github.nextcloud:android-library:$androidLibraryVersion") {
exclude group: 'org.ogce', module: 'xpp3'
includeBuild('[path to library clone]') {
dependencySubstitution {
substitute module('com.github.nextcloud:android-library') using project(':library')
}
}
```
with:
``` groovy
implementation project(':nextcloud-android-library')
```
- Sync project with gradle files
Now every change in library can be directly used in files app.
+43 -66
View File
@@ -3,16 +3,17 @@ import org.gradle.internal.jvm.Jvm
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0"
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.13.0'
classpath 'com.karumi:shot:5.14.0'
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.3.0"
}
}
@@ -27,12 +28,11 @@ apply plugin: 'com.hiya.jacoco-android'
apply plugin: 'com.github.spotbugs'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'shot'
apply plugin: "org.jlleitschuh.gradle.ktlint"
println "Gradle uses Java ${Jvm.current()}"
configurations {
ktlint
all {
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
@@ -54,24 +54,24 @@ configurations.configureEach {
}
}
repositories {
google()
maven { url "https://jitpack.io" }
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
// semantic versioning for version code
def versionMajor = 3
def versionMinor = 20
def versionMinor = 21
def versionPatch = 0
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
def ndkEnv = new HashMap<String, String>()
file("$project.rootDir/ndk.env").readLines().each() {
def (key, value) = it.tokenize('=')
ndkEnv.put(key, value)
}
android {
compileSdkVersion 31
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
ndkVersion "${ndkEnv.get("NDK_VERSION")}"
defaultConfig {
minSdkVersion 23
@@ -129,8 +129,8 @@ android {
versionDev {
applicationId "com.nextcloud.android.beta"
dimension "default"
versionCode 20200129
versionName "20200129"
versionCode 20220322
versionName "20220322"
}
qa {
@@ -185,7 +185,7 @@ android {
}
}
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'ktlintCheck', 'detekt'
buildFeatures {
dataBinding true
@@ -219,7 +219,7 @@ dependencies {
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.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.material:material:1.6.0'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.webkit:webkit:1.4.0'
@@ -241,20 +241,24 @@ dependencies {
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.google.android:flexbox:2.0.1'
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.8.0'
implementation 'com.vanniktech:emoji-google:0.9.0'
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido:$fidoVersion"
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido2:$fidoVersion"
implementation 'com.github.zynkware:Document-Scanning-Android-SDK:1.0.1'
// document scanner not available on FDroid (generic) due to OpenCV binaries
gplayImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
huaweiImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
qaImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
versionDevImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
implementation "com.google.dagger:dagger:$daggerVersion"
@@ -263,14 +267,15 @@ dependencies {
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
ktlint "com.pinterest:ktlint:0.44.0"
implementation 'org.conscrypt:conscrypt-android:2.5.2'
implementation "com.google.android.exoplayer:exoplayer:$exoplayerVersion"
implementation "com.google.android.exoplayer:extension-okhttp:$exoplayerVersion"
implementation 'me.zhanghai.android.fastscroll:library:1.1.8'
// Shimmer animation
implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0'
implementation 'io.github.elye:loaderviewlibrary:3.0.0'
// dependencies for markdown rendering
implementation "io.noties.markwon:core:$markwonVersion"
@@ -289,8 +294,8 @@ dependencies {
}
}
if (!ciBuild) {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
if (project.hasProperty("leakCanary")) {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
}
// dependencies for local unit tests
@@ -300,7 +305,7 @@ dependencies {
testImplementation "org.powermock:powermock-core:$powermockVersion"
testImplementation "org.powermock:powermock-module-junit4:$powermockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
testImplementation 'org.json:json:20211205'
testImplementation 'org.json:json:20220320'
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation "io.mockk:mockk:$mockkVersion"
@@ -313,12 +318,14 @@ dependencies {
// Android JUnit Runner
androidTestImplementation "androidx.test:runner:$androidxTestVersion"
androidTestUtil "androidx.test:orchestrator:$androidxTestVersion"
androidTestImplementation "androidx.test:core-ktx:$androidxTestVersion"
// Espresso core
// Espresso
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
// Mocking support
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
@@ -339,12 +346,11 @@ dependencies {
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
androidTestImplementation('androidx.test.espresso:espresso-intents:3.4.0')
implementation "com.github.stateless4j:stateless4j:2.6.0"
// upon each update first test: new registration, receive push
gplayImplementation "com.google.firebase:firebase-messaging:20.1.3"
gplayImplementation "com.google.firebase:firebase-messaging:23.0.4"
}
configurations.all {
@@ -373,38 +379,6 @@ android.applicationVariants.all { variant ->
}
}
tasks.register("combinedTestReport", JacocoReport) {
jacocoClasspath = configurations['jacocoAnt']
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.setFrom files(subprojects.sourceSets.main.output)
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
])
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "--reporter=plain", "--reporter=plain,output=${buildDir}/ktlint.txt,${projectDir}/src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "${projectDir}/src/**/*.kt"
}
task installGitHooks(type: Copy, group: "development") {
description = "Install git hooks"
from("${project.rootDir}/scripts/hooks") {
@@ -448,10 +422,13 @@ tasks.withType(SpotBugsTask){task ->
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
reports {
xml.enabled = false
xml {
required = true
}
html {
enabled = true
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
required = true
outputLocation = file("$project.buildDir/reports/spotbugs/spotbugs.html")
stylesheet = 'fancy.xsl'
}
}
}
+14 -74
View File
@@ -1,5 +1,5 @@
build:
maxIssues: 11
maxIssues: 3
weights:
# complexity: 2
# LongParameterList: 1
@@ -69,7 +69,8 @@ complexity:
excludes: ['**/androidTest/**']
LongParameterList:
active: true
threshold: 6
functionThreshold: 6
constructorThreshold: 6
ignoreDefaultParameters: false
MethodOverloading:
active: false
@@ -174,72 +175,6 @@ exceptions:
- Throwable
- RuntimeException
formatting:
active: true
android: false
ChainWrapping:
active: true
CommentSpacing:
active: true
Filename:
active: true
FinalNewline:
active: true
ImportOrdering:
active: false
Indentation:
active: true
indentSize: 4
continuationIndentSize: 4
MaximumLineLength:
active: true
maxLineLength: 120
ModifierOrdering:
active: true
NoBlankLineBeforeRbrace:
active: true
NoConsecutiveBlankLines:
active: true
NoEmptyClassBody:
active: true
NoLineBreakAfterElse:
active: true
NoLineBreakBeforeAssignment:
active: true
NoMultipleSpaces:
active: true
NoSemicolons:
active: true
NoTrailingSpaces:
active: true
NoUnitReturn:
active: true
NoUnusedImports:
active: true
NoWildcardImports:
active: true
PackageName:
active: true
ParameterListWrapping:
active: true
indentSize: 4
SpacingAroundColon:
active: true
SpacingAroundComma:
active: true
SpacingAroundCurly:
active: true
SpacingAroundKeyword:
active: true
SpacingAroundOperators:
active: true
SpacingAroundParens:
active: true
SpacingAroundRangeOperator:
active: true
StringTemplate:
active: true
naming:
active: true
ClassNaming:
@@ -267,7 +202,9 @@ naming:
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
ignoreOverridden: true
excludes: "**/*Test.kt"
excludes:
- "**/*Test.kt"
- "**/*IT.kt"
FunctionParameterNaming:
active: true
parameterPattern: '[a-z][A-Za-z0-9]*'
@@ -333,7 +270,7 @@ potential-bugs:
active: false
LateinitUsage:
active: false
excludeAnnotatedProperties: ""
ignoreAnnotated: []
ignoreOnClassesPattern: ""
UnconditionalJumpStatementInLoop:
active: false
@@ -389,7 +326,9 @@ style:
ignoreAnnotation: false
ignoreNamedArgument: true
ignoreEnums: false
excludes: "**/*Test.kt"
excludes:
- "**/*Test.kt"
- "**/*IT.kt"
MandatoryBracesIfStatements:
active: false
MaxLineLength:
@@ -439,10 +378,11 @@ style:
active: false
UnderscoresInNumericLiterals:
active: false
acceptableDecimalLength: 5
acceptableLength: 5
UnnecessaryAbstractClass:
active: false
excludeAnnotatedClasses: "dagger.Module"
ignoreAnnotated:
- "dagger.Module"
UnnecessaryApply:
active: false
UnnecessaryInheritance:
@@ -462,7 +402,7 @@ style:
allowedNames: "(_|ignored|expected|serialVersionUID)"
UseDataClass:
active: false
excludeAnnotatedClasses: ""
ignoreAnnotated: []
UtilityClassWithPublicConstructor:
active: false
VarCouldBeVal:
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@@ -185,12 +185,15 @@ class ActivitiesActivityIT : AbstractIT() {
fun error() {
val sut: ActivitiesActivity = activityRule.launchActivity(null)
shortSleep()
sut.runOnUiThread {
sut.showEmptyContent("Error", "Error! Please try again later!")
sut.setProgressIndicatorState(false)
sut.dismissSnackbar()
}
shortSleep()
shortSleep()
waitForIdleSync()
@@ -53,19 +53,21 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
@ScreenshotTest
fun open() {
val sut = activityRule.launchActivity(null)
sut.listOfFilesFragment!!.setFabEnabled(false)
shortSleep()
sut.runOnUiThread {
sut.listOfFilesFragment!!.setFabEnabled(false)
sut.resetScrolling()
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
sut.listOfFilesFragment!!.isLoading = false
}
shortSleep()
waitForIdleSync()
screenshot(sut)
}
// @Test
// @ScreenshotTest
@Test
@ScreenshotTest
fun showMediaThenAllFiles() {
val fileDisplayActivity = activityRule.launchActivity(null)
val sut = fileDisplayActivity.listOfFilesFragment
@@ -103,13 +105,16 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
fun drawer() {
val sut = activityRule.launchActivity(null)
Espresso.onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
sut.listOfFilesFragment!!.setFabEnabled(false)
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
sut.listOfFilesFragment!!.isLoading = false
shortSleep()
sut.runOnUiThread {
sut.hideInfoBox()
sut.resetScrolling()
sut.listOfFilesFragment!!.setFabEnabled(false)
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
sut.listOfFilesFragment!!.isLoading = false
}
shortSleep()
waitForIdleSync()
screenshot(sut)
}
@@ -21,10 +21,10 @@
package com.nextcloud.client
import android.Manifest
import android.os.Build
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import com.owncloud.android.utils.PermissionUtil
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
@@ -35,8 +35,7 @@ class GrantStoragePermissionRule private constructor() {
@JvmStatic
fun grant(): TestRule = when {
Build.VERSION.SDK_INT < Build.VERSION_CODES.R -> GrantPermissionRule.grant(
PermissionUtil
.getExternalStoragePermission()
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
else -> GrantManageExternalStoragePermissionRule()
}
@@ -36,7 +36,7 @@ import org.mockito.kotlin.eq
import org.mockito.kotlin.verify
@RunWith(AndroidJUnit4::class)
class ContentResolverHelperTest {
class ContentResolverHelperIT {
companion object {
private val URI = Uri.parse("http://foo.bar")
@@ -0,0 +1,211 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.files
import android.view.Menu
import androidx.appcompat.view.menu.MenuBuilder
import androidx.test.core.app.launchActivity
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.nextcloud.client.TestActivity
import com.nextcloud.client.account.User
import com.owncloud.android.AbstractIT
import com.owncloud.android.R
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.files.services.FileDownloader
import com.owncloud.android.files.services.FileUploader
import com.owncloud.android.lib.resources.files.model.FileLockType
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
import com.owncloud.android.lib.resources.status.OCCapability
import com.owncloud.android.services.OperationsService
import com.owncloud.android.ui.activity.ComponentsGetter
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class FileMenuFilterIT : AbstractIT() {
@MockK
private lateinit var mockComponentsGetter: ComponentsGetter
@MockK
private lateinit var mockStorageManager: FileDataStorageManager
@MockK
private lateinit var mockFileUploaderBinder: FileUploader.FileUploaderBinder
@MockK
private lateinit var mockFileDownloaderBinder: FileDownloader.FileDownloaderBinder
@MockK
private lateinit var mockOperationsServiceBinder: OperationsService.OperationsServiceBinder
@Before
fun setup() {
MockKAnnotations.init(this)
every { mockFileUploaderBinder.isUploading(any(), any()) } returns false
every { mockComponentsGetter.fileUploaderBinder } returns mockFileUploaderBinder
every { mockFileDownloaderBinder.isDownloading(any(), any()) } returns false
every { mockComponentsGetter.fileDownloaderBinder } returns mockFileDownloaderBinder
every { mockOperationsServiceBinder.isSynchronizing(any(), any()) } returns false
every { mockComponentsGetter.operationsServiceBinder } returns mockOperationsServiceBinder
}
@Test
fun filter_noLockingCapability_lockItemsInvisible() {
val capability = OCCapability().apply {
endToEndEncryption = CapabilityBooleanType.UNKNOWN
}
val file = OCFile("/foo.md")
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = false, unlockFile = false, lockedBy = false, lockedUntil = false)
)
}
@Test
fun filter_lockingCapability_fileUnlocked_lockVisible() {
val capability = OCCapability().apply {
endToEndEncryption = CapabilityBooleanType.UNKNOWN
filesLockingVersion = "1.0"
}
val file = OCFile("/foo.md")
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = true, unlockFile = false, lockedBy = false, lockedUntil = false)
)
}
@Test
fun filter_lockingCapability_fileLocked_lockedByAndProps() {
val capability = OCCapability().apply {
endToEndEncryption = CapabilityBooleanType.UNKNOWN
filesLockingVersion = "1.0"
}
val file = OCFile("/foo.md").apply {
isLocked = true
lockType = FileLockType.MANUAL
lockOwnerId = user.accountName.split("@")[0]
lockOwnerDisplayName = "TEST"
lockTimestamp = 1000 // irrelevant
lockTimeout = 1000 // irrelevant
}
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = false, unlockFile = true, lockedBy = true, lockedUntil = true)
)
}
@Test
fun filter_lockingCapability_fileLockedByOthers_lockedByAndProps() {
val capability = OCCapability().apply {
endToEndEncryption = CapabilityBooleanType.UNKNOWN
filesLockingVersion = "1.0"
}
val file = OCFile("/foo.md").apply {
isLocked = true
lockType = FileLockType.MANUAL
lockOwnerId = "A_DIFFERENT_USER"
lockOwnerDisplayName = "A_DIFFERENT_USER"
lockTimestamp = 1000 // irrelevant
lockTimeout = 1000 // irrelevant
}
testLockingVisibilities(
capability,
file,
ExpectedLockVisibilities(lockFile = false, unlockFile = false, lockedBy = true, lockedUntil = true)
)
}
private data class ExpectedLockVisibilities(
val lockFile: Boolean,
val unlockFile: Boolean,
val lockedBy: Boolean,
val lockedUntil: Boolean
)
private fun configureCapability(capability: OCCapability) {
every { mockStorageManager.getCapability(any<User>()) } returns capability
every { mockStorageManager.getCapability(any<String>()) } returns capability
every { mockComponentsGetter.storageManager } returns mockStorageManager
}
private fun getMenu(activity: TestActivity): Menu {
val inflater = activity.menuInflater
val menu = MenuBuilder(activity)
inflater.inflate(R.menu.item_file, menu)
return menu
}
private fun testLockingVisibilities(
capability: OCCapability,
file: OCFile,
expectedLockVisibilities: ExpectedLockVisibilities
) {
configureCapability(capability)
launchActivity<TestActivity>().use {
it.onActivity { activity ->
val menu = getMenu(activity)
val sut = FileMenuFilter(file, mockComponentsGetter, activity, true, user)
sut.filter(menu, false)
Assert.assertEquals(
expectedLockVisibilities.lockFile,
menu.findItem(R.id.action_lock_file).isVisible
)
Assert.assertEquals(
expectedLockVisibilities.unlockFile,
menu.findItem(R.id.action_unlock_file).isVisible
)
Assert.assertEquals(
expectedLockVisibilities.lockedBy,
menu.findItem(R.id.action_locked_by).isVisible
)
Assert.assertEquals(
expectedLockVisibilities.lockedUntil,
menu.findItem(R.id.action_locked_until).isVisible
)
// locked by and until should always be disabled, they're not real actions
Assert.assertFalse(menu.findItem(R.id.action_locked_by).isEnabled)
Assert.assertFalse(menu.findItem(R.id.action_locked_until).isEnabled)
}
}
}
}
@@ -38,7 +38,7 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
private val authority = context.getString(R.string.document_provider_authority)
private val rootFileId = storageManager.getFileByEncryptedRemotePath(ROOT_PATH).fileId
private val documentId = "${user.hashCode()}${DOCUMENTID_SEPARATOR}$rootFileId"
private val documentId = "${DocumentsStorageProvider.rootIdForUser(user)}${DOCUMENTID_SEPARATOR}$rootFileId"
private val uri = DocumentsContract.buildTreeDocumentUri(authority, documentId)
private val rootDir get() = DocumentFile.fromTreeUri(context, uri)!!
@@ -1,140 +0,0 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2020 Tobias Kaminsky
* Copyright (C) 2020 Nextcloud GmbH
*
* 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;
import android.accounts.Account;
import android.content.Context;
import android.os.Bundle;
import com.nextcloud.client.GrantStoragePermissionRule;
import com.nextcloud.client.RetryTestRule;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.account.UserAccountManagerImpl;
import com.owncloud.android.AbstractIT;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AuthenticatorActivity;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.web.webdriver.DriverAtoms;
import androidx.test.espresso.web.webdriver.Locator;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.web.sugar.Web.onWebView;
import static androidx.test.espresso.web.webdriver.DriverAtoms.findElement;
import static androidx.test.espresso.web.webdriver.DriverAtoms.webClick;
import static org.junit.Assert.assertEquals;
@LargeTest
public class LoginIT extends AbstractIT {
@Rule
public final TestRule permissionRule = GrantStoragePermissionRule.grant();
@Rule
public RetryTestRule retryTestRule = new RetryTestRule();
@Before
public void setUp() {
tearDown();
ActivityScenario.launch(AuthenticatorActivity.class);
}
@AfterClass
public static void tearDown() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
if (accountManager.getAccounts().length > 0) {
accountManager.removeAllAccounts();
}
}
@Test
public void login() throws InterruptedException {
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
String baseUrl = arguments.getString("TEST_SERVER_URL");
String loginName = arguments.getString("TEST_SERVER_USERNAME");
String password = arguments.getString("TEST_SERVER_PASSWORD");
onView(withId(R.id.login)).perform(click());
onView(withId(R.id.host_url_input)).perform(typeText(baseUrl));
onView(withId(R.id.host_url_input)).perform(typeTextIntoFocusedView("\n"));
Thread.sleep(3000);
onWebView().forceJavascriptEnabled();
// click on login
onWebView()
.withElement(findElement(Locator.XPATH, "//p[@id='redirect-link']/a"))
.perform(webClick());
// username
onWebView()
.withElement(findElement(Locator.XPATH, "//input[@id='user']"))
.perform(DriverAtoms.webKeys(loginName));
// password
onWebView()
.withElement(findElement(Locator.XPATH, "//input[@id='password']"))
.perform(DriverAtoms.webKeys(password));
// click login
onWebView()
.withElement(findElement(Locator.XPATH, "//input[@id='submit-form']"))
.perform(webClick());
Thread.sleep(2000);
// grant access
onWebView()
.withElement(findElement(Locator.XPATH, "//input[@type='submit']"))
.perform(webClick());
Thread.sleep(5 * 1000);
// check for account
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
assertEquals(1, accountManager.getAccounts().length);
Account account = accountManager.getAccounts()[0];
// account.name is loginName@baseUrl (without protocol)
assertEquals(loginName, account.name.split("@")[0]);
assertEquals(baseUrl.split("//")[1], account.name.split("@")[1]);
}
}
@@ -0,0 +1,124 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2020 Tobias Kaminsky
* Copyright (C) 2020 Nextcloud GmbH
*
* 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
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.web.sugar.Web
import androidx.test.espresso.web.webdriver.DriverAtoms
import androidx.test.espresso.web.webdriver.Locator
import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import com.nextcloud.client.GrantStoragePermissionRule
import com.nextcloud.client.RetryTestRule
import com.nextcloud.client.account.UserAccountManager
import com.nextcloud.client.account.UserAccountManagerImpl
import com.owncloud.android.AbstractIT
import com.owncloud.android.R
import com.owncloud.android.authentication.AuthenticatorActivity
import org.junit.AfterClass
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@LargeTest
class LoginIT : AbstractIT() {
@get:Rule
val permissionRule = GrantStoragePermissionRule.grant()
@get:Rule
var retryTestRule = RetryTestRule()
@Before
fun setUp() {
tearDown()
ActivityScenario.launch(AuthenticatorActivity::class.java)
}
@Test
@Throws(InterruptedException::class)
@Suppress("MagicNumber")
fun login() {
val arguments = InstrumentationRegistry.getArguments()
val baseUrl = arguments.getString("TEST_SERVER_URL")!!
val loginName = arguments.getString("TEST_SERVER_USERNAME")!!
val password = arguments.getString("TEST_SERVER_PASSWORD")!!
Espresso.onView(ViewMatchers.withId(R.id.login)).perform(ViewActions.click())
Espresso.onView(ViewMatchers.withId(R.id.host_url_input)).perform(ViewActions.typeText(baseUrl))
Espresso.onView(ViewMatchers.withId(R.id.host_url_input)).perform(ViewActions.typeTextIntoFocusedView("\n"))
Thread.sleep(3000)
Web.onWebView().forceJavascriptEnabled()
// click on login
Web.onWebView()
.withElement(DriverAtoms.findElement(Locator.XPATH, "//p[@id='redirect-link']/a"))
.perform(DriverAtoms.webClick())
// username
Web.onWebView()
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@id='user']"))
.perform(DriverAtoms.webKeys(loginName))
// password
Web.onWebView()
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@id='password']"))
.perform(DriverAtoms.webKeys(password))
// click login
Web.onWebView()
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@type='submit']"))
.perform(DriverAtoms.webClick())
Thread.sleep(2000)
// grant access
Web.onWebView()
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@type='submit']"))
.perform(DriverAtoms.webClick())
Thread.sleep((5 * 1000).toLong())
// check for account
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
val accountManager: UserAccountManager = UserAccountManagerImpl.fromContext(targetContext)
Assert.assertEquals(1, accountManager.accounts.size.toLong())
val account = accountManager.accounts[0]
// account.name is loginName@baseUrl (without protocol)
Assert.assertEquals(loginName, account.name.split("@".toRegex()).toTypedArray()[0])
Assert.assertEquals(
baseUrl.split("//".toRegex()).toTypedArray()[1],
account.name.split("@".toRegex()).toTypedArray()[1]
)
}
companion object {
@AfterClass
fun tearDown() {
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
val accountManager: UserAccountManager = UserAccountManagerImpl.fromContext(targetContext)
if (accountManager.accounts.isNotEmpty()) {
accountManager.removeAllAccounts()
}
}
}
}
@@ -42,6 +42,8 @@ class PassCodeActivityIT : AbstractIT() {
sut.runOnUiThread { sut.binding.txt0.clearFocus() }
Espresso.closeSoftKeyboard()
shortSleep()
waitForIdleSync()
screenshot(sut)
}
@@ -55,6 +57,8 @@ class PassCodeActivityIT : AbstractIT() {
sut.runOnUiThread { sut.binding.txt0.clearFocus() }
Espresso.closeSoftKeyboard()
shortSleep()
waitForIdleSync()
screenshot(sut)
}
@@ -68,6 +72,8 @@ class PassCodeActivityIT : AbstractIT() {
sut.runOnUiThread { sut.binding.txt0.clearFocus() }
Espresso.closeSoftKeyboard()
shortSleep()
waitForIdleSync()
screenshot(sut)
}
@@ -21,20 +21,84 @@
*/
package com.owncloud.android.ui.activity
import android.content.Intent
import androidx.test.espresso.intent.rule.IntentsTestRule
import com.nextcloud.client.GrantStoragePermissionRule
import com.owncloud.android.AbstractIT
import com.owncloud.android.utils.FileStorageUtils
import com.owncloud.android.utils.ScreenshotTest
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import java.io.File
class UploadFilesActivityIT : AbstractIT() {
@get:Rule
var activityRule = IntentsTestRule(UploadFilesActivity::class.java, true, false)
@get:Rule
var permissionRule = GrantStoragePermissionRule.grant()
private val directories = listOf("A", "B", "C", "D")
.map { File("${FileStorageUtils.getTemporalPath(account.name)}${File.separator}$it") }
@Before
fun setUp() {
directories.forEach { it.mkdirs() }
}
@After
fun tearDown() {
directories.forEach { it.deleteRecursively() }
}
@Test
// @ScreenshotTest // TODO re-enable and make sure that folder content on emulator is the same on all devices
@ScreenshotTest
fun noneSelected() {
val sut: UploadFilesActivity = activityRule.launchActivity(null)
sut.runOnUiThread {
sut.fileListFragment.setFiles(
directories +
listOf(
File("1.txt"),
File("2.pdf"),
File("3.mp3")
)
)
}
waitForIdleSync()
shortSleep()
screenshot(sut)
}
@Test
@ScreenshotTest
fun localFolderPickerMode() {
val sut: UploadFilesActivity = activityRule.launchActivity(
Intent().apply {
putExtra(
UploadFilesActivity.KEY_LOCAL_FOLDER_PICKER_MODE,
true
)
putExtra(
UploadFilesActivity.REQUEST_CODE_KEY,
FileDisplayActivity.REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM
)
}
)
sut.runOnUiThread {
sut.fileListFragment.setFiles(
directories
)
}
waitForIdleSync()
screenshot(sut)
}
@@ -57,10 +57,11 @@ import com.owncloud.android.lib.resources.users.Status;
import com.owncloud.android.lib.resources.users.StatusType;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions;
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog;
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialogFragment;
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.ScreenshotTest;
import com.owncloud.android.utils.theme.CapabilityUtils;
import org.junit.After;
import org.junit.Rule;
@@ -390,18 +391,17 @@ public class DialogFragmentIT extends AbstractIT {
capability.setRichDocuments(CapabilityBooleanType.TRUE);
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
capability.setRichDocumentsTemplatesAvailable(CapabilityBooleanType.TRUE);
capability.setAccountName(user.getAccountName());
OCFileListBottomSheetDialog sut = new OCFileListBottomSheetDialog(fda,
action,
info,
user,
ocFile);
CapabilityUtils.updateCapability(capability);
fda.runOnUiThread(sut::show);
OCFileListBottomSheetDialogFragment sut = new OCFileListBottomSheetDialogFragment(fda,
action,
info,
user,
ocFile);
waitForIdleSync();
screenshot(sut.getWindow().getDecorView());
showDialog(fda, sut);
}
@Test
@@ -436,7 +436,9 @@ public class DialogFragmentIT extends AbstractIT {
ProfileBottomSheetDialog sut = new ProfileBottomSheetDialog(fda,
user,
hoverCard);
hoverCard,
fda.themeColorUtils,
fda.themeDrawableUtils);
fda.runOnUiThread(sut::show);
@@ -21,7 +21,6 @@
*/
package com.owncloud.android.ui.dialog
import android.view.Window
import androidx.test.espresso.intent.rule.IntentsTestRule
import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread
import com.nextcloud.client.TestActivity
@@ -29,7 +28,6 @@ import com.owncloud.android.AbstractIT
import com.owncloud.android.utils.ScreenshotTest
import org.junit.Rule
import org.junit.Test
import java.util.Objects
class SetupEncryptionDialogFragmentIT : AbstractIT() {
@get:Rule
@@ -69,7 +67,7 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() {
waitForIdleSync()
screenshot(Objects.requireNonNull<Window>(sut.requireDialog().window).decorView)
screenshot(sut.requireDialog().window!!.decorView)
}
@Test
@@ -87,8 +85,9 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() {
sut.errorSavingKeys()
}
shortSleep()
waitForIdleSync()
screenshot(Objects.requireNonNull<Window>(sut.requireDialog().window).decorView)
screenshot(sut.requireDialog().window!!.decorView)
}
}
@@ -123,8 +123,8 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
"files",
"1",
"/text.txt",
null,
null
emptyList(),
RichElement()
)
)
@@ -86,6 +86,8 @@ class TrashbinActivityIT : AbstractIT() {
sut.runOnUiThread { sut.loadFolder() }
shortSleep()
shortSleep()
waitForIdleSync()
screenshot(sut)
}
+30
View File
@@ -0,0 +1,30 @@
<!--
~ Nextcloud Android client application
~
~ @author Álvaro Brey Vilas
~ Copyright (C) 2022 Álvaro Brey Vilas
~ Copyright (C) 2022 Nextcloud GmbH
~
~ 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/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity
android:name=".ui.activity.AppScanActivity"
tools:node="remove" />
</application>
</manifest>
@@ -0,0 +1,42 @@
/*
*
* 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.ui.activity
import android.app.Activity
import com.owncloud.android.lib.common.utils.Log_OC
class AppScanActivity {
// stub
companion object {
private val TAG = AppScanActivity::class.simpleName
@JvmStatic
val enabled: Boolean = false
@JvmStatic
fun scanFromCamera(activity: Activity, requestcode: Int) {
// stub
Log_OC.w(TAG, "scanFromCamera called in stub implementation")
}
}
}
@@ -0,0 +1,81 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.activity
import android.Manifest
import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle
import com.owncloud.android.R
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.PermissionUtil
import com.zynksoftware.documentscanner.ScanActivity
import com.zynksoftware.documentscanner.model.DocumentScannerErrorModel
import com.zynksoftware.documentscanner.model.ScannerResults
import com.zynksoftware.documentscanner.ui.DocumentScanner
@Suppress("unused")
class AppScanActivity : ScanActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addFragmentContentLayout()
}
override fun onError(error: DocumentScannerErrorModel) {
DisplayUtils.showSnackMessage(this, R.string.error_starting_scan_doc)
}
override fun onSuccess(scannerResults: ScannerResults) {
val intent = Intent()
intent.putExtra(
"file",
scannerResults.transformedImageFile?.absolutePath ?: scannerResults.croppedImageFile?.absolutePath
)
setResult(Activity.RESULT_OK, intent)
finish()
}
override fun onClose() {
finish()
}
companion object {
@JvmStatic
val enabled: Boolean = true
@JvmStatic
fun scanFromCamera(activity: Activity, requestCode: Int) {
val configuration = DocumentScanner.Configuration()
configuration.imageType = Bitmap.CompressFormat.PNG
DocumentScanner.init(activity, configuration)
val scanIntent = Intent(activity, AppScanActivity::class.java)
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
activity.startActivityForResult(scanIntent, requestCode)
} else {
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_SCAN_DOCUMENT)
}
}
}
}
@@ -15,38 +15,32 @@
* 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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package com.owncloud.android.utils
package com.owncloud.android.utils;
import android.app.Activity
import android.util.Log
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import android.app.Activity;
import android.util.Log;
object GooglePlayUtils {
private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
private const val TAG = "GooglePlayUtils"
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
public final class GooglePlayUtils {
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private static final String TAG = "GooglePlayUtils";
private GooglePlayUtils() {
}
public static boolean checkPlayServices(Activity activity) {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
@JvmStatic
fun checkPlayServices(activity: Activity): Boolean {
val apiAvailability = GoogleApiAvailability.getInstance()
val resultCode = apiAvailability.isGooglePlayServicesAvailable(activity)
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)?.show()
} else {
Log.i(TAG, "This device is not supported.");
activity.finish();
Log.i(TAG, "This device is not supported.")
activity.finish()
}
return false;
return false
}
return true;
return true
}
}
}
@@ -1,32 +0,0 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2021 Nextcloud
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or 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 <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.activity
import android.view.View
/**
* Activity providing information about ways to participate in the app's development.
*/
class HuaweiCommunityActivity : CommunityActivity() {
override fun setupContent() {
super.setupContent()
binding.communityReleaseCandidatePlaystore.visibility = View.GONE
}
}
@@ -1,35 +1,38 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* 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
* 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 Affero General Public License for more details.
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* 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.activity
import android.Manifest
import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle
import com.owncloud.android.R
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.PermissionUtil
import com.zynksoftware.documentscanner.ScanActivity
import com.zynksoftware.documentscanner.model.DocumentScannerErrorModel
import com.zynksoftware.documentscanner.model.ScannerResults
import com.zynksoftware.documentscanner.ui.DocumentScanner
class AppScanActivity : ScanActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -56,4 +59,22 @@ class AppScanActivity : ScanActivity() {
override fun onClose() {
finish()
}
companion object {
@JvmStatic
val enabled: Boolean = true
@JvmStatic
fun scanFromCamera(activity: Activity, requestCode: Int) {
val configuration = DocumentScanner.Configuration()
configuration.imageType = Bitmap.CompressFormat.PNG
DocumentScanner.init(activity, configuration)
val scanIntent = Intent(activity, AppScanActivity::class.java)
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
activity.startActivityForResult(scanIntent, requestCode)
} else {
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_SCAN_DOCUMENT)
}
}
}
}
@@ -0,0 +1,33 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.activity
import android.view.View
/**
* Activity providing information about ways to participate in the app's development.
*/
class HuaweiCommunityActivity : CommunityActivity() {
override fun setupContent() {
super.setupContent()
binding.communityReleaseCandidatePlaystore.visibility = View.GONE
}
}
+8
View File
@@ -26,6 +26,12 @@
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<!-- Used for document scanning, but lib declares it as required, which it's not -->
<uses-feature
android:name="android.hardware.camera2"
android:required="false"
tools:node="replace" />
<!-- WRITE_EXTERNAL_STORAGE may be enabled or disabled by the user after installation in
API >= 23; the app needs to handle this -->
<uses-permission
@@ -35,6 +41,8 @@
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
@@ -0,0 +1,38 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.nextcloud.android.files
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.resources.files.model.FileLockType
object FileLockingHelper {
/**
* Checks whether the given `userId` can unlock the [OCFile].
*/
@JvmStatic
fun canUserUnlockFile(userId: String, file: OCFile): Boolean {
if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
return false
}
return file.lockOwnerId == userId
}
}
@@ -0,0 +1,78 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.nextcloud.android.files
import android.content.Context
import android.graphics.Typeface
import android.os.Build
import android.text.style.StyleSpan
import android.view.Menu
import android.view.MenuItem
import com.nextcloud.utils.TimeConstants
import com.owncloud.android.R
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.resources.files.model.FileLockType
import com.owncloud.android.utils.DisplayUtils
/**
* Customizes a Menu to show locking information
*/
class FileLockingMenuCustomization(val context: Context) {
fun customizeMenu(menu: Menu, file: OCFile) {
if (file.isLocked) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
menu.setGroupDividerEnabled(true)
}
menu.findItem(R.id.action_locked_by).title = getLockedByText(file)
showLockedUntil(menu, file)
}
}
private fun getLockedByText(file: OCFile): CharSequence {
val username = file.lockOwnerDisplayName ?: file.lockOwnerId
val resource = when (file.lockType) {
FileLockType.COLLABORATIVE -> R.string.locked_by_app
else -> R.string.locked_by
}
return DisplayUtils.createTextWithSpan(
context.getString(resource, username),
username,
StyleSpan(Typeface.BOLD)
)
}
private fun showLockedUntil(menu: Menu, file: OCFile) {
val lockedUntil: MenuItem = menu.findItem(R.id.action_locked_until)
if (file.lockTimestamp == 0L || file.lockTimeout == 0L) {
lockedUntil.isVisible = false
} else {
lockedUntil.title =
context.getString(R.string.lock_expiration_info, getExpirationRelativeText(file))
lockedUntil.isVisible = true
}
}
private fun getExpirationRelativeText(file: OCFile): CharSequence? {
val expirationTimestamp = (file.lockTimestamp + file.lockTimeout) * TimeConstants.MILLIS_PER_SECOND
return DisplayUtils.getRelativeTimestamp(context, expirationTimestamp, true)
}
}
@@ -0,0 +1,42 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.nextcloud.android.files
import android.content.Context
import android.view.ContextThemeWrapper
import android.view.View
import androidx.appcompat.widget.PopupMenu
import com.owncloud.android.R
/**
* This is a [PopupMenu] with grayed out disabled elements
*/
class ThemedPopupMenu(
context: Context,
anchor: View
) : PopupMenu(wrapContext(context), anchor) {
companion object {
private fun wrapContext(context: Context): Context =
ContextThemeWrapper(context, R.style.Nextcloud_Widget_PopupMenu)
}
}
@@ -30,6 +30,8 @@ import com.nextcloud.client.network.NetworkModule;
import com.nextcloud.client.onboarding.OnboardingModule;
import com.nextcloud.client.preferences.PreferencesModule;
import com.owncloud.android.MainApp;
import com.owncloud.android.media.MediaControlView;
import com.owncloud.android.ui.ThemeableSwitchPreference;
import javax.inject.Singleton;
@@ -47,13 +49,18 @@ import dagger.android.support.AndroidSupportInjectionModule;
OnboardingModule.class,
ViewModelModule.class,
JobsModule.class,
IntegrationsModule.class
IntegrationsModule.class,
ThemeModule.class
})
@Singleton
public interface AppComponent {
void inject(MainApp app);
void inject(MediaControlView mediaControlView);
void inject(ThemeableSwitchPreference switchPreference);
@Component.Builder
interface Builder {
@BindsInstance
@@ -64,6 +64,7 @@ import com.owncloud.android.ui.activities.data.activities.RemoteActivitiesReposi
import com.owncloud.android.ui.activities.data.files.FilesRepository;
import com.owncloud.android.ui.activities.data.files.FilesServiceApiImpl;
import com.owncloud.android.ui.activities.data.files.RemoteFilesRepository;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import org.greenrobot.eventbus.EventBus;
@@ -81,7 +82,7 @@ class AppModule {
@Provides
AccountManager accountManager(Application application) {
return (AccountManager)application.getSystemService(Context.ACCOUNT_SERVICE);
return (AccountManager) application.getSystemService(Context.ACCOUNT_SERVICE);
}
@Provides
@@ -108,7 +109,7 @@ class AppModule {
UserAccountManager userAccountManager(
Context context,
AccountManager accountManager
) {
) {
return new UserAccountManagerImpl(context, accountManager);
}
@@ -165,7 +166,7 @@ class AppModule {
@Singleton
Logger logger(Context context, Clock clock) {
File logDir = new File(context.getFilesDir(), "logs");
FileLogHandler handler = new FileLogHandler(logDir, "log.txt", 1024*1024);
FileLogHandler handler = new FileLogHandler(logDir, "log.txt", 1024 * 1024);
LoggerImpl logger = new LoggerImpl(clock, handler, new Handler(), 1000);
logger.start();
return logger;
@@ -174,7 +175,7 @@ class AppModule {
@Provides
@Singleton
LogsRepository logsRepository(Logger logger) {
return (LogsRepository)logger;
return (LogsRepository) logger;
}
@Provides
@@ -194,12 +195,12 @@ class AppModule {
@Provides
NotificationManager notificationManager(Context context) {
return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
@Provides
AudioManager audioManager(Context context) {
return (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
return (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}
@Provides
@@ -226,8 +227,13 @@ class AppModule {
@Provides
@Singleton
AppNotificationManager notificationsManager(Context context, NotificationManager platformNotificationsManager) {
return new AppNotificationManagerImpl(context, context.getResources(), platformNotificationsManager);
AppNotificationManager notificationsManager(Context context,
NotificationManager platformNotificationsManager,
ThemeColorUtils themeColorUtils) {
return new AppNotificationManagerImpl(context,
context.getResources(),
platformNotificationsManager,
themeColorUtils);
}
@Provides
@@ -24,11 +24,14 @@ import com.nextcloud.client.etm.EtmActivity;
import com.nextcloud.client.files.downloader.FileTransferService;
import com.nextcloud.client.jobs.NotificationWork;
import com.nextcloud.client.logger.ui.LogsActivity;
import com.nextcloud.client.logger.ui.LogsViewModel;
import com.nextcloud.client.media.PlayerService;
import com.nextcloud.client.migrations.Migrations;
import com.nextcloud.client.onboarding.FirstRunActivity;
import com.nextcloud.client.onboarding.WhatsNewActivity;
import com.nextcloud.ui.ChooseAccountDialogFragment;
import com.nextcloud.ui.SetStatusDialogFragment;
import com.owncloud.android.MainApp;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.authentication.DeepLinkLoginActivity;
import com.owncloud.android.files.BootupBroadcastReceiver;
@@ -50,6 +53,7 @@ import com.owncloud.android.ui.activity.CopyToClipboardActivity;
import com.owncloud.android.ui.activity.DrawerActivity;
import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
import com.owncloud.android.ui.activity.ExternalSiteWebView;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.FilePickerActivity;
import com.owncloud.android.ui.activity.FolderPickerActivity;
@@ -65,85 +69,187 @@ import com.owncloud.android.ui.activity.ShareActivity;
import com.owncloud.android.ui.activity.SsoGrantPermissionActivity;
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
import com.owncloud.android.ui.activity.TextEditorWebView;
import com.owncloud.android.ui.activity.ToolbarActivity;
import com.owncloud.android.ui.activity.UploadFilesActivity;
import com.owncloud.android.ui.activity.UploadListActivity;
import com.owncloud.android.ui.activity.UserInfoActivity;
import com.owncloud.android.ui.dialog.AccountRemovalConfirmationDialog;
import com.owncloud.android.ui.dialog.ChooseRichDocumentsTemplateDialogFragment;
import com.owncloud.android.ui.dialog.ChooseTemplateDialogFragment;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
import com.owncloud.android.ui.dialog.LoadingDialog;
import com.owncloud.android.ui.dialog.LocalStoragePathPickerDialogFragment;
import com.owncloud.android.ui.dialog.MultipleAccountsDialog;
import com.owncloud.android.ui.dialog.NoteDialogFragment;
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
import com.owncloud.android.ui.dialog.RenamePublicShareDialogFragment;
import com.owncloud.android.ui.dialog.SendShareDialog;
import com.owncloud.android.ui.dialog.SetupEncryptionDialogFragment;
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
import com.owncloud.android.ui.dialog.SortingOrderDialogFragment;
import com.owncloud.android.ui.dialog.StoragePermissionDialogFragment;
import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment;
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
import com.owncloud.android.ui.fragment.ExtendedListFragment;
import com.owncloud.android.ui.fragment.FeatureFragment;
import com.owncloud.android.ui.fragment.FileDetailActivitiesFragment;
import com.owncloud.android.ui.fragment.FileDetailFragment;
import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
import com.owncloud.android.ui.fragment.GalleryFragment;
import com.owncloud.android.ui.fragment.LocalFileListFragment;
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialogFragment;
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.fragment.SharedListFragment;
import com.owncloud.android.ui.fragment.UnifiedSearchFragment;
import com.owncloud.android.ui.fragment.contactsbackup.BackupFragment;
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment;
import com.owncloud.android.ui.preview.FileDownloadFragment;
import com.owncloud.android.ui.preview.PreviewImageActivity;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.ui.preview.pdf.PreviewPdfFragment;
import com.owncloud.android.ui.preview.PreviewTextFileFragment;
import com.owncloud.android.ui.preview.PreviewTextFragment;
import com.owncloud.android.ui.preview.PreviewTextStringFragment;
import com.owncloud.android.ui.preview.PreviewVideoActivity;
import com.owncloud.android.ui.preview.pdf.PreviewPdfFragment;
import com.owncloud.android.ui.trashbin.TrashbinActivity;
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
/**
* Register classes that require dependency injection. This class is used by Dagger compiler
* only.
* Register classes that require dependency injection. This class is used by Dagger compiler only.
*/
@Module
abstract class ComponentsModule {
@ContributesAndroidInjector abstract ActivitiesActivity activitiesActivity();
@ContributesAndroidInjector abstract AuthenticatorActivity authenticatorActivity();
@ContributesAndroidInjector abstract BaseActivity baseActivity();
@ContributesAndroidInjector abstract ConflictsResolveActivity conflictsResolveActivity();
@ContributesAndroidInjector abstract ContactsPreferenceActivity contactsPreferenceActivity();
@ContributesAndroidInjector abstract CopyToClipboardActivity copyToClipboardActivity();
@ContributesAndroidInjector abstract DeepLinkLoginActivity deepLinkLoginActivity();
@ContributesAndroidInjector abstract DrawerActivity drawerActivity();
@ContributesAndroidInjector abstract ErrorsWhileCopyingHandlerActivity errorsWhileCopyingHandlerActivity();
@ContributesAndroidInjector abstract ExternalSiteWebView externalSiteWebView();
@ContributesAndroidInjector abstract FileDisplayActivity fileDisplayActivity();
@ContributesAndroidInjector abstract FilePickerActivity filePickerActivity();
@ContributesAndroidInjector abstract FirstRunActivity firstRunActivity();
@ContributesAndroidInjector abstract FolderPickerActivity folderPickerActivity();
@ContributesAndroidInjector abstract LogsActivity logsActivity();
@ContributesAndroidInjector abstract ManageAccountsActivity manageAccountsActivity();
@ContributesAndroidInjector abstract ManageSpaceActivity manageSpaceActivity();
@ContributesAndroidInjector abstract NotificationsActivity notificationsActivity();
@ContributesAndroidInjector abstract CommunityActivity participateActivity();
@ContributesAndroidInjector abstract PassCodeActivity passCodeActivity();
@ContributesAndroidInjector abstract PreviewImageActivity previewImageActivity();
@ContributesAndroidInjector abstract PreviewVideoActivity previewVideoActivity();
@ContributesAndroidInjector abstract ReceiveExternalFilesActivity receiveExternalFilesActivity();
@ContributesAndroidInjector abstract RequestCredentialsActivity requestCredentialsActivity();
@ContributesAndroidInjector abstract SettingsActivity settingsActivity();
@ContributesAndroidInjector abstract ShareActivity shareActivity();
@ContributesAndroidInjector abstract SsoGrantPermissionActivity ssoGrantPermissionActivity();
@ContributesAndroidInjector abstract SyncedFoldersActivity syncedFoldersActivity();
@ContributesAndroidInjector abstract TrashbinActivity trashbinActivity();
@ContributesAndroidInjector abstract UploadFilesActivity uploadFilesActivity();
@ContributesAndroidInjector abstract UploadListActivity uploadListActivity();
@ContributesAndroidInjector abstract UserInfoActivity userInfoActivity();
@ContributesAndroidInjector abstract WhatsNewActivity whatsNewActivity();
@ContributesAndroidInjector abstract EtmActivity etmActivity();
@ContributesAndroidInjector
abstract ActivitiesActivity activitiesActivity();
@ContributesAndroidInjector abstract RichDocumentsEditorWebView richDocumentsWebView();
@ContributesAndroidInjector abstract TextEditorWebView textEditorWebView();
@ContributesAndroidInjector
abstract AuthenticatorActivity authenticatorActivity();
@ContributesAndroidInjector abstract ExtendedListFragment extendedListFragment();
@ContributesAndroidInjector abstract FileDetailFragment fileDetailFragment();
@ContributesAndroidInjector abstract LocalFileListFragment localFileListFragment();
@ContributesAndroidInjector abstract OCFileListFragment ocFileListFragment();
@ContributesAndroidInjector abstract FileDetailActivitiesFragment fileDetailActivitiesFragment();
@ContributesAndroidInjector
abstract BaseActivity baseActivity();
@ContributesAndroidInjector
abstract ConflictsResolveActivity conflictsResolveActivity();
@ContributesAndroidInjector
abstract ContactsPreferenceActivity contactsPreferenceActivity();
@ContributesAndroidInjector
abstract CopyToClipboardActivity copyToClipboardActivity();
@ContributesAndroidInjector
abstract DeepLinkLoginActivity deepLinkLoginActivity();
@ContributesAndroidInjector
abstract DrawerActivity drawerActivity();
@ContributesAndroidInjector
abstract ErrorsWhileCopyingHandlerActivity errorsWhileCopyingHandlerActivity();
@ContributesAndroidInjector
abstract ExternalSiteWebView externalSiteWebView();
@ContributesAndroidInjector
abstract FileDisplayActivity fileDisplayActivity();
@ContributesAndroidInjector
abstract FilePickerActivity filePickerActivity();
@ContributesAndroidInjector
abstract FirstRunActivity firstRunActivity();
@ContributesAndroidInjector
abstract FolderPickerActivity folderPickerActivity();
@ContributesAndroidInjector
abstract LogsActivity logsActivity();
@ContributesAndroidInjector
abstract ManageAccountsActivity manageAccountsActivity();
@ContributesAndroidInjector
abstract ManageSpaceActivity manageSpaceActivity();
@ContributesAndroidInjector
abstract NotificationsActivity notificationsActivity();
@ContributesAndroidInjector
abstract CommunityActivity participateActivity();
@ContributesAndroidInjector
abstract PassCodeActivity passCodeActivity();
@ContributesAndroidInjector
abstract PreviewImageActivity previewImageActivity();
@ContributesAndroidInjector
abstract PreviewVideoActivity previewVideoActivity();
@ContributesAndroidInjector
abstract ReceiveExternalFilesActivity receiveExternalFilesActivity();
@ContributesAndroidInjector
abstract RequestCredentialsActivity requestCredentialsActivity();
@ContributesAndroidInjector
abstract SettingsActivity settingsActivity();
@ContributesAndroidInjector
abstract ShareActivity shareActivity();
@ContributesAndroidInjector
abstract SsoGrantPermissionActivity ssoGrantPermissionActivity();
@ContributesAndroidInjector
abstract SyncedFoldersActivity syncedFoldersActivity();
@ContributesAndroidInjector
abstract TrashbinActivity trashbinActivity();
@ContributesAndroidInjector
abstract UploadFilesActivity uploadFilesActivity();
@ContributesAndroidInjector
abstract UploadListActivity uploadListActivity();
@ContributesAndroidInjector
abstract UserInfoActivity userInfoActivity();
@ContributesAndroidInjector
abstract WhatsNewActivity whatsNewActivity();
@ContributesAndroidInjector
abstract EtmActivity etmActivity();
@ContributesAndroidInjector
abstract RichDocumentsEditorWebView richDocumentsWebView();
@ContributesAndroidInjector
abstract TextEditorWebView textEditorWebView();
@ContributesAndroidInjector
abstract ExtendedListFragment extendedListFragment();
@ContributesAndroidInjector
abstract FileDetailFragment fileDetailFragment();
@ContributesAndroidInjector
abstract LocalFileListFragment localFileListFragment();
@ContributesAndroidInjector
abstract OCFileListFragment ocFileListFragment();
@ContributesAndroidInjector
abstract FileDetailActivitiesFragment fileDetailActivitiesFragment();
@ContributesAndroidInjector
abstract FileDetailSharingFragment fileDetailSharingFragment();
@@ -178,8 +284,11 @@ abstract class ComponentsModule {
@ContributesAndroidInjector
abstract SetStatusDialogFragment setStatusDialogFragment();
@ContributesAndroidInjector abstract PreviewTextFileFragment previewTextFileFragment();
@ContributesAndroidInjector abstract PreviewTextStringFragment previewTextStringFragment();
@ContributesAndroidInjector
abstract PreviewTextFileFragment previewTextFileFragment();
@ContributesAndroidInjector
abstract PreviewTextStringFragment previewTextStringFragment();
@ContributesAndroidInjector
abstract UnifiedSearchFragment searchFragment();
@@ -199,20 +308,126 @@ abstract class ComponentsModule {
@ContributesAndroidInjector
abstract FileDownloader fileDownloader();
@ContributesAndroidInjector abstract BootupBroadcastReceiver bootupBroadcastReceiver();
@ContributesAndroidInjector abstract NotificationWork.NotificationReceiver notificationWorkBroadcastReceiver();
@ContributesAndroidInjector
abstract BootupBroadcastReceiver bootupBroadcastReceiver();
@ContributesAndroidInjector abstract FileContentProvider fileContentProvider();
@ContributesAndroidInjector abstract UsersAndGroupsSearchProvider usersAndGroupsSearchProvider();
@ContributesAndroidInjector abstract DiskLruImageCacheFileProvider diskLruImageCacheFileProvider();
@ContributesAndroidInjector abstract DocumentsStorageProvider documentsStorageProvider();
@ContributesAndroidInjector abstract AccountManagerService accountManagerService();
@ContributesAndroidInjector abstract OperationsService operationsService();
@ContributesAndroidInjector abstract PlayerService playerService();
@ContributesAndroidInjector abstract FileTransferService fileDownloaderService();
@ContributesAndroidInjector abstract FileSyncService fileSyncService();
@ContributesAndroidInjector
abstract NotificationWork.NotificationReceiver notificationWorkBroadcastReceiver();
@ContributesAndroidInjector
abstract FileContentProvider fileContentProvider();
@ContributesAndroidInjector
abstract UsersAndGroupsSearchProvider usersAndGroupsSearchProvider();
@ContributesAndroidInjector
abstract DiskLruImageCacheFileProvider diskLruImageCacheFileProvider();
@ContributesAndroidInjector
abstract DocumentsStorageProvider documentsStorageProvider();
@ContributesAndroidInjector
abstract AccountManagerService accountManagerService();
@ContributesAndroidInjector
abstract OperationsService operationsService();
@ContributesAndroidInjector
abstract PlayerService playerService();
@ContributesAndroidInjector
abstract FileTransferService fileDownloaderService();
@ContributesAndroidInjector
abstract FileSyncService fileSyncService();
@ContributesAndroidInjector
abstract PreviewPdfFragment previewPDFFragment();
@ContributesAndroidInjector
abstract SharedListFragment sharedFragment();
@ContributesAndroidInjector
abstract FeatureFragment featureFragment();
@ContributesAndroidInjector
abstract IndeterminateProgressDialog indeterminateProgressDialog();
@ContributesAndroidInjector
abstract SortingOrderDialogFragment sortingOrderDialogFragment();
@ContributesAndroidInjector
abstract ConfirmationDialogFragment confirmationDialogFragment();
@ContributesAndroidInjector
abstract ConflictsResolveDialog conflictsResolveDialog();
@ContributesAndroidInjector
abstract CreateFolderDialogFragment createFolderDialogFragment();
@ContributesAndroidInjector
abstract ExpirationDatePickerDialogFragment expirationDatePickerDialogFragment();
@ContributesAndroidInjector
abstract FileActivity fileActivity();
@ContributesAndroidInjector
abstract FileDownloadFragment fileDownloadFragment();
@ContributesAndroidInjector
abstract LoadingDialog loadingDialog();
@ContributesAndroidInjector
abstract LocalStoragePathPickerDialogFragment localStoragePathPickerDialogFragment();
@ContributesAndroidInjector
abstract LogsViewModel logsViewModel();
@ContributesAndroidInjector
abstract MainApp mainApp();
@ContributesAndroidInjector
abstract Migrations migrations();
@ContributesAndroidInjector
abstract NoteDialogFragment noteDialogFragment();
@ContributesAndroidInjector
abstract NotificationWork notificationWork();
@ContributesAndroidInjector
abstract OCFileListBottomSheetDialog ocFileListBottomSheetDialog();
@ContributesAndroidInjector
abstract RemoveFilesDialogFragment removeFilesDialogFragment();
@ContributesAndroidInjector
abstract RenamePublicShareDialogFragment renamePublicShareDialogFragment();
@ContributesAndroidInjector
abstract SendShareDialog sendShareDialog();
@ContributesAndroidInjector
abstract SetupEncryptionDialogFragment setupEncryptionDialogFragment();
@ContributesAndroidInjector
abstract SharePasswordDialogFragment sharePasswordDialogFragment();
@ContributesAndroidInjector
abstract SyncedFolderPreferencesDialogFragment syncedFolderPreferencesDialogFragment();
@ContributesAndroidInjector
abstract ToolbarActivity toolbarActivity();
@ContributesAndroidInjector
abstract StoragePermissionDialogFragment storagePermissionDialogFragment();
@ContributesAndroidInjector
abstract OCFileListBottomSheetDialogFragment ocfileListBottomSheetDialogFragment();
@ContributesAndroidInjector
abstract RenameFileDialogFragment renameFileDialogFragment();
@ContributesAndroidInjector
abstract SyncFileNotEnoughSpaceDialogFragment syncFileNotEnoughSpaceDialogFragment();
}
@@ -0,0 +1,131 @@
/*
* 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 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.nextcloud.client.di
import android.content.Context
import javax.inject.Singleton
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.ThemeFabUtils
import com.owncloud.android.utils.theme.ThemeLayoutUtils
import com.owncloud.android.utils.theme.ThemeTextInputUtils
import com.owncloud.android.utils.theme.ThemeToolbarUtils
import com.owncloud.android.utils.theme.ThemeMenuUtils
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
import com.owncloud.android.utils.theme.ThemeTextUtils
import com.owncloud.android.utils.theme.ThemeButtonUtils
import com.owncloud.android.utils.theme.ThemeBarUtils
import com.owncloud.android.utils.theme.ThemeCheckableUtils
import com.owncloud.android.utils.theme.ThemeAvatarUtils
import com.owncloud.android.utils.theme.ThemeUtils
import dagger.Module
import dagger.Provides
@Module
internal class ThemeModule {
@Provides
@Singleton
fun themeColorUtils(): ThemeColorUtils {
return ThemeColorUtils()
}
@Provides
@Singleton
fun themeFabUtils(themeColorUtils: ThemeColorUtils?, themeDrawableUtils: ThemeDrawableUtils?): ThemeFabUtils {
return ThemeFabUtils(themeColorUtils, themeDrawableUtils)
}
@Provides
@Singleton
fun themeLayoutUtils(themeColorUtils: ThemeColorUtils?): ThemeLayoutUtils {
return ThemeLayoutUtils(themeColorUtils)
}
@Provides
@Singleton
fun themeToolbarUtils(
themeColorUtils: ThemeColorUtils?,
themeDrawableUtils: ThemeDrawableUtils?,
themeTextInputUtils: ThemeTextInputUtils?
): ThemeToolbarUtils {
return ThemeToolbarUtils(themeColorUtils, themeDrawableUtils, themeTextInputUtils)
}
@Provides
@Singleton
fun themeDrawableUtils(context: Context?): ThemeDrawableUtils {
return ThemeDrawableUtils(context)
}
@Provides
@Singleton
fun themeUtils(): ThemeUtils {
return ThemeUtils()
}
@Provides
@Singleton
fun themeMenuUtils(): ThemeMenuUtils {
return ThemeMenuUtils()
}
@Provides
@Singleton
fun themeSnackbarUtils(): ThemeSnackbarUtils {
return ThemeSnackbarUtils()
}
@Provides
@Singleton
fun themeTextUtils(): ThemeTextUtils {
return ThemeTextUtils()
}
@Provides
@Singleton
fun themeButtonUtils(): ThemeButtonUtils {
return ThemeButtonUtils()
}
@Provides
@Singleton
fun themeBarUtils(): ThemeBarUtils {
return ThemeBarUtils()
}
@Provides
@Singleton
fun themeTextInputUtils(): ThemeTextInputUtils {
return ThemeTextInputUtils()
}
@Provides
@Singleton
fun themeCheckableUtils(): ThemeCheckableUtils {
return ThemeCheckableUtils()
}
@Provides
@Singleton
fun themeAvatarUtils(): ThemeAvatarUtils {
return ThemeAvatarUtils()
}
}
@@ -58,7 +58,6 @@ import com.owncloud.android.utils.FileStorageUtils
import com.owncloud.android.utils.PushUtils
import org.greenrobot.eventbus.EventBus
import java.io.File
import java.util.ArrayList
/**
* Removes account and all local files
@@ -150,6 +149,9 @@ class AccountRemovalWork(
deleteAppPasswordRemoteOperation.execute(optionNextcloudClient.get())
}
// delete cached OwncloudClient
OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(user.toOwnCloudAccount())
if (userRemoved) {
eventBus.post(AccountRemovedEvent())
}
@@ -40,6 +40,9 @@ import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.datamodel.ArbitraryDataProvider
import com.owncloud.android.datamodel.SyncedFolderProvider
import com.owncloud.android.datamodel.UploadsStorageManager
import com.owncloud.android.utils.theme.ThemeButtonUtils
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
import javax.inject.Provider
@@ -63,7 +66,10 @@ class BackgroundJobFactory @Inject constructor(
private val connectivityService: ConnectivityService,
private val notificationManager: NotificationManager,
private val eventBus: EventBus,
private val deckApi: DeckApi
private val deckApi: DeckApi,
private val themeColorUtils: ThemeColorUtils,
private val themeSnackbarUtils: ThemeSnackbarUtils,
private val themeButtonUtils: ThemeButtonUtils
) : WorkerFactory() {
@SuppressLint("NewApi")
@@ -192,7 +198,10 @@ class BackgroundJobFactory @Inject constructor(
contentResolver,
accountManager,
preferences,
clock
clock,
themeColorUtils,
themeSnackbarUtils,
themeButtonUtils
)
}
@@ -202,7 +211,8 @@ class BackgroundJobFactory @Inject constructor(
params,
notificationManager,
accountManager,
deckApi
deckApi,
themeColorUtils
)
}
@@ -55,8 +55,9 @@ import com.owncloud.android.ui.activity.ManageAccountsActivity.PENDING_FOR_REMOV
import com.owncloud.android.ui.activity.SyncedFoldersActivity
import com.owncloud.android.ui.notifications.NotificationUtils
import com.owncloud.android.utils.SyncedFolderUtils
import com.owncloud.android.utils.theme.ThemeButtonUtils
import com.owncloud.android.utils.theme.ThemeColorUtils
import java.util.ArrayList
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
import java.util.Random
@Suppress("LongParameterList") // dependencies injection
@@ -67,7 +68,10 @@ class MediaFoldersDetectionWork constructor(
private val contentResolver: ContentResolver,
private val userAccountManager: UserAccountManager,
private val preferences: AppPreferences,
private val clock: Clock
private val clock: Clock,
private val themeColorUtils: ThemeColorUtils,
private val themeSnackbarUtils: ThemeSnackbarUtils,
private val themeButtonUtils: ThemeButtonUtils
) : Worker(context, params) {
companion object {
@@ -88,8 +92,20 @@ class MediaFoldersDetectionWork constructor(
val syncedFolderProvider = SyncedFolderProvider(contentResolver, preferences, clock)
val gson = Gson()
val mediaFoldersModel: MediaFoldersModel
val imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true)
val videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true)
val imageMediaFolders = MediaProvider.getImageFolders(
contentResolver,
1,
null,
true,
themeSnackbarUtils
)
val videoMediaFolders = MediaProvider.getVideoFolders(
contentResolver,
1,
null,
true,
themeSnackbarUtils
)
val imageMediaFolderPaths: MutableList<String> = ArrayList()
val videoMediaFolderPaths: MutableList<String> = ArrayList()
for (imageMediaFolder in imageMediaFolders) {
@@ -206,7 +222,7 @@ class MediaFoldersDetectionWork constructor(
)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
.setColor(ThemeColorUtils.primaryColor(context))
.setColor(themeColorUtils.primaryColor(context))
.setSubText(user.accountName)
.setContentTitle(contentTitle)
.setContentText(subtitle)
@@ -70,12 +70,14 @@ import java.security.SecureRandom
import javax.crypto.Cipher
import javax.inject.Inject
@Suppress("LongParameterList")
class NotificationWork constructor(
private val context: Context,
params: WorkerParameters,
private val notificationManager: NotificationManager,
private val accountManager: UserAccountManager,
private val deckApi: DeckApi
private val deckApi: DeckApi,
private val themeColorUtils: ThemeColorUtils
) : Worker(context, params) {
companion object {
@@ -167,7 +169,7 @@ class NotificationWork constructor(
val notificationBuilder = NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_PUSH)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
.setColor(ThemeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
.setColor(themeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
.setShowWhen(true)
.setSubText(user.accountName)
.setContentTitle(notification.getSubject())
@@ -222,7 +224,7 @@ class NotificationWork constructor(
NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_PUSH)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
.setColor(ThemeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
.setColor(themeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
.setShowWhen(true)
.setSubText(user.accountName)
.setContentTitle(context.getString(R.string.new_notification))
@@ -34,13 +34,14 @@ import com.owncloud.android.R
import com.owncloud.android.databinding.LogsActivityBinding
import com.owncloud.android.ui.activity.ToolbarActivity
import com.owncloud.android.utils.theme.ThemeBarUtils
import com.owncloud.android.utils.theme.ThemeToolbarUtils
import javax.inject.Inject
class LogsActivity : ToolbarActivity() {
@Inject
protected lateinit var viewModelFactory: ViewModelFactory
@Inject
protected lateinit var themeBarUtils: ThemeBarUtils
private lateinit var vm: LogsViewModel
private lateinit var binding: LogsActivityBinding
private lateinit var logsAdapter: LogsAdapter
@@ -65,7 +66,7 @@ class LogsActivity : ToolbarActivity() {
}
findViewById<ProgressBar>(R.id.logs_loading_progress).apply {
ThemeBarUtils.themeProgressBar(context, this)
themeBarUtils.themeProgressBar(context, this, themeColorUtils)
}
logsAdapter = LogsAdapter(this)
@@ -79,9 +80,9 @@ class LogsActivity : ToolbarActivity() {
setupToolbar()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.apply { ThemeToolbarUtils.setColoredTitle(this, getString(R.string.logs_title), baseContext) }
supportActionBar?.apply { themeToolbarUtils.setColoredTitle(this, getString(R.string.logs_title), baseContext) }
ThemeToolbarUtils.tintBackButton(supportActionBar, baseContext)
themeToolbarUtils.tintBackButton(supportActionBar, baseContext)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@@ -89,7 +90,7 @@ class LogsActivity : ToolbarActivity() {
(menu.findItem(R.id.action_search).actionView as SearchView).apply {
setOnQueryTextListener(searchBoxListener)
ThemeToolbarUtils.themeSearchView(this, context)
themeToolbarUtils.themeSearchView(this, context)
}
return super.onCreateOptionsMenu(menu)
}
@@ -89,6 +89,9 @@ class PlayerService : Service() {
@Inject
protected lateinit var clientFactory: ClientFactory
@Inject
protected lateinit var themeColorUtils: ThemeColorUtils
private lateinit var player: Player
private lateinit var notificationBuilder: NotificationCompat.Builder
private var isRunning = false
@@ -98,7 +101,7 @@ class PlayerService : Service() {
AndroidInjection.inject(this)
player = Player(applicationContext, clientFactory, playerListener, audioManager)
notificationBuilder = NotificationCompat.Builder(this)
notificationBuilder.color = ThemeColorUtils.primaryColor(this)
notificationBuilder.color = themeColorUtils.primaryColor(this)
val stop = Intent(this, PlayerService::class.java)
stop.action = ACTION_STOP
@@ -31,6 +31,7 @@ import com.nextcloud.java.util.Optional
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.lib.resources.status.OCCapability
import com.owncloud.android.ui.activity.BaseActivity
import com.owncloud.android.utils.theme.CapabilityUtils
/**
* Session mixin collects all account / user handling logic currently
@@ -53,8 +54,10 @@ class SessionMixin constructor(
private set
var storageManager: FileDataStorageManager? = null
private set
var capabilities: OCCapability? = null
private set
val capabilities: OCCapability?
get() = getUser()
.map { CapabilityUtils.getCapability(it, activity) }
.orElse(null)
fun setAccount(account: Account?) {
val validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name)
@@ -67,7 +70,6 @@ class SessionMixin constructor(
currentAccount?.let {
val storageManager = FileDataStorageManager(getUser().get(), contentResolver)
this.storageManager = storageManager
this.capabilities = storageManager.getCapability(it.name)
}
}
@@ -22,7 +22,8 @@ import javax.inject.Inject
class AppNotificationManagerImpl @Inject constructor(
private val context: Context,
private val resources: Resources,
private val platformNotificationsManager: NotificationManager
private val platformNotificationsManager: NotificationManager,
private val themeColorUtils: ThemeColorUtils
) : AppNotificationManager {
companion object {
@@ -31,7 +32,7 @@ class AppNotificationManagerImpl @Inject constructor(
}
private fun builder(channelId: String): NotificationCompat.Builder {
val color = ThemeColorUtils.primaryColor(context, true)
val color = themeColorUtils.primaryColor(context, true)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationCompat.Builder(context, channelId).setColor(color)
} else {
@@ -56,6 +56,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
@Inject AppPreferences preferences;
@Inject AppInfo appInfo;
@Inject OnboardingService onboarding;
@Inject ThemeButtonUtils themeButtonUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -85,7 +86,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
mPager.addOnPageChangeListener(this);
mForwardFinishButton = findViewById(R.id.forward);
ThemeButtonUtils.colorImageButton(mForwardFinishButton, fontColor);
themeButtonUtils.colorImageButton(mForwardFinishButton, fontColor);
mForwardFinishButton.setOnClickListener(view -> {
if (mProgress.hasNextStep()) {
@@ -373,4 +373,8 @@ public interface AppPreferences {
void setPdfZoomTipShownCount(int count);
int getPdfZoomTipShownCount();
boolean isStoragePermissionRequested();
void setStoragePermissionRequested(boolean value);
}
@@ -97,6 +97,8 @@ public final class AppPreferencesImpl implements AppPreferences {
private static final String PREF__PDF_ZOOM_TIP_SHOWN = "pdf_zoom_tip_shown";
private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested";
private final Context context;
private final SharedPreferences preferences;
private final CurrentAccountProvider currentAccountProvider;
@@ -696,6 +698,16 @@ public final class AppPreferencesImpl implements AppPreferences {
return preferences.getInt(PREF__PDF_ZOOM_TIP_SHOWN, 0);
}
@Override
public boolean isStoragePermissionRequested() {
return preferences.getBoolean(PREF__STORAGE_PERMISSION_REQUESTED, false);
}
@Override
public void setStoragePermissionRequested(boolean value) {
preferences.edit().putBoolean(PREF__STORAGE_PERMISSION_REQUESTED, value).apply();
}
@VisibleForTesting
public int computeBruteForceDelay(int count) {
return (int) Math.min(count / 3d, 10);
@@ -0,0 +1,42 @@
/*
* Nextcloud Android Library is available under MIT license
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.nextcloud.client.utils
import org.apache.commons.codec.binary.Hex
import java.security.MessageDigest
object HashUtil {
private const val ALGORITHM_MD5 = "MD5"
@JvmStatic
fun md5Hash(input: String): String {
val digest = MessageDigest.getInstance(ALGORITHM_MD5)
.digest(input.toByteArray())
return String(Hex.encodeHex(digest))
}
}
@@ -50,7 +50,6 @@ import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import java.util.ArrayList
import javax.inject.Inject
private const val ARG_CURRENT_USER_PARAM = "currentUser"
@@ -73,6 +72,12 @@ class ChooseAccountDialogFragment :
@Inject
lateinit var clientFactory: ClientFactory
@Inject
lateinit var themeColorUtils: ThemeColorUtils
@Inject
lateinit var themeDrawableUtils: ThemeDrawableUtils
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
@@ -112,9 +117,9 @@ class ChooseAccountDialogFragment :
binding.currentAccount.account.text = user.accountName
// Defining user right indicator
val icon = ThemeDrawableUtils.tintDrawable(
val icon = themeDrawableUtils.tintDrawable(
ContextCompat.getDrawable(requireContext(), R.drawable.ic_check_circle),
ThemeColorUtils.primaryColor(requireContext(), true)
themeColorUtils.primaryColor(requireContext(), true)
)
binding.currentAccount.accountMenu.setImageDrawable(icon)
@@ -125,7 +130,9 @@ class ChooseAccountDialogFragment :
getAccountListItems(),
this,
false,
false
false,
themeColorUtils,
themeDrawableUtils
)
binding.accountsList.adapter = adapter
@@ -59,7 +59,6 @@ import com.owncloud.android.utils.theme.ThemeTextInputUtils
import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.EmojiPopup
import com.vanniktech.emoji.google.GoogleEmojiProvider
import java.util.ArrayList
import java.util.Calendar
import java.util.Locale
import javax.inject.Inject
@@ -82,6 +81,9 @@ private const val LAST_HOUR_OF_DAY = 23
private const val LAST_MINUTE_OF_HOUR = 59
private const val LAST_SECOND_OF_MINUTE = 59
private const val CLEAR_AT_TYPE_PERIOD = "period"
private const val CLEAR_AT_TYPE_END_OF = "end-of"
class SetStatusDialogFragment :
DialogFragment(),
PredefinedStatusClickListener,
@@ -107,6 +109,15 @@ class SetStatusDialogFragment :
@Inject
lateinit var clientFactory: ClientFactory
@Inject
lateinit var themeColorUtils: ThemeColorUtils
@Inject
lateinit var themeButtonUtils: ThemeButtonUtils
@Inject
lateinit var themeTextInputUtils: ThemeTextInputUtils
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
@@ -139,26 +150,7 @@ class SetStatusDialogFragment :
accountManager = (activity as BaseActivity).userAccountManager
currentStatus?.let {
binding.emoji.setText(it.icon)
binding.customStatusInput.text?.clear()
binding.customStatusInput.setText(it.message)
visualizeStatus(it.status)
if (it.clearAt > 0) {
binding.clearStatusAfterSpinner.visibility = View.GONE
binding.remainingClearTime.apply {
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message)
visibility = View.VISIBLE
text = DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true)
.toString()
.decapitalize(Locale.getDefault())
setOnClickListener {
visibility = View.GONE
binding.clearStatusAfterSpinner.visibility = View.VISIBLE
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message_after)
}
}
}
updateCurrentStatusViews(it)
}
adapter = PredefinedStatusListAdapter(this, requireContext())
@@ -175,7 +167,7 @@ class SetStatusDialogFragment :
binding.clearStatus.setOnClickListener { clearStatus() }
binding.setStatus.setOnClickListener { setStatusMessage() }
binding.emoji.setOnClickListener { openEmojiPopup() }
binding.emoji.setOnClickListener { popup.show() }
popup = EmojiPopup.Builder
.fromRootView(view)
@@ -212,92 +204,93 @@ class SetStatusDialogFragment :
}
}
binding.clearStatus.setTextColor(ThemeColorUtils.primaryColor(context, true))
ThemeButtonUtils.colorPrimaryButton(binding.setStatus, context)
ThemeTextInputUtils.colorTextInput(
binding.clearStatus.setTextColor(themeColorUtils.primaryColor(context, true))
themeButtonUtils.colorPrimaryButton(binding.setStatus, context, themeColorUtils)
themeTextInputUtils.colorTextInput(
binding.customStatusInputContainer,
binding.customStatusInput,
ThemeColorUtils.primaryColor(activity)
themeColorUtils.primaryColor(activity)
)
}
@Suppress("ComplexMethod")
private fun setClearStatusAfterValue(item: Int) {
when (item) {
POS_DONT_CLEAR -> {
// don't clear
clearAt = null
}
private fun updateCurrentStatusViews(it: Status) {
binding.emoji.setText(it.icon)
binding.customStatusInput.text?.clear()
binding.customStatusInput.setText(it.message)
visualizeStatus(it.status)
if (it.clearAt > 0) {
binding.clearStatusAfterSpinner.visibility = View.GONE
binding.remainingClearTime.apply {
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message)
visibility = View.VISIBLE
text = DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true)
.toString()
.replaceFirstChar { it.lowercase(Locale.getDefault()) }
setOnClickListener {
visibility = View.GONE
binding.clearStatusAfterSpinner.visibility = View.VISIBLE
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message_after)
}
}
}
}
private fun setClearStatusAfterValue(item: Int) {
clearAt = when (item) {
POS_DONT_CLEAR -> null // don't clear
POS_HALF_AN_HOUR -> {
// 30 minutes
clearAt = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + THIRTY_MINUTES * ONE_MINUTE_IN_SECONDS
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + THIRTY_MINUTES * ONE_MINUTE_IN_SECONDS
}
POS_AN_HOUR -> {
// one hour
clearAt =
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
}
POS_FOUR_HOURS -> {
// four hours
clearAt =
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
+FOUR_HOURS * ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS +
FOUR_HOURS * ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
}
POS_TODAY -> {
// today
val date = Calendar.getInstance().apply {
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
}
clearAt = date.timeInMillis / ONE_SECOND_IN_MILLIS
val date = getLastSecondOfToday()
dateToSeconds(date)
}
POS_END_OF_WEEK -> {
// end of week
val date = Calendar.getInstance().apply {
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
}
val date = getLastSecondOfToday()
while (date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
date.add(Calendar.DAY_OF_YEAR, 1)
}
clearAt = date.timeInMillis / ONE_SECOND_IN_MILLIS
dateToSeconds(date)
}
else -> clearAt
}
}
@Suppress("ReturnCount")
private fun clearAtToUnixTime(clearAt: ClearAt?): Long {
if (clearAt != null) {
if (clearAt.type.equals("period")) {
return System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + clearAt.time.toLong()
} else if (clearAt.type.equals("end-of")) {
if (clearAt.time.equals("day")) {
val date = Calendar.getInstance().apply {
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
}
return date.timeInMillis / ONE_SECOND_IN_MILLIS
}
}
private fun clearAtToUnixTime(clearAt: ClearAt?): Long = when {
clearAt?.type == CLEAR_AT_TYPE_PERIOD -> {
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + clearAt.time.toLong()
}
return -1
clearAt?.type == CLEAR_AT_TYPE_END_OF && clearAt.time == "day" -> {
val date = getLastSecondOfToday()
dateToSeconds(date)
}
else -> -1
}
private fun openEmojiPopup() {
popup.show()
private fun getLastSecondOfToday(): Calendar {
val date = Calendar.getInstance().apply {
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
}
return date
}
private fun dateToSeconds(date: Calendar) = date.timeInMillis / ONE_SECOND_IN_MILLIS
private fun clearStatus() {
asyncRunner.postQuickTask(
ClearStatusTask(accountManager.currentOwnCloudAccount?.savedAccount, context),
@@ -327,19 +320,19 @@ class SetStatusDialogFragment :
when (statusType) {
StatusType.ONLINE -> {
clearTopStatus()
binding.onlineStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
binding.onlineStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
StatusType.AWAY -> {
clearTopStatus()
binding.awayStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
binding.awayStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
StatusType.DND -> {
clearTopStatus()
binding.dndStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
binding.dndStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
StatusType.INVISIBLE -> {
clearTopStatus()
binding.invisibleStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
binding.invisibleStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
}
else -> clearTopStatus()
}
@@ -417,28 +410,35 @@ class SetStatusDialogFragment :
binding.clearStatusAfterSpinner.visibility = View.VISIBLE
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message_after)
if (predefinedStatus.clearAt == null) {
val clearAt = predefinedStatus.clearAt
if (clearAt == null) {
binding.clearStatusAfterSpinner.setSelection(0)
} else {
val clearAt = predefinedStatus.clearAt!!
if (clearAt.type.equals("period")) {
when (clearAt.time) {
"1800" -> binding.clearStatusAfterSpinner.setSelection(POS_HALF_AN_HOUR)
"3600" -> binding.clearStatusAfterSpinner.setSelection(POS_AN_HOUR)
"14400" -> binding.clearStatusAfterSpinner.setSelection(POS_FOUR_HOURS)
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
}
} else if (clearAt.type.equals("end-of")) {
when (clearAt.time) {
"day" -> binding.clearStatusAfterSpinner.setSelection(POS_TODAY)
"week" -> binding.clearStatusAfterSpinner.setSelection(POS_END_OF_WEEK)
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
}
when (clearAt.type) {
CLEAR_AT_TYPE_PERIOD -> updateClearAtViewsForPeriod(clearAt)
CLEAR_AT_TYPE_END_OF -> updateClearAtViewsForEndOf(clearAt)
}
}
setClearStatusAfterValue(binding.clearStatusAfterSpinner.selectedItemPosition)
}
private fun updateClearAtViewsForPeriod(clearAt: ClearAt) {
when (clearAt.time) {
"1800" -> binding.clearStatusAfterSpinner.setSelection(POS_HALF_AN_HOUR)
"3600" -> binding.clearStatusAfterSpinner.setSelection(POS_AN_HOUR)
"14400" -> binding.clearStatusAfterSpinner.setSelection(POS_FOUR_HOURS)
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
}
}
private fun updateClearAtViewsForEndOf(clearAt: ClearAt) {
when (clearAt.time) {
"day" -> binding.clearStatusAfterSpinner.setSelection(POS_TODAY)
"week" -> binding.clearStatusAfterSpinner.setSelection(POS_END_OF_WEEK)
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
}
}
@VisibleForTesting
fun setPredefinedStatus(predefinedStatus: ArrayList<PredefinedStatus>) {
adapter.list = predefinedStatus
@@ -0,0 +1,26 @@
/*
* Nextcloud Android client application
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* 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.nextcloud.utils
object TimeConstants {
const val MILLIS_PER_SECOND = 1000
}
@@ -0,0 +1,61 @@
/*
* Nextcloud Android Library is available under MIT license
*
* @author Álvaro Brey Vilas
* Copyright (C) 2022 Álvaro Brey Vilas
* Copyright (C) 2022 Nextcloud GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.nextcloud.utils.view
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.appbar.AppBarLayout
import me.zhanghai.android.fastscroll.FastScroller
import me.zhanghai.android.fastscroll.FastScrollerBuilder
object FastScroll {
@JvmStatic
@JvmOverloads
fun applyFastScroll(recyclerView: RecyclerView, viewHelper: FastScroller.ViewHelper? = null) {
val builder = FastScrollerBuilder(recyclerView).useMd2Style()
if (viewHelper != null) {
builder.setViewHelper(viewHelper)
}
builder.build()
}
@JvmStatic
fun fixAppBarForFastScroll(appBarLayout: AppBarLayout, content: ViewGroup) {
val contentLayoutInitialPaddingBottom = content.paddingBottom
appBarLayout.addOnOffsetChangedListener(
AppBarLayout.OnOffsetChangedListener { _, offset ->
content.setPadding(
content.paddingLeft,
content.paddingTop,
content.paddingRight,
contentLayoutInitialPaddingBottom + appBarLayout.totalScrollRange + offset
)
}
)
}
}
@@ -45,6 +45,7 @@ import com.nextcloud.client.appinfo.AppInfo;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.di.ActivityInjector;
import com.nextcloud.client.di.AppComponent;
import com.nextcloud.client.di.DaggerAppComponent;
import com.nextcloud.client.errorhandling.ExceptionHandler;
import com.nextcloud.client.jobs.BackgroundJobManager;
@@ -77,6 +78,7 @@ import com.owncloud.android.utils.FilesSyncHelper;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.ReceiversHelper;
import com.owncloud.android.utils.SecurityUtils;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
import org.conscrypt.Conscrypt;
import org.greenrobot.eventbus.EventBus;
@@ -172,9 +174,13 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@Inject
PassCodeManager passCodeManager;
@Inject ThemeSnackbarUtils themeSnackbarUtils;
@SuppressWarnings("unused")
private boolean mBound;
private static AppComponent appComponent;
/**
* Temporary hack
*/
@@ -223,16 +229,13 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
super.attachBaseContext(base);
initGlobalContext(this);
DaggerAppComponent.builder()
.application(this)
.build()
.inject(this);
initDagger();
// we don't want to handle crashes occurring inside crash reporter activity/process;
// let the platform deal with those
final boolean isCrashReportingProcess = getAppProcessName().endsWith(":crash");
if (!isCrashReportingProcess) {
if (!isCrashReportingProcess && !appInfo.isDebugBuild()) {
Thread.UncaughtExceptionHandler defaultPlatformHandler = Thread.getDefaultUncaughtExceptionHandler();
final ExceptionHandler crashReporter = new ExceptionHandler(this,
defaultPlatformHandler);
@@ -240,6 +243,29 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
}
}
private void initDagger() {
appComponent = DaggerAppComponent.builder()
.application(this)
.build();
appComponent.inject(this);
}
/**
* <b>USE SPARINGLY!</b> This should only be used for injection of Theme classes in custom Views, and they need to
* be added as methods in the {@link AppComponent} itself.
* <p>
* Once we adopt Hilt this won't be necessary either, as View is a supported target in Hilt.
*
* @return the {@link AppComponent} for this app
*/
public static AppComponent getAppComponent() {
if (appComponent == null) {
throw new IllegalStateException("Dagger not initialized!");
}
return appComponent;
}
@SuppressFBWarnings("ST")
@Override
public void onCreate() {
@@ -290,7 +316,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
connectivityService,
powerManagementService,
backgroundJobManager,
clock);
clock,
themeSnackbarUtils);
initContactsBackup(accountManager, backgroundJobManager);
notificationChannels();
@@ -448,7 +475,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
final ConnectivityService connectivityService,
final PowerManagementService powerManagementService,
final BackgroundJobManager backgroundJobManager,
final Clock clock
final Clock clock,
final ThemeSnackbarUtils themeSnackbarUtils
) {
updateToAutoUpload();
cleanOldEntries(clock);
@@ -456,7 +484,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
if (getAppContext() != null) {
if (PermissionUtil.checkExternalStoragePermission(getAppContext())) {
splitOutAutoUploadEntries(clock);
splitOutAutoUploadEntries(clock, themeSnackbarUtils);
} else {
preferences.setAutoUploadSplitEntriesEnabled(true);
}
@@ -678,7 +706,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
}
}
private static void splitOutAutoUploadEntries(Clock clock) {
private static void splitOutAutoUploadEntries(Clock clock,
ThemeSnackbarUtils themeSnackbarUtils) {
Context context = getAppContext();
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
if (!preferences.isAutoUploadSplitEntriesEnabled()) {
@@ -689,8 +718,16 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences, clock);
final List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true);
final List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true);
final List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver,
1,
null,
true,
themeSnackbarUtils);
final List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver,
1,
null,
true,
themeSnackbarUtils);
ArrayList<Long> idsToDelete = new ArrayList<>();
List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
@@ -143,6 +143,8 @@ import de.cotech.hw.fido2.WebViewWebauthnBridge;
import de.cotech.hw.fido2.ui.WebauthnDialogOptions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import static com.owncloud.android.utils.PermissionUtil.PERMISSIONS_CAMERA;
/**
* This Activity is used to add an ownCloud account to the App
*/
@@ -231,6 +233,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
@Inject OnboardingService onboarding;
@Inject DeviceInfo deviceInfo;
@Inject PassCodeManager passCodeManager;
@Inject ThemeToolbarUtils themeToolbarUtils;
@Inject ThemeDrawableUtils themeDrawableUtils;
private boolean onlyAdd = false;
@SuppressLint("ResourceAsColor") @ColorInt
private int primaryColor = R.color.primary;
@@ -434,7 +439,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
accountSetupWebviewBinding.loginWebviewProgressBar.setVisibility(View.GONE);
accountSetupWebviewBinding.loginWebview.setVisibility(View.VISIBLE);
ThemeToolbarUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor);
themeToolbarUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor);
getWindow().setNavigationBarColor(primaryColor);
}
@@ -524,7 +529,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
if (deviceInfo.hasCamera(this)) {
accountSetupBinding.scanQr.setOnClickListener(v -> onScan());
ThemeDrawableUtils.tintDrawable(accountSetupBinding.scanQr.getDrawable(),
themeDrawableUtils.tintDrawable(accountSetupBinding.scanQr.getDrawable(),
getResources().getColor(R.color.login_text_color));
} else {
accountSetupBinding.scanQr.setVisibility(View.GONE);
@@ -1298,7 +1303,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
if (PermissionUtil.checkSelfPermission(this, Manifest.permission.CAMERA)) {
startQRScanner();
} else {
PermissionUtil.requestCameraPermission(this);
PermissionUtil.requestCameraPermission(this, PERMISSIONS_CAMERA);
}
}
@@ -5,10 +5,16 @@ import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.nextcloud.client.di.Injectable;
import com.owncloud.android.R;
import com.owncloud.android.utils.theme.ThemeColorUtils;
public class DeepLinkLoginActivity extends AuthenticatorActivity {
import javax.inject.Inject;
public class DeepLinkLoginActivity extends AuthenticatorActivity implements Injectable {
@Inject
public ThemeColorUtils themeColorUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -29,7 +35,7 @@ public class DeepLinkLoginActivity extends AuthenticatorActivity {
LoginUrlInfo loginUrlInfo = parseLoginDataUrl(prefix, data.toString());
TextView loginText = findViewById(R.id.loginInfo);
loginText.setTextColor(ThemeColorUtils.fontColor(this));
loginText.setTextColor(themeColorUtils.fontColor(this));
loginText.setText(String.format("Login with %1$s to %2$s", loginUrlInfo.username,
loginUrlInfo.serverAddress));
} catch (IllegalArgumentException e) {
@@ -45,6 +45,7 @@ import com.owncloud.android.lib.common.network.WebdavEntry;
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.FileLockType;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
@@ -70,6 +71,7 @@ import java.util.Set;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
public class FileDataStorageManager {
@@ -83,9 +85,9 @@ public class FileDataStorageManager {
public static final int ROOT_PARENT_ID = 0;
public static final String NULL_STRING = "null";
private ContentResolver contentResolver;
private ContentProviderClient contentProviderClient;
private User user;
private final ContentResolver contentResolver;
private final ContentProviderClient contentProviderClient;
private final User user;
public FileDataStorageManager(User user, ContentResolver contentResolver) {
this.contentProviderClient = null;
@@ -208,44 +210,10 @@ public class FileDataStorageManager {
public boolean saveFile(OCFile ocFile) {
boolean overridden = false;
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, ocFile.getModificationTimestamp());
cv.put(
ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
ocFile.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, ocFile.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, ocFile.getFileLength());
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, ocFile.getMimeType());
cv.put(ProviderTableMeta.FILE_NAME, ocFile.getFileName());
cv.put(ProviderTableMeta.FILE_ENCRYPTED_NAME, ocFile.getEncryptedFileName());
cv.put(ProviderTableMeta.FILE_PARENT, ocFile.getParentId());
cv.put(ProviderTableMeta.FILE_PATH, ocFile.getRemotePath());
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, ocFile.getDecryptedRemotePath());
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, ocFile.isEncrypted());
if (!ocFile.isFolder()) {
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, ocFile.getStoragePath());
final ContentValues cv = createContentValuesForFile(ocFile);
if (ocFile.isFolder()) {
cv.remove(ProviderTableMeta.FILE_STORAGE_PATH);
}
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, ocFile.getLastSyncDateForProperties());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, ocFile.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_ETAG, ocFile.getEtag());
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, ocFile.getEtagOnServer());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, ocFile.isSharedViaLink() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, ocFile.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, ocFile.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, ocFile.getRemoteId());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, ocFile.isUpdateThumbnailNeeded());
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, ocFile.isDownloading());
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, ocFile.getEtagInConflict());
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, ocFile.getUnreadCommentsCount());
cv.put(ProviderTableMeta.FILE_OWNER_ID, ocFile.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, ocFile.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, ocFile.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(ocFile.getSharees()));
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, ocFile.getRichWorkspace());
cv.put(ProviderTableMeta.FILE_HAS_PREVIEW, ocFile.isPreviewAvailable() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_FAVORITE, ocFile.isFavorite());
boolean sameRemotePath = fileExists(ocFile.getRemotePath());
if (sameRemotePath ||
@@ -369,7 +337,8 @@ public class FileDataStorageManager {
// prepare operations to insert or update files to save in the given folder
for (OCFile ocFile : updatedFiles) {
ContentValues contentValues = createContentValueForFile(ocFile, folder);
ContentValues contentValues = createContentValuesForFile(ocFile);
contentValues.put(ProviderTableMeta.FILE_PARENT, folder.getFileId());
if (fileExists(ocFile.getFileId()) || fileExists(ocFile.getRemotePath())) {
long fileId;
@@ -423,7 +392,7 @@ public class FileDataStorageManager {
}
// update metadata of folder
ContentValues contentValues = createContentValueForFile(folder);
ContentValues contentValues = createContentValuesForFolder(folder);
operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI)
.withValues(contentValues)
@@ -467,76 +436,76 @@ public class FileDataStorageManager {
}
}
private ContentValues createContentValueForFile(OCFile folder) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, folder.getModificationTimestamp());
cv.put(
ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
folder.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, folder.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, 0);
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, folder.getMimeType());
cv.put(ProviderTableMeta.FILE_NAME, folder.getFileName());
cv.put(ProviderTableMeta.FILE_PARENT, folder.getParentId());
cv.put(ProviderTableMeta.FILE_PATH, folder.getRemotePath());
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, folder.getDecryptedRemotePath());
/**
* Returns a {@link ContentValues} filled with values that are common to both files and folders
* @see #createContentValuesForFile(OCFile)
* @see #createContentValuesForFolder(OCFile)
*/
private ContentValues createContentValuesBase(OCFile fileOrFolder) {
final ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, fileOrFolder.getModificationTimestamp());
cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, fileOrFolder.getModificationTimestampAtLastSyncForData());
cv.put(ProviderTableMeta.FILE_PARENT, fileOrFolder.getParentId());
cv.put(ProviderTableMeta.FILE_CREATION, fileOrFolder.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, fileOrFolder.getMimeType());
cv.put(ProviderTableMeta.FILE_NAME, fileOrFolder.getFileName());
cv.put(ProviderTableMeta.FILE_PATH, fileOrFolder.getRemotePath());
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, fileOrFolder.getDecryptedRemotePath());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, folder.getEtagOnServer());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, folder.isSharedViaLink() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, folder.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.isFavorite());
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, folder.isEncrypted());
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, folder.getUnreadCommentsCount());
cv.put(ProviderTableMeta.FILE_OWNER_ID, folder.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, folder.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, folder.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(folder.getSharees()));
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, folder.getRichWorkspace());
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, fileOrFolder.isEncrypted());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, fileOrFolder.getLastSyncDateForProperties());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, fileOrFolder.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_ETAG, fileOrFolder.getEtag());
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, fileOrFolder.getEtagOnServer());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, fileOrFolder.isSharedViaLink() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
cv.put(ProviderTableMeta.FILE_FAVORITE, fileOrFolder.isFavorite());
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, fileOrFolder.getUnreadCommentsCount());
cv.put(ProviderTableMeta.FILE_OWNER_ID, fileOrFolder.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, fileOrFolder.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, fileOrFolder.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(fileOrFolder.getSharees()));
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, fileOrFolder.getRichWorkspace());
return cv;
}
private ContentValues createContentValueForFile(OCFile file, OCFile folder) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, file.getModificationTimestampAtLastSyncForData());
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
/**
* Returns a {@link ContentValues} filled with values for a folder
* @see #createContentValuesForFile(OCFile)
* @see #createContentValuesBase(OCFile)
*/
private ContentValues createContentValuesForFolder(OCFile folder) {
final ContentValues cv = createContentValuesBase(folder);
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, 0);
return cv;
}
/**
* Returns a {@link ContentValues} filled with values for a file
* @see #createContentValuesForFolder(OCFile)
* @see #createContentValuesBase(OCFile)
*/
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
private ContentValues createContentValuesForFile(OCFile file) {
final ContentValues cv = createContentValuesBase(file);
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimeType());
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
cv.put(ProviderTableMeta.FILE_ENCRYPTED_NAME, file.getEncryptedFileName());
cv.put(ProviderTableMeta.FILE_PARENT, folder.getFileId());
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, file.getDecryptedRemotePath());
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, file.isEncrypted());
cv.put(ProviderTableMeta.FILE_MOUNT_TYPE, file.getMountType().ordinal());
cv.put(ProviderTableMeta.FILE_HAS_PREVIEW, file.isPreviewAvailable() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, file.getUnreadCommentsCount());
cv.put(ProviderTableMeta.FILE_OWNER_ID, file.getOwnerId());
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, file.getOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_NOTE, file.getNote());
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(file.getSharees()));
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, file.getRichWorkspace());
cv.put(ProviderTableMeta.FILE_LOCKED, file.isLocked());
final FileLockType lockType = file.getLockType();
cv.put(ProviderTableMeta.FILE_LOCK_TYPE, lockType != null ? lockType.getValue() : -1);
cv.put(ProviderTableMeta.FILE_LOCK_OWNER, file.getLockOwnerId());
cv.put(ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME, file.getLockOwnerDisplayName());
cv.put(ProviderTableMeta.FILE_LOCK_OWNER_EDITOR, file.getLockOwnerEditor());
cv.put(ProviderTableMeta.FILE_LOCK_TIMESTAMP, file.getLockTimestamp());
cv.put(ProviderTableMeta.FILE_LOCK_TIMEOUT, file.getLockTimeout());
cv.put(ProviderTableMeta.FILE_LOCK_TOKEN, file.getLockToken());
return cv;
}
@@ -1030,6 +999,16 @@ public class FileDataStorageManager {
ocFile.setOwnerDisplayName(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME)));
ocFile.setNote(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_NOTE)));
ocFile.setRichWorkspace(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_RICH_WORKSPACE)));
ocFile.setLocked(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCKED)) == 1);
final int lockTypeInt = cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TYPE));
ocFile.setLockType(lockTypeInt != -1 ? FileLockType.fromValue(lockTypeInt) : null);
ocFile.setLockOwnerId(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_OWNER)));
ocFile.setLockOwnerDisplayName(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME)));
ocFile.setLockOwnerEditor(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_OWNER_EDITOR)));
ocFile.setLockTimestamp(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TIMESTAMP)));
ocFile.setLockTimeout(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TIMEOUT)));
ocFile.setLockToken(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TOKEN)));
String sharees = cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_SHAREES));
@@ -1192,12 +1171,12 @@ public class FileDataStorageManager {
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
if (!ShareType.PUBLIC_LINK.equals(type)) {
if (ShareType.PUBLIC_LINK != type) {
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?";
}
String[] selectionArgs;
if (ShareType.PUBLIC_LINK.equals(type)) {
if (ShareType.PUBLIC_LINK == type) {
selectionArgs = new String[]{
path,
Integer.toString(type.getValue()),
@@ -1424,86 +1403,6 @@ public class FileDataStorageManager {
}
}
public void updateSharedFiles(Collection<OCFile> sharedFiles) {
resetShareFlagsInAllFiles();
if (sharedFiles != null) {
ArrayList<ContentProviderOperation> operations = new ArrayList<>(sharedFiles.size());
// prepare operations to insert or update files to save in the given folder
for (OCFile file : sharedFiles) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
cv.put(
ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
file.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimeType());
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
if (!file.isFolder()) {
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
}
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
cv.put(
ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
file.getLastSyncDateForData()
);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
boolean existsByPath = fileExists(file.getRemotePath());
if (existsByPath || fileExists(file.getFileId())) {
// updating an existing file
operations.add(
ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
withValues(cv).
withSelection(ProviderTableMeta._ID + "=?",
new String[]{String.valueOf(file.getFileId())})
.build());
} else {
// adding a new file
operations.add(
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI).
withValues(cv).
build()
);
}
}
// apply operations in batch
if (operations.size() > 0) {
@SuppressWarnings("unused")
ContentProviderResult[] results = null;
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
try {
if (getContentResolver() != null) {
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
} else {
results = getContentProviderClient().applyBatch(operations);
}
} catch (OperationApplicationException | RemoteException e) {
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e);
}
}
}
}
public void removeShare(OCShare share) {
Uri contentUriShare = ProviderTableMeta.CONTENT_URI_SHARE;
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
@@ -2075,6 +1974,8 @@ public class FileDataStorageManager {
contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS, capability.getUserStatus().getValue());
contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI,
capability.getUserStatusSupportsEmoji().getValue());
contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION,
capability.getFilesLockingVersion());
return contentValues;
}
@@ -2224,6 +2125,8 @@ public class FileDataStorageManager {
capability.setUserStatus(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS));
capability.setUserStatusSupportsEmoji(
getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI));
capability.setFilesLockingVersion(
getString(cursor, ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION));
}
return capability;
}
@@ -2258,22 +2161,6 @@ public class FileDataStorageManager {
}
}
public void saveVirtual(VirtualFolderType type, OCFile file) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.VIRTUAL_TYPE, type.toString());
cv.put(ProviderTableMeta.VIRTUAL_OCFILE_ID, file.getFileId());
if (getContentResolver() != null) {
getContentResolver().insert(ProviderTableMeta.CONTENT_URI_VIRTUAL, cv);
} else {
try {
getContentProviderClient().insert(ProviderTableMeta.CONTENT_URI_VIRTUAL, cv);
} catch (RemoteException e) {
Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e);
}
}
}
public List<OCFile> getAllGalleryItems() {
return getGalleryItems(0, Long.MAX_VALUE);
}
@@ -0,0 +1,25 @@
/*
*
* 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.datamodel
data class GalleryItems(val date: Long, val files: List<OCFile>)
@@ -21,17 +21,16 @@
package com.owncloud.android.datamodel;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;
import com.google.android.material.snackbar.Snackbar;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
import java.io.File;
@@ -42,6 +41,8 @@ import java.util.Map;
import javax.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
* Media queries to gain access to media lists for the device.
*/
@@ -71,10 +72,13 @@ public final class MediaProvider {
* @param itemLimit the number of media items (usually images) to be returned per media folder.
* @return list with media folders
*/
public static List<MediaFolder> getImageFolders(ContentResolver contentResolver, int itemLimit,
@Nullable final Activity activity, boolean getWithoutActivity) {
public static List<MediaFolder> getImageFolders(ContentResolver contentResolver,
int itemLimit,
@Nullable final AppCompatActivity activity,
boolean getWithoutActivity,
ThemeSnackbarUtils themeSnackbarUtils) {
// check permissions
checkPermissions(activity);
checkPermissions(activity, themeSnackbarUtils);
// query media/image folders
Cursor cursorFolders = null;
@@ -171,31 +175,21 @@ public final class MediaProvider {
return filePath != null && filePath.lastIndexOf('/') > 0 && new File(filePath).exists();
}
private static void checkPermissions(@Nullable Activity activity) {
private static void checkPermissions(@Nullable AppCompatActivity activity,
ThemeSnackbarUtils themeSnackbarUtils) {
if (activity != null &&
!PermissionUtil.checkExternalStoragePermission(activity.getApplicationContext())) {
// Check if we should show an explanation
if (PermissionUtil
.shouldShowRequestPermissionRationale(activity, PermissionUtil.getExternalStoragePermission())) {
// Show explanation to the user and then request permission
Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.ListLayout),
R.string.permission_storage_access, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.common_ok, v -> PermissionUtil.requestExternalStoragePermission(activity));
ThemeSnackbarUtils.colorSnackbar(activity.getApplicationContext(), snackbar);
snackbar.show();
} else {
// No explanation needed, request the permission.
PermissionUtil.requestExternalStoragePermission(activity);
}
PermissionUtil.requestExternalStoragePermission(activity, themeSnackbarUtils, true);
}
}
public static List<MediaFolder> getVideoFolders(ContentResolver contentResolver, int itemLimit,
@Nullable final Activity activity, boolean getWithoutActivity) {
public static List<MediaFolder> getVideoFolders(ContentResolver contentResolver,
int itemLimit,
@Nullable final AppCompatActivity activity,
boolean getWithoutActivity,
ThemeSnackbarUtils themeSnackbarUtils) {
// check permissions
checkPermissions(activity);
checkPermissions(activity, themeSnackbarUtils);
// query media/image folders
Cursor cursorFolders = null;
@@ -33,6 +33,7 @@ import com.owncloud.android.R;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.model.FileLockType;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import com.owncloud.android.lib.resources.shares.ShareeUser;
import com.owncloud.android.utils.MimeType;
@@ -68,6 +69,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
* synchronization of THE CONTENTS of this file.
*/
private long modificationTimestampAtLastSyncForData;
private long firstShareTimestamp; // UNIX timestamp of the first share time
private String remotePath;
private String decryptedRemotePath;
private String localPath;
@@ -94,10 +96,23 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
String note;
private List<ShareeUser> sharees;
private String richWorkspace;
private boolean locked;
@Nullable
private FileLockType lockType;
@Nullable
private String lockOwnerId;
@Nullable
private String lockOwnerDisplayName;
@Nullable
private String lockOwnerEditor;
private long lockTimestamp;
private long lockTimeout;
@Nullable
private String lockToken;
/**
* URI to the local path of the file contents, if stored in the device; cached after first call
* to {@link #getStorageUri()}
* URI to the local path of the file contents, if stored in the device; cached after first call to {@link
* #getStorageUri()}
*/
private Uri localUri;
@@ -160,6 +175,15 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
mountType = (WebdavEntry.MountType) source.readSerializable();
richWorkspace = source.readString();
previewAvailable = source.readInt() == 1;
firstShareTimestamp = source.readLong();
locked = source.readInt() == 1;
lockType = FileLockType.fromValue(source.readInt());
lockOwnerId = source.readString();
lockOwnerDisplayName = source.readString();
lockOwnerEditor = source.readString();
lockTimestamp = source.readLong();
lockTimeout = source.readLong();
lockToken = source.readString();
}
@Override
@@ -193,6 +217,15 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
dest.writeSerializable(mountType);
dest.writeString(richWorkspace);
dest.writeInt(previewAvailable ? 1 : 0);
dest.writeLong(firstShareTimestamp);
dest.writeInt(locked ? 1 : 0);
dest.writeInt(lockType != null ? lockType.getValue() : -1);
dest.writeString(lockOwnerId);
dest.writeString(lockOwnerDisplayName);
dest.writeString(lockOwnerEditor);
dest.writeLong(lockTimestamp);
dest.writeLong(lockTimeout);
dest.writeString(lockToken);
}
public void setDecryptedRemotePath(String path) {
@@ -455,6 +488,15 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
encrypted = false;
mountType = WebdavEntry.MountType.INTERNAL;
richWorkspace = "";
firstShareTimestamp = 0;
locked = false;
lockType = null;
lockOwnerId = null;
lockOwnerDisplayName = null;
lockOwnerEditor = null;
lockTimestamp = 0;
lockTimeout = 0;
lockToken = null;
}
/**
@@ -819,4 +861,81 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
public void setRichWorkspace(String richWorkspace) {
this.richWorkspace = richWorkspace;
}
public long getFirstShareTimestamp() {
return firstShareTimestamp;
}
public void setFirstShareTimestamp(long firstShareTimestamp) {
this.firstShareTimestamp = firstShareTimestamp;
}
public boolean isLocked() {
return locked;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
@Nullable
public FileLockType getLockType() {
return lockType;
}
public void setLockType(@Nullable FileLockType lockType) {
this.lockType = lockType;
}
@Nullable
public String getLockOwnerId() {
return lockOwnerId;
}
public void setLockOwnerId(@Nullable String lockOwnerId) {
this.lockOwnerId = lockOwnerId;
}
@Nullable
public String getLockOwnerDisplayName() {
return lockOwnerDisplayName;
}
public void setLockOwnerDisplayName(@Nullable String lockOwnerDisplayName) {
this.lockOwnerDisplayName = lockOwnerDisplayName;
}
@Nullable
public String getLockOwnerEditor() {
return lockOwnerEditor;
}
public void setLockOwnerEditor(@Nullable String lockOwnerEditor) {
this.lockOwnerEditor = lockOwnerEditor;
}
public long getLockTimestamp() {
return lockTimestamp;
}
public void setLockTimestamp(long lockTimestamp) {
this.lockTimestamp = lockTimestamp;
}
public long getLockTimeout() {
return lockTimeout;
}
public void setLockTimeout(long lockTimeout) {
this.lockTimeout = lockTimeout;
}
@Nullable
public String getLockToken() {
return lockToken;
}
public void setLockToken(@Nullable String lockToken) {
this.lockToken = lockToken;
}
}
@@ -65,6 +65,8 @@ import com.owncloud.android.utils.BitmapUtils;
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
@@ -251,14 +253,14 @@ public final class ThumbnailsCacheManager {
}
public static class ResizedImageGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private FileFragment fileFragment;
private FileDataStorageManager storageManager;
private User user;
private WeakReference<ImageView> imageViewReference;
private WeakReference<FrameLayout> frameLayoutReference;
private final FileFragment fileFragment;
private final FileDataStorageManager storageManager;
private final User user;
private final WeakReference<ImageView> imageViewReference;
private final WeakReference<FrameLayout> frameLayoutReference;
private OCFile file;
private ConnectivityService connectivityService;
private int backgroundColor;
private final ConnectivityService connectivityService;
private final int backgroundColor;
public ResizedImageGenerationTask(FileFragment fileFragment,
@@ -416,8 +418,8 @@ public final class ThumbnailsCacheManager {
}
public static class ThumbnailGenerationTaskObject {
private Object file;
private String imageKey;
private final Object file;
private final String imageKey;
public ThumbnailGenerationTaskObject(Object file, String imageKey) {
this.file = file;
@@ -462,19 +464,27 @@ public final class ThumbnailsCacheManager {
mAsyncTasks = asyncTasks;
}
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
User user, List<ThumbnailGenerationTask> asyncTasks,
boolean gridViewEnabled)
public ThumbnailGenerationTask(ImageView imageView,
FileDataStorageManager storageManager,
User user,
List<ThumbnailGenerationTask> asyncTasks,
boolean gridViewEnabled,
String imageKey)
throws IllegalArgumentException {
this(imageView, storageManager, user, asyncTasks);
this.gridViewEnabled = gridViewEnabled;
mImageKey = imageKey;
}
public GetMethod getGetMethod() {
return getMethod;
}
public ThumbnailGenerationTask(FileDataStorageManager storageManager, User user){
public String getImageKey() {
return mImageKey;
}
public ThumbnailGenerationTask(FileDataStorageManager storageManager, User user) {
if (storageManager == null) {
throw new IllegalArgumentException("storageManager must not be NULL");
}
@@ -730,15 +740,23 @@ public final class ThumbnailsCacheManager {
private static final int IMAGE_KEY_PARAMS_LENGTH = 2;
private enum Type {IMAGE, VIDEO}
private final WeakReference<ImageView> mImageViewReference;
private File mFile;
private String mImageKey;
private Context mContext;
private final Context mContext;
private final ThemeColorUtils themeColorUtils;
private final ThemeDrawableUtils themeDrawableUtils;
public MediaThumbnailGenerationTask(ImageView imageView, Context context) {
public MediaThumbnailGenerationTask(ImageView imageView,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<>(imageView);
mContext = context;
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
}
@Override
@@ -785,13 +803,18 @@ public final class ThumbnailsCacheManager {
} else {
if (mFile != null) {
if (mFile.isDirectory()) {
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(mContext));
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(mContext,
themeColorUtils,
themeDrawableUtils));
} else {
if (MimeTypeUtil.isVideo(mFile)) {
imageView.setImageBitmap(ThumbnailsCacheManager.mDefaultVideo);
} else {
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(null, mFile.getName(),
mContext));
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(null,
mFile.getName(),
mContext,
themeColorUtils,
themeDrawableUtils));
}
}
}
@@ -814,7 +837,7 @@ public final class ThumbnailsCacheManager {
// Not found in disk cache
if (thumbnail == null) {
if (Type.IMAGE.equals(type)) {
if (Type.IMAGE == type) {
int px = getThumbnailDimension();
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getAbsolutePath(), px, px);
@@ -822,7 +845,7 @@ public final class ThumbnailsCacheManager {
if (bitmap != null) {
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), px, px);
}
} else if (Type.VIDEO.equals(type)) {
} else if (Type.VIDEO == type) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try {
retriever.setDataSource(file.getAbsolutePath());
@@ -862,11 +885,11 @@ public final class ThumbnailsCacheManager {
private final Object mCallContext;
private final Resources mResources;
private final float mAvatarRadius;
private User user;
private String mUserId;
private String displayName;
private String mServerName;
private Context mContext;
private final User user;
private final String mUserId;
private final String displayName;
private final String mServerName;
private final Context mContext;
public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener,
@@ -35,7 +35,7 @@ import java.util.List;
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 62;
public static final int DB_VERSION = 63;
private ProviderMeta() {
// No instance
@@ -117,6 +117,14 @@ public class ProviderMeta {
public static final String FILE_NOTE = "note";
public static final String FILE_SHAREES = "sharees";
public static final String FILE_RICH_WORKSPACE = "rich_workspace";
public static final String FILE_LOCKED = "locked";
public static final String FILE_LOCK_TYPE = "lock_type";
public static final String FILE_LOCK_OWNER = "lock_owner";
public static final String FILE_LOCK_OWNER_DISPLAY_NAME = "lock_owner_display_name";
public static final String FILE_LOCK_OWNER_EDITOR = "lock_owner_editor";
public static final String FILE_LOCK_TIMESTAMP = "lock_timestamp";
public static final String FILE_LOCK_TIMEOUT = "lock_timeout";
public static final String FILE_LOCK_TOKEN = "lock_token";
public static final List<String> FILE_ALL_COLUMNS = Collections.unmodifiableList(Arrays.asList(
_ID,
@@ -153,8 +161,15 @@ public class ProviderMeta {
FILE_OWNER_DISPLAY_NAME,
FILE_NOTE,
FILE_SHAREES,
FILE_RICH_WORKSPACE));
FILE_RICH_WORKSPACE,
FILE_LOCKED,
FILE_LOCK_TYPE,
FILE_LOCK_OWNER,
FILE_LOCK_OWNER_DISPLAY_NAME,
FILE_LOCK_OWNER_EDITOR,
FILE_LOCK_TIMESTAMP,
FILE_LOCK_TIMEOUT,
FILE_LOCK_TOKEN));
public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc";
// Columns of ocshares table
@@ -210,6 +225,7 @@ public class ProviderMeta {
public static final String CAPABILITIES_FILES_BIGFILECHUNKING = "files_bigfilechunking";
public static final String CAPABILITIES_FILES_UNDELETE = "files_undelete";
public static final String CAPABILITIES_FILES_VERSIONING = "files_versioning";
public static final String CAPABILITIES_FILES_LOCKING_VERSION = "files_locking_version";
public static final String CAPABILITIES_EXTERNAL_LINKS = "external_links";
public static final String CAPABILITIES_SERVER_NAME = "server_name";
public static final String CAPABILITIES_SERVER_COLOR = "server_color";
@@ -36,6 +36,9 @@ import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
import javax.inject.Inject;
@@ -57,12 +60,13 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
@Inject PowerManagementService powerManagementService;
@Inject BackgroundJobManager backgroundJobManager;
@Inject Clock clock;
@Inject ThemeSnackbarUtils themeSnackbarUtils;
/**
* Receives broadcast intent reporting that the system was just boot up.
**
* @param context The context where the receiver is running.
* @param intent The intent received.
* Receives broadcast intent reporting that the system was just boot up. *
*
* @param context The context where the receiver is running.
* @param intent The intent received.
*/
@Override
public void onReceive(Context context, Intent intent) {
@@ -75,7 +79,8 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
connectivityService,
powerManagementService,
backgroundJobManager,
clock);
clock,
themeSnackbarUtils);
MainApp.initContactsBackup(accountManager, backgroundJobManager);
} else {
Log_OC.d(TAG, "Getting wrong intent: " + intent.getAction());
@@ -21,12 +21,14 @@
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;
@@ -58,12 +60,13 @@ public class FileMenuFilter {
private static final int SINGLE_SELECT_ITEMS = 1;
public static final String SEND_OFF = "off";
private int numberOfAllFiles;
private Collection<OCFile> files;
private ComponentsGetter componentsGetter;
private Context context;
private boolean overflowMenu;
private User user;
private final int numberOfAllFiles;
private final Collection<OCFile> files;
private final ComponentsGetter componentsGetter;
private final Context context;
private final boolean overflowMenu;
private final User user;
private final String userId;
/**
* Constructor
@@ -88,6 +91,10 @@ public class FileMenuFilter {
this.context = context;
this.overflowMenu = overflowMenu;
this.user = user;
userId = AccountManager
.get(context)
.getUserData(this.user.toPlatformAccount(),
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
}
/**
@@ -125,11 +132,23 @@ public class FileMenuFilter {
filter(toShow, toHide, inSingleFileFragment);
for (int i : toShow) {
showMenuItem(menu.findItem(i));
final MenuItem item = menu.findItem(i);
if (item != null) {
showMenuItem(item);
} else {
// group
menu.setGroupVisible(i, true);
}
}
for (int i : toHide) {
hideMenuItem(menu.findItem(i));
final MenuItem item = menu.findItem(i);
if (item != null) {
hideMenuItem(item);
} else {
// group
menu.setGroupVisible(i, false);
}
}
}
}
@@ -181,11 +200,13 @@ public class FileMenuFilter {
boolean synchronizing = anyFileSynchronizing();
OCCapability capability = componentsGetter.getStorageManager().getCapability(user.getAccountName());
boolean endToEndEncryptionEnabled = capability.getEndToEndEncryption().isTrue();
boolean fileLockingEnabled = capability.getFilesLockingVersion() != null;
filterEdit(toShow, toHide, capability);
filterDownload(toShow, toHide, synchronizing);
filterRename(toShow, toHide, synchronizing);
filterMoveCopy(toShow, toHide, synchronizing);
filterCopy(toShow, toHide, synchronizing);
filterMove(toShow, toHide, synchronizing);
filterRemove(toShow, toHide, synchronizing);
filterSelectAll(toShow, toHide, inSingleFileFragment);
filterDeselectAll(toShow, toHide, inSingleFileFragment);
@@ -201,6 +222,9 @@ public class FileMenuFilter {
filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
filterSetPictureAs(toShow, toHide);
filterStream(toShow, toHide);
filterLock(toShow, toHide, fileLockingEnabled);
filterUnlock(toShow, toHide, fileLockingEnabled);
filterLockInfo(toShow, toHide, fileLockingEnabled);
}
private void filterShareFile(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
@@ -252,9 +276,48 @@ public class FileMenuFilter {
}
}
private void filterLock(List<Integer> toShow, List<Integer> toHide, boolean fileLockingEnabled) {
if (files.isEmpty() || !isSingleSelection() || !fileLockingEnabled) {
toHide.add(R.id.action_lock_file);
} else {
OCFile file = files.iterator().next();
if (file.isLocked() || file.isFolder()) {
toHide.add(R.id.action_lock_file);
} else {
toShow.add(R.id.action_lock_file);
}
}
}
private void filterUnlock(List<Integer> toShow, List<Integer> toHide, boolean fileLockingEnabled) {
if (files.isEmpty() || !isSingleSelection() || !fileLockingEnabled) {
toHide.add(R.id.action_unlock_file);
} else {
OCFile file = files.iterator().next();
if (FileLockingHelper.canUserUnlockFile(userId, file)) {
toShow.add(R.id.action_unlock_file);
} else {
toHide.add(R.id.action_unlock_file);
}
}
}
private void filterLockInfo(List<Integer> toShow, List<Integer> toHide, boolean fileLockingEnabled) {
if (files.isEmpty() || !isSingleSelection() || !fileLockingEnabled) {
toHide.add(R.id.menu_group_lock_info);
} else {
OCFile file = files.iterator().next();
if (file.isLocked()) {
toShow.add(R.id.menu_group_lock_info);
} else {
toHide.add(R.id.menu_group_lock_info);
}
}
}
private void filterEncrypt(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) {
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || isEncryptedFolder()
|| !endToEndEncryptionEnabled) {
|| !endToEndEncryptionEnabled) {
toHide.add(R.id.action_encrypted);
} else {
toShow.add(R.id.action_encrypted);
@@ -391,25 +454,32 @@ public class FileMenuFilter {
}
private void filterRemove(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
if (files.isEmpty() || synchronizing || containsEncryptedFolder()) {
if (files.isEmpty() || synchronizing || containsEncryptedFolder() || containsLockedFile()) {
toHide.add(R.id.action_remove_file);
} else {
toShow.add(R.id.action_remove_file);
}
}
private void filterMoveCopy(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
private void filterMove(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
toHide.add(R.id.action_move);
toHide.add(R.id.action_copy);
} else {
toShow.add(R.id.action_move);
}
}
private void filterCopy(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
toHide.add(R.id.action_copy);
} else {
toShow.add(R.id.action_copy);
}
}
private void filterRename(Collection<Integer> toShow, Collection<Integer> toHide, boolean synchronizing) {
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
toHide.add(R.id.action_rename_file);
} else {
toShow.add(R.id.action_rename_file);
@@ -528,6 +598,15 @@ public class FileMenuFilter {
return false;
}
private boolean containsLockedFile() {
for (OCFile file : files) {
if (file.isLocked()) {
return true;
}
}
return false;
}
private boolean containsEncryptedFolder() {
for (OCFile file : files) {
if (file.isFolder() && file.isEncrypted()) {
@@ -125,6 +125,7 @@ public class FileDownloader extends Service
@Inject UserAccountManager accountManager;
@Inject UploadsStorageManager uploadsStorageManager;
@Inject LocalBroadcastManager localBroadcastManager;
@Inject ThemeColorUtils themeColorUtils;
public static String getDownloadAddedMessage() {
return FileDownloader.class.getName() + DOWNLOAD_ADDED_MESSAGE;
@@ -150,11 +151,11 @@ public class FileDownloader extends Service
mBinder = new FileDownloaderBinder();
NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setContentTitle(
getApplicationContext().getResources().getString(R.string.app_name))
.setContentText(getApplicationContext().getResources().getString(R.string.foreground_service_download))
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
.setColor(ThemeColorUtils.primaryColor(getApplicationContext(), true));
getApplicationContext().getResources().getString(R.string.app_name))
.setContentText(getApplicationContext().getResources().getString(R.string.foreground_service_download))
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
.setColor(themeColorUtils.primaryColor(getApplicationContext(), true));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
@@ -314,20 +315,13 @@ public class FileDownloader extends Service
/**
* Cancels all the downloads for an account
*
* @param account ownCloud account.
*/
public void cancel(Account account) {
Log_OC.d(TAG, "Account= " + account.name);
if (mCurrentDownload != null) {
Log_OC.d(TAG, "Current Download Account= " + mCurrentDownload.getAccount().name);
if (mCurrentDownload.getAccount().name.equals(account.name)) {
mCurrentDownload.cancel();
}
public void cancel(String accountName) {
if (mCurrentDownload != null && mCurrentDownload.getUser().nameEquals(accountName)) {
mCurrentDownload.cancel();
}
// Cancel pending downloads
cancelDownloadsForAccount(account);
cancelPendingDownloads(accountName);
}
public void clearListeners() {
@@ -491,15 +485,10 @@ public class FileDownloader extends Service
/// notify result
notifyDownloadResult(mCurrentDownload, downloadResult);
sendBroadcastDownloadFinished(mCurrentDownload, downloadResult, removeResult.second);
}
} else {
// Cancel the transfer
Log_OC.d(TAG, "Account " + mCurrentDownload.getAccount() + " doesn't exist");
cancelDownloadsForAccount(mCurrentDownload.getAccount());
cancelPendingDownloads(mCurrentDownload.getUser().getAccountName());
}
}
}
@@ -550,17 +539,17 @@ public class FileDownloader extends Service
private void notifyDownloadStart(DownloadFileOperation download) {
/// create status notification with a progress bar
mLastPercent = 0;
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this);
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this, themeColorUtils);
mNotificationBuilder
.setSmallIcon(R.drawable.notification_icon)
.setTicker(getString(R.string.downloader_download_in_progress_ticker))
.setContentTitle(getString(R.string.downloader_download_in_progress_ticker))
.setOngoing(true)
.setProgress(100, 0, download.getSize() < 0)
.setContentText(
String.format(getString(R.string.downloader_download_in_progress_content), 0,
new File(download.getSavePath()).getName())
);
.setSmallIcon(R.drawable.notification_icon)
.setTicker(getString(R.string.downloader_download_in_progress_ticker))
.setContentTitle(getString(R.string.downloader_download_in_progress_ticker))
.setOngoing(true)
.setProgress(100, 0, download.getSize() < 0)
.setContentText(
String.format(getString(R.string.downloader_download_in_progress_content), 0,
new File(download.getSavePath()).getName())
);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
@@ -640,7 +629,7 @@ public class FileDownloader extends Service
int tickerId = downloadResult.isSuccess() ?
R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(downloadResult.getCode());
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED == downloadResult.getCode();
tickerId = needsToUpdateCredentials ?
R.string.downloader_download_failed_credentials_error : tickerId;
@@ -741,13 +730,7 @@ public class FileDownloader extends Service
localBroadcastManager.sendBroadcast(added);
}
/**
* Remove downloads of an account
*
* @param account Downloads account to remove
*/
private void cancelDownloadsForAccount(Account account) {
// Cancel pending downloads
mPendingDownloads.remove(account.name);
private void cancelPendingDownloads(String accountName) {
mPendingDownloads.remove(accountName);
}
}
@@ -194,6 +194,7 @@ public class FileUploader extends Service
@Inject ConnectivityService connectivityService;
@Inject PowerManagementService powerManagementService;
@Inject LocalBroadcastManager localBroadcastManager;
@Inject ThemeColorUtils themeColorUtils;
private IndexedForest<UploadFileOperation> mPendingUploads = new IndexedForest<>();
@@ -234,7 +235,7 @@ public class FileUploader extends Service
.setContentText(getApplicationContext().getResources().getString(R.string.foreground_service_upload))
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
.setColor(ThemeColorUtils.primaryColor(getApplicationContext(), true));
.setColor(themeColorUtils.primaryColor(getApplicationContext(), true));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD);
@@ -602,7 +603,7 @@ public class FileUploader extends Service
if (!accountManager.exists(mCurrentUpload.getAccount())) {
Log_OC.w(TAG, "Account " + mCurrentUpload.getAccount().name +
" does not exist anymore -> cancelling all its uploads");
cancelUploadsForAccount(mCurrentUpload.getAccount());
cancelPendingUploads(mCurrentUpload.getUser().getAccountName());
return;
}
@@ -700,7 +701,7 @@ public class FileUploader extends Service
private void notifyUploadStart(UploadFileOperation upload) {
// / create status notification with a progress bar
mLastPercent = 0;
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this);
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this, themeColorUtils);
mNotificationBuilder
.setOngoing(true)
.setSmallIcon(R.drawable.notification_icon)
@@ -709,7 +710,7 @@ public class FileUploader extends Service
.setProgress(100, 0, false)
.setContentText(
String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName())
);
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD);
@@ -778,11 +779,11 @@ public class FileUploader extends Service
// Only notify if the upload fails
if (!uploadResult.isCancelled() &&
!uploadResult.isSuccess() &&
!ResultCode.LOCAL_FILE_NOT_FOUND.equals(uploadResult.getCode()) &&
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_WIFI) &&
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_CHARGING) &&
!uploadResult.getCode().equals(ResultCode.DELAYED_IN_POWER_SAVE_MODE) &&
!uploadResult.getCode().equals(ResultCode.LOCK_FAILED)) {
ResultCode.LOCAL_FILE_NOT_FOUND != uploadResult.getCode() &&
uploadResult.getCode() != ResultCode.DELAYED_FOR_WIFI &&
uploadResult.getCode() != ResultCode.DELAYED_FOR_CHARGING &&
uploadResult.getCode() != ResultCode.DELAYED_IN_POWER_SAVE_MODE &&
uploadResult.getCode() != ResultCode.LOCK_FAILED) {
int tickerId = R.string.uploader_upload_failed_ticker;
@@ -827,7 +828,7 @@ public class FileUploader extends Service
));
} else {
Intent intent;
if (uploadResult.getCode().equals(ResultCode.SYNC_CONFLICT)) {
if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
intent = ConflictsResolveActivity.createIntent(upload.getFile(),
upload.getUser(),
upload.getOCUploadId(),
@@ -917,16 +918,15 @@ public class FileUploader extends Service
}
/**
* Remove and 'forgets' pending uploads of an account.
* Remove and 'forgets' pending uploads of a user.
*
* @param account Account which uploads will be cancelled
* @param accountName User which uploads will be cancelled
*/
private void cancelUploadsForAccount(Account account) {
mPendingUploads.remove(account.name);
mUploadsStorageManager.removeUploads(account.name);
private void cancelPendingUploads(String accountName) {
mPendingUploads.remove(accountName);
mUploadsStorageManager.removeUploads(accountName);
}
/**
* Upload a new file
*/
@@ -1187,22 +1187,21 @@ public class FileUploader extends Service
}
/**
* Cancels all the uploads for an account.
* Cancels all the uploads for a user, both running and pending.
*
* @param account ownCloud account.
* @param user Nextcloud user
*/
public void cancel(Account account) {
Log_OC.d(TAG, "Account= " + account.name);
if (mCurrentUpload != null) {
Log_OC.d(TAG, "Current Upload Account= " + mCurrentUpload.getAccount().name);
if (mCurrentUpload.getAccount().name.equals(account.name)) {
mCurrentUpload.cancel(ResultCode.CANCELLED);
}
public void cancel(User user) {
if (mCurrentUpload != null && mCurrentUpload.getUser().nameEquals(user)) {
mCurrentUpload.cancel(ResultCode.CANCELLED);
}
cancelPendingUploads(user.getAccountName());
}
// Cancel pending uploads
cancelUploadsForAccount(account);
public void cancel(String accountName) {
if (mCurrentUpload != null && mCurrentUpload.getUser().nameEquals(accountName)) {
mCurrentUpload.cancel(ResultCode.CANCELLED);
}
}
public void clearListeners() {
@@ -38,6 +38,7 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.theme.ThemeBarUtils;
@@ -46,6 +47,8 @@ import com.owncloud.android.utils.theme.ThemeColorUtils;
import java.util.Formatter;
import java.util.Locale;
import javax.inject.Inject;
/**
* View containing controls for a {@link MediaPlayer}.
@@ -59,7 +62,7 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
private static final int SHOW_PROGRESS = 1;
private MediaPlayerControl playerControl;
private View root;
private final View root;
private ProgressBar progressBar;
private TextView endTime;
private TextView currentTime;
@@ -68,12 +71,21 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
private ImageButton forwardButton;
private ImageButton rewindButton;
public MediaControlView(Context context, AttributeSet attrs) {
@Inject
ThemeColorUtils themeColorUtils;
@Inject
ThemeBarUtils themeBarUtils;
public MediaControlView(Context context,
AttributeSet attrs) {
super(context, attrs);
MainApp.getAppComponent().inject(this);
FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
root = inflate.inflate(R.layout.media_control, null);
@@ -125,10 +137,10 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
if (progressBar != null) {
if (progressBar instanceof SeekBar) {
SeekBar seeker = (SeekBar) progressBar;
ThemeBarUtils.colorHorizontalSeekBar(seeker, getContext());
themeBarUtils.colorHorizontalSeekBar(seeker, getContext(), themeColorUtils);
seeker.setOnSeekBarChangeListener(this);
} else {
ThemeBarUtils.colorHorizontalProgressBar(progressBar, ThemeColorUtils.primaryAccentColor(getContext()));
themeBarUtils.colorHorizontalProgressBar(progressBar, themeColorUtils.primaryAccentColor(getContext()));
}
progressBar.setMax(1000);
}
@@ -161,7 +173,7 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
}
}
private Handler handler = new Handler() {
private final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == SHOW_PROGRESS) {
@@ -25,6 +25,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.theme.CapabilityUtils;
/**
* Get and save capabilities from the server
@@ -53,6 +54,9 @@ public class GetCapabilitiesOperation extends SyncOperation {
// Save the capabilities into database
storageManager.saveCapabilities(capability);
// update cached entry
CapabilityUtils.updateCapability(capability);
}
return result;
@@ -699,7 +699,7 @@ public class RefreshFolderOperation extends RemoteOperation {
for (Object obj : result.getData()) {
share = (OCShare) obj;
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
if (ShareType.NO_SHARED != share.getShareType()) {
shares.add(share);
}
}
@@ -68,10 +68,10 @@ public class UnshareOperation extends SyncOperation {
if (result.isSuccess()) {
Log_OC.d(TAG, "Share id = " + share.getRemoteId() + " deleted");
if (ShareType.PUBLIC_LINK.equals(share.getShareType())) {
if (ShareType.PUBLIC_LINK == share.getShareType()) {
file.setSharedViaLink(false);
} else if (ShareType.USER.equals(share.getShareType()) || ShareType.GROUP.equals(share.getShareType())
|| ShareType.FEDERATED.equals(share.getShareType())) {
} else if (ShareType.USER == share.getShareType() || ShareType.GROUP == share.getShareType()
|| ShareType.FEDERATED == share.getShareType()) {
// Check if it is the last share
List<OCShare> sharesWith = getStorageManager().
getSharesWithForAFile(remotePath,
@@ -40,7 +40,6 @@ import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract;
import android.provider.DocumentsProvider;
import android.util.Log;
import android.util.SparseArray;
import android.widget.Toast;
import com.nextcloud.client.account.User;
@@ -48,6 +47,7 @@ import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.files.downloader.DownloadTask;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.nextcloud.client.utils.HashUtil;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -82,7 +82,9 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@@ -113,7 +115,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@VisibleForTesting
static final String DOCUMENTID_SEPARATOR = "/";
private static final int DOCUMENTID_PARTS = 2;
private final SparseArray<FileDataStorageManager> rootIdToStorageManager = new SparseArray<>();
private final Map<String, FileDataStorageManager> rootIdToStorageManager = new HashMap<>();
private final Executor executor = Executors.newCachedThreadPool();
@@ -132,8 +134,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
final RootCursor result = new RootCursor(projection);
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
result.addRoot(new Document(rootIdToStorageManager.valueAt(i), ROOT_PATH), getContext());
for(FileDataStorageManager manager: rootIdToStorageManager.values()) {
result.addRoot(new Document(manager, ROOT_PATH), getContext());
}
return result;
@@ -678,14 +680,12 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
private FileDataStorageManager getStorageManager(String rootId) {
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
FileDataStorageManager storageManager = rootIdToStorageManager.valueAt(i);
if (storageManager.getUser().nameEquals(rootId)) {
return storageManager;
}
}
return rootIdToStorageManager.get(rootId);
}
return null;
@VisibleForTesting
public static String rootIdForUser(User user) {
return HashUtil.md5Hash(user.getAccountName());
}
private void initiateStorageMap() {
@@ -696,7 +696,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
for (User user : accountManager.getAllUsers()) {
final FileDataStorageManager storageManager = new FileDataStorageManager(user, contentResolver);
rootIdToStorageManager.put(user.hashCode(), storageManager);
rootIdToStorageManager.put(rootIdForUser(user), storageManager);
}
}
@@ -725,7 +725,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
throw new FileNotFoundException("Invalid documentID " + documentId + "!");
}
FileDataStorageManager storageManager = rootIdToStorageManager.get(Integer.parseInt(separated[0]));
FileDataStorageManager storageManager = rootIdToStorageManager.get(separated[0]);
if (storageManager == null) {
throw new FileNotFoundException("No storage manager associated for " + documentId + "!");
}
@@ -803,9 +803,9 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
public String getDocumentId() {
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
if (Objects.equals(storageManager, rootIdToStorageManager.valueAt(i))) {
return rootIdToStorageManager.keyAt(i) + DOCUMENTID_SEPARATOR + fileId;
for(String key: rootIdToStorageManager.keySet()) {
if (Objects.equals(storageManager, rootIdToStorageManager.get(key))) {
return key + DOCUMENTID_SEPARATOR + fileId;
}
}
return null;
@@ -753,7 +753,15 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.FILE_OWNER_DISPLAY_NAME + TEXT
+ ProviderTableMeta.FILE_NOTE + TEXT
+ ProviderTableMeta.FILE_SHAREES + TEXT
+ ProviderTableMeta.FILE_RICH_WORKSPACE + " TEXT);"
+ ProviderTableMeta.FILE_RICH_WORKSPACE + TEXT
+ ProviderTableMeta.FILE_LOCKED + INTEGER // boolean
+ ProviderTableMeta.FILE_LOCK_TYPE + INTEGER
+ ProviderTableMeta.FILE_LOCK_OWNER + TEXT
+ ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME + TEXT
+ ProviderTableMeta.FILE_LOCK_OWNER_EDITOR + TEXT
+ ProviderTableMeta.FILE_LOCK_TIMESTAMP + INTEGER
+ ProviderTableMeta.FILE_LOCK_TIMEOUT + INTEGER
+ ProviderTableMeta.FILE_LOCK_TOKEN + " TEXT );"
);
}
@@ -829,7 +837,8 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG + TEXT
+ ProviderTableMeta.CAPABILITIES_USER_STATUS + INTEGER
+ ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI + INTEGER
+ ProviderTableMeta.CAPABILITIES_ETAG + " TEXT );");
+ ProviderTableMeta.CAPABILITIES_ETAG + TEXT
+ ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION + " TEXT );");
}
private void createUploadsTable(SQLiteDatabase db) {
@@ -2454,6 +2463,39 @@ public class FileContentProvider extends ContentProvider {
}
}
if (oldVersion < 63 && newVersion >= 63) {
Log_OC.i(SQL, "Adding file locking columns");
db.beginTransaction();
try {
// locking capabilities
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME + ADD_COLUMN + ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION + " TEXT ");
// force refresh
db.execSQL("UPDATE capabilities SET etag = '' WHERE 1=1");
// locking properties
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCKED + " INTEGER "); // boolean
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TYPE + " INTEGER ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_OWNER + " TEXT ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME + " TEXT ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_OWNER_EDITOR + " TEXT ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TIMESTAMP + " INTEGER ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TIMEOUT + " INTEGER ");
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TOKEN + " TEXT ");
db.execSQL("UPDATE " + ProviderTableMeta.FILE_TABLE_NAME + " SET " + ProviderTableMeta.FILE_ETAG + " = '' WHERE 1=1");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
@@ -106,35 +106,49 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
/** Counter of conflicts found between local and remote files */
private int mConflictsFound;
/** Counter of failed operations in synchronization of kept-in-sync files */
/**
* Counter of failed operations in synchronization of kept-in-sync files
*/
private int mFailsInFavouritesFound;
/** Map of remote and local paths to files that where locally stored in a location out
* of the ownCloud folder and couldn't be copied automatically into it */
/**
* Map of remote and local paths to files that where locally stored in a location out of the ownCloud folder and
* couldn't be copied automatically into it
*/
private Map<String, String> mForgottenLocalFiles;
/** {@link SyncResult} instance to return to the system when the synchronization finish */
/**
* {@link SyncResult} instance to return to the system when the synchronization finish
*/
private SyncResult mSyncResult;
private final ThemeColorUtils themeColorUtils;
/**
* Creates a {@link FileSyncAdapter}
*
* <p>
* {@inheritDoc}
*/
public FileSyncAdapter(Context context, boolean autoInitialize, UserAccountManager userAccountManager) {
public FileSyncAdapter(Context context,
boolean autoInitialize,
UserAccountManager userAccountManager,
ThemeColorUtils themeColorUtils) {
super(context, autoInitialize, userAccountManager);
this.themeColorUtils = themeColorUtils;
}
/**
* Creates a {@link FileSyncAdapter}
*
* <p>
* {@inheritDoc}
*/
public FileSyncAdapter(Context context,
boolean autoInitialize,
boolean allowParallelSyncs,
UserAccountManager userAccountManager) {
UserAccountManager userAccountManager,
ThemeColorUtils themeColorUtils) {
super(context, autoInitialize, allowParallelSyncs, userAccountManager);
this.themeColorUtils = themeColorUtils;
}
@@ -292,7 +306,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
} else if (result.getCode() != ResultCode.FILE_NOT_FOUND) {
// in failures, the statistics for the global result are updated
if (RemoteOperationResult.ResultCode.UNAUTHORIZED.equals(result.getCode())) {
if (ResultCode.UNAUTHORIZED == result.getCode()) {
mSyncResult.stats.numAuthExceptions++;
} else if (result.getException() instanceof DavException) {
@@ -321,10 +335,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
private boolean isFinisher(RemoteOperationResult failedResult) {
if (failedResult != null) {
RemoteOperationResult.ResultCode code = failedResult.getCode();
return code.equals(RemoteOperationResult.ResultCode.SSL_ERROR)
|| code.equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)
|| code.equals(RemoteOperationResult.ResultCode.BAD_OC_VERSION)
|| code.equals(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
return code == ResultCode.SSL_ERROR
|| code == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
|| code == ResultCode.BAD_OC_VERSION
|| code == ResultCode.INSTANCE_NOT_CONFIGURED;
}
return false;
}
@@ -391,7 +405,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
private void notifyFailedSynchronization() {
NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
boolean needsToUpdateCredentials = mLastFailedResult != null
&& ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode());
&& ResultCode.UNAUTHORIZED == mLastFailedResult.getCode();
if (needsToUpdateCredentials) {
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
@@ -510,7 +524,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
private NotificationCompat.Builder createNotificationBuilder() {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext());
notificationBuilder.setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
notificationBuilder.setColor(ThemeColorUtils.primaryColor(getContext(), true));
notificationBuilder.setColor(themeColorUtils.primaryColor(getContext(), true));
return notificationBuilder;
}
@@ -25,6 +25,7 @@ import android.content.Intent;
import android.os.IBinder;
import com.nextcloud.client.account.UserAccountManager;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import javax.inject.Inject;
@@ -43,6 +44,7 @@ public class FileSyncService extends Service {
private static final Object syncAdapterLock = new Object();
@Inject UserAccountManager userAccountManager;
@Inject ThemeColorUtils themeColorUtils;
/*
* {@inheritDoc}
@@ -52,7 +54,7 @@ public class FileSyncService extends Service {
AndroidInjection.inject(this);
synchronized (syncAdapterLock) {
if (syncAdapter == null) {
syncAdapter = new FileSyncAdapter(getApplicationContext(), true, userAccountManager);
syncAdapter = new FileSyncAdapter(getApplicationContext(), true, userAccountManager, themeColorUtils);
}
}
}
@@ -39,6 +39,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.ShareeUser;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import java.util.List;
@@ -83,7 +84,11 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
DrawableCompat.setTint(borderDrawable, ContextCompat.getColor(context, R.color.bg_default));
}
public void setAvatars(@NonNull User user, @NonNull List<ShareeUser> sharees) {
public void setAvatars(@NonNull User user,
@NonNull List<ShareeUser> sharees,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils,
ThemeAvatarUtils themeAvatarUtils) {
@NonNull Context context = getContext();
removeAllViews();
RelativeLayout.LayoutParams avatarLayoutParams;
@@ -109,7 +114,7 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
if (avatarCount == 0 && sharees.size() > MAX_AVATAR_COUNT) {
avatar.setImageResource(R.drawable.ic_people);
ThemeDrawableUtils.setIconColor(avatar.getDrawable());
themeDrawableUtils.setIconColor(avatar.getDrawable());
} else {
sharee = sharees.get(avatarCount);
switch (sharee.getShareType()) {
@@ -117,10 +122,15 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
case EMAIL:
case ROOM:
case CIRCLE:
ThemeAvatarUtils.createAvatar(sharee.getShareType(), avatar, context);
themeAvatarUtils.createAvatar(sharee.getShareType(), avatar, context, themeColorUtils);
break;
case FEDERATED:
showFederatedShareAvatar(context, sharee.getUserId(), avatarRadius, resources, avatar);
showFederatedShareAvatar(context,
sharee.getUserId(),
avatarRadius,
resources,
avatar,
themeDrawableUtils);
break;
default:
avatar.setTag(sharee);
@@ -148,7 +158,8 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
String user,
float avatarRadius,
Resources resources,
ImageView avatar) {
ImageView avatar,
ThemeDrawableUtils themeDrawableUtils) {
// maybe federated share
String[] split = user.split("@");
String userId = split[0];
@@ -162,7 +173,7 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
placeholder = ThemeDrawableUtils.tintDrawable(ResourcesCompat.getDrawable(resources,
placeholder = themeDrawableUtils.tintDrawable(ResourcesCompat.getDrawable(resources,
R.drawable.account_circle_white,
null),
R.color.black);
@@ -29,8 +29,7 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/**
* Extends RecyclerView to show a custom view if no data is available
* Inspired by http://alexzh.com/tutorials/how-to-setemptyview-to-recyclerview
* Extends RecyclerView to show a custom view if no data is available Inspired by http://alexzh.com/tutorials/how-to-setemptyview-to-recyclerview
*/
public class EmptyRecyclerView extends RecyclerView {
private View mEmptyView;
@@ -29,29 +29,36 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import javax.inject.Inject;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.graphics.drawable.DrawableCompat;
/**
* Themeable switch preference
* TODO Migrate to androidx
* Themeable switch preference TODO Migrate to androidx
*/
public class ThemeableSwitchPreference extends SwitchPreference {
@Inject
ThemeColorUtils themeColorUtils;
public ThemeableSwitchPreference(Context context) {
super(context);
MainApp.getAppComponent().inject(this);
}
public ThemeableSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
MainApp.getAppComponent().inject(this);
}
public ThemeableSwitchPreference(Context context, AttributeSet attrs) {
super(context, attrs);
MainApp.getAppComponent().inject(this);
}
@Override
@@ -74,19 +81,19 @@ public class ThemeableSwitchPreference extends SwitchPreference {
Switch switchView = (Switch) child;
if(thumbColorStateList == null && trackColorStateList == null) {
int thumbColor = ThemeColorUtils.primaryAccentColor(getContext());
if (ThemeColorUtils.darkTheme(getContext()) &&
int thumbColor = themeColorUtils.primaryAccentColor(getContext());
if (themeColorUtils.darkTheme(getContext()) &&
AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) {
thumbColor = Color.WHITE;
}
int trackColor = Color.argb(77, Color.red(thumbColor), Color.green(thumbColor), Color.blue(thumbColor));
int trackColorUnchecked = getContext().getResources().getColor(R.color.switch_track_color_unchecked);
thumbColorStateList = new ColorStateList(
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
new int[]{thumbColor, getContext().getResources().getColor(R.color.switch_thumb_color_unchecked)});
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
new int[]{thumbColor, getContext().getResources().getColor(R.color.switch_thumb_color_unchecked)});
trackColorStateList = new ColorStateList(
new int[][]{new int[]{android.R.attr.state_checked},
new int[]{}},
new int[][]{new int[]{android.R.attr.state_checked},
new int[]{}},
new int[]{trackColor, trackColorUnchecked});
}
@@ -41,7 +41,6 @@ import com.owncloud.android.ui.interfaces.ActivityListInterface;
import com.owncloud.android.ui.preview.PreviewImageActivity;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.theme.ThemeLayoutUtils;
import java.util.List;
@@ -85,7 +84,7 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
// setup toolbar
setupToolbar();
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
themeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
// setup drawer
setupDrawer(R.id.nav_activity);
@@ -114,7 +113,9 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
getUserAccountManager(),
this,
clientFactory,
false);
false,
themeColorUtils,
themeDrawableUtils);
binding.list.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
@@ -31,8 +31,6 @@ import com.google.android.material.button.MaterialButton;
import com.owncloud.android.R;
import com.owncloud.android.databinding.CommunityLayoutBinding;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
/**
* Activity providing information about ways to participate in the app's development.
@@ -66,7 +64,7 @@ public class CommunityActivity extends DrawerActivity {
contributeForumView.setMovementMethod(LinkMovementMethod.getInstance());
contributeForumView.setText(Html.fromHtml(getString(R.string.community_contribute_forum_text) + " " +
getString(R.string.community_contribute_forum_text_link,
ThemeColorUtils.primaryColorToHexString(this),
themeColorUtils.primaryColorToHexString(this),
getString(R.string.help_link),
getString(R.string.community_contribute_forum_forum))));
@@ -74,7 +72,7 @@ public class CommunityActivity extends DrawerActivity {
contributeTranslationView.setMovementMethod(LinkMovementMethod.getInstance());
contributeTranslationView.setText(Html.fromHtml(
getString(R.string.community_contribute_translate_link,
ThemeColorUtils.primaryColorToHexString(this),
themeColorUtils.primaryColorToHexString(this),
getString(R.string.translation_link),
getString(R.string.community_contribute_translate_translate)) + " " +
getString(R.string.community_contribute_translate_text)));
@@ -84,11 +82,11 @@ public class CommunityActivity extends DrawerActivity {
contributeGithubView.setText(Html.fromHtml(
getString(R.string.community_contribute_github_text,
getString(R.string.community_contribute_github_text_link,
ThemeColorUtils.primaryColorToHexString(this),
themeColorUtils.primaryColorToHexString(this),
getString(R.string.contributing_link)))));
MaterialButton reportButton = binding.communityTestingReport;
ThemeButtonUtils.colorPrimaryButton(reportButton, this);
themeButtonUtils.colorPrimaryButton(reportButton, this, themeColorUtils);
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
binding.communityBetaFdroid.setOnClickListener(
@@ -79,7 +79,6 @@ import com.owncloud.android.R;
import com.owncloud.android.authentication.PassCodeManager;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.ExternalLinksProvider;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.ExternalLink;
import com.owncloud.android.lib.common.ExternalLinkType;
@@ -102,6 +101,7 @@ import com.owncloud.android.ui.events.SearchEvent;
import com.owncloud.android.ui.fragment.FileDetailsSharingProcessFragment;
import com.owncloud.android.ui.fragment.GalleryFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.fragment.SharedListFragment;
import com.owncloud.android.ui.preview.PreviewTextStringFragment;
import com.owncloud.android.ui.trashbin.TrashbinActivity;
import com.owncloud.android.utils.BitmapUtils;
@@ -112,9 +112,8 @@ import com.owncloud.android.utils.svg.MenuSimpleTarget;
import com.owncloud.android.utils.svg.SVGorImage;
import com.owncloud.android.utils.svg.SvgOrImageBitmapTranscoder;
import com.owncloud.android.utils.svg.SvgOrImageDecoder;
import com.owncloud.android.utils.theme.CapabilityUtils;
import com.owncloud.android.utils.theme.ThemeBarUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.ThemeMenuUtils;
import org.greenrobot.eventbus.EventBus;
@@ -211,6 +210,12 @@ public abstract class DrawerActivity extends ToolbarActivity
@Inject
ClientFactory clientFactory;
@Inject
ThemeMenuUtils themeMenuUtils;
@Inject
ThemeBarUtils themeBarUtils;
/**
* Initializes the drawer, its content and highlights the menu item with the given id. This method needs to be
* called after the content view has been set.
@@ -283,8 +288,8 @@ public abstract class DrawerActivity extends ToolbarActivity
R.drawable.ic_arrow_back,
null);
mDrawerToggle.setHomeAsUpIndicator(
ThemeDrawableUtils.tintDrawable(backArrow, ThemeColorUtils.appBarPrimaryFontColor(this)));
mDrawerToggle.getDrawerArrowDrawable().setColor(ThemeColorUtils.appBarPrimaryFontColor(this));
themeDrawableUtils.tintDrawable(backArrow, themeColorUtils.appBarPrimaryFontColor(this)));
mDrawerToggle.getDrawerArrowDrawable().setColor(themeColorUtils.appBarPrimaryFontColor(this));
}
/**
@@ -295,20 +300,20 @@ public abstract class DrawerActivity extends ToolbarActivity
mQuotaProgressBar = (ProgressBar) findQuotaViewById(R.id.drawer_quota_ProgressBar);
mQuotaTextPercentage = (TextView) findQuotaViewById(R.id.drawer_quota_percentage);
mQuotaTextLink = (TextView) findQuotaViewById(R.id.drawer_quota_link);
ThemeBarUtils.colorProgressBar(mQuotaProgressBar, ThemeColorUtils.primaryColor(this));
themeBarUtils.colorProgressBar(mQuotaProgressBar, themeColorUtils.primaryColor(this));
}
public void updateHeader() {
if (getAccount() != null &&
getStorageManager().getCapability(getAccount().name).getServerBackground() != null) {
getCapabilities().getServerBackground() != null) {
OCCapability capability = getStorageManager().getCapability(getAccount().name);
OCCapability capability = getCapabilities();
String logo = capability.getServerLogo();
int primaryColor = ThemeColorUtils.primaryColor(getAccount(), false, this);
int primaryColor = themeColorUtils.primaryColor(getAccount(), false, this);
// set background to primary color
LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view);
drawerHeader.setBackgroundColor(ThemeColorUtils.unchangedPrimaryColor(getAccount(), this));
drawerHeader.setBackgroundColor(themeColorUtils.unchangedPrimaryColor(getAccount(), this));
if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) {
// background image
@@ -369,7 +374,7 @@ public abstract class DrawerActivity extends ToolbarActivity
if (!TextUtils.isEmpty(name)) {
TextView serverName = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name);
serverName.setText(name);
serverName.setTextColor(ThemeColorUtils.unchangedFontColor(this));
serverName.setTextColor(themeColorUtils.unchangedFontColor(this));
}
}
@@ -378,7 +383,7 @@ public abstract class DrawerActivity extends ToolbarActivity
* setup drawer header, basically the logo color
*/
private void setupDrawerHeader(FrameLayout drawerHeader) {
drawerHeader.setBackgroundColor(ThemeColorUtils.primaryColor(getAccount(), true, this));
drawerHeader.setBackgroundColor(themeColorUtils.primaryColor(getAccount(), true, this));
}
/**
@@ -403,9 +408,7 @@ public abstract class DrawerActivity extends ToolbarActivity
}
private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
FileDataStorageManager storageManager = new FileDataStorageManager(user,
getContentResolver());
OCCapability capability = storageManager.getCapability(user.getAccountName());
OCCapability capability = getCapabilities();
DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources());
DrawerMenuUtil.filterTrashbinMenuItem(menu, capability);
@@ -433,6 +436,7 @@ public abstract class DrawerActivity extends ToolbarActivity
if (itemId == R.id.nav_all_files) {
if (this instanceof FileDisplayActivity &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof SharedListFragment) &&
!(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
showFiles(false);
((FileDisplayActivity) this).browseToRoot();
@@ -472,8 +476,7 @@ public abstract class DrawerActivity extends ToolbarActivity
UserInfoActivity.openAccountRemovalConfirmationDialog(optionalUser.get(), getSupportFragmentManager());
}
} else if (itemId == R.id.nav_shared) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
menuItem.getItemId());
startSharedSearch(menuItem);
} else if (itemId == R.id.nav_recently_modified) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
menuItem.getItemId());
@@ -521,6 +524,13 @@ public abstract class DrawerActivity extends ToolbarActivity
}
}
private void startSharedSearch(MenuItem menuItem) {
SearchEvent searchEvent = new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER);
MainApp.showOnlyFilesOnDevice(false);
launchActivityForSearch(searchEvent, menuItem.getItemId());
}
private void startPhotoSearch(MenuItem menuItem) {
SearchEvent searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
MainApp.showOnlyFilesOnDevice(false);
@@ -530,7 +540,8 @@ public abstract class DrawerActivity extends ToolbarActivity
private void handleSearchEvents(SearchEvent searchEvent, int menuItemId) {
if (this instanceof FileDisplayActivity) {
if (((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) {
final Fragment leftFragment = ((FileDisplayActivity) this).getLeftFragment();
if (leftFragment instanceof GalleryFragment || leftFragment instanceof SharedListFragment) {
launchActivityForSearch(searchEvent, menuItemId);
} else {
EventBus.getDefault().post(searchEvent);
@@ -684,7 +695,9 @@ public abstract class DrawerActivity extends ToolbarActivity
mQuotaProgressBar.setProgress(relative);
ThemeBarUtils.colorProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
themeBarUtils.colorProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this,
relative,
themeColorUtils));
updateQuotaLink();
showQuota(true);
@@ -772,7 +785,7 @@ public abstract class DrawerActivity extends ToolbarActivity
mCheckedMenuItem = menuItemId;
MenuItem currentItem = mNavigationView.getMenu().findItem(menuItemId);
int drawerColor = getResources().getColor(R.color.drawer_text_color);
int activeColor = ThemeColorUtils.primaryColor(null, true, true, this);
int activeColor = themeColorUtils.primaryColor(null, true, true, this);
currentItem.setChecked(true);
@@ -781,11 +794,11 @@ public abstract class DrawerActivity extends ToolbarActivity
MenuItem menuItem = mNavigationView.getMenu().getItem(i);
if (menuItem.getIcon() != null) {
if (menuItem == currentItem) {
ThemeDrawableUtils.tintDrawable(currentItem.getIcon(), activeColor);
ThemeMenuUtils.tintMenuItemText(currentItem, activeColor);
themeDrawableUtils.tintDrawable(currentItem.getIcon(), activeColor);
themeMenuUtils.tintMenuItemText(currentItem, activeColor);
} else {
ThemeDrawableUtils.tintDrawable(menuItem.getIcon(), drawerColor);
ThemeMenuUtils.tintMenuItemText(menuItem, drawerColor);
themeDrawableUtils.tintDrawable(menuItem.getIcon(), drawerColor);
themeMenuUtils.tintMenuItemText(menuItem, drawerColor);
}
}
}
@@ -905,7 +918,7 @@ public abstract class DrawerActivity extends ToolbarActivity
if (menuItem != null) {
if (drawable != null) {
menuItem.setIcon(ThemeDrawableUtils.tintDrawable(drawable, greyColor));
menuItem.setIcon(themeDrawableUtils.tintDrawable(drawable, greyColor));
} else {
menuItem.setIcon(R.drawable.ic_link);
}
@@ -1136,8 +1149,8 @@ public abstract class DrawerActivity extends ToolbarActivity
}
User user = accountManager.getUser();
String name = user.getAccountName();
if (getStorageManager() != null && getStorageManager().getCapability(name).getExternalLinks().isTrue()) {
if (getStorageManager() != null && CapabilityUtils.getCapability(user, this)
.getExternalLinks().isTrue()) {
int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
FileActivity.APP_OPENED_COUNT);
@@ -43,7 +43,6 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
public abstract class EditorWebView extends ExternalSiteWebView {
protected Snackbar loadingSnackbar;
@@ -79,7 +78,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
R.string.timeout_richDocuments, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.common_back, v -> closeView());
ThemeSnackbarUtils.colorSnackbar(getApplicationContext(), snackbar);
themeSnackbarUtils.colorSnackbar(getApplicationContext(), snackbar);
setLoadingSnackbar(snackbar);
snackbar.show();
}
@@ -158,7 +157,9 @@ public abstract class EditorWebView extends ExternalSiteWebView {
file.isSharedViaLink(),
file.isEncrypted(),
file.getMountType(),
this));
this,
themeColorUtils,
themeDrawableUtils));
} else {
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
// Thumbnail in cache?
@@ -181,7 +182,9 @@ public abstract class EditorWebView extends ExternalSiteWebView {
Drawable icon = MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
file.getFileName(),
user,
getApplicationContext());
getApplicationContext(),
themeColorUtils,
themeDrawableUtils);
binding.thumbnail.setImageDrawable(icon);
}
}
@@ -39,7 +39,6 @@ import com.owncloud.android.databinding.ExternalsiteWebviewBinding;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.NextcloudWebViewClient;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import java.io.InputStream;
@@ -203,7 +202,7 @@ public class ExternalSiteWebView extends FileActivity {
private void setupActionBar(String title) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
ThemeToolbarUtils.setColoredTitle(actionBar, title, this);
themeToolbarUtils.setColoredTitle(actionBar, title, this);
if (showSidebar) {
actionBar.setDisplayHomeAsUpEnabled(true);
@@ -93,7 +93,6 @@ import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.ErrorMessageAdapter;
import com.owncloud.android.utils.FilesSyncHelper;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -172,6 +171,9 @@ public abstract class FileActivity extends DrawerActivity
@Inject
BackgroundJobManager backgroundJobManager;
@Inject
ThemeSnackbarUtils themeSnackbarUtils;
@Override
public void showFiles(boolean onDeviceOnly) {
// must be specialized in subclasses
@@ -200,9 +202,11 @@ public abstract class FileActivity extends DrawerActivity
mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
mFileOperationsHelper.setOpIdWaitingFor(
savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
);
ThemeToolbarUtils.setColoredTitle(getSupportActionBar(), savedInstanceState.getString(KEY_ACTION_BAR_TITLE), this);
savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
);
themeToolbarUtils.setColoredTitle(getSupportActionBar(),
savedInstanceState.getString(KEY_ACTION_BAR_TITLE),
this);
} else {
User user = getIntent().getParcelableExtra(FileActivity.EXTRA_USER);
mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
@@ -348,27 +352,27 @@ public abstract class FileActivity extends DrawerActivity
if (!result.isSuccess() && (
result.getCode() == ResultCode.UNAUTHORIZED ||
(result.isException() && result.getException() instanceof AuthenticatorException)
)) {
)) {
requestCredentialsUpdate(this);
if (result.getCode() == ResultCode.UNAUTHORIZED) {
DisplayUtils.showSnackMessage(
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
);
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
);
}
} else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(result.getCode())) {
} else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == result.getCode()) {
showUntrustedCertDialog(result);
} else if (operation == null ||
operation instanceof CreateShareWithShareeOperation ||
operation instanceof UnshareOperation ||
operation instanceof SynchronizeFolderOperation ||
operation instanceof UpdateShareViaLinkOperation ||
operation instanceof UpdateSharePermissionsOperation
) {
operation instanceof CreateShareWithShareeOperation ||
operation instanceof UnshareOperation ||
operation instanceof SynchronizeFolderOperation ||
operation instanceof UpdateShareViaLinkOperation ||
operation instanceof UpdateSharePermissionsOperation
) {
if (result.isSuccess()) {
updateFileFromDB();
@@ -692,12 +696,15 @@ public abstract class FileActivity extends DrawerActivity
}
}
public static void copyAndShareFileLink(FileActivity activity, OCFile file, String link) {
public static void copyAndShareFileLink(FileActivity activity,
OCFile file,
String link,
ThemeSnackbarUtils themeSnackbarUtils) {
ClipboardUtil.copyToClipboard(activity, link, false);
Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), R.string.clipboard_text_copied,
Snackbar.LENGTH_LONG)
.setAction(R.string.share, v -> showShareLinkDialog(activity, file, link));
ThemeSnackbarUtils.colorSnackbar(activity, snackbar);
themeSnackbarUtils.colorSnackbar(activity, snackbar);
snackbar.show();
}
@@ -743,7 +750,7 @@ public abstract class FileActivity extends DrawerActivity
if (result.isSuccess()) {
if (sharingFragment != null) {
sharingFragment.onUpdateShareInformation(result, getFile());
sharingFragment.onUpdateShareInformation(result);
}
} else {
DisplayUtils.showSnackMessage(this, R.string.note_could_not_sent);
@@ -757,7 +764,7 @@ public abstract class FileActivity extends DrawerActivity
if (result.isSuccess()) {
updateFileFromDB();
if (sharingFragment != null) {
sharingFragment.onUpdateShareInformation(result, getFile());
sharingFragment.onUpdateShareInformation(result);
}
} else if (sharingFragment != null && sharingFragment.getView() != null) {
if (TextUtils.isEmpty(result.getMessage())) {
@@ -766,7 +773,7 @@ public abstract class FileActivity extends DrawerActivity
snackbar = Snackbar.make(sharingFragment.getView(), result.getMessage(), Snackbar.LENGTH_LONG);
}
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
themeSnackbarUtils.colorSnackbar(this, snackbar);
snackbar.show();
}
}
@@ -791,7 +798,7 @@ public abstract class FileActivity extends DrawerActivity
}
}
copyAndShareFileLink(this, file, link);
copyAndShareFileLink(this, file, link, themeSnackbarUtils);
if (sharingFragment != null) {
sharingFragment.onUpdateShareInformation(result, file);
@@ -821,7 +828,7 @@ public abstract class FileActivity extends DrawerActivity
operation,
getResources()),
Snackbar.LENGTH_LONG);
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
themeSnackbarUtils.colorSnackbar(this, snackbar);
snackbar.show();
}
}
@@ -877,10 +884,11 @@ public abstract class FileActivity extends DrawerActivity
/**
* open the new sharing process fragment to create the share
*
* @param shareeName
* @param shareType
*/
private void doShareWith(String shareeName, ShareType shareType) {
protected void doShareWith(String shareeName, ShareType shareType) {
FileDetailFragment fragment = getFileDetailFragment();
if (fragment != null) {
fragment.initiateSharingProcess(shareeName, shareType);
@@ -61,6 +61,7 @@ import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.utils.IntentUtil;
import com.nextcloud.java.util.Optional;
import com.nextcloud.utils.view.FastScroll;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.databinding.FilesBinding;
@@ -100,6 +101,7 @@ import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.ui.fragment.GalleryFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.fragment.SearchType;
import com.owncloud.android.ui.fragment.SharedListFragment;
import com.owncloud.android.ui.fragment.TaskRetainerFragment;
import com.owncloud.android.ui.fragment.UnifiedSearchFragment;
import com.owncloud.android.ui.helpers.FileOperationsHelper;
@@ -120,9 +122,6 @@ import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.PushUtils;
import com.owncloud.android.utils.StringUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -136,9 +135,9 @@ import java.util.List;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SearchView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -267,6 +266,9 @@ public class FileDisplayActivity extends FileActivity
mSwitchAccountButton.setOnClickListener(v -> showManageAccountsDialog());
FastScroll.fixAppBarForFastScroll(binding.appbar.appbar, binding.rootLayout);
// Init Fragment without UI to retain AsyncTask across configuration changes
FragmentManager fm = getSupportFragmentManager();
TaskRetainerFragment taskRetainerFragment =
@@ -304,7 +306,8 @@ public class FileDisplayActivity extends FileActivity
.create();
alertDialog.show();
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
themeButtonUtils.themeBorderlessButton(themeColorUtils,
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
} catch (WindowManager.BadTokenException e) {
Log_OC.e(TAG, "Error showing wrong storage info, so skipping it: " + e.getMessage());
}
@@ -316,22 +319,7 @@ public class FileDisplayActivity extends FileActivity
super.onPostCreate(savedInstanceState);
if (!PermissionUtil.checkExternalStoragePermission(this)) {
// Check if we should show an explanation
if (PermissionUtil.shouldShowRequestPermissionRationale(this,
PermissionUtil.getExternalStoragePermission())) {
// Show explanation to the user and then request permission
Snackbar snackbar = Snackbar.make(binding.rootLayout,
R.string.permission_storage_access,
Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.common_ok, v -> PermissionUtil.requestExternalStoragePermission(this));
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
snackbar.show();
} else {
// No explanation needed, request the permission.
PermissionUtil.requestExternalStoragePermission(this);
}
}
PermissionUtil.requestExternalStoragePermission(this, themeSnackbarUtils);
if (getIntent().getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null) {
switchToSearchFragment(savedInstanceState);
@@ -399,7 +387,7 @@ public class FileDisplayActivity extends FileActivity
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
switch (requestCode) {
case PermissionUtil.PERMISSIONS_EXTERNAL_STORAGE: {
case PermissionUtil.PERMISSIONS_EXTERNAL_STORAGE:
// If request is cancelled, result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
@@ -407,24 +395,25 @@ public class FileDisplayActivity extends FileActivity
EventBus.getDefault().post(new TokenPushEvent());
syncAndUpdateFolder(true);
// toggle on is save since this is the only scenario this code gets accessed
} else {
// permission denied --> do nothing
return;
}
return;
}
case PermissionUtil.PERMISSIONS_CAMERA: {
break;
case PermissionUtil.PERMISSIONS_SCAN_DOCUMENT:
// If request is cancelled, result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
AppScanActivity.scanFromCamera(
this,
FileDisplayActivity.REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA);
}
break;
case PermissionUtil.PERMISSIONS_CAMERA:
// If request is cancelled, result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
getFileOperationsHelper()
.uploadFromCamera(this, FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA);
} else {
// permission denied
return;
}
return;
}
break;
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@@ -498,7 +487,7 @@ public class FileDisplayActivity extends FileActivity
SearchEvent searchEvent = intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT);
if (searchEvent != null) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.getSearchType())) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == searchEvent.getSearchType()) {
Log_OC.d(this, "Switch to photo search fragment");
GalleryFragment photoFragment = new GalleryFragment();
@@ -506,6 +495,13 @@ public class FileDisplayActivity extends FileActivity
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
photoFragment.setArguments(bundle);
setLeftFragment(photoFragment);
} else if (searchEvent.getSearchType() == SearchRemoteOperation.SearchType.SHARED_FILTER) {
Log_OC.d(this, "Switch to shared fragment");
SharedListFragment sharedListFragment = new SharedListFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
sharedListFragment.setArguments(bundle);
setLeftFragment(sharedListFragment);
} else {
Log_OC.d(this, "Switch to oc file search fragment");
@@ -520,6 +516,8 @@ public class FileDisplayActivity extends FileActivity
Log_OC.d(this, "Switch to oc file fragment");
setLeftFragment(new OCFileListFragment());
getSupportFragmentManager().executePendingTransactions();
browseToRoot();
}
}
@@ -538,7 +536,7 @@ public class FileDisplayActivity extends FileActivity
transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
transaction.commit();
if (fragment instanceof UnifiedSearchFragment) {
if (fragment instanceof UnifiedSearchFragment || fragment instanceof PreviewMediaFragment) {
showSortListGroup(false);
} else {
showSortListGroup(true);
@@ -566,8 +564,7 @@ public class FileDisplayActivity extends FileActivity
protected void resetTitleBarAndScrolling() {
updateActionBarTitleAndHomeButton(null);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
resetScrolling();
}
public void updateListOfFilesFragment(boolean fromSearch) {
@@ -661,7 +658,7 @@ public class FileDisplayActivity extends FileActivity
searchView.setIconified(false);
});
ThemeToolbarUtils.themeSearchView(searchView, this);
themeToolbarUtils.themeSearchView(searchView, this);
// populate list of menu items to show/hide when drawer is opened/closed
mDrawerMenuItemstoShowHideList = new ArrayList<>(1);
@@ -856,6 +853,8 @@ public class FileDisplayActivity extends FileActivity
},
DELAY_TO_REQUEST_OPERATIONS_LATER
);
} else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
syncAndUpdateFolder(true);
} else {
super.onActivityResult(requestCode, resultCode, data);
}
@@ -1041,8 +1040,7 @@ public class FileDisplayActivity extends FileActivity
createMinFragments(null);
} else {
// pop back
((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams())
.setBehavior(new AppBarLayout.ScrollingViewBehavior());
resetScrolling();
hideSearchView(getCurrentDir());
showSortListGroup(true);
super.onBackPressed();
@@ -1097,7 +1095,7 @@ public class FileDisplayActivity extends FileActivity
OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
ocFileListFragment.setLoading(mSyncInProgress);
syncAndUpdateFolder(false);
syncAndUpdateFolder(false, true);
OCFile startFile = null;
if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
@@ -1286,16 +1284,25 @@ public class FileDisplayActivity extends FileActivity
DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
if (ocFileListFragment != null) {
ocFileListFragment.setLoading(mSyncInProgress);
if (!mSyncInProgress && !ocFileListFragment.isLoading()) {
// update scrolling when load finishes
if (ocFileListFragment.isEmpty()) {
lockScrolling();
} else {
resetScrolling();
}
}
}
setBackgroundText();
}
}
if (synchResult != null && synchResult.getCode().equals(
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
if (synchResult != null && synchResult.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {
mLastSslUntrustedServerResult = synchResult;
}
} catch (RuntimeException e) {
@@ -1313,7 +1320,7 @@ public class FileDisplayActivity extends FileActivity
}
private boolean checkForRemoteOperationError(RemoteOperationResult syncResult) {
return ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) ||
return ResultCode.UNAUTHORIZED == syncResult.getCode() ||
(syncResult.isException() && syncResult.getException()
instanceof AuthenticatorException);
}
@@ -1491,6 +1498,7 @@ public class FileDisplayActivity extends FileActivity
public void browseToRoot() {
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { // should never be null, indeed
MainApp.showOnlyFilesOnDevice(false);
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
listOfFiles.listDirectory(root, MainApp.isOnlyOnDevice(), false);
setFile(listOfFiles.getCurrentFile());
@@ -1527,7 +1535,7 @@ public class FileDisplayActivity extends FileActivity
public void showDetails(OCFile file, int activeTab) {
User currentUser = getUser().orElseThrow(RuntimeException::new);
resetHeaderScrollingState();
resetScrolling();
Fragment detailFragment = FileDetailFragment.newInstance(file, currentUser, activeTab);
setLeftFragment(detailFragment);
@@ -1536,14 +1544,26 @@ public class FileDisplayActivity extends FileActivity
mDrawerToggle.setDrawerIndicatorEnabled(false);
}
private void resetHeaderScrollingState() {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
AppBarLayout appBarLayout = findViewById(R.id.appbar);
/**
* Prevents content scrolling and toolbar collapse
*/
@VisibleForTesting
public void lockScrolling() {
binding.appbar.appbar.setExpanded(true, false);
final AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) binding.appbar.toolbarFrame.getLayoutParams();
appbarParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
binding.appbar.toolbarFrame.setLayoutParams(appbarParams);
}
if (appBarLayout != null) {
appBarLayout.setExpanded(true);
}
/**
* Resets content scrolling and toolbar collapse
*/
@VisibleForTesting
public void resetScrolling() {
AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) binding.appbar.toolbarFrame.getLayoutParams();
appbarParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
binding.appbar.toolbarFrame.setLayoutParams(appbarParams);
binding.appbar.appbar.setExpanded(true, false);
}
@Override
@@ -2098,10 +2118,9 @@ public class FileDisplayActivity extends FileActivity
return; // not reachable under normal conditions
}
if (showPreview && file.isDown() && !file.isDownloading() || streamMedia) {
showSortListGroup(false);
configureToolbarForMediaPreview(file);
Fragment mediaFragment = PreviewMediaFragment.newInstance(file, user.get(), startPlaybackPosition, autoplay);
setLeftFragment(mediaFragment);
configureToolbarForMediaPreview(file);
} else {
Intent previewIntent = new Intent();
previewIntent.putExtra(EXTRA_FILE, file);
@@ -2116,7 +2135,7 @@ public class FileDisplayActivity extends FileActivity
public void configureToolbarForMediaPreview(OCFile file) {
showSortListGroup(false);
((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams()).setBehavior(null);
lockScrolling();
super.updateActionBarTitleAndHomeButton(file);
}
@@ -2243,11 +2262,15 @@ public class FileDisplayActivity extends FileActivity
}
private void syncAndUpdateFolder(boolean ignoreETag) {
syncAndUpdateFolder(ignoreETag, false);
}
private void syncAndUpdateFolder(boolean ignoreETag, boolean ignoreFocus) {
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null && !listOfFiles.isSearchFragment()) {
OCFile folder = listOfFiles.getCurrentFile();
if (folder != null) {
startSyncFolderOperation(folder, ignoreETag);
startSyncFolderOperation(folder, ignoreETag, ignoreFocus);
}
}
}
@@ -2268,8 +2291,10 @@ public class FileDisplayActivity extends FileActivity
public void onMessageEvent(final SearchEvent event) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
Log_OC.d(this, "Switch to photo search fragment");
setLeftFragment(new GalleryFragment());
} else if (event.getSearchType() == SearchRemoteOperation.SearchType.SHARED_FILTER) {
Log_OC.d(this, "Switch to Shared fragment");
setLeftFragment(new SharedListFragment());
}
}
@@ -56,10 +56,6 @@ import com.owncloud.android.utils.DataHolderUtil;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.ErrorMessageAdapter;
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import com.owncloud.android.utils.theme.ThemeUtils;
import java.io.File;
import java.util.ArrayList;
@@ -133,11 +129,11 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
mDoNotEnterEncryptedFolder = true;
break;
default:
caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
caption = themeUtils.getDefaultDisplayNameForRootFolder(this);
break;
}
} else {
caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
caption = themeUtils.getDefaultDisplayNameForRootFolder(this);
}
if (getIntent().getParcelableExtra(EXTRA_CURRENT_FOLDER) != null) {
@@ -385,9 +381,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
actionBar.setDisplayHomeAsUpEnabled(!atRoot);
actionBar.setHomeButtonEnabled(!atRoot);
ThemeToolbarUtils.tintBackButton(actionBar, this);
themeToolbarUtils.tintBackButton(actionBar, this);
ThemeToolbarUtils.setColoredTitle(getSupportActionBar(), atRoot ? caption : currentDir.getFileName(), this);
themeToolbarUtils.setColoredTitle(getSupportActionBar(), atRoot ? caption : currentDir.getFileName(), this);
}
}
@@ -399,15 +395,15 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
if (mChooseBtn != null) {
ThemeButtonUtils.colorPrimaryButton(mChooseBtn, this);
themeButtonUtils.colorPrimaryButton(mChooseBtn, this, themeColorUtils);
mChooseBtn.setOnClickListener(this);
}
if (mCancelBtn != null) {
if (this instanceof FilePickerActivity) {
ThemeButtonUtils.colorPrimaryButton(mCancelBtn, this);
themeButtonUtils.colorPrimaryButton(mCancelBtn, this, themeColorUtils);
} else {
mCancelBtn.setTextColor(ThemeColorUtils.primaryColor(this, true));
mCancelBtn.setTextColor(themeColorUtils.primaryColor(this, true));
}
mCancelBtn.setOnClickListener(this);
}
@@ -520,11 +516,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
/// TODO refactor and make common
syncResult != null && !syncResult.isSuccess()) {
if (ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) || (syncResult.isException()
if (ResultCode.UNAUTHORIZED == syncResult.getCode() || (syncResult.isException()
&& syncResult.getException() instanceof AuthenticatorException)) {
requestCredentialsUpdate(context);
} else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
.equals(syncResult.getCode())) {
} else if (ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult.getCode()) {
showUntrustedCertDialog(syncResult);
}
@@ -45,6 +45,7 @@ import com.nextcloud.client.onboarding.FirstRunActivity;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.files.services.FileDownloader;
@@ -58,7 +59,6 @@ import com.owncloud.android.ui.adapter.UserListItem;
import com.owncloud.android.ui.dialog.AccountRemovalConfirmationDialog;
import com.owncloud.android.ui.events.AccountRemovedEvent;
import com.owncloud.android.ui.helpers.FileOperationsHelper;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
@@ -135,7 +135,7 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
// set title Action bar
updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.prefs_manage_accounts));
ThemeToolbarUtils.tintBackButton(actionBar, this);
themeToolbarUtils.tintBackButton(actionBar, this);
List<User> users = accountManager.getAllUsers();
originalUsers = toAccountNames(users);
@@ -153,7 +153,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
accountManager,
getUserListItems(),
this,
multipleAccountsSupported, true);
multipleAccountsSupported,
true,
themeColorUtils,
themeDrawableUtils);
recyclerView.setAdapter(userListAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
@@ -180,11 +183,18 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
@Override
public void onBackPressed() {
Intent resultIntent = new Intent();
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, hasAccountListChanged());
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, hasCurrentAccountChanged());
setResult(RESULT_OK, resultIntent);
if (accountManager.getAllUsers().size() > 0) {
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, hasAccountListChanged());
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, hasCurrentAccountChanged());
setResult(RESULT_OK, resultIntent);
super.onBackPressed();
super.onBackPressed();
} else {
final Intent intent = new Intent(this, AuthenticatorActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
}
/**
@@ -298,7 +308,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
accountManager,
getUserListItems(),
this,
multipleAccountsSupported, false);
multipleAccountsSupported,
false,
themeColorUtils,
themeDrawableUtils);
recyclerView.setAdapter(userListAdapter);
runOnUiThread(() -> userListAdapter.notifyDataSetChanged());
} catch (OperationCanceledException e) {
@@ -322,23 +335,23 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
public void run(AccountManagerFuture<Boolean> future) {
if (future.isDone()) {
// after remove account
Account account = new Account(accountName, MainApp.getAccountType(this));
if (!accountManager.exists(account)) {
Optional<User> user = accountManager.getUser(accountName);
if (!user.isPresent()) {
// Cancel transfers of the removed account
if (mUploaderBinder != null) {
mUploaderBinder.cancel(account);
mUploaderBinder.cancel(accountName);
}
if (mDownloaderBinder != null) {
mDownloaderBinder.cancel(account);
mDownloaderBinder.cancel(accountName);
}
}
User user = getUserAccountManager().getUser();
if (user.isAnonymous()) {
User currentUser = getUserAccountManager().getUser();
if (currentUser.isAnonymous()) {
String accountName = "";
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
if (accounts.length != 0) {
accountName = accounts[0].name;
List<User> users = accountManager.getAllUsers();
if (users.size() > 0) {
accountName = users.get(0).getAccountName();
}
accountManager.setCurrentOwnCloudAccount(accountName);
}
@@ -349,7 +362,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
accountManager,
userListItemArray,
this,
multipleAccountsSupported, false);
multipleAccountsSupported,
false,
themeColorUtils,
themeDrawableUtils);
recyclerView.setAdapter(userListAdapter);
} else {
onBackPressed();
@@ -418,10 +434,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
// Cancel transfers
if (mUploaderBinder != null) {
mUploaderBinder.cancel(user.toPlatformAccount());
mUploaderBinder.cancel(user);
}
if (mDownloaderBinder != null) {
mDownloaderBinder.cancel(user.toPlatformAccount());
mDownloaderBinder.cancel(user.getAccountName());
}
backgroundJobManager.startAccountRemovalJob(user.getAccountName(), false);
@@ -49,7 +49,6 @@ import com.owncloud.android.ui.asynctasks.DeleteAllNotificationsTask;
import com.owncloud.android.ui.notifications.NotificationsContract;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PushUtils;
import com.owncloud.android.utils.theme.ThemeLayoutUtils;
import java.util.List;
@@ -101,8 +100,8 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_notifications));
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingEmpty);
themeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
themeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingEmpty);
// setup drawer
setupDrawer(R.id.nav_notifications);
@@ -259,7 +258,7 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
private void initializeAdapter() {
initializeClient();
if (adapter == null) {
adapter = new NotificationListAdapter(client, this);
adapter = new NotificationListAdapter(client, this, themeColorUtils, themeButtonUtils);
binding.list.setAdapter(adapter);
}
}
Loaded 100 of 333 files, more files were not shown because too many files have changed in this diff. Show more