Compare commits

...
Author SHA1 Message Date
Tobias Kaminsky 30f96aa984 daily dev 20191129
2c57e3709 Merge pull request #4784 from nextcloud/hideAutoUploadEntries
5257fb236 [tx-robot] updated from transifex
aa431815a Merge pull request #4882 from nextcloud/dependabot/gradle/com.google.android-flexbox-2.0.0
1f4e85768 Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
d17c85349 re-add button/action and improve upon code review
74bfe473c remove action button, use checkable menu item for shown/hidden state display
3e872df68 add more spotbug exclusions (for 3rd party libs)
4e0b40517 Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
7c62ad6b0 unify use of boolean, make use of lombok getter/setters, remove unneeded boolean boxing
bedc2b48e housekeeping, removing unused resources
ca6918f9f show/hide improvements when list is completed hidden + nicer empty UI + action button
23e44243d show/hide auto upload list items
540c649ef Merge pull request #4894 from nextcloud/dependabot/gradle/kotlin_version-1.3.61
f34ba2cdc Bump kotlin_version from 1.3.60 to 1.3.61
48038d564 Merge pull request #4883 from nextcloud/dependabot/gradle/io.gitlab.arturbosch.detekt-detekt-gradle-plugin-1.2.0
83e0ebc46 [tx-robot] updated from transifex
21c0de3cd daily dev 20191127
2019-11-29 03:39:58 +01:00
Tobias Kaminsky 2c57e37097 Merge pull request #4784 from nextcloud/hideAutoUploadEntries
Show/Hide auto upload list items
2019-11-28 08:19:15 +01:00
Nextcloud bot 5257fb236c [tx-robot] updated from transifex 2019-11-28 03:14:35 +00:00
Andy Scherzinger aa431815aa Merge pull request #4882 from nextcloud/dependabot/gradle/com.google.android-flexbox-2.0.0
Bump flexbox from 1.1.1 to 2.0.0
2019-11-27 23:36:39 +01:00
nextcloud-android-bot 1f4e857681 Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
Signed-off-by: nextcloud-android-bot <[email protected]>
2019-11-27 20:55:41 +00:00
Andy Scherzinger d17c853493 re-add button/action and improve upon code review
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:43:53 +01:00
Andy Scherzinger 74bfe473c4 remove action button, use checkable menu item for shown/hidden state display
(design review)

Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:35:31 +01:00
Andy Scherzinger 3e872df68c add more spotbug exclusions (for 3rd party libs)
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:35:19 +01:00
nextcloud-android-bot 4e0b40517c Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
Signed-off-by: nextcloud-android-bot <[email protected]>
2019-11-27 21:35:18 +01:00
Andy Scherzinger 7c62ad6b06 unify use of boolean, make use of lombok getter/setters, remove unneeded boolean boxing
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:35:05 +01:00
Andy Scherzinger bedc2b48ee housekeeping, removing unused resources
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:35:05 +01:00
Andy Scherzinger ca6918f9fc show/hide improvements when list is completed hidden + nicer empty UI + action button
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:35:03 +01:00
Andy Scherzinger 23e44243da show/hide auto upload list items
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-27 21:34:40 +01:00
Andy Scherzinger 540c649efe Merge pull request #4894 from nextcloud/dependabot/gradle/kotlin_version-1.3.61
Bump kotlin_version from 1.3.60 to 1.3.61
2019-11-27 20:16:12 +01:00
dependabot-preview[bot] f34ba2cdca Bump kotlin_version from 1.3.60 to 1.3.61
Bumps `kotlin_version` from 1.3.60 to 1.3.61.

Updates `kotlin-gradle-plugin` from 1.3.60 to 1.3.61

Updates `kotlin-stdlib-jdk7` from 1.3.60 to 1.3.61
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.3.61/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.60...v1.3.61)

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-27 13:03:07 +00:00
Tobias Kaminsky 48038d564e Merge pull request #4883 from nextcloud/dependabot/gradle/io.gitlab.arturbosch.detekt-detekt-gradle-plugin-1.2.0
Bump detekt-gradle-plugin from 1.1.1 to 1.2.0
2019-11-27 14:01:50 +01:00
Nextcloud bot 83e0ebc463 [tx-robot] updated from transifex 2019-11-27 03:10:14 +00:00
Tobias Kaminsky 21c0de3cdd daily dev 20191127
e92daa2fc Merge pull request #4853 from nextcloud/migrate-simple-cases-of-get-current-account-to-get-user
99d9a6923 Merge pull request #4885 from nextcloud/disable_android_backup_qa
10960bf3a [tx-robot] updated from transifex
9f24b254f [tx-robot] updated from transifex
b7876c425 disable GoogleAppIndexingWarning lint check
11687c65c Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
80fb800ef Merge commit 'a7eb7148fa0ceb42981366eb2ddcf0ff921e6a55'
b91136c36 Disable android backup on the QA app
a7eb7148f Migrate simple cases of getCurrentAccount() to getUser()
6249a06a8 daily dev 20191123
2019-11-27 03:37:10 +01:00
Tobias Kaminsky e92daa2fc4 Merge pull request #4853 from nextcloud/migrate-simple-cases-of-get-current-account-to-get-user
Migrate simple cases of get current account to get user
2019-11-26 14:04:32 +01:00
Andy Scherzinger 99d9a6923e Merge pull request #4885 from nextcloud/disable_android_backup_qa
Disable android backup on the QA app
2019-11-26 08:47:53 +01:00
Nextcloud bot 10960bf3a2 [tx-robot] updated from transifex 2019-11-26 03:10:16 +00:00
Nextcloud bot 9f24b254f9 [tx-robot] updated from transifex 2019-11-25 14:33:17 +00:00
tobiasKaminsky b7876c4252 disable GoogleAppIndexingWarning lint check
Signed-off-by: tobiasKaminsky <[email protected]>
2019-11-25 15:26:08 +01:00
nextcloud-android-bot 11687c65cb Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
Signed-off-by: nextcloud-android-bot <[email protected]>
2019-11-25 12:22:26 +00:00
drone 80fb800ef1 Merge commit 'a7eb7148fa0ceb42981366eb2ddcf0ff921e6a55' 2019-11-25 12:08:09 +00:00
Alice Gaudon b91136c362 Disable android backup on the QA app
Signed-off-by: Alice Gaudon <[email protected]>
2019-11-25 10:22:12 +01:00
Chris Narkiewicz a7eb7148fa Migrate simple cases of getCurrentAccount() to getUser()
Migrate trivially convertible uses of getCurrentAccount()
to new user model - getUser().

Signed-off-by: Chris Narkiewicz <[email protected]>
2019-11-25 08:53:50 +00:00
dependabot-preview[bot] 4f26261bf8 Bump detekt-gradle-plugin from 1.1.1 to 1.2.0
Bumps detekt-gradle-plugin from 1.1.1 to 1.2.0.

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-25 02:15:52 +00:00
dependabot-preview[bot] 0691786fb8 Bump flexbox from 1.1.1 to 2.0.0
Bumps [flexbox](https://github.com/google/flexbox-layout) from 1.1.1 to 2.0.0.
- [Release notes](https://github.com/google/flexbox-layout/releases)
- [Commits](https://github.com/google/flexbox-layout/compare/1.1.1...2.0.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-25 02:15:12 +00:00
Tobias Kaminsky 6249a06a8d daily dev 20191123
c8eba1d5a Merge pull request #4835 from nextcloud/ezaquarii/new-user-model
609b99666 New user model
44220d73f Merge pull request #4867 from nextcloud/dependabot/gradle/androidx.exifinterface-exifinterface-1.1.0
6e5d7a89c daily dev 20191121
2019-11-23 03:36:58 +01:00
Tobias Kaminsky c8eba1d5ad Merge pull request #4835 from nextcloud/ezaquarii/new-user-model
New user model
2019-11-22 07:57:04 +01:00
Chris Narkiewicz 609b99666f New user model
New non-nullable user model abstracts away all complexities of Nextcloud
user account and provides.

- backported java.util.Optional
- extended UserAccountManager with User getters
- deprecated CurrentAccountProvider.getCurrentAccount() method
- migrated connectivity service to new user model
- migrated UploadsStorageManager to new user model
- migrated OCFileListAdapter

Signed-off-by: Chris Narkiewicz <[email protected]>
2019-11-21 19:58:57 +00:00
Tobias Kaminsky 44220d73fe Merge pull request #4867 from nextcloud/dependabot/gradle/androidx.exifinterface-exifinterface-1.1.0
Bump exifinterface from 1.0.0 to 1.1.0
2019-11-21 10:05:00 +01:00
Tobias Kaminsky 6e5d7a89c1 daily dev 20191121
b9ff6cecf Merge pull request #4843 from Unpublished/fix4842
0977c9d2e daily dev 20191120
2019-11-21 03:37:08 +01:00
dependabot-preview[bot] 16c220e7af Bump exifinterface from 1.0.0 to 1.1.0
Bumps exifinterface from 1.0.0 to 1.1.0.

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-21 02:16:42 +00:00
Tobias Kaminsky b9ff6cecfc Merge pull request #4843 from Unpublished/fix4842
Use png instead of vector drawable for bitmap
2019-11-20 16:09:22 +01:00
Tobias Kaminsky 0977c9d2e1 daily dev 20191120
21ef00654 Merge pull request #4858 from nextcloud/changeScreenshot
0223085a8 shorten text a bit
8879179cf Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
94502f66b Merge pull request #4787 from ArisuOngaku/auto-upload-start-date-persistence
21109375c Merge pull request #4839 from nextcloud/dependabot/gradle/markwonVersion-4.2.0
f1a0ac5c2 [tx-robot] updated from transifex
a00677cd6 daily dev 20191119
2019-11-20 03:37:09 +01:00
Unpublished 26c5c5e015 Use png for checker image to use it via bitmap
Signed-off-by: Unpublished <[email protected]>
2019-11-19 20:10:19 +01:00
Andy Scherzinger 21ef006544 Merge pull request #4858 from nextcloud/changeScreenshot
Screenshots: shorten text a bit
2019-11-19 17:45:37 +01:00
tobiasKaminsky 0223085a8d shorten text a bit
Signed-off-by: tobiasKaminsky <[email protected]>
2019-11-19 14:35:31 +01:00
nextcloud-android-bot 8879179cff Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
Signed-off-by: nextcloud-android-bot <[email protected]>
2019-11-19 12:28:44 +00:00
Tobias Kaminsky 94502f66b5 Merge pull request #4787 from ArisuOngaku/auto-upload-start-date-persistence
Make synced folder init/enable date persistent
2019-11-19 13:21:43 +01:00
Tobias Kaminsky 21109375c3 Merge pull request #4839 from nextcloud/dependabot/gradle/markwonVersion-4.2.0
Bump markwonVersion from 4.1.2 to 4.2.0
2019-11-19 07:44:51 +01:00
Nextcloud bot f1a0ac5c26 [tx-robot] updated from transifex 2019-11-19 03:10:54 +00:00
Tobias Kaminsky a00677cd63 daily dev 20191119
dbe12e6d2 Merge pull request #4789 from nextcloud/name_pattern_menus
77b6b178a Merge pull request #4841 from nextcloud/disableOldLoginMethod
b561f6883 allow to switch off old login method
b59d96ace [tx-robot] updated from transifex
9ae550731 [tx-robot] updated from transifex
bfdaba8bd [tx-robot] updated from transifex
c82c08059 daily dev 20191116
2019-11-19 03:37:08 +01:00
Tobias Kaminsky dbe12e6d20 Merge pull request #4789 from nextcloud/name_pattern_menus
Improve menu file name pattern
2019-11-18 15:26:35 +01:00
Tobias Kaminsky 77b6b178a9 Merge pull request #4841 from nextcloud/disableOldLoginMethod
allow to switch off old login method
2019-11-18 13:51:38 +01:00
tobiasKaminsky b561f68834 allow to switch off old login method
Signed-off-by: tobiasKaminsky <[email protected]>
2019-11-18 10:13:09 +01:00
Nextcloud bot b59d96ace0 [tx-robot] updated from transifex 2019-11-18 03:09:26 +00:00
dependabot-preview[bot] b6d682683c Bump markwonVersion from 4.1.2 to 4.2.0
Bumps `markwonVersion` from 4.1.2 to 4.2.0.

Updates `core` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/noties/Markwon/releases)
- [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/noties/Markwon/compare/v4.1.2...v4.2.0)

Updates `ext-strikethrough` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/noties/Markwon/releases)
- [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/noties/Markwon/compare/v4.1.2...v4.2.0)

Updates `ext-tables` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/noties/Markwon/releases)
- [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/noties/Markwon/compare/v4.1.2...v4.2.0)

Updates `ext-tasklist` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/noties/Markwon/releases)
- [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/noties/Markwon/compare/v4.1.2...v4.2.0)

Updates `html` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/noties/Markwon/releases)
- [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/noties/Markwon/compare/v4.1.2...v4.2.0)

Updates `syntax-highlight` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/noties/Markwon/releases)
- [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/noties/Markwon/compare/v4.1.2...v4.2.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-18 02:15:46 +00:00
Nextcloud bot 9ae550731e [tx-robot] updated from transifex 2019-11-17 03:12:24 +00:00
Nextcloud bot bfdaba8bde [tx-robot] updated from transifex 2019-11-16 03:09:26 +00:00
Tobias Kaminsky c82c08059a daily dev 20191116
5273e1e7f Merge pull request #4832 from nextcloud/dependabot/gradle/kotlin_version-1.3.60
bd503a86c [tx-robot] updated from transifex
20c9ce361 Bump kotlin_version from 1.3.50 to 1.3.60
3943e1c75 [tx-robot] updated from transifex
75de7b88d daily dev 20191114
2019-11-16 03:40:11 +01:00
Alice Gaudon 65da616f81 FilesSyncHelper: use our own logging framework
Signed-off-by: Alice Gaudon <[email protected]>
2019-11-15 07:56:17 +01:00
Andy Scherzinger 5273e1e7fc Merge pull request #4832 from nextcloud/dependabot/gradle/kotlin_version-1.3.60
Bump kotlin_version from 1.3.50 to 1.3.60
2019-11-15 07:36:39 +01:00
Nextcloud bot bd503a86c7 [tx-robot] updated from transifex 2019-11-15 03:10:28 +00:00
dependabot-preview[bot] 20c9ce361a Bump kotlin_version from 1.3.50 to 1.3.60
Bumps `kotlin_version` from 1.3.50 to 1.3.60.

Updates `kotlin-gradle-plugin` from 1.3.50 to 1.3.60
- [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-jdk7` from 1.3.50 to 1.3.60
- [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)

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-15 02:18:56 +00:00
Nextcloud bot 3943e1c753 [tx-robot] updated from transifex 2019-11-14 03:10:34 +00:00
Tobias Kaminsky 75de7b88d4 daily dev 20191114
ed8b9cbb7 Merge pull request #4713 from nextcloud/ezaquarii/remove-set-account-from-first-run-activity
f38900d98 [tx-robot] updated from transifex
e43ef8e06 daily dev 20191113
2019-11-14 03:36:56 +01:00
Andy Scherzinger 693f408276 Improve menu file name pattern
Signed-off-by: Andy Scherzinger <[email protected]>
2019-11-13 11:47:23 +01:00
Tobias Kaminsky ed8b9cbb72 Merge pull request #4713 from nextcloud/ezaquarii/remove-set-account-from-first-run-activity
Remove out of band setAccount/onAccountSet calls
2019-11-13 10:02:29 +01:00
Nextcloud bot f38900d989 [tx-robot] updated from transifex 2019-11-13 03:10:02 +00:00
Tobias Kaminsky e43ef8e062 daily dev 20191113
f245b72de Merge pull request #4823 from nextcloud/changelog-master-stable-3.9.0
d30b574ff Add changelog for 3.9.0
df6d847f2 [tx-robot] updated from transifex
4343c3d67 Merge pull request #4814 from nextcloud/dependabot/gradle/org.jetbrains-annotations-18.0.0
86027dd09 Bump annotations from 17.0.0 to 18.0.0
4690042b0 [tx-robot] updated from transifex
ff646aa3d daily dev 20191108
2019-11-13 03:37:07 +01:00
Andy Scherzinger f245b72ded Merge pull request #4823 from nextcloud/changelog-master-stable-3.9.0
Add changelog for 3.9.0
2019-11-12 12:37:16 +01:00
tobiasKaminsky d30b574ff6 Add changelog for 3.9.0
Signed-off-by: tobiasKaminsky <[email protected]>
2019-11-12 10:53:05 +01:00
Chris Narkiewicz fb615ef279 Remove out-of-band setAccount/onAccountSet calls
Activity account is set in FilesActivity.onAccount(),
but related components are updated in BaseActivity.onStart().

1. Initialize account in BaseActivity.onCreate()
2. Update storage manager and capabilities immediately
   on account set, not waiting for onStart() lifecycle.
3. inline storage manager and capabilities update in setAccount()
4. Remove setAccount()/onAccountSet() calls that sets default
   account, as this duplicates BaseActivity.onCreate()

Signed-off-by: Chris Narkiewicz <[email protected]>
2019-11-12 06:21:05 +00:00
Nextcloud bot df6d847f29 [tx-robot] updated from transifex 2019-11-12 03:11:59 +00:00
Tobias Kaminsky 4343c3d67f Merge pull request #4814 from nextcloud/dependabot/gradle/org.jetbrains-annotations-18.0.0
Bump annotations from 17.0.0 to 18.0.0
2019-11-11 10:14:50 +01:00
dependabot-preview[bot] 86027dd091 Bump annotations from 17.0.0 to 18.0.0
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 17.0.0 to 18.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Commits](https://github.com/JetBrains/java-annotations/compare/17.0.0...18.0.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-11 02:14:20 +00:00
Nextcloud bot 4690042b06 [tx-robot] updated from transifex 2019-11-10 03:14:29 +00:00
Tobias Kaminsky ff646aa3d0 daily dev 20191108
403fc8756 [tx-robot] updated from transifex
142c79bc0 daily dev 20191107
2019-11-08 03:38:19 +01:00
Nextcloud bot 403fc87562 [tx-robot] updated from transifex 2019-11-07 03:08:34 +00:00
Tobias Kaminsky 142c79bc03 daily dev 20191107
890789f0a Merge pull request #4797 from nextcloud/ezaquarii/replace-shared-preferences-with-app-preferences-in-base-activity
180bdee72 Merge pull request #4801 from Infomaniak/feature/resolve-set-as-wallpaper-issue
039adc0a1 [tx-robot] updated from transifex
b59938d96 daily dev 20191106
2019-11-07 03:36:57 +01:00
Tobias Kaminsky 890789f0a7 Merge pull request #4797 from nextcloud/ezaquarii/replace-shared-preferences-with-app-preferences-in-base-activity
Replace BaseActivity.sharedPreferences with app preferences
2019-11-06 13:52:54 +01:00
Tobias Kaminsky 180bdee721 Merge pull request #4801 from Infomaniak/feature/resolve-set-as-wallpaper-issue
Fixing picture "set as wallpaper" issue in properties (duplicate)
2019-11-06 13:48:23 +01:00
Nextcloud bot 039adc0a18 [tx-robot] updated from transifex 2019-11-06 03:10:30 +00:00
Tobias Kaminsky b59938d960 daily dev 20191106
9e15f5ea3 Merge pull request #4799 from nextcloud/dependabot/gradle/com.android.tools.build-gradle-3.5.2
d208681fe Merge pull request #4796 from nextcloud/datepicker
7a8aee3e2 [tx-robot] updated from transifex
a3ae32129 Bump gradle from 3.5.1 to 3.5.2
b0563b931 Theming: Fix date picker button text colour
207f8947c [tx-robot] updated from transifex
1ec09848b [tx-robot] updated from transifex
513151491 [tx-robot] updated from transifex
38a83bb36 daily dev 20191102
2019-11-06 03:39:59 +01:00
Alice Gaudon 2e13212752 SyncedFolderProvider: pass Clock dependency via constructor instead of dagger
Signed-off-by: Alice Gaudon <[email protected]>
2019-11-06 01:59:06 +01:00
Alice Gaudon c2ea4de802 FileContentProvider: add dagger injection
Signed-off-by: Alice Gaudon <[email protected]>
2019-11-06 01:50:32 +01:00
Alice Gaudon 7f4db3fdd0 Make synced folder init/enable date persistent
Signed-off-by: Alice Gaudon <[email protected]>
2019-11-05 21:23:45 +01:00
Andy Scherzinger 9e15f5ea39 Merge pull request #4799 from nextcloud/dependabot/gradle/com.android.tools.build-gradle-3.5.2
Bump gradle from 3.5.1 to 3.5.2
2019-11-05 20:35:08 +01:00
Tobias Kaminsky d208681fed Merge pull request #4796 from nextcloud/datepicker
Theming: Fix date picker button text colour
2019-11-05 20:10:13 +01:00
Kilian Périsset 25aaf4b907 Applied ability to set as wallpaper from properties of a picture
Signed-off-by: Kilian Périsset <[email protected]>
2019-11-05 14:20:35 +01:00
Chris Narkiewicz 6b01382e7f Replace BaseActivity.sharedPreferences with app preferences
- Eliminate access to shared preferences when setting dark theme.
- Extend AppPreferences interface to allow subscription for preference changes
- Improve preferences interface documentation

Fixes #4791

Signed-off-by: Chris Narkiewicz <[email protected]>
2019-11-05 06:00:58 +00:00
Nextcloud bot 7a8aee3e22 [tx-robot] updated from transifex 2019-11-05 03:07:49 +00:00
dependabot-preview[bot] a3ae32129d Bump gradle from 3.5.1 to 3.5.2
Bumps gradle from 3.5.1 to 3.5.2.

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-11-05 02:19:42 +00:00
Daniel Bailey b0563b9310 Theming: Fix date picker button text colour
Signed-off-by: Daniel Bailey <[email protected]>
2019-11-04 14:52:54 +00:00
Nextcloud bot 207f8947cf [tx-robot] updated from transifex 2019-11-04 03:10:40 +00:00
Nextcloud bot 1ec09848b6 [tx-robot] updated from transifex 2019-11-03 03:12:13 +00:00
Nextcloud bot 5131514917 [tx-robot] updated from transifex 2019-11-02 03:06:45 +00:00
Tobias Kaminsky 38a83bb361 daily dev 20191102
62fc6fa53 Merge pull request #4782 from nextcloud/internalLinkWording
71264e19b use file/folder in "copy internal link" description
bd3ce6098 Merge pull request #4777 from nextcloud/v16
327817c04 [tx-robot] updated from transifex
a39022fbb daily dev 20191101
2019-11-02 03:38:27 +01:00
Tobias Kaminsky 62fc6fa53d Merge pull request #4782 from nextcloud/internalLinkWording
use file/folder in "copy internal link" description
2019-11-01 15:17:11 +01:00
tobiasKaminsky 71264e19b8 use file/folder in "copy internal link" description
Signed-off-by: tobiasKaminsky <[email protected]>
2019-11-01 12:32:07 +01:00
Tobias Kaminsky bd3ce60985 Merge pull request #4777 from nextcloud/v16
Make Android v16/JellyBean the new min-supported Android version
2019-11-01 09:11:36 +01:00
Nextcloud bot 327817c047 [tx-robot] updated from transifex 2019-11-01 02:59:14 +00:00
Tobias Kaminsky a39022fbbe daily dev 20191101
e3280b0bb Merge pull request #4775 from nextcloud/dependabot/gradle/com.h3xstream.findsecbugs-findsecbugs-plugin-1.10.1
575cd014d Bump findsecbugs-plugin from 1.10.0 to 1.10.1
946e5c2c1 Merge pull request #4768 from nextcloud/colorNames
78ed97ca0 [tx-robot] updated from transifex
f77b5bd4b daily dev 20191031
2019-11-01 03:38:35 +01:00
Andy Scherzinger d3d0df46f1 make Android v16/JellyBean the new min-supported Android version
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-31 23:36:06 +01:00
Andy Scherzinger e3280b0bb7 Merge pull request #4775 from nextcloud/dependabot/gradle/com.h3xstream.findsecbugs-findsecbugs-plugin-1.10.1
Bump findsecbugs-plugin from 1.10.0 to 1.10.1
2019-10-31 23:35:36 +01:00
dependabot-preview[bot] 575cd014d2 Bump findsecbugs-plugin from 1.10.0 to 1.10.1
Bumps [findsecbugs-plugin](https://github.com/find-sec-bugs/find-sec-bugs) from 1.10.0 to 1.10.1.
- [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/compare/version-1.10.0...version-1.10.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-10-31 22:06:14 +00:00
Andy Scherzinger 946e5c2c1e Merge pull request #4768 from nextcloud/colorNames
consistently use snake_case for color resources
2019-10-31 08:51:59 +01:00
Nextcloud bot 78ed97ca07 [tx-robot] updated from transifex 2019-10-31 03:00:33 +00:00
Tobias Kaminsky f77b5bd4b8 daily dev 20191031
c4e20a652 Merge pull request #4762 from nextcloud/color
af63eed65 overwrite in values-night/colors only values that differ move branding colors back to setup.xml
a9fcc7b03 daily dev 20191030
2019-10-31 03:36:52 +01:00
Andy Scherzinger fe353a7561 consistently use snake_case for color resources
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-30 16:13:29 +01:00
Tobias Kaminsky c4e20a652d Merge pull request #4762 from nextcloud/color
Dark theme: color enhancements
2019-10-30 11:08:30 +01:00
tobiasKaminsky af63eed654 overwrite in values-night/colors only values that differ
move branding colors back to setup.xml

Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-30 09:32:58 +01:00
Tobias Kaminsky a9fcc7b03a daily dev 20191030
2a43da6bd Merge pull request #4746 from nextcloud/createChooser
f8d7ddd9d Merge pull request #4758 from nextcloud/fixDarkTheme
bee8770ce - fix typo in styles - fix sign up with provider in dark primary color
cc710b09c Merge pull request #3459 from nextcloud/dark_theme
c1aa005db changes due to code review
c801a2c7b Merge pull request #4744 from nextcloud/v3100_Alpha1
12fe91a6d use default open chooser with "just once", "always"
8b4481f7f [tx-robot] updated from transifex
2ea1f4e59 daily dev 20191029
2019-10-30 03:37:08 +01:00
Andy Scherzinger 2a43da6bdf Merge pull request #4746 from nextcloud/createChooser
use default open chooser with "just once", "always"
2019-10-29 16:23:00 +01:00
Andy Scherzinger f8d7ddd9de Merge pull request #4758 from nextcloud/fixDarkTheme
Fix dark theme #1
2019-10-29 14:01:49 +01:00
tobiasKaminsky bee8770ce0 - fix typo in styles
- fix sign up with provider in dark primary color

Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-29 11:27:03 +01:00
Tobias Kaminsky cc710b09cb Merge pull request #3459 from nextcloud/dark_theme
Dark theme
2019-10-29 11:18:48 +01:00
Andy Scherzinger c1aa005db9 changes due to code review
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-29 11:05:44 +01:00
Tobias Kaminsky c801a2c7bb Merge pull request #4744 from nextcloud/v3100_Alpha1
bump to 3.10.0 Alpha1
2019-10-29 07:57:26 +01:00
tobiasKaminsky 12fe91a6dd use default open chooser with "just once", "always"
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-29 07:28:51 +01:00
Nextcloud bot 8b4481f7fd [tx-robot] updated from transifex 2019-10-29 03:08:13 +00:00
Tobias Kaminsky 2ea1f4e593 daily dev 20191029
cabe2fcff Merge pull request #4725 from nextcloud/ssoHeaders
8e3931edf SSO: return response headers new headers in parallel
98487b501 Merge pull request #4733 from nextcloud/codacy
17709cc69 [tx-robot] updated from transifex
2bb13a154 move suppress annotation to newly created method
a098a5cf2 [tx-robot] updated from transifex
a6fdec865 shorten method
1d3fca653 codacy: Avoid declaring a variable if it is unreferenced before a possible exit point.
816991c17 codacy: avoid unused imports
ba3c2ca8b daily dev 20191026
2019-10-29 03:36:45 +01:00
Andy Scherzinger ee10f7c0d9 bump to 3.10.0 Alpha1
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 22:37:00 +01:00
Andy Scherzinger 3de5e8fa52 remove possible overdraws
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 22:24:44 +01:00
Andy Scherzinger ae2dcbea33 align user info toolbar theming with main toolbar theming
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 18:11:36 +01:00
Andy Scherzinger 48e1384219 make circular checkIcon background day/night aware
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 17:48:25 +01:00
Tobias Kaminsky cabe2fcff0 Merge pull request #4725 from nextcloud/ssoHeaders
SSO: return response headers
2019-10-28 16:12:32 +01:00
Andy Scherzinger 2021da0a8b proper contacts backup button theming
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 15:36:30 +01:00
Andy Scherzinger 48b43581cc proper button theming for notification actions
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 15:36:06 +01:00
tobiasKaminsky 8e3931edf6 SSO: return response headers
new headers in parallel

Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-28 14:48:24 +01:00
Daniel Bailey 9a9e0e6c42 Merge branch 'dark_theme' of github.com:nextcloud/android into dark_theme
Signed-off-by: Daniel Bailey <[email protected]>
2019-10-28 13:32:14 +00:00
Daniel Bailey 853d7cd113 Dark theme updates
TextInputLayout in share password dialog is styled to match the app.
Receive files picker shows server primary colour on Upload button.

Signed-off-by: Daniel Bailey <[email protected]>
2019-10-28 13:03:19 +00:00
Daniel Bailey 4ce4027250 Update to Alert Dialogs in api 21 and upwards.
Signed-off-by: Daniel Bailey <[email protected]>
2019-10-28 12:59:34 +01:00
Andy Scherzinger b5d1de3601 bump material to 1.1.0-beta01
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:33 +01:00
Daniel Bailey 1615130093 Fix activity foreground text colour for >=API21.
Share expiration date picker now has buttons that are the primary
colour.

Theme change is now done in BaseActivity and ThemedPreferenceActivity.
This should help any activities in the back stack show the correct
theme.

Fixed style issues on firstrun and authenticator activities.

Signed-off-by: Daniel Bailey <[email protected]>
2019-10-28 12:59:32 +01:00
Andy Scherzinger a518885612 add dark/light theming for activities headline
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:32 +01:00
Andy Scherzinger f5a1a9a9cc bump to alpha10
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:31 +01:00
Andy Scherzinger 284bbf34e6 material design alpha09
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:30 +01:00
Andy Scherzinger 57db615a33 icons with light background need to be keep with dark color
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:29 +01:00
Andy Scherzinger cc2593cbdb proper icon display for night theme for activities and notifications
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:29 +01:00
Andy Scherzinger 44020dcc76 make progress bar day/night aware
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:28 +01:00
Andy Scherzinger 1e3f86cfe1 Bump material to alpha-08
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:27 +01:00
Andy Scherzinger 375fb97c06 use day/night color
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:27 +01:00
Andy Scherzinger cf839eac08 bump material lib to alpha07
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:26 +01:00
Andy Scherzinger 9a88ee24d3 remove unused radio button preference code
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:25 +01:00
Andy Scherzinger 110ce5e951 bump material lib to alpha06
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:24 +01:00
Andy Scherzinger 5554585348 make toolbar menu use the proper day/night popup theme
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:24 +01:00
Andy Scherzinger 1bdccebce8 use proper colors storage selector text
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:23 +01:00
Andy Scherzinger e14dc52fa7 use correct color after rebase
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:22 +01:00
Daniel Bailey 6bb9a70603 Various improvements to dark theme
Signed-off-by: Daniel Bailey <[email protected]>
2019-10-28 12:59:22 +01:00
Andy Scherzinger 6eb0744986 use proper color for storage location text
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:21 +01:00
Andy Scherzinger 8f8b67f57f don't tint avatars within the drawer menu
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:20 +01:00
Andy Scherzinger e32ec7a192 rebase fixing plus proper theming of legacy login fields
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:59:19 +01:00
Andy Scherzinger dc4cbb71e2 bump com.google.android.material:material to alpha5
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:52 +01:00
Daniel 689a0a216b "Activities" drawer selection background colour.
Signed-off-by: Daniel <[email protected]>
2019-10-28 12:58:51 +01:00
Andy Scherzinger b7e9d3f954 remove unused theme getter from interface
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:51 +01:00
Daniel Bailey 8d0ff8fecc Corrects "Choose" button colour in FolderPickerActivity. Removes un-used import from NotificationListAdapter.
MaterialButtons.
SearchView highlight text colour.
First run activity, outlined button colour.

Signed-off-by: Daniel Bailey <[email protected]>
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:50 +01:00
Andy Scherzinger c6218a0e5f bump material lib to alpha03
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:08 +01:00
Daniel Bailey c7049788f7 DatePickerDialog theme and style.
Button styling.
Small improvements to layouts and correction of spelling errors.
Sets edittext highlight colour to theme colour.

Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:07 +01:00
Andy Scherzinger 30a5ec6ee1 improve codacy score
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:07 +01:00
Andy Scherzinger 562338cad1 set background color for primary action buttons on upload and participate
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:06 +01:00
Andy Scherzinger 913d8276e1 use xml drawables for shared state icon including day/night state
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:05 +01:00
Andy Scherzinger 790e3fa2f8 findbugs: accesses list or array with constant index
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:04 +01:00
Andy Scherzinger 3d60c83ba2 use right colors for drawer menu item text and icons
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:04 +01:00
Andy Scherzinger 55a32df928 use style instead of theme attribute for secondary action buttons
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:58:03 +01:00
Daniel 27b8ed4327 Dark theme v1
Fixing migration to androidx
Dark theme styling
File details fragment tab text colour
File list overflow menu background colour

Signed-off-by: Daniel Bailey <[email protected]>
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-28 12:57:58 +01:00
Tobias Kaminsky 98487b501d Merge pull request #4733 from nextcloud/codacy
Codacy
2019-10-28 11:17:13 +01:00
Daniel Bailey bf0779a3ed Update to Alert Dialogs in api 21 and upwards.
Signed-off-by: Daniel Bailey <[email protected]>
2019-10-27 20:51:01 +00:00
Nextcloud bot 17709cc692 [tx-robot] updated from transifex 2019-10-27 03:06:49 +00:00
Andy Scherzinger 2bb13a1545 move suppress annotation to newly created method
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-26 09:36:58 +02:00
Nextcloud bot a098a5cf22 [tx-robot] updated from transifex 2019-10-26 03:08:29 +00:00
Andy Scherzinger a6fdec8656 shorten method
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-26 04:33:03 +02:00
Andy Scherzinger 1d3fca653f codacy: Avoid declaring a variable if it is unreferenced before a possible exit point.
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-26 04:22:34 +02:00
Andy Scherzinger 816991c172 codacy: avoid unused imports
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-26 04:20:27 +02:00
Tobias Kaminsky ba3c2ca8bc daily dev 20191026
4f8fc49d1 Merge pull request #4730 from nextcloud/taskTwice
ea77b4497 Merge pull request #4731 from nextcloud/markdownPreview_cleanup
1ecd563b5 remove unused dependencies
0444d07b0 Merge pull request #4728 from nextcloud/markdownPreview_Theming
44fefe906 fix notification task, if it failed first
5ec79a9ff [tx-robot] updated from transifex
01c480f01 daily dev 20191025
2019-10-26 03:36:47 +02:00
Andy Scherzinger 4f8fc49d15 Merge pull request #4730 from nextcloud/taskTwice
fix notification task, if it failed first
2019-10-25 10:18:10 +02:00
Tobias Kaminsky ea77b4497e Merge pull request #4731 from nextcloud/markdownPreview_cleanup
remove unused dependencies
2019-10-25 09:57:49 +02:00
Andy Scherzinger 1ecd563b53 remove unused dependencies
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-25 09:46:22 +02:00
Tobias Kaminsky 0444d07b02 Merge pull request #4728 from nextcloud/markdownPreview_Theming
Theming for rendering markdown
2019-10-25 09:18:42 +02:00
tobiasKaminsky 44fefe9064 fix notification task, if it failed first
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-25 09:16:58 +02:00
Nextcloud bot 5ec79a9ff5 [tx-robot] updated from transifex 2019-10-25 03:08:36 +00:00
Tobias Kaminsky 01c480f01f daily dev 20191025
272f6203b Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
75dd657ba Merge pull request #3905 from jmue/storageprovider
8a3ea78a5 Merge pull request #4701 from nextcloud/markdownPreview_SyntaxHighlighting
d5ff4f9a4 Fix spotbugs filter
7f0e6beb8 try to correct regex for spotbugs ignore
0e90952b5 increase spotbugs due to unfixable warning
669ad540e minor refactoring due to codacy
93f384817 proper spotbugs exclusion
f5ebba9ef use consistent dependency referencing style
587c8f74a Merge pull request #4716 from nextcloud/davX5loginFlow
9eb77178e Merge pull request #4726 from nextcloud/npeNote
1ef6f5820 ignore library code of markdown render dependencies
bf43a798d add syntax highlighting to markdown rendering * bump gradle memory due to GC mem limit during code generation (gradle.properties)
622cc45e7 use new login flow only when we have a server url
ccd6dfaec NPE in setting note
71bb3124f Merge pull request #4724 from nextcloud/dependabot/gradle/daggerVersion-2.25.2
99368fa3f [tx-robot] updated from transifex
1afb02567 daily dev 20191024
2019-10-25 03:36:52 +02:00
Andy Scherzinger 460b5a75cd repect theming colors when rendering markdown
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-24 20:30:48 +02:00
nextcloud-android-bot 272f6203b9 Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
Signed-off-by: nextcloud-android-bot <[email protected]>
2019-10-24 17:29:43 +00:00
Andy Scherzinger 75dd657ba8 Merge pull request #3905 from jmue/storageprovider
enhance DocumentsProvider
2019-10-24 19:18:59 +02:00
Andy Scherzinger 8a3ea78a55 Merge pull request #4701 from nextcloud/markdownPreview_SyntaxHighlighting
Markdown preview syntax highlighting
2019-10-24 16:11:04 +02:00
tobiasKaminsky d5ff4f9a4f Fix spotbugs filter
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-24 14:34:34 +02:00
Andy Scherzinger 7f0e6beb83 try to correct regex for spotbugs ignore
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-24 13:58:03 +02:00
tobiasKaminsky 0e90952b5b increase spotbugs due to unfixable warning
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-24 13:28:11 +02:00
tobiasKaminsky 669ad540e5 minor refactoring due to codacy
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-24 13:24:14 +02:00
Andy Scherzinger 93f3848172 proper spotbugs exclusion
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-24 12:25:29 +02:00
Andy Scherzinger f5ebba9eff use consistent dependency referencing style
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-24 10:42:29 +02:00
Andy Scherzinger 587c8f74a1 Merge pull request #4716 from nextcloud/davX5loginFlow
DavX5: support login flow
2019-10-24 10:36:15 +02:00
Tobias Kaminsky 9eb77178e8 Merge pull request #4726 from nextcloud/npeNote
NPE in setting note
2019-10-24 10:00:36 +02:00
Andy Scherzinger 1ef6f58204 ignore library code of markdown render dependencies
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-24 09:29:47 +02:00
Andy Scherzinger bf43a798df add syntax highlighting to markdown rendering
* bump gradle memory due to GC mem limit during code generation (gradle.properties)

Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-24 09:29:41 +02:00
tobiasKaminsky 622cc45e72 use new login flow only when we have a server url
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-24 09:10:48 +02:00
tobiasKaminsky ccd6dfaec0 NPE in setting note
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-24 08:47:11 +02:00
Andy Scherzinger 71bb3124f4 Merge pull request #4724 from nextcloud/dependabot/gradle/daggerVersion-2.25.2
Bump daggerVersion from 2.25 to 2.25.2
2019-10-24 07:59:37 +02:00
Nextcloud bot 99368fa3f7 [tx-robot] updated from transifex 2019-10-24 03:08:02 +00:00
dependabot-preview[bot] 16d1946205 Bump daggerVersion from 2.25 to 2.25.2
Bumps `daggerVersion` from 2.25 to 2.25.2.

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

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

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

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

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

Signed-off-by: dependabot-preview[bot] <[email protected]>
2019-10-24 01:13:27 +00:00
Jens Mueller 62f7c479fa fix file creation time
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:37 +02:00
Jens Mueller 332e67c72d refactor/cleanup
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:37 +02:00
Jens Mueller 8d24d80fdc Revert "reduce contentresolver/sql queries"
This reverts commit ec5a73142dee30cd909db9e68b97ef65456f7c48.

Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:36 +02:00
Jens Mueller 5de451fa98 fix initialization of storage manager collection
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:35 +02:00
Jens Mueller fa5e5dd8cd notify storageprovider on account creation/removal
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:35 +02:00
Jens Mueller cfd3aab952 reduce contentresolver/sql queries
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:34 +02:00
Jens Mueller a2350598da fix isChildDocument()
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:33 +02:00
tobiasKaminsky b2eacc46b4 - fix error when temp folder does not yet exist
- do not use FileUploader for uploads

Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-23 17:27:32 +02:00
Jens Mueller a14747623d move checks into toDocument()
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:32 +02:00
Jens Mueller 65655c5753 fix build
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:31 +02:00
Jens Mueller 3693ad88c1 remove unused imports
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:30 +02:00
Jens Mueller fbff63bb02 fix lint warnings
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:30 +02:00
Jens Mueller dddffce2a1 fix review comments
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:29 +02:00
Jens Mueller e62879ac91 cleanup
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:28 +02:00
Jens Mueller fe43e503a3 cleanup/fix review comments
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:28 +02:00
Jens Mueller 7f157a9ff1 enhance documents storage provider
Signed-off-by: Jens Mueller <[email protected]>
2019-10-23 17:27:24 +02:00
tobiasKaminsky 2911a86263 DavX5: support login flow
Signed-off-by: tobiasKaminsky <[email protected]>
2019-10-23 13:47:33 +02:00
Andy Scherzinger 25f58cd259 bump material to 1.1.0-beta01
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:54:13 +02:00
Daniel Bailey f5aa60bae9 Fix activity foreground text colour for >=API21.
Share expiration date picker now has buttons that are the primary
colour.

Theme change is now done in BaseActivity and ThemedPreferenceActivity.
This should help any activities in the back stack show the correct
theme.

Fixed style issues on firstrun and authenticator activities.

Signed-off-by: Daniel Bailey <[email protected]>
2019-10-07 16:43:36 +02:00
Andy Scherzinger 8aaf29a7c3 add dark/light theming for activities headline
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:35 +02:00
Andy Scherzinger 9eb6fe838e bump to alpha10
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:34 +02:00
Andy Scherzinger f6680a3375 material design alpha09
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:33 +02:00
Andy Scherzinger a2963d9fc3 icons with light background need to be keep with dark color
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:32 +02:00
Andy Scherzinger 2d0f4e83a6 proper icon display for night theme for activities and notifications
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:31 +02:00
Andy Scherzinger 01642564ed make progress bar day/night aware
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:30 +02:00
Andy Scherzinger ff9795d421 Bump material to alpha-08
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:28 +02:00
Andy Scherzinger 196e33998a use day/night color
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:27 +02:00
Andy Scherzinger 4a808ab15c bump material lib to alpha07
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:26 +02:00
Andy Scherzinger 916580cb19 remove unused radio button preference code
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:25 +02:00
Andy Scherzinger 21fb11d79b bump material lib to alpha06
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:24 +02:00
Andy Scherzinger e54db7c7c5 make toolbar menu use the proper day/night popup theme
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:23 +02:00
Andy Scherzinger 691ee27cc5 use proper colors storage selector text
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:21 +02:00
Andy Scherzinger dc0ca5cc84 use correct color after rebase
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:20 +02:00
Daniel Bailey c43633ebb9 Various improvements to dark theme
Signed-off-by: Daniel Bailey <[email protected]>
2019-10-07 16:43:19 +02:00
Andy Scherzinger 01cfd0ad33 use proper color for storage location text
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:18 +02:00
Andy Scherzinger eff6a5bed9 don't tint avatars within the drawer menu
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:16 +02:00
Andy Scherzinger f53f246f6e rebase fixing plus proper theming of legacy login fields
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:15 +02:00
Andy Scherzinger 5a4df84fc4 bump com.google.android.material:material to alpha5
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:13 +02:00
Daniel f459cd2c98 "Activities" drawer selection background colour.
Signed-off-by: Daniel <[email protected]>
2019-10-07 16:43:12 +02:00
Andy Scherzinger 55d5f2f41a remove unused theme getter from interface
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:11 +02:00
Daniel Bailey 66144bb8b6 Corrects "Choose" button colour in FolderPickerActivity. Removes un-used import from NotificationListAdapter.
MaterialButtons.
SearchView highlight text colour.
First run activity, outlined button colour.

Signed-off-by: Daniel Bailey <[email protected]>
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:09 +02:00
Andy Scherzinger d1f1e6cff7 bump material lib to alpha03
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:08 +02:00
Daniel Bailey 9f7fa6b6b6 DatePickerDialog theme and style.
Button styling.
Small improvements to layouts and correction of spelling errors.
Sets edittext highlight colour to theme colour.

Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:07 +02:00
Andy Scherzinger b0734f5768 improve codacy score
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:06 +02:00
Andy Scherzinger 34cef89ce8 set background color for primary action buttons on upload and participate
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:04 +02:00
Andy Scherzinger c4b5d8f2e9 use xml drawables for shared state icon including day/night state
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:03 +02:00
Andy Scherzinger 1930e5dc74 findbugs: accesses list or array with constant index
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:02 +02:00
Andy Scherzinger cab2b12594 use right colors for drawer menu item text and icons
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:01 +02:00
Andy Scherzinger df15340fc2 use style instead of theme attribute for secondary action buttons
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:43:00 +02:00
Daniel 44099c0792 Dark theme v1
Fixing migration to androidx
Dark theme styling
File details fragment tab text colour
File list overflow menu background colour

Signed-off-by: Daniel Bailey <[email protected]>
Signed-off-by: Andy Scherzinger <[email protected]>
2019-10-07 16:42:49 +02:00
320 changed files with 5754 additions and 4603 deletions

No files matched your search

+15 -1
View File
@@ -27,6 +27,11 @@
<emptyLine />
</value>
</option>
<option name="RIGHT_MARGIN" value="120" />
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<AndroidXmlCodeStyleSettings>
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
</AndroidXmlCodeStyleSettings>
<JavaCodeStyleSettings>
<option name="IMPORT_LAYOUT_TABLE">
<value>
@@ -86,6 +91,7 @@
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
@@ -96,6 +102,7 @@
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
@@ -107,6 +114,7 @@
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
@@ -117,6 +125,7 @@
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
@@ -127,6 +136,7 @@
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
@@ -137,6 +147,7 @@
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
@@ -147,6 +158,7 @@
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
@@ -158,6 +170,7 @@
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
@@ -169,6 +182,7 @@
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
@@ -179,4 +193,4 @@
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>
</component>
+13
View File
@@ -1,3 +1,16 @@
3.9.0 (November, 12, 2019)
- preview Markdown with syntax highlighting @AndyScherzinger
- improved DavX5 integration @bitfireAT
- AutoUpload: allow files to upload into subfolder
- new media player service @ezaquarii
- Remote wipe integration
- Print from within Collabora
- enhanced SingleSignOn
- outdated server warning set to NC14
For a full list, please see https://github.com/nextcloud/android/milestone/38
## 3.8.1 (October, 11, 2019)
- upload images into subfolder, if source folder also has subfolder
+20
View File
@@ -23,6 +23,8 @@
1. Backport pull request
1. Pull requests that also need changes on library
1. Adding new files
1. File naming
1. Menu files
1. Translations
1. Releases
1. Types
@@ -236,6 +238,24 @@ Source code of app:
-->
```
## File naming
The file naming patterns are inspired and based on [Ribot's Android Project And Code Guidelines](https://github.com/ribot/android-guidelines/blob/c1d8c9c904eb31bf01fe24aadb963b74281fe79a/project_and_code_guidelines.md).
### Menu files
Similar to layout files, menu files should match the name of the component. For example, if we are defining a menu file that is going to be used in the `UserProfileActivity`, then the name of the file should be `activity_user_profile.xml`. Same pattern applies for menus used in adapter view items, dialogs, etc.
| Component | Class Name | Menu Name |
| ---------------- | ---------------------- | ----------------------------- |
| Activity | `UserProfileActivity` | `activity_user_profile.xml` |
| Fragment | `SignUpFragment` | `fragment_sign_up.xml` |
| Dialog | `ChangePasswordDialog` | `dialog_change_password.xml` |
| AdapterView item | --- | `item_person.xml` |
| Partial layout | --- | `partial_stats_bar.xml` |
A good practice is to not include the word `menu` as part of the name because these files are already located in the `menu` directory. In case a component uses several menus in different places (via popup menus) then the resource name would be extended. For example, if the user profile activity has two popup menus for configuring the users settings and one for the handling group assignments then the file names for the menus would be: `activity_user_profile_user_settings.xml` and `activity_user_profile_group_assignments.xml`.
## Translations
We manage translations via [Transifex](https://www.transifex.com/nextcloud/nextcloud/android/). So just request joining the translation team for Android on the site and start translating. All translations will then be automatically pushed to this repository, there is no need for any pull request for translations.
+31 -22
View File
@@ -7,7 +7,7 @@
import com.github.spotbugs.SpotBugsTask
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
@@ -20,13 +20,13 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.5.2'
classpath('com.dicedmelon.gradle:jacoco-android:0.1.4') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.1.1"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.2.0"
}
}
@@ -48,6 +48,7 @@ configurations {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitely
// check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
@@ -56,8 +57,9 @@ configurations {
ext {
jacocoVersion = "0.8.2"
daggerVersion = "2.25"
markwonVersion = '4.1.2'
daggerVersion = "2.25.2"
markwonVersion = "4.2.0"
prismVersion = "2.0.0"
androidLibraryVersion = "master-SNAPSHOT"
travisBuild = System.getenv("TRAVIS") == "true"
@@ -79,7 +81,7 @@ repositories {
// semantic versioning for version code
def versionMajor = 3
def versionMinor = 9
def versionMinor = 10
def versionPatch = 0
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
@@ -103,7 +105,12 @@ android {
abortOnError false
htmlReport true
htmlOutput file("$project.buildDir/reports/lint/lint.html")
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities'
disable 'MissingTranslation',
'GradleDependency',
'VectorPath',
'IconMissingDensityFolder',
'IconDensities',
'GoogleAppIndexingWarning'
}
dexOptions {
@@ -113,7 +120,7 @@ android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 14
minSdkVersion 16
targetSdkVersion 28
// arguments to be passed to functional tests
@@ -160,8 +167,8 @@ android {
versionDev {
applicationId "com.nextcloud.android.beta"
dimension "default"
versionCode 20191024
versionName "20191024"
versionCode 20191129
versionName "20191129"
}
qa {
@@ -267,11 +274,11 @@ dependencies {
qaImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.1.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
implementation "androidx.work:work-runtime:2.2.0"
implementation "androidx.work:work-runtime-ktx:2.2.0"
@@ -290,7 +297,7 @@ dependencies {
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.2' // 'com.github.blikoon:QRCodeScanner:0.1.2'
implementation 'com.google.android:flexbox:1.1.1'
implementation 'com.google.android:flexbox:2.0.0'
implementation 'org.parceler:parceler-api:1.1.12'
kapt 'org.parceler:parceler:1.1.12'
implementation('com.github.bumptech.glide:glide:3.8.0') {
@@ -299,11 +306,11 @@ dependencies {
implementation 'com.caverock:androidsvg:1.4'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.jetbrains:annotations:17.0.0'
implementation 'org.jetbrains:annotations:18.0.0'
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:2.5.1'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.0'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
implementation "com.google.dagger:dagger:$daggerVersion"
@@ -319,13 +326,15 @@ dependencies {
implementation 'org.conscrypt:conscrypt-android:2.2.1'
// dependencies for markdown rendering
implementation ("io.noties.markwon:core:$markwonVersion")
implementation ("io.noties.markwon:ext-latex:$markwonVersion")
implementation ("io.noties.markwon:ext-strikethrough:$markwonVersion")
implementation ("io.noties.markwon:ext-tables:$markwonVersion")
implementation ("io.noties.markwon:ext-tasklist:$markwonVersion")
implementation ("io.noties.markwon:html:$markwonVersion")
implementation ("io.noties.markwon:linkify:$markwonVersion")
implementation "io.noties.markwon:core:$markwonVersion"
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
implementation "io.noties.markwon:ext-tables:$markwonVersion"
implementation "io.noties.markwon:ext-tasklist:$markwonVersion"
implementation "io.noties.markwon:html:$markwonVersion"
implementation "io.noties.markwon:syntax-highlight:$markwonVersion"
implementation "io.noties:prism4j:$prismVersion"
kapt "io.noties:prism4j-bundler:$prismVersion"
// dependencies for local unit tests
testImplementation 'junit:junit:4.12'
+1 -1
View File
@@ -1 +1 @@
421
407
+18 -2
View File
@@ -17,7 +17,8 @@
<Match>
<Or>
<Class name="~.*\.Dagger.*" />
<Class name="~com.nextcloud.client.di\..*_.*" />
<Class name="~com\.nextcloud\.client\.di\..*_.*" />
<Class name="~dagger\.android\..*" />
</Or>
</Match>
<!-- Dagger generated code uses internal APIs -->
@@ -30,10 +31,25 @@
<Match>
<Or>
<Class name="~.*BindingImpl"/>
<Class name="~.*\.DataBinderMapperImpl"/>
<Class name="~.*\.DataBinderMapperImpl"/>
</Or>
</Match>
<!-- Third-party library code -->
<Match>
<Or>
<Package name="~io\.noties\..*" />
<Package name="~third_parties\.ezvcard_android\..*" />
<Package name="~com\.afollestad\.sectionedrecyclerview\..*" />
<Package name="~butterknife\..*" />
<Package name="~de\.cotech\..*" />
<Package name="~pl\.droidsonroids\..*" />
</Or>
</Match>
<Match>
<Class name="~com\.owncloud\.android\.ui\.preview\.MarkwonGrammarLocator.*" />
</Match>
<Bug pattern="PATH_TRAVERSAL_IN" />
<Bug pattern="ANDROID_EXTERNAL_FILE_ACCESS" />
<Bug pattern="BAS_BLOATED_ASSIGNMENT_SCOPE" />
@@ -1,19 +1,17 @@
Svobodně licencovaná Nexcloud Android aplikace, dávající vám mobilní svobodu.
Software, který můžete nasadit na vlastní server a ten organizuje ukládání a synchronizaci souborů. Díky doplňkům jde o kompletní groupwarové řešení.
Funkce:
* Snadno použitelné moderní rozhraní, přizpůsobené vzhledu, používaném na vašem serveru
* Nahrávejte soubory na svůj Nextcloud server
* Sdílejte je s ostatními
* Udržujte své oblíbené soubory a složky synchronizované
* Hledejte napříč všemi složkami na svém serveru
* Automaticky nahrávejte své fotky a videa, pořízená zařízením
* Udržujte si přehled pomocí oznámení
* Podporuje vícero účtů
* Zabezpečený přístup k vašim datům pomocí otisku prstu nebo PIN kódu
* Napojení na DAVx5 (dříve známé pod názvem DAVdroid) pro snadné nastavení synchronizace kalendáře a kontaktů
* Soubory nahrané do nexcloudu lze snadno sdílet s ostatními.
* Přístup odkudkoli přes webové a mobilní rozhraní.
* Synchronizace s počítačem umožňující offline práci.
* Vaše data jsou na vašem serveru a máte nad nimi plnou kontrolu.
* Jde o svobodný software, který snadno můžete sami hostovat a volně si ho přizplsobit. V případě potřeby je ale k dispozici komerční podpora.
* Vyhledávání napříč soubory.
* Synchronizace kontaktů a zpráv.
* Sdílení kalendářů do mobilu (DAVx5/DAVdroid)
* Neomezený počet uživatelů, autoupload fotek přímo z mobilu, oznámení,
* Klienti pro WIndows, MacOS, iOS, Android, web.
* Mnoho dalších doplňků s dalšími funkcemi.
Veškeré nalezené problémy hlaste na https://github.com/nextcloud/android/issues a diskutujte o aplikaci na https://help.nextcloud.com/c/clients/android
Díky Nextcloudu budete mít kompletní privátní řešení pro všechy vaše soubory, fotky, kalendáře a kontakty.
Noví v Nextcloud? Nextcloud je soukromý server pro synchronizaci souborů a jejich sdílení, dále pro komunikaci. Jedná se o svobodný software a můžete ho hostovat svými silami nebo za to zaplatit nějaké společnosti. Tím máte pod kontrolou své fotky, kalendář a kontakty, dokumenty a vše ostatní.
Podívejte se na Nextcloud na https://nextcloud.com
Připomínky zasílejte na https://github.com/nextcloud/android/issues, diskutovat lze na https://help.nextcloud.com/c/clients a vše ostatní najdete na https://nextcloud.com 
@@ -1 +1 @@
Produktivní platforma hostovaná u vás, kde vaše data jsou opravdu vaše
Platforma pro produktivitu hostovaná u vás, kde vaše data jsou opravdu vaše
@@ -1 +1 @@
Nextcloud Android 앱으로 내 Nextcloud에 있는 모든 파일을 사용하십시오.
컨트롤 가능한 자체 호스팅 생산성 플랫폼
@@ -24,4 +24,9 @@ interface IInputStreamService {
in ParcelFileDescriptor requestBodyParcelFileDescriptor);
ParcelFileDescriptor performNextcloudRequest(in ParcelFileDescriptor input);
ParcelFileDescriptor performNextcloudRequestAndBodyStreamV2(in ParcelFileDescriptor input,
in ParcelFileDescriptor requestBodyParcelFileDescriptor);
ParcelFileDescriptor performNextcloudRequestV2(in ParcelFileDescriptor input);
}
@@ -94,6 +94,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
private static final int HTTP_STATUS_CODE_MULTIPLE_CHOICES = 300;
private static final char PATH_SEPARATOR = '/';
private static final int ZERO_LENGTH = 0;
private Context context;
private UserAccountManager accountManager;
@@ -112,6 +113,42 @@ public class InputStreamBinder extends IInputStreamService.Stub {
return nvp;
}
public ParcelFileDescriptor performNextcloudRequestV2(ParcelFileDescriptor input) {
return performNextcloudRequestAndBodyStreamV2(input, null);
}
public ParcelFileDescriptor performNextcloudRequestAndBodyStreamV2(
ParcelFileDescriptor input,
ParcelFileDescriptor requestBodyParcelFileDescriptor) {
// read the input
final InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input);
final InputStream requestBodyInputStream = requestBodyParcelFileDescriptor != null ?
new ParcelFileDescriptor.AutoCloseInputStream(requestBodyParcelFileDescriptor) : null;
Exception exception = null;
Response response = new Response();
try {
// Start request and catch exceptions
NextcloudRequest request = deserializeObjectAndCloseStream(is);
response = processRequestV2(request, requestBodyInputStream);
} catch (Exception e) {
Log_OC.e(TAG, "Error during Nextcloud request", e);
exception = e;
}
try {
// Write exception to the stream followed by the actual network stream
InputStream exceptionStream = serializeObjectToInputStreamV2(exception, response.getPlainHeadersString());
InputStream resultStream = new java.io.SequenceInputStream(exceptionStream, response.getBody());
return ParcelFileDescriptorUtil.pipeFrom(resultStream, thread -> Log.d(TAG, "Done sending result"));
} catch (IOException e) {
Log_OC.e(TAG, "Error while sending response back to client app", e);
}
return null;
}
public ParcelFileDescriptor performNextcloudRequest(ParcelFileDescriptor input) {
return performNextcloudRequestAndBodyStream(input, null);
}
@@ -128,7 +165,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
InputStream httpStream = new InputStream() {
@Override
public int read() {
return 0;
return ZERO_LENGTH;
}
};
@@ -157,6 +194,23 @@ public class InputStreamBinder extends IInputStreamService.Stub {
return null;
}
private ByteArrayInputStream serializeObjectToInputStreamV2(Exception exception, String headers) {
byte[] baosByteArray = new byte[0];
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(exception);
oos.writeObject(headers);
oos.flush();
oos.close();
baosByteArray = baos.toByteArray();
} catch (IOException e) {
Log_OC.e(TAG, "Error while sending response back to client app", e);
}
return new ByteArrayInputStream(baosByteArray);
}
private <T extends Serializable> ByteArrayInputStream serializeObjectToInputStream(T obj) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -315,6 +369,71 @@ public class InputStreamBinder extends IInputStreamService.Stub {
}
}
private Response processRequestV2(final NextcloudRequest request, final InputStream requestBodyInputStream)
throws UnsupportedOperationException,
com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException,
OperationCanceledException, AuthenticatorException, IOException {
Account account = accountManager.getAccountByName(request.getAccountName());
if (account == null) {
throw new IllegalStateException(EXCEPTION_ACCOUNT_NOT_FOUND);
}
// Validate token
if (!isValid(request)) {
throw new IllegalStateException(EXCEPTION_INVALID_TOKEN);
}
// Validate URL
if (request.getUrl().length() == 0 || request.getUrl().charAt(0) != PATH_SEPARATOR) {
throw new IllegalStateException(EXCEPTION_INVALID_REQUEST_URL,
new IllegalStateException("URL need to start with a /"));
}
OwnCloudClientManager ownCloudClientManager = OwnCloudClientManagerFactory.getDefaultSingleton();
OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
OwnCloudClient client = ownCloudClientManager.getClientFor(ocAccount, context);
HttpMethodBase method = buildMethod(request, client.getBaseUri(), requestBodyInputStream);
method.setQueryString(convertMapToNVP(request.getParameter()));
method.addRequestHeader("OCS-APIREQUEST", "true");
for (Map.Entry<String, List<String>> header : request.getHeader().entrySet()) {
// https://stackoverflow.com/a/3097052
method.addRequestHeader(header.getKey(), TextUtils.join(",", header.getValue()));
if ("OCS-APIREQUEST".equalsIgnoreCase(header.getKey())) {
throw new IllegalStateException(
"The 'OCS-APIREQUEST' header will be automatically added by the Nextcloud SSO Library. " +
"Please remove the header before making a request");
}
}
client.setFollowRedirects(request.isFollowRedirects());
int status = client.executeMethod(method);
// Check if status code is 2xx --> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success
if (status >= HTTP_STATUS_CODE_OK && status < HTTP_STATUS_CODE_MULTIPLE_CHOICES) {
return new Response(method.getResponseBodyAsStream(), method.getResponseHeaders());
} else {
StringBuilder total = new StringBuilder();
InputStream inputStream = method.getResponseBodyAsStream();
// If response body is available
if (inputStream != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = reader.readLine();
while (line != null) {
total.append(line).append('\n');
line = reader.readLine();
}
Log_OC.e(TAG, total.toString());
}
throw new IllegalStateException(EXCEPTION_HTTP_REQUEST_FAILED,
new IllegalStateException(String.valueOf(status),
new IllegalStateException(total.toString())));
}
}
private boolean isValid(NextcloudRequest request) {
String callingPackageName = context.getPackageManager().getNameForUid(Binder.getCallingUid());
@@ -0,0 +1,54 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2019 Tobias Kaminsky
* Copyright (C) 2019 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.nextcloud.android.sso;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import lombok.Getter;
public class PlainHeader implements Serializable {
private static final long serialVersionUID = 3284979177401282512L;
@Getter
private String name;
@Getter
private String value;
PlainHeader(String name, String value) {
this.name = name;
this.value = value;
}
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.writeObject(name);
oos.writeObject(value);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
name = (String) in.readObject();
value = (String) in.readObject();
}
}
@@ -0,0 +1,65 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2019 Tobias Kaminsky
* Copyright (C) 2019 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.nextcloud.android.sso;
import com.google.gson.Gson;
import org.apache.commons.httpclient.Header;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
public class Response {
@Getter
private InputStream body;
private Header[] headers;
public Response() {
headers = new Header[0];
body = new InputStream() {
@Override
public int read() {
return 0;
}
};
}
public Response(InputStream inputStream, Header[] headers) {
this.body = inputStream;
this.headers = headers;
}
public String getPlainHeadersString() {
List<PlainHeader> arrayList = new ArrayList<>(headers.length);
for (Header header : headers) {
arrayList.add(new PlainHeader(header.getName(), header.getValue()));
}
Gson gson = new Gson();
return gson.toJson(arrayList);
}
}
@@ -0,0 +1,58 @@
/*
* Nextcloud Android client application
*
* @author Chris Narkiewicz <[email protected]>
* Copyright (C) 2019 Chris Narkiewicz
* Copyright (C) 2019 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.nextcloud.client.account
import android.accounts.Account
import android.content.Context
import android.net.Uri
import com.owncloud.android.MainApp
import com.owncloud.android.R
import com.owncloud.android.lib.common.OwnCloudAccount
import com.owncloud.android.lib.common.OwnCloudBasicCredentials
import java.net.URI
/**
* This object represents anonymous user, ie. user that did not log in the Nextcloud server.
* It serves as a semantically correct "empty value", allowing simplification of logic
* in various components requiring user data, such as DB queries.
*/
internal class AnonymousUser(private val accountType: String) : User {
companion object {
@JvmStatic
fun fromContext(context: Context): AnonymousUser {
val type = context.getString(R.string.account_type)
return AnonymousUser(type)
}
}
override val accountName: String = "anonymous"
override val server = Server(URI.create(""), MainApp.MINIMUM_SUPPORTED_SERVER_VERSION)
override val isAnonymous = true
override fun toPlatformAccount(): Account {
return Account(accountName, accountType)
}
override fun toOwnCloudAccount(): OwnCloudAccount {
return OwnCloudAccount(Uri.EMPTY, OwnCloudBasicCredentials("", ""))
}
}
@@ -2,19 +2,31 @@ package com.nextcloud.client.account;
import android.accounts.Account;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* This interface provides access to currently selected user Account.
* This interface provides access to currently selected user.
*
* @see UserAccountManager
*/
@FunctionalInterface
public interface CurrentAccountProvider {
/**
* Get currently active account.
* Get currently active account.
*
* @return Currently selected {@link Account} or first valid {@link Account} registered in OS or null, if not available at all.
*/
@Deprecated
@Nullable
Account getCurrentAccount();
/**
* Get currently active user profile. If there is no actice user, anonymous user is returned.
*
* @return User profile. Profile is never null.
*/
@NonNull
default User getUser() {
return new AnonymousUser("dummy");
}
}
@@ -0,0 +1,47 @@
/*
* Nextcloud Android client application
*
* @author Chris Narkiewicz <[email protected]>
* Copyright (C) 2019 Chris Narkiewicz
* Copyright (C) 2019 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.nextcloud.client.account
import android.accounts.Account
import com.owncloud.android.lib.common.OwnCloudAccount
/**
* This class represents normal user logged into the Nextcloud server.
*/
internal class RegisteredUser(
private val account: Account,
private val ownCloudAccount: OwnCloudAccount,
override val server: Server
) : User {
override val isAnonymous = false
override val accountName: String get() {
return account.name
}
override fun toPlatformAccount(): Account {
return account
}
override fun toOwnCloudAccount(): OwnCloudAccount {
return ownCloudAccount
}
}
@@ -0,0 +1,30 @@
/*
* Nextcloud Android client application
*
* @author Chris Narkiewicz <[email protected]>
* Copyright (C) 2019 Chris Narkiewicz
* Copyright (C) 2019 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.nextcloud.client.account
import com.owncloud.android.lib.resources.status.OwnCloudVersion
import java.net.URI
/**
* This object provides all information necessary to interact
* with backend server.
*/
data class Server(val uri: URI, val version: OwnCloudVersion)
@@ -0,0 +1,54 @@
/*
* Nextcloud Android client application
*
* @author Chris Narkiewicz <[email protected]>
* Copyright (C) 2019 Chris Narkiewicz
* Copyright (C) 2019 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.nextcloud.client.account
import android.accounts.Account
import com.owncloud.android.lib.common.OwnCloudAccount
interface User {
val accountName: String
val server: Server
val isAnonymous: Boolean
/**
* This is temporary helper method created to facilitate incremental refactoring.
* Code using legacy platform Account can be partially converted to instantiate User
* object and use account instance when required.
*
* This method calls will allow tracing code awaiting further refactoring.
*
* @return Account instance that is associated with this User object.
*/
@Deprecated("Temporary workaround")
fun toPlatformAccount(): Account
/**
* This is temporary helper method created to facilitate incremental refactoring.
* Code using legacy ownCloud account can be partially converted to instantiate User
* object and use account instance when required.
*
* This method calls will allow tracing code awaiting further refactoring.
*
* @return OwnCloudAccount instance that is associated with this User object.
*/
@Deprecated("Temporary workaround")
fun toOwnCloudAccount(): OwnCloudAccount
}
@@ -21,10 +21,13 @@ package com.nextcloud.client.account;
import android.accounts.Account;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -51,6 +54,22 @@ public interface UserAccountManager extends CurrentAccountProvider {
@NonNull
Account[] getAccounts();
/**
* Get configured nextcloud user accounts
* @return List of users or empty list, if users are not registered.
*/
@NonNull
List<User> getAllUsers();
/**
* Get user with a specific account name.
*
* @param accountName Account name of the requested user
* @return User or empty optional if user does not exist.
*/
@NonNull
Optional<User> getUser(CharSequence accountName);
/**
* Check if Nextcloud account is registered in {@link android.accounts.AccountManager}
*
@@ -78,10 +97,24 @@ public interface UserAccountManager extends CurrentAccountProvider {
* @return Version of the OC server corresponding to account, according to the data saved
* in the system AccountManager
*/
@Deprecated
@NonNull
OwnCloudVersion getServerVersion(Account account);
@Deprecated
boolean isSearchSupported(@Nullable Account account);
/**
* Check if user's account supports media streaming. This is a property of server where user has his account.
*
* @deprecated Please use {@link OwnCloudVersion#isMediaStreamingSupported()} directly,
* obtainable from {@link User#getServer()} and {@link Server#getVersion()}
*
* @param account Account used to perform {@link android.accounts.AccountManager} lookup.
*
* @return true is server supports media streaming, false otherwise
*/
@Deprecated
boolean isMediaStreamingSupported(@Nullable Account account);
void resetOwnCloudAccount();
@@ -27,6 +27,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
@@ -35,11 +36,18 @@ import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.UserInfo;
import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation;
import org.jetbrains.annotations.NotNull;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import androidx.annotation.NonNull;
@@ -80,6 +88,20 @@ public class UserAccountManagerImpl implements UserAccountManager {
return accountManager.getAccountsByType(getAccountType());
}
@Override
@NonNull
public List<User> getAllUsers() {
Account[] accounts = getAccounts();
List<User> users = new ArrayList<>(accounts.length);
for (Account account : accounts) {
User user = createUserFromAccount(account);
if (user != null) {
users.add(user);
}
}
return users;
}
@Override
public boolean exists(Account account) {
Account[] nextcloudAccounts = getAccounts();
@@ -103,6 +125,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
return false;
}
@Override
@Nullable
public Account getCurrentAccount() {
Account[] ocAccounts = getAccounts();
@@ -139,6 +162,76 @@ public class UserAccountManagerImpl implements UserAccountManager {
return defaultAccount;
}
/**
* Temporary solution to convert platform account to user instance.
* It takes null and returns null on error to ease error handling
* in legacy code.
*
* @param account Account instance
* @return User instance or null, if conversion failed
*/
@Nullable
private User createUserFromAccount(@Nullable Account account) {
if (account == null) {
return null;
}
OwnCloudAccount ownCloudAccount = null;
try {
ownCloudAccount = new OwnCloudAccount(account, context);
} catch (AccountUtils.AccountNotFoundException ex) {
return null;
}
/*
* Server version
*/
String serverVersionStr = accountManager.getUserData(account, AccountUtils.Constants.KEY_OC_VERSION);
OwnCloudVersion serverVersion;
if (serverVersionStr != null) {
serverVersion = new OwnCloudVersion(serverVersionStr);
} else {
serverVersion = MainApp.MINIMUM_SUPPORTED_SERVER_VERSION;
}
/*
* Server address
*/
String serverAddressStr = accountManager.getUserData(account, AccountUtils.Constants.KEY_OC_BASE_URL);
if (serverAddressStr == null || serverAddressStr.isEmpty()) {
return AnonymousUser.fromContext(context);
}
URI serverUri = URI.create(serverAddressStr); // TODO: validate
return new RegisteredUser(
account,
ownCloudAccount,
new Server(serverUri, serverVersion)
);
}
/**
* Get user. If user cannot be retrieved due to data error, anonymous user is returned instead.
*
*
* @return User instance
*/
@NotNull
@Override
public User getUser() {
Account account = getCurrentAccount();
User user = createUserFromAccount(account);
return user != null ? user : AnonymousUser.fromContext(context);
}
@Override
@NonNull
public Optional<User> getUser(CharSequence accountName) {
Account account = getAccountByName(accountName.toString());
User user = createUserFromAccount(account);
return Optional.of(user);
}
@Override
@Nullable
public OwnCloudAccount getCurrentOwnCloudAccount() {
@@ -197,6 +290,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
return result;
}
@Deprecated
@Override
@NonNull
public OwnCloudVersion getServerVersion(Account account) {
@@ -41,6 +41,7 @@ import com.nextcloud.client.logger.FileLogHandler;
import com.nextcloud.client.logger.Logger;
import com.nextcloud.client.logger.LoggerImpl;
import com.nextcloud.client.logger.LogsRepository;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
@@ -106,8 +107,8 @@ class AppModule {
}
@Provides
FilesRepository filesRepository(UserAccountManager accountManager) {
return new RemoteFilesRepository(new FilesServiceApiImpl(accountManager));
FilesRepository filesRepository(UserAccountManager accountManager, ClientFactory clientFactory) {
return new RemoteFilesRepository(new FilesServiceApiImpl(accountManager, clientFactory));
}
@Provides
@@ -32,6 +32,7 @@ import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.jobs.NotificationJob;
import com.owncloud.android.providers.DiskLruImageCacheFileProvider;
import com.owncloud.android.providers.FileContentProvider;
import com.owncloud.android.providers.UsersAndGroupsSearchProvider;
import com.owncloud.android.services.AccountManagerService;
import com.owncloud.android.services.OperationsService;
@@ -148,6 +149,7 @@ abstract class ComponentsModule {
@ContributesAndroidInjector abstract BootupBroadcastReceiver bootupBroadcastReceiver();
@ContributesAndroidInjector abstract NotificationJob.NotificationReceiver notificationJobBroadcastReceiver();
@ContributesAndroidInjector abstract FileContentProvider fileContentProvider();
@ContributesAndroidInjector abstract UsersAndGroupsSearchProvider usersAndGroupsSearchProvider();
@ContributesAndroidInjector abstract DiskLruImageCacheFileProvider diskLruImageCacheFileProvider();
@@ -69,7 +69,7 @@ class ShowErrorActivity : AppCompatActivity() {
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.activity_error_show, menu)
menuInflater.inflate(R.menu.activity_show_error, menu)
return super.onCreateOptionsMenu(menu)
}
@@ -51,7 +51,7 @@ class EtmPreferencesFragment : EtmBaseFragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.etm_preferences, menu)
inflater.inflate(R.menu.fragment_etm_preferences, menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@@ -26,6 +26,7 @@ import androidx.annotation.RequiresApi
import androidx.work.ListenableWorker
import androidx.work.WorkerFactory
import androidx.work.WorkerParameters
import com.nextcloud.client.core.Clock
import com.nextcloud.client.device.DeviceInfo
import com.nextcloud.client.device.PowerManagementService
import com.nextcloud.client.preferences.AppPreferences
@@ -40,6 +41,7 @@ import javax.inject.Provider
class BackgroundJobFactory @Inject constructor(
private val preferences: AppPreferences,
private val contentResolver: ContentResolver,
private val clock: Clock,
private val powerManagerService: PowerManagementService,
private val backgroundJobManager: Provider<BackgroundJobManager>,
private val deviceInfo: DeviceInfo
@@ -58,13 +60,14 @@ class BackgroundJobFactory @Inject constructor(
}
return when (workerClass) {
ContentObserverWork::class -> createContentObserverJob(context, workerParameters)
ContentObserverWork::class -> createContentObserverJob(context, workerParameters, clock)
else -> null // falls back to default factory
}
}
private fun createContentObserverJob(context: Context, workerParameters: WorkerParameters): ListenableWorker? {
val folderResolver = SyncedFolderProvider(contentResolver, preferences)
private fun createContentObserverJob(context: Context, workerParameters: WorkerParameters, clock: Clock):
ListenableWorker? {
val folderResolver = SyncedFolderProvider(contentResolver, preferences, clock)
@RequiresApi(Build.VERSION_CODES.N)
if (deviceInfo.apiLevel >= Build.VERSION_CODES.N) {
return ContentObserverWork(
@@ -84,7 +84,7 @@ class LogsActivity : ToolbarActivity() {
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.logs_menu, menu)
menuInflater.inflate(R.menu.activity_logs, menu)
(menu.findItem(R.id.action_search).actionView as SearchView).apply {
setOnQueryTextListener(searchBoxListener)
@@ -26,6 +26,7 @@ import android.accounts.OperationCanceledException;
import android.app.Activity;
import android.net.Uri;
import com.nextcloud.client.account.User;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.accounts.AccountUtils;
@@ -35,10 +36,31 @@ import java.io.IOException;
public interface ClientFactory {
/**
* This exception wraps all possible errors thrown by trigger-happy
* OwnCloudClient constructor, making try-catch blocks manageable.
*
* This is a temporary refactoring measure, until a better
* error handling method can be procured.
*/
@Deprecated
class CreationException extends Exception {
private static final long serialVersionUID = 0L;
CreationException(Throwable t) {
super(t);
}
}
OwnCloudClient create(User user) throws CreationException;
@Deprecated
OwnCloudClient create(Account account)
throws OperationCanceledException, AuthenticatorException, IOException,
AccountUtils.AccountNotFoundException;
@Deprecated
OwnCloudClient create(Account account, Activity currentActivity)
throws OperationCanceledException, AuthenticatorException, IOException,
AccountUtils.AccountNotFoundException;
@@ -27,6 +27,7 @@ import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import com.nextcloud.client.account.User;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.accounts.AccountUtils;
@@ -41,6 +42,18 @@ class ClientFactoryImpl implements ClientFactory {
this.context = context;
}
@Override
public OwnCloudClient create(User user) throws CreationException {
try {
return OwnCloudClientFactory.createOwnCloudClient(user.toPlatformAccount(), context);
} catch (OperationCanceledException|
AuthenticatorException|
IOException|
AccountUtils.AccountNotFoundException e) {
throw new CreationException(e);
}
}
@Override
public OwnCloudClient create(Account account)
throws OperationCanceledException, AuthenticatorException, IOException,
@@ -20,14 +20,13 @@
package com.nextcloud.client.network;
import android.accounts.Account;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.evernote.android.job.JobRequest;
import com.nextcloud.client.account.Server;
import com.nextcloud.client.account.UserAccountManager;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.nextcloud.client.logger.Logger;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import org.apache.commons.httpclient.HttpClient;
@@ -44,10 +43,11 @@ class ConnectivityServiceImpl implements ConnectivityService {
private final static String TAG = ConnectivityServiceImpl.class.getName();
private ConnectivityManager connectivityManager;
private UserAccountManager accountManager;
private ClientFactory clientFactory;
private GetRequestBuilder requestBuilder;
private final ConnectivityManager connectivityManager;
private final UserAccountManager accountManager;
private final ClientFactory clientFactory;
private final GetRequestBuilder requestBuilder;
private final Logger logger;
static class GetRequestBuilder implements Function1<String, GetMethod> {
@Override
@@ -59,55 +59,55 @@ class ConnectivityServiceImpl implements ConnectivityService {
ConnectivityServiceImpl(ConnectivityManager connectivityManager,
UserAccountManager accountManager,
ClientFactory clientFactory,
GetRequestBuilder requestBuilder) {
GetRequestBuilder requestBuilder,
Logger logger) {
this.connectivityManager = connectivityManager;
this.accountManager = accountManager;
this.clientFactory = clientFactory;
this.requestBuilder = requestBuilder;
this.logger = logger;
}
@Override
public boolean isInternetWalled() {
if (isOnlineWithWifi()) {
try {
Account account = accountManager.getCurrentAccount();
OwnCloudAccount ocAccount = accountManager.getCurrentOwnCloudAccount();
if (account != null && ocAccount != null) {
OwnCloudVersion serverVersion = accountManager.getServerVersion(account);
Server server = accountManager.getUser().getServer();
String baseServerAddress = server.getUri().toString();
if (baseServerAddress.isEmpty()) {
return true;
}
String url;
if (server.getVersion().compareTo(OwnCloudVersion.nextcloud_13) > 0) {
url = baseServerAddress + "/index.php/204";
} else {
url = baseServerAddress + "/status.php";
}
String url;
if (serverVersion.compareTo(OwnCloudVersion.nextcloud_13) > 0) {
url = ocAccount.getBaseUri() + "/index.php/204";
} else {
url = ocAccount.getBaseUri() + "/status.php";
}
GetMethod get = requestBuilder.invoke(url);
HttpClient client = clientFactory.createPlainClient();
GetMethod get = requestBuilder.invoke(url);
HttpClient client = clientFactory.createPlainClient();
int status = client.executeMethod(get);
int status = client.executeMethod(get);
if (serverVersion.compareTo(OwnCloudVersion.nextcloud_13) > 0) {
return !(status == HttpStatus.SC_NO_CONTENT &&
(get.getResponseContentLength() == -1 || get.getResponseContentLength() == 0));
} else {
if (status == HttpStatus.SC_OK) {
try {
// try parsing json to verify response
// check if json contains maintenance and it should be false
String json = get.getResponseBodyAsString();
return new JSONObject(json).getBoolean("maintenance");
} catch (Exception e) {
return true;
}
} else {
if (server.getVersion().compareTo(OwnCloudVersion.nextcloud_13) > 0) {
return !(status == HttpStatus.SC_NO_CONTENT &&
(get.getResponseContentLength() == -1 || get.getResponseContentLength() == 0));
} else {
if (status == HttpStatus.SC_OK) {
try {
// try parsing json to verify response
// check if json contains maintenance and it should be false
String json = get.getResponseBodyAsString();
return new JSONObject(json).getBoolean("maintenance");
} catch (Exception e) {
return true;
}
} else {
return true;
}
}
} catch (IOException e) {
Log_OC.e(TAG, "Error checking internet connection", e);
logger.e(TAG, "Error checking internet connection", e);
}
} else {
return getActiveNetworkType() == JobRequest.NetworkType.ANY;
@@ -24,6 +24,7 @@ import android.content.Context;
import android.net.ConnectivityManager;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.logger.Logger;
import javax.inject.Singleton;
@@ -36,11 +37,13 @@ public class NetworkModule {
@Provides
ConnectivityService connectivityService(ConnectivityManager connectivityManager,
UserAccountManager accountManager,
ClientFactory clientFactory) {
ClientFactory clientFactory,
Logger logger) {
return new ConnectivityServiceImpl(connectivityManager,
accountManager,
clientFactory,
new ConnectivityServiceImpl.GetRequestBuilder());
new ConnectivityServiceImpl.GetRequestBuilder(),
logger);
}
@Provides
@@ -28,7 +28,6 @@ import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
@@ -81,7 +80,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
Button loginButton = findViewById(R.id.login);
loginButton.setBackgroundColor(Color.WHITE);
loginButton.setBackgroundColor(getResources().getColor(R.color.login_btn_tint));
loginButton.setTextColor(getResources().getColor(R.color.primary));
loginButton.setOnClickListener(v -> {
@@ -95,7 +94,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
});
Button providerButton = findViewById(R.id.signup);
providerButton.setBackgroundColor(getResources().getColor(R.color.primary_dark));
providerButton.setBackgroundColor(getResources().getColor(R.color.primary));
providerButton.setTextColor(getResources().getColor(R.color.login_text_color));
providerButton.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE);
providerButton.setOnClickListener(v -> {
@@ -218,17 +217,19 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
return;
}
setAccount(account);
userAccountManager.setCurrentOwnCloudAccount(account.name);
onAccountSet();
Intent i = new Intent(this, FileDisplayActivity.class);
i.setAction(FileDisplayActivity.RESTART);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}
}
public static FeatureItem[] getFirstRun() {
return new FeatureItem[]{
new FeatureItem(R.drawable.logo, R.string.first_run_1_text, R.string.empty, true, false),
@@ -23,8 +23,42 @@ package com.nextcloud.client.preferences;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.utils.FileSortOrder;
import androidx.annotation.Nullable;
/**
* This interface provides single point of entry for access to all application
* preferences and allows clients to subscribe for specific configuration
* changes.
*/
public interface AppPreferences {
/**
* Preferences listener. Callbacks should be invoked on main thread.
*
* Miantainers should extend this interface with callbacks for specific
* events.
*/
interface Listener {
default void onDarkThemeEnabledChanged(boolean enabled) {
/* default empty implementation */
};
}
/**
* Registers preferences listener. It no-ops if listener
* is already registered.
*
* @param listener application preferences listener
*/
void addListener(@Nullable Listener listener);
/**
* Unregister listener. It no-ops if listener is not registered.
*
* @param listener application preferences listener
*/
void removeListener(@Nullable Listener listener);
void setKeysReInitEnabled();
boolean isKeysReInitEnabled();
@@ -239,6 +273,20 @@ public interface AppPreferences {
*/
int getUploaderBehaviour();
/**
* Enable dark theme.
*
* This is reactive property. Listeners will be invoked if registered.
*
* @param enabled true to turn dark theme on, false to turn it off
*/
void setDarkThemeEnabled(boolean enabled);
/**
* @return true if application uses dark UI theme, false otherwise
*/
boolean isDarkThemeEnabled();
/**
* Saves the uploader behavior which the user has set last.
*
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManagerImpl;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -35,12 +36,21 @@ import com.owncloud.android.ui.activity.PassCodeActivity;
import com.owncloud.android.ui.activity.SettingsActivity;
import com.owncloud.android.utils.FileSortOrder;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import androidx.annotation.Nullable;
import static com.owncloud.android.ui.fragment.OCFileListFragment.FOLDER_LAYOUT_LIST;
/**
* Helper to simplify reading of Preferences all around the app
* Implementation of application-wide preferences using {@link SharedPreferences}.
*
* Users should not use this class directly. Please use {@link AppPreferences} interafce
* instead.
*/
public final class AppPreferencesImpl implements AppPreferences {
/**
* Constant to access value of last path selected by the user to upload a file shared from other app.
* Value handled by the app without direct access in the UI.
@@ -48,6 +58,7 @@ public final class AppPreferencesImpl implements AppPreferences {
public static final String AUTO_PREF__LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
public static final String STORAGE_PATH = "storage_path";
public static final float DEFAULT_GRID_COLUMN = 4.0f;
private static final String AUTO_PREF__LAST_UPLOAD_PATH = "last_upload_path";
private static final String AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH = "upload_from_local_last_path";
private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_MAP_URL = "prefs_upload_file_extension_map_url";
@@ -68,6 +79,8 @@ public final class AppPreferencesImpl implements AppPreferences {
private static final String PREF__AUTO_UPLOAD_INIT = "autoUploadInit";
private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
private static final String PREF__FOLDER_LAYOUT = "folder_layout";
static final String PREF__DARK_THEME_ENABLED = "dark_theme_enabled";
private static final String PREF__LOCK_TIMESTAMP = "lock_timestamp";
private static final String PREF__SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
private static final String PREF__LOCK = SettingsActivity.PREFERENCE_LOCK;
@@ -79,7 +92,54 @@ public final class AppPreferencesImpl implements AppPreferences {
private final Context context;
private final SharedPreferences preferences;
private final CurrentAccountProvider currentAccountProvider;
private final ListenerRegistry listeners;
/**
* Adapter delegating raw {@link SharedPreferences.OnSharedPreferenceChangeListener} calls
* with key-value pairs to respective {@link com.nextcloud.client.preferences.AppPreferences.Listener} method.
*/
static class ListenerRegistry implements SharedPreferences.OnSharedPreferenceChangeListener {
private final AppPreferences preferences;
private final Set<Listener> listeners;
ListenerRegistry(AppPreferences preferences) {
this.preferences = preferences;
this.listeners = new CopyOnWriteArraySet<>();
}
void add(@Nullable final Listener listener) {
if (listener != null) {
listeners.add(listener);
}
}
void remove(@Nullable final Listener listener) {
if (listener != null) {
listeners.remove(listener);
}
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(PREF__DARK_THEME_ENABLED.equals(key)) {
boolean enabled = preferences.isDarkThemeEnabled();
for(Listener l : listeners) {
l.onDarkThemeEnabledChanged(enabled);
}
}
}
}
/**
* This is a temporary workaround to access app preferences in places that cannot use
* dependency injection yet. Use injected component via {@link AppPreferences} interface.
*
* WARNING: this creates new instance! it does not return app-wide singleton
*
* @param context Context used to create shared preferences
* @return New instance of app preferences component
*/
@Deprecated
public static AppPreferences fromContext(Context context) {
final CurrentAccountProvider currentAccountProvider = UserAccountManagerImpl.fromContext(context);
final SharedPreferences prefs = android.preference.PreferenceManager.getDefaultSharedPreferences(context);
@@ -90,6 +150,18 @@ public final class AppPreferencesImpl implements AppPreferences {
this.context = appContext;
this.preferences = preferences;
this.currentAccountProvider = currentAccountProvider;
this.listeners = new ListenerRegistry(this);
this.preferences.registerOnSharedPreferenceChangeListener(listeners);
}
@Override
public void addListener(@Nullable AppPreferences.Listener listener) {
this.listeners.add(listener);
}
@Override
public void removeListener(@Nullable AppPreferences.Listener listener) {
this.listeners.remove(listener);
}
@Override
@@ -211,7 +283,7 @@ public final class AppPreferencesImpl implements AppPreferences {
@Override
public String getFolderLayout(OCFile folder) {
return getFolderPreference(context,
currentAccountProvider.getCurrentAccount(),
currentAccountProvider.getUser(),
PREF__FOLDER_LAYOUT,
folder,
FOLDER_LAYOUT_LIST);
@@ -220,7 +292,7 @@ public final class AppPreferencesImpl implements AppPreferences {
@Override
public void setFolderLayout(OCFile folder, String layout_name) {
setFolderPreference(context,
currentAccountProvider.getCurrentAccount(),
currentAccountProvider.getUser(),
PREF__FOLDER_LAYOUT,
folder,
layout_name);
@@ -229,7 +301,7 @@ public final class AppPreferencesImpl implements AppPreferences {
@Override
public FileSortOrder getSortOrderByFolder(OCFile folder) {
return FileSortOrder.sortOrders.get(getFolderPreference(context,
currentAccountProvider.getCurrentAccount(),
currentAccountProvider.getUser(),
PREF__FOLDER_SORT_ORDER,
folder,
FileSortOrder.sort_a_to_z.name));
@@ -238,7 +310,7 @@ public final class AppPreferencesImpl implements AppPreferences {
@Override
public void setSortOrder(OCFile folder, FileSortOrder sortOrder) {
setFolderPreference(context,
currentAccountProvider.getCurrentAccount(),
currentAccountProvider.getUser(),
PREF__FOLDER_SORT_ORDER,
folder,
sortOrder.name);
@@ -251,28 +323,23 @@ public final class AppPreferencesImpl implements AppPreferences {
@Override
public FileSortOrder getSortOrderByType(FileSortOrder.Type type, FileSortOrder defaultOrder) {
Account account = currentAccountProvider.getCurrentAccount();
if (account == null) {
User user = currentAccountProvider.getUser();
if (user.isAnonymous()) {
return defaultOrder;
}
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
String value = dataProvider.getValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type);
String value = dataProvider.getValue(user.getAccountName(), PREF__FOLDER_SORT_ORDER + "_" + type);
return value.isEmpty() ? defaultOrder : FileSortOrder.sortOrders.get(value);
}
@Override
public void setSortOrder(FileSortOrder.Type type, FileSortOrder sortOrder) {
Account account = currentAccountProvider.getCurrentAccount();
if (account == null) {
throw new IllegalArgumentException("Account may not be null!");
}
User user = currentAccountProvider.getUser();
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
dataProvider.storeOrUpdateKeyValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
dataProvider.storeOrUpdateKeyValue(user.getAccountName(), PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
}
@Override
@@ -340,6 +407,16 @@ public final class AppPreferencesImpl implements AppPreferences {
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
}
@Override
public void setDarkThemeEnabled(boolean enabled) {
preferences.edit().putBoolean(PREF__DARK_THEME_ENABLED, enabled).apply();
}
@Override
public boolean isDarkThemeEnabled() {
return preferences.getBoolean(PREF__DARK_THEME_ENABLED, false);
}
@Override
public void setUploaderBehaviour(int uploaderBehaviour) {
preferences.edit().putInt(AUTO_PREF__UPLOADER_BEHAVIOR, uploaderBehaviour).apply();
@@ -495,22 +572,22 @@ public final class AppPreferencesImpl implements AppPreferences {
* @return Preference value
*/
private static String getFolderPreference(final Context context,
final Account account,
final User user,
final String preferenceName,
final OCFile folder,
final String defaultValue) {
if (account == null) {
if (user.isAnonymous()) {
return defaultValue;
}
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), context.getContentResolver());
String value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, folder));
String value = dataProvider.getValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder));
OCFile prefFolder = folder;
while (prefFolder != null && value.isEmpty()) {
prefFolder = storageManager.getFileById(prefFolder.getParentId());
value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, prefFolder));
value = dataProvider.getValue(user.getAccountName(), getKeyFromFolder(preferenceName, prefFolder));
}
return value.isEmpty() ? defaultValue : value;
}
@@ -524,16 +601,12 @@ public final class AppPreferencesImpl implements AppPreferences {
* @param value Preference value to set.
*/
private static void setFolderPreference(final Context context,
final Account account,
final User user,
final String preferenceName,
final OCFile folder,
final String value) {
if (account == null) {
throw new IllegalArgumentException("Account may not be null!");
}
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
dataProvider.storeOrUpdateKeyValue(account.name, getKeyFromFolder(preferenceName, folder), value);
dataProvider.storeOrUpdateKeyValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder), value);
}
private static String getKeyFromFolder(String preferenceName, OCFile folder) {
@@ -0,0 +1,366 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.nextcloud.java.util;
import com.nextcloud.java.util.function.Predicate;
import java.util.NoSuchElementException;
import androidx.core.util.Consumer;
import androidx.core.util.ObjectsCompat;
import androidx.core.util.Supplier;
import kotlin.jvm.functions.Function1;
/**
* This class is backported from Java 8 to be used on older Android API levels.
* It uses available interfaces from Kotlin and androidx. It is semantically
* identical with Java 8 API, allowing smooth migration when those APIs become
* available.
*
* A container object which may or may not contain a non-null value.
* If a value is present, {@code isPresent()} will return {@code true} and
* {@code get()} will return the value.
*
* <p>Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(java.lang.Object) orElse()}
* (return a default value if value not present) and
* {@link #ifPresent(Consumer) ifPresent()} (execute a block
* of code if the value is present).
*/
public final class Optional<T> {
/**
* Common instance for {@code empty()}.
*/
private static final Optional<?> EMPTY = new Optional<>();
/**
* If non-null, the value; if null, indicates no value is present
*/
private final T value;
/**
* Constructs an empty instance.
*
* @implNote Generally only one empty instance, {@link Optional#EMPTY},
* should exist per VM.
*/
private Optional() {
this.value = null;
}
/**
* Returns an empty {@code Optional} instance. No value is present for this
* Optional.
*
* @apiNote Though it may be tempting to do so, avoid testing if an object
* is empty by comparing with {@code ==} against instances returned by
* {@code Option.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @param <T> Type of the non-existent value
* @return an empty {@code Optional}
*/
public static<T> Optional<T> empty() {
@SuppressWarnings("unchecked")
Optional<T> t = (Optional<T>) EMPTY;
return t;
}
/**
* Constructs an instance with the value present.
*
* @param value the non-null value to be present
* @throws NullPointerException if value is null
*/
private Optional(T value) {
if (value == null) {
throw new NullPointerException();
}
this.value = value;
}
/**
* Returns an {@code Optional} with the specified present non-null value.
*
* @param <T> the class of the value
* @param value the value to be present, which must be non-null
* @return an {@code Optional} with the value present
* @throws NullPointerException if value is null
*/
public static <T> Optional<T> of(T value) {
return new Optional<>(value);
}
/**
* Returns an {@code Optional} describing the specified value, if non-null,
* otherwise returns an empty {@code Optional}.
*
* @param <T> the class of the value
* @param value the possibly-null value to describe
* @return an {@code Optional} with a present value if the specified value
* is non-null, otherwise an empty {@code Optional}
*/
public static <T> Optional<T> ofNullable(T value) {
return value == null ? empty() : of(value);
}
/**
* If a value is present in this {@code Optional}, returns the value,
* otherwise throws {@code NoSuchElementException}.
*
* @return the non-null value held by this {@code Optional}
* @throws NoSuchElementException if there is no value present
*
* @see Optional#isPresent()
*/
public T get() {
if (value == null) {
throw new NoSuchElementException("No value present");
}
return value;
}
/**
* Return {@code true} if there is a value present, otherwise {@code false}.
*
* @return {@code true} if there is a value present, otherwise {@code false}
*/
public boolean isPresent() {
return value != null;
}
/**
* If a value is present, invoke the specified consumer with the value,
* otherwise do nothing.
*
* @param consumer block to be executed if a value is present
* @throws NullPointerException if value is present and {@code consumer} is
* null
*/
public void ifPresent(Consumer<? super T> consumer) {
if (value != null) {
consumer.accept(value);
}
}
/**
* If a value is present, and the value matches the given predicate,
* return an {@code Optional} describing the value, otherwise return an
* empty {@code Optional}.
*
* @param predicate a predicate to apply to the value, if present
* @return an {@code Optional} describing the value of this {@code Optional}
* if a value is present and the value matches the given predicate,
* otherwise an empty {@code Optional}
* @throws NullPointerException if the predicate is null
*/
public Optional<T> filter(Predicate<? super T> predicate) {
if (predicate == null) {
throw new NullPointerException();
}
if (!isPresent()) {
return this;
} else {
return predicate.test(value) ? this : empty();
}
}
/**
* If a value is present, apply the provided mapping function to it,
* and if the result is non-null, return an {@code Optional} describing the
* result. Otherwise return an empty {@code Optional}.
*
* @apiNote This method supports post-processing on optional values, without
* the need to explicitly check for a return status. For example, the
* following code traverses a stream of file names, selects one that has
* not yet been processed, and then opens that file, returning an
* {@code Optional<FileInputStream>}:
*
* <pre>{@code
* Optional<FileInputStream> fis =
* names.stream().filter(name -> !isProcessedYet(name))
* .findFirst()
* .map(name -> new FileInputStream(name));
* }</pre>
*
* Here, {@code findFirst} returns an {@code Optional<String>}, and then
* {@code map} returns an {@code Optional<FileInputStream>} for the desired
* file if one exists.
*
* @param <U> The type of the result of the mapping function
* @param mapper a mapping function to apply to the value, if present
* @return an {@code Optional} describing the result of applying a mapping
* function to the value of this {@code Optional}, if a value is present,
* otherwise an empty {@code Optional}
* @throws NullPointerException if the mapping function is null
*/
public<U> Optional<U> map(Function1<? super T, ? extends U> mapper) {
if (mapper == null) {
throw new NullPointerException();
}
if (!isPresent()) {
return empty();
} else {
return Optional.ofNullable(mapper.invoke(value));
}
}
/**
* If a value is present, apply the provided {@code Optional}-bearing
* mapping function to it, return that result, otherwise return an empty
* {@code Optional}. This method is similar to {@link #map(Function1)},
* but the provided mapper is one whose result is already an {@code Optional},
* and if invoked, {@code flatMap} does not wrap it with an additional
* {@code Optional}.
*
* @param <U> The type parameter to the {@code Optional} returned by
* @param mapper a mapping function to apply to the value, if present
* the mapping function
* @return the result of applying an {@code Optional}-bearing mapping
* function to the value of this {@code Optional}, if a value is present,
* otherwise an empty {@code Optional}
* @throws NullPointerException if the mapping function is null or returns
* a null result
*/
public<U> Optional<U> flatMap(Function1<? super T, Optional<U>> mapper) {
if(mapper == null) {
throw new NullPointerException();
}
if (!isPresent()) {
return empty();
} else {
Optional<U> u = mapper.invoke(value);
if (u == null) {
throw new NullPointerException();
}
return u;
}
}
/**
* Return the value if present, otherwise return {@code other}.
*
* @param other the value to be returned if there is no value present, may
* be null
* @return the value, if present, otherwise {@code other}
*/
public T orElse(T other) {
return value != null ? value : other;
}
/**
* Return the value if present, otherwise invoke {@code other} and return
* the result of that invocation.
*
* @param other a {@code Supplier} whose result is returned if no value
* is present
* @return the value if present otherwise the result of {@code other.get()}
* @throws NullPointerException if value is not present and {@code other} is
* null
*/
public T orElseGet(Supplier<? extends T> other) {
return value != null ? value : other.get();
}
/**
* Return the contained value, if present, otherwise throw an exception
* to be created by the provided supplier.
*
* @apiNote A method reference to the exception constructor with an empty
* argument list can be used as the supplier. For example,
* {@code IllegalStateException::new}
*
* @param <X> Type of the exception to be thrown
* @param exceptionSupplier The supplier which will return the exception to
* be thrown
* @return the present value
* @throws X if there is no value present
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
if (value != null) {
return value;
} else {
throw exceptionSupplier.get();
}
}
/**
* Indicates whether some other object is "equal to" this Optional. The
* other object is considered equal if:
* <ul>
* <li>it is also an {@code Optional} and;
* <li>both instances have no value present or;
* <li>the present values are "equal to" each other via {@code equals()}.
* </ul>
*
* @param obj an object to be tested for equality
* @return {code true} if the other object is "equal to" this object
* otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Optional)) {
return false;
}
Optional<?> other = (Optional<?>) obj;
return ObjectsCompat.equals(value, other.value);
}
/**
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
*
* @return hash code value of the present value or 0 if no value is present
*/
@Override
public int hashCode() {
return ObjectsCompat.hashCode(value);
}
/**
* Returns a non-empty string representation of this Optional suitable for
* debugging. The exact presentation format is unspecified and may vary
* between implementations and versions.
*
* @implSpec If a value is present the result must include its string
* representation in the result. Empty and present Optionals must be
* unambiguously differentiable.
*
* @return the string representation of this instance
*/
@Override
public String toString() {
return value != null
? String.format("Optional[%s]", value)
: "Optional.empty";
}
}
@@ -0,0 +1,121 @@
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.nextcloud.java.util.function;
/**
* This class is backported from Java 8 to be used on older Android API levels.
*
* Represents a predicate (boolean-valued function) of one argument.
*
* <p>This is a <a href="package-summary.html">functional interface</a>
* whose functional method is {@link #test(Object)}.
*
* @param <T> the type of the input to the predicate
*/
@FunctionalInterface
public interface Predicate<T> {
/**
* Evaluates this predicate on the given argument.
*
* @param t the input argument
* @return {@code true} if the input argument matches the predicate,
* otherwise {@code false}
*/
boolean test(T t);
/**
* Returns a composed predicate that represents a short-circuiting logical
* AND of this predicate and another. When evaluating the composed
* predicate, if this predicate is {@code false}, then the {@code other}
* predicate is not evaluated.
*
* <p>Any exceptions thrown during evaluation of either predicate are relayed
* to the caller; if evaluation of this predicate throws an exception, the
* {@code other} predicate will not be evaluated.
*
* @param other a predicate that will be logically-ANDed with this
* predicate
* @return a composed predicate that represents the short-circuiting logical
* AND of this predicate and the {@code other} predicate
* @throws NullPointerException if other is null
*/
default Predicate<T> and(Predicate<? super T> other) {
if (other == null) {
throw new NullPointerException();
}
return (t) -> test(t) && other.test(t);
}
/**
* Returns a predicate that represents the logical negation of this
* predicate.
*
* @return a predicate that represents the logical negation of this
* predicate
*/
default Predicate<T> negate() {
return (t) -> !test(t);
}
/**
* Returns a composed predicate that represents a short-circuiting logical
* OR of this predicate and another. When evaluating the composed
* predicate, if this predicate is {@code true}, then the {@code other}
* predicate is not evaluated.
*
* <p>Any exceptions thrown during evaluation of either predicate are relayed
* to the caller; if evaluation of this predicate throws an exception, the
* {@code other} predicate will not be evaluated.
*
* @param other a predicate that will be logically-ORed with this
* predicate
* @return a composed predicate that represents the short-circuiting logical
* OR of this predicate and the {@code other} predicate
* @throws NullPointerException if other is null
*/
default Predicate<T> or(Predicate<? super T> other) {
if (other == null) {
throw new NullPointerException();
}
return (t) -> test(t) || other.test(t);
}
/**
* Returns a predicate that tests if two arguments are equal according
* to {@link androidx.core.util.ObjectsCompat#equals(Object, Object)}.
*
* @param <T> the type of arguments to the predicate
* @param targetRef the object reference with which to compare for equality,
* which may be {@code null}
* @return a predicate that tests if two arguments are equal according
* to {@link androidx.core.util.ObjectsCompat#equals(Object, Object)}
*/
static <T> Predicate<T> isEqual(Object targetRef) {
return (null == targetRef)
? object -> object == null
: object -> targetRef.equals(object);
}
}
@@ -0,0 +1,26 @@
/*
* Nextcloud Android client application
*
* @author Chris Narkiewicz <[email protected]>
* Copyright (C) 2019 Chris Narkiewicz
* Copyright (C) 2019 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/>.
*/
/**
* This is a compatibility package providing some backported Java 8 classes
* not available in some older Android runtimes.
*/
package com.nextcloud.java.util;
+32 -15
View File
@@ -45,6 +45,7 @@ import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest;
import com.nextcloud.client.account.UserAccountManager;
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.DaggerAppComponent;
@@ -100,6 +101,7 @@ import javax.net.ssl.SSLEngine;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.util.Pair;
import androidx.multidex.MultiDexApplication;
import dagger.android.AndroidInjector;
@@ -160,6 +162,9 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@Inject
BackgroundJobManager backgroundJobManager;
@Inject
Clock clock;
private PassCodeManager passCodeManager;
@SuppressWarnings("unused")
@@ -242,6 +247,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@SuppressFBWarnings("ST")
@Override
public void onCreate() {
setAppTheme(preferences.isDarkThemeEnabled());
super.onCreate();
insertConscrypt();
@@ -266,7 +272,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
preferences,
uploadsStorageManager,
connectivityService,
powerManagementService
powerManagementService,
clock
)
);
@@ -302,7 +309,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
accountManager,
connectivityService,
powerManagementService,
backgroundJobManager);
backgroundJobManager,
clock);
initContactsBackup(accountManager);
notificationChannels();
@@ -460,23 +468,24 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
final UserAccountManager accountManager,
final ConnectivityService connectivityService,
final PowerManagementService powerManagementService,
final BackgroundJobManager jobManager
final BackgroundJobManager jobManager,
final Clock clock
) {
updateToAutoUpload();
cleanOldEntries();
updateAutoUploadEntries();
cleanOldEntries(clock);
updateAutoUploadEntries(clock);
if (getAppContext() != null) {
if (PermissionUtil.checkSelfPermission(getAppContext(),
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
splitOutAutoUploadEntries();
splitOutAutoUploadEntries(clock);
} else {
AppPreferences preferences = AppPreferencesImpl.fromContext(getAppContext());
preferences.setAutoUploadSplitEntriesEnabled(true);
}
}
initiateExistingAutoUploadEntries();
initiateExistingAutoUploadEntries(clock);
FilesSyncHelper.scheduleFilesSyncIfNeeded(mContext, jobManager);
FilesSyncHelper.restartJobsIfNeeded(
@@ -683,18 +692,18 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
}
}
private static void updateAutoUploadEntries() {
private static void updateAutoUploadEntries(Clock clock) {
// updates entries to reflect their true paths
Context context = getAppContext();
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
if (!preferences.isAutoUploadPathsUpdateEnabled()) {
SyncedFolderProvider syncedFolderProvider =
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences);
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences, clock);
syncedFolderProvider.updateAutoUploadPaths(mContext);
}
}
private static void splitOutAutoUploadEntries() {
private static void splitOutAutoUploadEntries(Clock clock) {
Context context = getAppContext();
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
if (!preferences.isAutoUploadSplitEntriesEnabled()) {
@@ -703,7 +712,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
Log_OC.i(TAG, "Migrate synced_folders records for image/video split");
ContentResolver contentResolver = context.getContentResolver();
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences);
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);
@@ -749,12 +758,12 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
}
}
private static void initiateExistingAutoUploadEntries() {
private static void initiateExistingAutoUploadEntries(Clock clock) {
new Thread(() -> {
AppPreferences preferences = AppPreferencesImpl.fromContext(getAppContext());
if (!preferences.isAutoUploadInitialized()) {
SyncedFolderProvider syncedFolderProvider =
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences);
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences, clock);
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
if (syncedFolder.isEnabled()) {
@@ -768,7 +777,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
}).start();
}
private static void cleanOldEntries() {
private static void cleanOldEntries(Clock clock) {
// previous versions of application created broken entries in the SyncedFolderProvider
// database, and this cleans all that and leaves 1 (newest) entry per synced folder
@@ -777,7 +786,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
if (!preferences.isLegacyClean()) {
SyncedFolderProvider syncedFolderProvider =
new SyncedFolderProvider(context.getContentResolver(), preferences);
new SyncedFolderProvider(context.getContentResolver(), preferences, clock);
List<SyncedFolder> syncedFolderList = syncedFolderProvider.getSyncedFolders();
Map<Pair<String, String>, Long> syncedFolders = new HashMap<>();
@@ -811,4 +820,12 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
return dispatchingAndroidInjector;
}
public static void setAppTheme(Boolean darkTheme) {
if (darkTheme) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
}
@@ -62,6 +62,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.provider.DocumentsContract;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
@@ -91,6 +92,7 @@ import android.widget.Toast;
import com.blikoon.qrcodescanner.QrCodeActivity;
import com.google.android.material.snackbar.Snackbar;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.device.DeviceInfo;
import com.nextcloud.client.di.Injectable;
@@ -189,7 +191,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private static final String KEY_USERNAME = "USERNAME";
private static final String KEY_PASSWORD = "PASSWORD";
private static final String KEY_ASYNC_TASK_IN_PROGRESS = "AUTH_IN_PROGRESS";
private static final String WEB_LOGIN = "/index.php/login/flow";
public static final String WEB_LOGIN = "/index.php/login/flow";
public static final String PROTOCOL_SUFFIX = "://";
public static final String LOGIN_URL_DATA_KEY_VALUE_SEPARATOR = ":";
public static final String HTTPS_PROTOCOL = "https://";
@@ -401,12 +403,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
setClient(progressBar);
// show snackbar after 60s to switch back to old login method
if (showLegacyLogin) {
if (showLegacyLogin && getResources().getBoolean(R.bool.show_old_login)) {
final String finalBaseURL = baseURL;
new Handler().postDelayed(() -> DisplayUtils.createSnackbar(mLoginWebView,
R.string.fallback_weblogin_text,
Snackbar.LENGTH_INDEFINITE)
.setActionTextColor(getResources().getColor(R.color.white))
.setActionTextColor(getResources().getColor(R.color.themed_fg))
.setBackgroundTint(getResources().getColor(R.color.themed_bg))
.setTextColor(getResources().getColor(R.color.themed_fg))
.setAction(R.string.fallback_weblogin_back, v -> {
mLoginWebView.setVisibility(View.INVISIBLE);
webViewLoginMethod = false;
@@ -1732,8 +1736,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
/// add the new account as default in preferences, if there is none already
Account defaultAccount = accountManager.getCurrentAccount();
if (defaultAccount == null) {
User defaultAccount = accountManager.getUser();
if (defaultAccount.isAnonymous()) {
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putString("select_oc_account", accountName);
editor.apply();
@@ -1768,6 +1772,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
setAccountAuthenticatorResult(intent.getExtras());
setResult(RESULT_OK, intent);
// notify Document Provider
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String authority = getResources().getString(R.string.document_provider_authority);
Uri rootsUri = DocumentsContract.buildRootsUri(authority);
getContentResolver().notifyChange(rootsUri, null);
}
return true;
}
}
@@ -1259,8 +1259,8 @@ public class FileDataStorageManager {
private void resetShareFlagsInAllFiles() {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
String[] whereArgs = new String[]{account.name};
@@ -1279,8 +1279,8 @@ public class FileDataStorageManager {
private void resetShareFlagsInFolder(OCFile folder) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PARENT + "=?";
String[] whereArgs = new String[]{account.name, String.valueOf(folder.getFileId())};
@@ -1299,8 +1299,8 @@ public class FileDataStorageManager {
private void resetShareFlagInAFile(String filePath) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
String[] whereArgs = new String[]{account.name, filePath};
@@ -23,30 +23,29 @@ package com.owncloud.android.datamodel;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
/**
* Synced folder entity containing all information per synced folder.
*/
@Getter
@Setter
@AllArgsConstructor
public class SyncedFolder implements Serializable, Cloneable {
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
public static final long EMPTY_ENABLED_TIMESTAMP_MS = -1;
private static final long serialVersionUID = -793476118299906429L;
private long id = UNPERSISTED_ID;
private String localPath;
private String remotePath;
private Boolean wifiOnly;
private Boolean chargingOnly;
private Boolean subfolderByDate;
private String account;
private Integer uploadAction;
private boolean enabled;
private MediaFolderType type;
@Getter @Setter private long id;
@Getter @Setter private String localPath;
@Getter @Setter private String remotePath;
@Getter @Setter private boolean wifiOnly;
@Getter @Setter private boolean chargingOnly;
@Getter @Setter private boolean subfolderByDate;
@Getter @Setter private String account;
@Getter @Setter private int uploadAction;
@Getter private boolean enabled;
@Getter private long enabledTimestampMs;
@Getter @Setter private MediaFolderType type;
@Getter @Setter private boolean hidden;
/**
* constructor for new, to be persisted entity.
@@ -59,11 +58,43 @@ public class SyncedFolder implements Serializable, Cloneable {
* @param account the account owning the synced folder
* @param uploadAction the action to be done after the upload
* @param enabled flag if synced folder config is active
* @param timestampMs the current timestamp in milliseconds
* @param type the type of the folder
* @param hidden hide item flag
*/
public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
MediaFolderType type) {
public SyncedFolder(String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
MediaFolderType type,
boolean hidden) {
this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction,
enabled, timestampMs, type, hidden);
}
/**
* constructor for wrapping existing folders.
*
* @param id id
*/
protected SyncedFolder(long id,
String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
MediaFolderType type,
boolean hidden) {
this.id = id;
this.localPath = localPath;
this.remotePath = remotePath;
this.wifiOnly = wifiOnly;
@@ -71,8 +102,17 @@ public class SyncedFolder implements Serializable, Cloneable {
this.subfolderByDate = subfolderByDate;
this.account = account;
this.uploadAction = uploadAction;
this.enabled = enabled;
this.setEnabled(enabled, timestampMs);
this.type = type;
this.hidden = hidden;
}
/**
* @param timestampMs the current timestamp in milliseconds
*/
public void setEnabled(boolean enabled, long timestampMs) {
this.enabled = enabled;
this.enabledTimestampMs = enabled ? timestampMs : EMPTY_ENABLED_TIMESTAMP_MS;
}
public Object clone() {
@@ -53,21 +53,43 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
* @param folderName the UI info for the folder's name
* @param numberOfFiles the UI info for number of files within the folder
* @param type the type of the folder
* @param hidden hide item flag
*/
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
List<String> filePaths, String folderName, long numberOfFiles, MediaFolderType type)
{
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
public SyncedFolderDisplayItem(long id,
String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
List<String> filePaths,
String folderName,
long numberOfFiles,
MediaFolderType type,
boolean hidden) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
timestampMs, type, hidden);
this.filePaths = filePaths;
this.folderName = folderName;
this.numberOfFiles = numberOfFiles;
}
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
String folderName, MediaFolderType type) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
public SyncedFolderDisplayItem(long id,
String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
String folderName, MediaFolderType type, boolean hidden) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
timestampMs, type, hidden);
this.folderName = folderName;
}
}
@@ -27,6 +27,7 @@ import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.db.ProviderMeta;
@@ -47,20 +48,22 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
public class SyncedFolderProvider extends Observable {
static private final String TAG = SyncedFolderProvider.class.getSimpleName();
private ContentResolver mContentResolver;
private AppPreferences preferences;
private final ContentResolver mContentResolver;
private final AppPreferences preferences;
private final Clock clock;
/**
* constructor.
*
* @param contentResolver the ContentResolver to work with.
*/
public SyncedFolderProvider(ContentResolver contentResolver, AppPreferences preferences) {
public SyncedFolderProvider(ContentResolver contentResolver, AppPreferences preferences, Clock clock) {
if (contentResolver == null) {
throw new IllegalArgumentException("Cannot create an instance with a NULL contentResolver");
}
mContentResolver = contentResolver;
this.preferences = preferences;
this.clock = clock;
}
/**
@@ -162,7 +165,7 @@ public class SyncedFolderProvider extends Observable {
// read sync folder object and update
SyncedFolder syncedFolder = createSyncedFolderFromCursor(cursor);
syncedFolder.setEnabled(enabled);
syncedFolder.setEnabled(enabled, clock.getCurrentTime());
// update sync folder object in db
result = updateSyncFolder(syncedFolder);
@@ -335,23 +338,27 @@ public class SyncedFolderProvider extends Observable {
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH));
String remotePath = cursor.getString(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH));
Boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY)) == 1;
Boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY)) == 1;
Boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE)) == 1;
String accountName = cursor.getString(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT));
Integer uploadAction = cursor.getInt(cursor.getColumnIndex(
int uploadAction = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
Boolean enabled = cursor.getInt(cursor.getColumnIndex(
boolean enabled = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
long enabledTimestampMs = cursor.getLong(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS));
MediaFolderType type = MediaFolderType.getById(cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
boolean hidden = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;
syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
accountName, uploadAction, enabled, type);
accountName, uploadAction, enabled, enabledTimestampMs, type, hidden);
}
return syncedFolder;
}
@@ -367,13 +374,15 @@ public class SyncedFolderProvider extends Observable {
ContentValues cv = new ContentValues();
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH, syncedFolder.getLocalPath());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH, syncedFolder.getRemotePath());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.getWifiOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.getChargingOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.isWifiOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.isChargingOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE, syncedFolder.getType().getId());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.isHidden());
return cv;
}
@@ -1173,7 +1173,8 @@ public final class ThumbnailsCacheManager {
Bitmap resultBitmap = Bitmap.createBitmap(pxW, pxH, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(resultBitmap);
c.drawColor(MainApp.getAppContext().getResources().getColor(R.color.background_color));
// TODO check based on https://github.com/nextcloud/android/pull/3459#discussion_r339935975
c.drawColor(MainApp.getAppContext().getResources().getColor(R.color.background_color_png));
c.drawBitmap(bitmap, 0, 0, null);
return resultBitmap;
@@ -30,6 +30,7 @@ import android.database.Cursor;
import android.net.Uri;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.account.User;
import com.owncloud.android.db.OCUpload;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.db.UploadResult;
@@ -345,24 +346,19 @@ public class UploadsStorageManager extends Observable {
}
public OCUpload[] getCurrentAndPendingUploadsForCurrentAccount() {
Account account = currentAccountProvider.getCurrentAccount();
User user = currentAccountProvider.getUser();
if (account != null) {
return getUploads(
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.DELAYED_FOR_WIFI.getValue() +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.LOCK_FAILED.getValue() +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
" AND " + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
account.name);
} else {
return new OCUpload[0];
}
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.DELAYED_FOR_WIFI.getValue() +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.LOCK_FAILED.getValue() +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
"==" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
" AND " + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
user.getAccountName());
}
/**
@@ -384,14 +380,10 @@ public class UploadsStorageManager extends Observable {
}
public OCUpload[] getFinishedUploadsForCurrentAccount() {
Account account = currentAccountProvider.getCurrentAccount();
User user = currentAccountProvider.getUser();
if (account != null) {
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", account.name);
} else {
return new OCUpload[0];
}
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", user.getAccountName());
}
/**
@@ -403,23 +395,19 @@ public class UploadsStorageManager extends Observable {
}
public OCUpload[] getFailedButNotDelayedUploadsForCurrentAccount() {
Account account = currentAccountProvider.getCurrentAccount();
User user = currentAccountProvider.getUser();
if (account != null) {
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.LOCK_FAILED.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
account.name);
} else {
return new OCUpload[0];
}
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.LOCK_FAILED.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
user.getAccountName());
}
/**
@@ -446,50 +434,41 @@ public class UploadsStorageManager extends Observable {
}
public long clearFailedButNotDelayedUploads() {
Account account = currentAccountProvider.getCurrentAccount();
long result = 0;
if (account != null) {
result = getDB().delete(
ProviderTableMeta.CONTENT_URI_UPLOADS,
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.LOCK_FAILED.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
new String[]{account.name}
);
}
User user = currentAccountProvider.getUser();
final long deleted = getDB().delete(
ProviderTableMeta.CONTENT_URI_UPLOADS,
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.LOCK_FAILED.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
new String[]{user.getAccountName()}
);
Log_OC.d(TAG, "delete all failed uploads but those delayed for Wifi");
if (result > 0) {
if (deleted > 0) {
notifyObserversNow();
}
return result;
return deleted;
}
public long clearSuccessfulUploads() {
Account account = currentAccountProvider.getCurrentAccount();
long result = 0;
if (account != null) {
result = getDB().delete(
ProviderTableMeta.CONTENT_URI_UPLOADS,
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{account.name}
);
}
User user = currentAccountProvider.getUser();
final long deleted = getDB().delete(
ProviderTableMeta.CONTENT_URI_UPLOADS,
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{user.getAccountName()}
);
Log_OC.d(TAG, "delete all successful uploads");
if (result > 0) {
if (deleted > 0) {
notifyObserversNow();
}
return result;
return deleted;
}
/**
@@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 49;
public static final int DB_VERSION = 51;
private ProviderMeta() {
// No instance
@@ -220,10 +220,12 @@ public class ProviderMeta {
public static final String SYNCED_FOLDER_WIFI_ONLY = "wifi_only";
public static final String SYNCED_FOLDER_CHARGING_ONLY = "charging_only";
public static final String SYNCED_FOLDER_ENABLED = "enabled";
public static final String SYNCED_FOLDER_ENABLED_TIMESTAMP_MS = "enabled_timestamp_ms";
public static final String SYNCED_FOLDER_TYPE = "type";
public static final String SYNCED_FOLDER_SUBFOLDER_BY_DATE = "subfolder_by_date";
public static final String SYNCED_FOLDER_ACCOUNT = "account";
public static final String SYNCED_FOLDER_UPLOAD_ACTION = "upload_option";
public static final String SYNCED_FOLDER_HIDDEN = "hidden";
// Columns of external links table
public static final String EXTERNAL_LINKS_ICON_URL = "icon_url";
@@ -28,6 +28,7 @@ import android.content.Context;
import android.content.Intent;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.jobs.BackgroundJobManager;
import com.nextcloud.client.network.ConnectivityService;
@@ -53,6 +54,7 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
@Inject ConnectivityService connectivityService;
@Inject PowerManagementService powerManagementService;
@Inject BackgroundJobManager backgroundJobManager;
@Inject Clock clock;
/**
* Receives broadcast intent reporting that the system was just boot up.
@@ -69,7 +71,8 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
accountManager,
connectivityService,
powerManagementService,
backgroundJobManager);
backgroundJobManager,
clock);
MainApp.initContactsBackup(accountManager);
} else {
Log_OC.d(TAG, "Getting wrong intent: " + intent.getAction());
@@ -28,14 +28,17 @@ import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
import android.text.TextUtils;
import com.evernote.android.job.Job;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.google.gson.Gson;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
@@ -55,7 +58,6 @@ import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
import com.owncloud.android.ui.events.AccountRemovedEvent;
import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.FilesSyncHelper;
import com.owncloud.android.utils.PushUtils;
import org.greenrobot.eventbus.EventBus;
@@ -79,12 +81,14 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
public static final String ACCOUNT = "account";
public static final String REMOTE_WIPE = "remote_wipe";
private UploadsStorageManager uploadsStorageManager;
private UserAccountManager userAccountManager;
private final UploadsStorageManager uploadsStorageManager;
private final UserAccountManager userAccountManager;
private final Clock clock;
public AccountRemovalJob(UploadsStorageManager uploadStorageManager, UserAccountManager accountManager) {
public AccountRemovalJob(UploadsStorageManager uploadStorageManager, UserAccountManager accountManager, Clock clock) {
this.uploadsStorageManager = uploadStorageManager;
this.userAccountManager = accountManager;
this.clock = clock;
}
@NonNull
@@ -127,7 +131,7 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
arbitraryDataProvider.deleteKeyForAccount(account.name, PENDING_FOR_REMOVAL);
// remove synced folders set for account
remoceSyncedFolders(context, account, arbitraryDataProvider);
remoceSyncedFolders(context, account, clock);
// delete all uploads for account
uploadsStorageManager.removeAccountUploads(account);
@@ -142,6 +146,13 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
new RemoteWipeSuccessRemoteOperation(authToken).execute(client);
}
// notify Document Provider
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String authority = context.getResources().getString(R.string.document_provider_authority);
Uri rootsUri = DocumentsContract.buildRootsUri(authority);
context.getContentResolver().notifyChange(rootsUri, null);
}
return Result.SUCCESS;
} else {
return Result.FAILURE;
@@ -165,17 +176,16 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
}
}
private void remoceSyncedFolders(Context context, Account account, ArbitraryDataProvider arbitraryDataProvider) {
private void remoceSyncedFolders(Context context, Account account, Clock clock) {
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(context.getContentResolver(),
AppPreferencesImpl.fromContext(context));
AppPreferencesImpl.fromContext(context),
clock);
List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
List<Long> syncedFolderIds = new ArrayList<>();
for (SyncedFolder syncedFolder : syncedFolders) {
if (syncedFolder.getAccount().equals(account.name)) {
arbitraryDataProvider.deleteKeyForAccount(FilesSyncHelper.GLOBAL,
FilesSyncHelper.SYNCEDFOLDERINITIATED + syncedFolder.getId());
syncedFolderIds.add(syncedFolder.getId());
}
}
@@ -34,6 +34,7 @@ import android.text.TextUtils;
import com.evernote.android.job.Job;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.client.preferences.AppPreferences;
@@ -76,22 +77,25 @@ public class FilesSyncJob extends Job {
public static final String OVERRIDE_POWER_SAVING = "overridePowerSaving";
private static final String WAKELOCK_TAG_SEPARATION = ":";
private UserAccountManager userAccountManager;
private AppPreferences preferences;
private UploadsStorageManager uploadsStorageManager;
private ConnectivityService connectivityService;
private PowerManagementService powerManagementService;
private final UserAccountManager userAccountManager;
private final AppPreferences preferences;
private final UploadsStorageManager uploadsStorageManager;
private final ConnectivityService connectivityService;
private final PowerManagementService powerManagementService;
private final Clock clock;
FilesSyncJob(final UserAccountManager userAccountManager,
final AppPreferences preferences,
final UploadsStorageManager uploadsStorageManager,
final ConnectivityService connectivityService,
final PowerManagementService powerManagementService) {
final PowerManagementService powerManagementService,
final Clock clock) {
this.userAccountManager = userAccountManager;
this.preferences = preferences;
this.uploadsStorageManager = uploadsStorageManager;
this.connectivityService = connectivityService;
this.powerManagementService = powerManagementService;
this.clock = clock;
}
@NonNull
@@ -126,13 +130,12 @@ public class FilesSyncJob extends Job {
userAccountManager,
connectivityService,
powerManagementService);
FilesSyncHelper.insertAllDBEntries(preferences, skipCustom);
FilesSyncHelper.insertAllDBEntries(preferences, clock, skipCustom);
// Create all the providers we'll need
final ContentResolver contentResolver = context.getContentResolver();
final FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver,
preferences);
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences, clock);
Locale currentLocale = context.getResources().getConfiguration().locale;
SimpleDateFormat sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale);
@@ -189,10 +192,10 @@ public class FilesSyncJob extends Job {
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
} else {
needsCharging = syncedFolder.getChargingOnly();
needsWifi = syncedFolder.getWifiOnly();
needsCharging = syncedFolder.isChargingOnly();
needsWifi = syncedFolder.isWifiOnly();
uploadAction = syncedFolder.getUploadAction();
subfolderByDate = syncedFolder.getSubfolderByDate();
subfolderByDate = syncedFolder.isSubfolderByDate();
remotePath = syncedFolder.getRemotePath();
}
@@ -39,6 +39,7 @@ import android.text.TextUtils;
import com.evernote.android.job.Job;
import com.google.gson.Gson;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.R;
@@ -74,11 +75,13 @@ public class MediaFoldersDetectionJob extends Job {
private static final String DISABLE_DETECTION_CLICK = "DISABLE_DETECTION_CLICK";
private UserAccountManager userAccountManager;
private Random randomId = new Random();
private final UserAccountManager userAccountManager;
private final Clock clock;
private final Random randomId = new Random();
MediaFoldersDetectionJob(UserAccountManager accountManager) {
MediaFoldersDetectionJob(UserAccountManager accountManager, Clock clock) {
this.userAccountManager = accountManager;
this.clock = clock;
}
@NonNull
@@ -88,7 +91,8 @@ public class MediaFoldersDetectionJob extends Job {
ContentResolver contentResolver = context.getContentResolver();
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(contentResolver);
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver,
AppPreferencesImpl.fromContext(context));
AppPreferencesImpl.fromContext(context),
clock);
Gson gson = new Gson();
String arbitraryDataString;
MediaFoldersModel mediaFoldersModel;
@@ -29,6 +29,7 @@ import android.content.Context;
import com.evernote.android.job.Job;
import com.evernote.android.job.JobCreator;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.client.preferences.AppPreferences;
@@ -48,6 +49,7 @@ public class NCJobCreator implements JobCreator {
private final UploadsStorageManager uploadsStorageManager;
private final ConnectivityService connectivityService;
private final PowerManagementService powerManagementService;
private final Clock clock;
public NCJobCreator(
Context context,
@@ -55,7 +57,8 @@ public class NCJobCreator implements JobCreator {
AppPreferences preferences,
UploadsStorageManager uploadsStorageManager,
ConnectivityService connectivityServices,
PowerManagementService powerManagementService
PowerManagementService powerManagementService,
Clock clock
) {
this.context = context;
this.accountManager = accountManager;
@@ -63,6 +66,7 @@ public class NCJobCreator implements JobCreator {
this.uploadsStorageManager = uploadsStorageManager;
this.connectivityService = connectivityServices;
this.powerManagementService = powerManagementService;
this.clock = clock;
}
@Override
@@ -73,19 +77,20 @@ public class NCJobCreator implements JobCreator {
case ContactsImportJob.TAG:
return new ContactsImportJob();
case AccountRemovalJob.TAG:
return new AccountRemovalJob(uploadsStorageManager, accountManager);
return new AccountRemovalJob(uploadsStorageManager, accountManager, clock);
case FilesSyncJob.TAG:
return new FilesSyncJob(accountManager,
preferences,
uploadsStorageManager,
connectivityService,
powerManagementService);
powerManagementService,
clock);
case OfflineSyncJob.TAG:
return new OfflineSyncJob(accountManager, connectivityService, powerManagementService);
case NotificationJob.TAG:
return new NotificationJob(context, accountManager);
case MediaFoldersDetectionJob.TAG:
return new MediaFoldersDetectionJob(accountManager);
return new MediaFoldersDetectionJob(accountManager, clock);
default:
return null;
}
@@ -31,6 +31,7 @@ import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.provider.OpenableColumns;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -61,8 +62,8 @@ public class DiskLruImageCacheFileProvider extends ContentProvider {
}
private OCFile getFile(Uri uri) {
Account account = accountManager.getCurrentAccount();
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account,
User user = accountManager.getUser();
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(user.toPlatformAccount(),
MainApp.getAppContext().getContentResolver());
return fileDataStorageManager.getFileByPath(uri.getPath());
@@ -34,17 +34,19 @@ import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Point;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
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.evernote.android.job.JobRequest;
import com.evernote.android.job.util.Device;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.account.UserAccountManagerImpl;
import com.nextcloud.client.preferences.AppPreferences;
@@ -55,12 +57,12 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.operations.CopyFileOperation;
import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.operations.MoveFileOperation;
@@ -68,7 +70,6 @@ import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.ui.activity.ConflictsResolveActivity;
import com.owncloud.android.ui.activity.SettingsActivity;
import com.owncloud.android.utils.FileStorageUtils;
@@ -81,9 +82,11 @@ 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;
import java.util.concurrent.TimeUnit;
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
@@ -91,16 +94,25 @@ import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
@TargetApi(Build.VERSION_CODES.KITKAT)
public class DocumentsStorageProvider extends DocumentsProvider {
private static final String TAG = "DocumentsStorageProvider";
private static final String TAG = DocumentsStorageProvider.class.getSimpleName();
private FileDataStorageManager currentStorageManager;
private Map<Long, FileDataStorageManager> rootIdToStorageManager;
private OwnCloudClient client;
private static final long CACHE_EXPIRATION = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
UserAccountManager accountManager;
private static final String DOCUMENTID_SEPARATOR = "/";
private static final int DOCUMENTID_PARTS = 2;
private final SparseArray<FileDataStorageManager> rootIdToStorageManager = new SparseArray<>();
private final Executor executor = Executors.newCachedThreadPool();
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
public Cursor queryRoots(String[] projection) {
// always recreate storage manager collection, as it will change after account creation/removal
// and we need to serve document(tree)s with persist permissions
initiateStorageMap();
Context context = MainApp.getAppContext();
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
if (SettingsActivity.LOCK_PASSCODE.equals(preferences.getLockPreference()) ||
@@ -108,12 +120,9 @@ public class DocumentsStorageProvider extends DocumentsProvider {
return new FileCursor();
}
initiateStorageMap();
final RootCursor result = new RootCursor(projection);
for (Account account : accountManager.getAccounts()) {
result.addRoot(account, getContext());
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
result.addRoot(new Document(rootIdToStorageManager.valueAt(i), ROOT_PATH), getContext());
}
return result;
@@ -121,28 +130,12 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
final long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);
Log.d(TAG, "queryDocument(), id=" + documentId);
if (currentStorageManager == null) {
for (Map.Entry<Long, FileDataStorageManager> entry : rootIdToStorageManager.entrySet()) {
if (entry.getValue().getFileById(docId) != null) {
currentStorageManager = entry.getValue();
break;
}
}
}
if (currentStorageManager == null) {
throw new FileNotFoundException("File with id " + documentId + " not found");
}
Document document = toDocument(documentId);
final FileCursor result = new FileCursor(projection);
OCFile file = currentStorageManager.getFileById(docId);
if (file != null) {
result.addFile(file);
}
result.addFile(document);
return result;
}
@@ -151,34 +144,37 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder)
throws FileNotFoundException {
final long folderId = Long.parseLong(parentDocumentId);
updateCurrentStorageManagerIfNeeded(folderId);
Log.d(TAG, "queryChildDocuments(), id=" + parentDocumentId);
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null");
}
Account account = currentStorageManager.getAccount();
final OCFile browsedDir = currentStorageManager.getFileById(folderId);
if (Device.getNetworkType(context).equals(JobRequest.NetworkType.UNMETERED)) {
RemoteOperationResult result = new RefreshFolderOperation(browsedDir, System.currentTimeMillis(), false,
false, true, currentStorageManager, account,
getContext()).execute(client);
Document parentFolder = toDocument(parentDocumentId);
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to update document " + parentDocumentId);
}
}
FileDataStorageManager storageManager = parentFolder.getStorageManager();
final FileCursor resultCursor = new FileCursor(projection);
for (OCFile file : currentStorageManager.getFolderContent(browsedDir, false)) {
resultCursor.addFile(file);
for (OCFile file : storageManager.getFolderContent(parentFolder.getFile(), false)) {
resultCursor.addFile(new Document(storageManager, file));
}
boolean isLoading = false;
if (parentFolder.isExpired()) {
final ReloadFolderDocumentTask task = new ReloadFolderDocumentTask(parentFolder, result -> {
getContext().getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false);
});
task.executeOnExecutor(executor);
resultCursor.setLoadingTask(task);
isLoading = true;
}
final Bundle extra = new Bundle();
extra.putBoolean(DocumentsContract.EXTRA_LOADING, isLoading);
resultCursor.setExtras(extra);
resultCursor.setNotificationUri(getContext().getContentResolver(), toNotifyUri(parentFolder));
return resultCursor;
}
@@ -186,22 +182,18 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@Override
public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal cancellationSignal)
throws FileNotFoundException {
final long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);
Log.d(TAG, "openDocument(), id=" + documentId);
OCFile ocFile = currentStorageManager.getFileById(docId);
if (ocFile == null) {
throw new FileNotFoundException("File not found: " + documentId);
}
Document document = toDocument(documentId);
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
Account account = currentStorageManager.getAccount();
OCFile ocFile = document.getFile();
Account account = document.getAccount();
if (!ocFile.isDown()) {
Intent i = new Intent(getContext(), FileDownloader.class);
i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
@@ -216,7 +208,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
if (!waitOrGetCancelled(cancellationSignal)) {
throw new FileNotFoundException("File with id " + documentId + " not found!");
}
ocFile = currentStorageManager.getFileById(docId);
ocFile = document.getFile();
if (ocFile == null) {
throw new FileNotFoundException("File with id " + documentId + " not found!");
@@ -226,11 +218,10 @@ public class DocumentsStorageProvider extends DocumentsProvider {
OCFile finalFile = ocFile;
Thread syncThread = new Thread(() -> {
try {
FileDataStorageManager storageManager =
new FileDataStorageManager(account, context.getContentResolver());
SynchronizeFileOperation sfo =
new SynchronizeFileOperation(finalFile, null, account, true, context);
RemoteOperationResult result = sfo.execute(storageManager, context);
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
RemoteOperationResult result = new SynchronizeFileOperation(finalFile, null, account,
true, context)
.execute(storageManager, context);
if (result.getCode() == RemoteOperationResult.ResultCode.SYNC_CONFLICT) {
// ISSUE 5: if the user is not running the app (this is a service!),
// this can be very intrusive; a notification should be preferred
@@ -271,7 +262,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
return ParcelFileDescriptor.open(file, accessMode, handler, l -> {
RemoteOperationResult result = new SynchronizeFileOperation(newFile, oldFile, account, true,
context)
.execute(client, currentStorageManager);
.execute(document.getClient(), document.getStorageManager());
boolean success = result.isSuccess();
@@ -297,6 +288,11 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@Override
public boolean onCreate() {
accountManager = UserAccountManagerImpl.fromContext(getContext());
// initiate storage manager collection, because we need to serve document(tree)s
// with persist permissions
initiateStorageMap();
return true;
}
@@ -305,141 +301,140 @@ public class DocumentsStorageProvider extends DocumentsProvider {
Point sizeHint,
CancellationSignal signal)
throws FileNotFoundException {
long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);
OCFile file = currentStorageManager.getFileById(docId);
if (file == null) {
throw new FileNotFoundException("File with id " + documentId + " not found!");
}
Log.d(TAG, "openDocumentThumbnail(), id=" + documentId);
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
Document document = toDocument(documentId);
boolean exists = ThumbnailsCacheManager.containsBitmap(ThumbnailsCacheManager.PREFIX_THUMBNAIL
+ file.getRemoteId());
+ document.getFile().getRemoteId());
if (!exists) {
ThumbnailsCacheManager.generateThumbnailFromOCFile(file);
ThumbnailsCacheManager.generateThumbnailFromOCFile(document.getFile());
}
Uri uri = Uri.parse(UriUtils.URI_CONTENT_SCHEME + context.getResources().getString(
R.string.image_cache_provider_authority) + file.getRemotePath());
R.string.image_cache_provider_authority) + document.getRemotePath());
Log.d(TAG, "open thumbnail, uri=" + uri);
return context.getContentResolver().openAssetFileDescriptor(uri, "r");
}
@Override
public String renameDocument(String documentId, String displayName) throws FileNotFoundException {
long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);
Log.d(TAG, "renameDocument(), id=" + documentId);
OCFile file = currentStorageManager.getFileById(docId);
if (file == null) {
throw new FileNotFoundException("File " + documentId + " not found!");
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
RemoteOperationResult result = new RenameFileOperation(file.getRemotePath(), displayName)
.execute(client, currentStorageManager);
Document document = toDocument(documentId);
RemoteOperationResult result = new RenameFileOperation(document.getRemotePath(), displayName)
.execute(document.getClient(), document.getStorageManager());
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to rename document with documentId " + documentId + ": " +
result.getException());
}
context.getContentResolver().notifyChange(toNotifyUri(document.getParent()), null, false);
return null;
}
@Override
public String copyDocument(String sourceDocumentId, String targetParentDocumentId) throws FileNotFoundException {
long sourceId = Long.parseLong(sourceDocumentId);
Log.d(TAG, "copyDocument(), id=" + sourceDocumentId);
updateCurrentStorageManagerIfNeeded(sourceId);
OCFile file = currentStorageManager.getFileById(sourceId);
if (file == null) {
throw new FileNotFoundException("File " + sourceDocumentId + " not found!");
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
long targetId = Long.parseLong(targetParentDocumentId);
OCFile targetFolder = currentStorageManager.getFileById(targetId);
if (targetFolder == null) {
throw new FileNotFoundException("File " + targetParentDocumentId + " not found!");
}
Document document = toDocument(sourceDocumentId);
RemoteOperationResult result = new CopyFileOperation(file.getRemotePath(), targetFolder.getRemotePath())
.execute(client, currentStorageManager);
FileDataStorageManager storageManager = document.getStorageManager();
Document targetFolder = toDocument(targetParentDocumentId);
RemoteOperationResult result = new CopyFileOperation(document.getRemotePath(), targetFolder.getRemotePath())
.execute(document.getClient(), storageManager);
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to copy document with documentId " + sourceDocumentId
+ " to " + targetParentDocumentId);
}
Account account = currentStorageManager.getAccount();
Account account = document.getAccount();
RemoteOperationResult updateParent = new RefreshFolderOperation(targetFolder, System.currentTimeMillis(),
false, false, true, currentStorageManager,
account, getContext()).execute(client);
RemoteOperationResult updateParent = new RefreshFolderOperation(targetFolder.getFile(), System.currentTimeMillis(),
false, false, true, storageManager,
account, context)
.execute(targetFolder.getClient());
if (!updateParent.isSuccess()) {
throw new FileNotFoundException("Failed to copy document with documentId " + sourceDocumentId
+ " to " + targetParentDocumentId);
}
String newPath = targetFolder.getRemotePath() + file.getFileName();
String newPath = targetFolder.getRemotePath() + document.getFile().getFileName();
if (file.isFolder()) {
if (document.getFile().isFolder()) {
newPath = newPath + PATH_SEPARATOR;
}
OCFile newFile = currentStorageManager.getFileByPath(newPath);
Document newFile = new Document(storageManager, newPath);
return String.valueOf(newFile.getFileId());
context.getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false);
return newFile.getDocumentId();
}
@Override
public String moveDocument(String sourceDocumentId, String sourceParentDocumentId, String targetParentDocumentId)
throws FileNotFoundException {
long sourceId = Long.parseLong(sourceDocumentId);
Log.d(TAG, "moveDocument(), id=" + sourceDocumentId);
updateCurrentStorageManagerIfNeeded(sourceId);
OCFile file = currentStorageManager.getFileById(sourceId);
if (file == null) {
throw new FileNotFoundException("File " + sourceDocumentId + " not found!");
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
long targetId = Long.parseLong(targetParentDocumentId);
OCFile targetFolder = currentStorageManager.getFileById(targetId);
Document document = toDocument(sourceDocumentId);
Document targetFolder = toDocument(targetParentDocumentId);
if (targetFolder == null) {
throw new FileNotFoundException("File " + targetParentDocumentId + " not found!");
}
RemoteOperationResult result = new MoveFileOperation(file.getRemotePath(), targetFolder.getRemotePath())
.execute(client, currentStorageManager);
RemoteOperationResult result = new MoveFileOperation(document.getRemotePath(), targetFolder.getRemotePath())
.execute(document.getClient(), document.getStorageManager());
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to move document with documentId " + sourceDocumentId
+ " to " + targetParentDocumentId);
}
return String.valueOf(file.getFileId());
Document sourceFolder = toDocument(sourceParentDocumentId);
getContext().getContentResolver().notifyChange(toNotifyUri(sourceFolder), null, false);
getContext().getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false);
return sourceDocumentId;
}
@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) {
updateCurrentStorageManagerIfNeeded(rootId);
Log.d(TAG, "querySearchDocuments(), rootId=" + rootId);
OCFile root = currentStorageManager.getFileByPath(ROOT_PATH);
FileCursor result = new FileCursor(projection);
for (OCFile f : findFiles(root, query)) {
result.addFile(f);
FileDataStorageManager storageManager = getStorageManager(rootId);
if (storageManager == null) {
return result;
}
for (Document d : findFiles(new Document(storageManager, ROOT_PATH), query)) {
result.addFile(d);
}
return result;
@@ -447,53 +442,73 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@Override
public String createDocument(String documentId, String mimeType, String displayName) throws FileNotFoundException {
long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);
Log.d(TAG, "createDocument(), id=" + documentId);
OCFile parent = currentStorageManager.getFileById(docId);
Document folderDocument = toDocument(documentId);
if (parent == null) {
throw new FileNotFoundException("Parent file not found");
}
if ("vnd.android.document/directory".equalsIgnoreCase(mimeType)) {
return createFolder(parent, displayName, documentId);
if (DocumentsContract.Document.MIME_TYPE_DIR.equalsIgnoreCase(mimeType)) {
return createFolder(folderDocument, displayName);
} else {
return createFile(parent, displayName, documentId);
return createFile(folderDocument, displayName);
}
}
private String createFolder(OCFile parent, String displayName, String documentId) throws FileNotFoundException {
private String createFolder(Document targetFolder, String displayName) throws FileNotFoundException {
CreateFolderOperation createFolderOperation = new CreateFolderOperation(parent.getRemotePath() + displayName
+ PATH_SEPARATOR, true);
RemoteOperationResult result = createFolderOperation.execute(client, currentStorageManager);
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to create document with name " +
displayName + " and documentId " + documentId);
}
String newDirPath = parent.getRemotePath() + displayName + PATH_SEPARATOR;
OCFile newFolder = currentStorageManager.getFileByPath(newDirPath);
return String.valueOf(newFolder.getFileId());
}
private String createFile(OCFile parent, String displayName, String documentId) throws FileNotFoundException {
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
Account account = currentStorageManager.getAccount();
String newDirPath = targetFolder.getRemotePath() + displayName + PATH_SEPARATOR;
FileDataStorageManager storageManager = targetFolder.getStorageManager();
RemoteOperationResult result = new CreateFolderOperation(newDirPath, true)
.execute(targetFolder.getClient(), storageManager);
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to create document with name " +
displayName + " and documentId " + targetFolder.getDocumentId());
}
RemoteOperationResult updateParent = new RefreshFolderOperation(targetFolder.getFile(), System.currentTimeMillis(),
false, false, true, storageManager,
targetFolder.getAccount(), context)
.execute(targetFolder.getClient());
if (!updateParent.isSuccess()) {
throw new FileNotFoundException("Failed to create document with documentId " + targetFolder.getDocumentId());
}
Document newFolder = new Document(storageManager, newDirPath);
context.getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false);
return newFolder.getDocumentId();
}
private String createFile(Document targetFolder, String displayName) throws FileNotFoundException {
Context context = getContext();
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
Account account = targetFolder.getAccount();
// create dummy file
File tempDir = new File(FileStorageUtils.getTemporalPath(account.name));
if (!tempDir.exists() && !tempDir.mkdirs()) {
throw new FileNotFoundException("Temp folder could not be created: " + tempDir.getAbsolutePath());
}
File emptyFile = new File(tempDir, displayName);
if (emptyFile.exists() && !emptyFile.delete()) {
throw new FileNotFoundException("Previous file could not be deleted");
}
try {
if (!emptyFile.createNewFile()) {
throw new FileNotFoundException("File could not be created");
@@ -502,30 +517,40 @@ public class DocumentsStorageProvider extends DocumentsProvider {
throw new FileNotFoundException("File could not be created");
}
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
requester.uploadNewFile(getContext(), account, new String[]{emptyFile.getAbsolutePath()},
new String[]{parent.getRemotePath() + displayName}, null,
FileUploader.LOCAL_BEHAVIOUR_MOVE, true, UploadFileOperation.CREATED_BY_USER, false,
false);
String newFilePath = targetFolder.getRemotePath() + displayName;
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Log_OC.e(TAG, "Thread interruption error");
// perform the upload, no need for chunked operation as we have a empty file
OwnCloudClient client = targetFolder.getClient();
RemoteOperationResult result = new UploadFileRemoteOperation(emptyFile.getAbsolutePath(),
newFilePath,
null,
"",
String.valueOf(System.currentTimeMillis() / 1000))
.execute(client);
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to upload document with path " + newFilePath);
}
RemoteOperationResult updateParent = new RefreshFolderOperation(parent, System.currentTimeMillis(),
false, false, true, currentStorageManager,
account, getContext()).execute(client);
RemoteOperationResult updateParent = new RefreshFolderOperation(targetFolder.getFile(),
System.currentTimeMillis(),
false,
false,
true,
targetFolder.getStorageManager(),
account,
context)
.execute(client);
if (!updateParent.isSuccess()) {
throw new FileNotFoundException("Failed to create document with documentId " + documentId);
throw new FileNotFoundException("Failed to create document with documentId " + targetFolder.getDocumentId());
}
String newFilePath = parent.getRemotePath() + displayName;
OCFile newFile = currentStorageManager.getFileByPath(newFilePath);
Document newFile = new Document(targetFolder.getStorageManager(), newFilePath);
return String.valueOf(newFile.getFileId());
context.getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false);
return newFile.getDocumentId();
}
@Override
@@ -535,76 +560,84 @@ public class DocumentsStorageProvider extends DocumentsProvider {
@Override
public void deleteDocument(String documentId) throws FileNotFoundException {
long docId = Long.parseLong(documentId);
updateCurrentStorageManagerIfNeeded(docId);
OCFile file = currentStorageManager.getFileById(docId);
if (file == null) {
throw new FileNotFoundException("File " + documentId + " not found!");
}
Account account = currentStorageManager.getAccount();
RemoveFileOperation removeFileOperation = new RemoveFileOperation(file.getRemotePath(), false, account, true,
getContext());
RemoteOperationResult result = removeFileOperation.execute(client, currentStorageManager);
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to delete document with documentId " + documentId);
}
}
@SuppressLint("LongLogTag")
private void updateCurrentStorageManagerIfNeeded(long docId) {
if (rootIdToStorageManager == null) {
try {
queryRoots(FileCursor.DEFAULT_DOCUMENT_PROJECTION);
} catch (FileNotFoundException e) {
Log.e(TAG, "Failed to query roots");
}
}
if (currentStorageManager == null ||
rootIdToStorageManager.containsKey(docId) && currentStorageManager != rootIdToStorageManager.get(docId)) {
currentStorageManager = rootIdToStorageManager.get(docId);
}
try {
Account account = currentStorageManager.getAccount();
OwnCloudAccount ocAccount = new OwnCloudAccount(account, MainApp.getAppContext());
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, getContext());
} catch (OperationCanceledException | IOException | AuthenticatorException |
com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Failed to set client", e);
}
}
private void updateCurrentStorageManagerIfNeeded(String rootId) {
for (FileDataStorageManager data : rootIdToStorageManager.values()) {
if (data.getAccount().name.equals(rootId)) {
currentStorageManager = data;
}
}
}
@SuppressLint("UseSparseArrays")
private void initiateStorageMap() throws FileNotFoundException {
Log.d(TAG, "deleteDocument(), id=" + documentId);
Context context = getContext();
final Account[] allAccounts = accountManager.getAccounts();
rootIdToStorageManager = new HashMap<>(allAccounts.length);
if (context == null) {
throw new FileNotFoundException("Context may not be null!");
}
final ContentResolver contentResolver = context.getContentResolver();
for (Account account : allAccounts) {
Document document = toDocument(documentId);
recursiveRevokePermission(document);
RemoteOperationResult result = new RemoveFileOperation(document.getRemotePath(), false,
document.getAccount(), true, context)
.execute(document.getClient(), document.getStorageManager());
if (!result.isSuccess()) {
throw new FileNotFoundException("Failed to delete document with documentId " + documentId);
}
Document parentFolder = document.getParent();
context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void recursiveRevokePermission(Document document) {
FileDataStorageManager storageManager = document.getStorageManager();
OCFile file = document.getFile();
if (file.isFolder()) {
for (OCFile child : storageManager.getFolderContent(file, false)) {
recursiveRevokePermission(new Document(storageManager, child));
}
}
revokeDocumentPermission(document.getDocumentId());
}
@Override
public boolean isChildDocument(String parentDocumentId, String documentId) {
Log.d(TAG, "isChildDocument(), parent=" + parentDocumentId + ", id=" + documentId);
try {
Document currentDocument = toDocument(documentId);
Document parentDocument = toDocument(parentDocumentId);
while (!ROOT_PATH.equals(currentDocument.getRemotePath())) {
currentDocument = currentDocument.getParent();
if (parentDocument.getFile().equals(currentDocument.getFile())) {
return true;
}
}
} catch (FileNotFoundException e) {
Log.e(TAG, "failed to check for child document", e);
}
return false;
}
private FileDataStorageManager getStorageManager(String rootId) {
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
FileDataStorageManager storageManager = rootIdToStorageManager.valueAt(i);
if (storageManager.getAccount().name.equals(rootId)) {
return storageManager;
}
}
return null;
}
private void initiateStorageMap() {
rootIdToStorageManager.clear();
ContentResolver contentResolver = getContext().getContentResolver();
for (Account account : accountManager.getAccounts()) {
final FileDataStorageManager storageManager = new FileDataStorageManager(account, contentResolver);
final OCFile rootDir = storageManager.getFileByPath(ROOT_PATH);
rootIdToStorageManager.put(rootDir.getFileId(), storageManager);
rootIdToStorageManager.put(account.hashCode(), storageManager);
}
}
@@ -618,15 +651,136 @@ public class DocumentsStorageProvider extends DocumentsProvider {
return !(cancellationSignal != null && cancellationSignal.isCanceled());
}
List<OCFile> findFiles(OCFile root, String query) {
List<OCFile> result = new ArrayList<>();
for (OCFile f : currentStorageManager.getFolderContent(root, false)) {
private List<Document> findFiles(Document root, String query) {
FileDataStorageManager storageManager = root.getStorageManager();
List<Document> result = new ArrayList<>();
for (OCFile f : storageManager.getFolderContent(root.getFile(), false)) {
if (f.isFolder()) {
result.addAll(findFiles(f, query));
result.addAll(findFiles(new Document(storageManager, f), query));
} else if (f.getFileName().contains(query)) {
result.add(f);
result.add(new Document(storageManager, f));
}
}
return result;
}
private Uri toNotifyUri(Document document) {
return DocumentsContract.buildDocumentUri(
getContext().getString(R.string.document_provider_authority),
document.getDocumentId());
}
private Document toDocument(String documentId) throws FileNotFoundException {
String[] separated = documentId.split(DOCUMENTID_SEPARATOR, DOCUMENTID_PARTS);
if (separated.length != DOCUMENTID_PARTS) {
throw new FileNotFoundException("Invalid documentID " + documentId + "!");
}
FileDataStorageManager storageManager = rootIdToStorageManager.get(Integer.parseInt(separated[0]));
if (storageManager == null) {
throw new FileNotFoundException("No storage manager associated for " + documentId + "!");
}
return new Document(storageManager, Long.parseLong(separated[1]));
}
public interface OnTaskFinishedCallback {
void onTaskFinished(RemoteOperationResult result);
}
static class ReloadFolderDocumentTask extends AsyncTask<Void, Void, RemoteOperationResult> {
private final Document folder;
private final OnTaskFinishedCallback callback;
ReloadFolderDocumentTask(Document folder, OnTaskFinishedCallback callback) {
this.folder = folder;
this.callback = callback;
}
@Override
public final RemoteOperationResult doInBackground(Void... params) {
Log.d(TAG, "run ReloadFolderDocumentTask(), id=" + folder.getDocumentId());
return new RefreshFolderOperation(folder.getFile(), System.currentTimeMillis(), false,
false, true, folder.getStorageManager(), folder.getAccount(),
MainApp.getAppContext())
.execute(folder.getClient());
}
@Override
public final void onPostExecute(RemoteOperationResult result) {
if (callback != null) {
callback.onTaskFinished(result);
}
}
}
public class Document {
private final FileDataStorageManager storageManager;
private final long fileId;
Document(FileDataStorageManager storageManager, long fileId) {
this.storageManager = storageManager;
this.fileId = fileId;
}
Document(FileDataStorageManager storageManager, OCFile file) {
this.storageManager = storageManager;
this.fileId = file.getFileId();
}
Document(FileDataStorageManager storageManager, String filePath) {
this.storageManager = storageManager;
this.fileId = storageManager.getFileByPath(filePath).getFileId();
}
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;
}
}
return null;
}
FileDataStorageManager getStorageManager() {
return storageManager;
}
public Account getAccount() {
return getStorageManager().getAccount();
}
public OCFile getFile() {
return getStorageManager().getFileById(fileId);
}
public String getRemotePath() {
return getFile().getRemotePath();
}
OwnCloudClient getClient() {
try {
OwnCloudAccount ocAccount = new OwnCloudAccount(getAccount(), MainApp.getAppContext());
return OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, getContext());
} catch (OperationCanceledException | IOException | AuthenticatorException |
com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Failed to set client", e);
}
return null;
}
boolean isExpired() {
return getFile().getLastSyncDateForData() + CACHE_EXPIRATION < System.currentTimeMillis();
}
Document getParent() {
long parentId = getFile().getParentId();
if (parentId <= 0) {
return null;
}
return new Document(getStorageManager(), parentId);
}
}
}
@@ -42,9 +42,11 @@ import android.net.Uri;
import android.os.Binder;
import android.text.TextUtils;
import com.nextcloud.client.core.Clock;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.SyncedFolder;
import com.owncloud.android.db.ProviderMeta;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.lib.common.accounts.AccountUtils;
@@ -58,7 +60,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import dagger.android.AndroidInjection;
/**
* The ContentProvider for the ownCloud App.
@@ -91,6 +96,7 @@ public class FileContentProvider extends ContentProvider {
public static final int ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION = 20;
public static final int MINIMUM_PATH_SEGMENTS_SIZE = 1;
@Inject protected Clock clock;
private DataBaseHelper mDbHelper;
private Context mContext;
private UriMatcher mUriMatcher;
@@ -414,6 +420,7 @@ public class FileContentProvider extends ContentProvider {
@Override
public boolean onCreate() {
AndroidInjection.inject(this);
mDbHelper = new DataBaseHelper(getContext());
mContext = getContext();
@@ -822,10 +829,12 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY + " INTEGER, " // wifi_only
+ ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY + " INTEGER, " // charging only
+ ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, " // enabled
+ ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " INTEGER, " // enable date
+ ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
+ ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " TEXT, " // account
+ ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER, " // upload action
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER );" // type
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER, " // type
+ ProviderTableMeta.SYNCED_FOLDER_HIDDEN + " INTEGER );" // hidden
);
}
@@ -2013,6 +2022,48 @@ public class FileContentProvider extends ContentProvider {
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
if (oldVersion < 50 && newVersion >= 50) {
Log_OC.i(SQL, "Entering in the #50 add persistent enable date to synced_folders table");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " INTEGER ");
db.execSQL("UPDATE " + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME + " SET " +
ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " = CASE " +
" WHEN enabled = 0 THEN " + SyncedFolder.EMPTY_ENABLED_TIMESTAMP_MS + " " +
" ELSE " + clock.getCurrentTime() +
" END ");
upgraded = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
if (oldVersion < 51 && newVersion >= 51) {
Log_OC.i(SQL, "Entering in the #51 add show/hide to folderSync table");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_HIDDEN + " INTEGER ");
upgraded = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
}
@Override
@@ -34,6 +34,7 @@ import android.os.Looper;
import android.provider.BaseColumns;
import android.widget.Toast;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -180,18 +181,14 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
// need to trust on the AccountUtils to get the current account since the query in the client side is not
// directly started by our code, but from SearchView implementation
Account account = accountManager.getCurrentAccount();
if (account == null) {
throw new IllegalArgumentException("Account may not be null!");
}
User user = accountManager.getUser();
String userQuery = lastPathSegment.toLowerCase(Locale.ROOT);
// request to the OC server about users and groups matching userQuery
GetShareesRemoteOperation searchRequest = new GetShareesRemoteOperation(userQuery, REQUESTED_PAGE,
RESULTS_PER_PAGE);
RemoteOperationResult result = searchRequest.execute(account, getContext());
RemoteOperationResult result = searchRequest.execute(user.toPlatformAccount(), getContext());
List<JSONObject> names = new ArrayList<>();
if (result.isSuccess()) {
@@ -217,8 +214,10 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
Uri remoteBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_REMOTE).build();
Uri emailBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_EMAIL).build();
FileDataStorageManager manager = new FileDataStorageManager(account, getContext().getContentResolver());
boolean federatedShareAllowed = manager.getCapability(account.name).getFilesSharingFederationOutgoing()
FileDataStorageManager manager = new FileDataStorageManager(user.toPlatformAccount(),
getContext().getContentResolver());
boolean federatedShareAllowed = manager.getCapability(user.getAccountName())
.getFilesSharingFederationOutgoing()
.isTrue();
try {
@@ -1,38 +0,0 @@
/**
* ownCloud Android client application
*
* Copyright (C) 2015 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui;
import android.content.Context;
import android.preference.CheckBoxPreference;
import android.view.View;
import com.owncloud.android.R;
public class RadioButtonPreference extends CheckBoxPreference implements View.OnLongClickListener {
public RadioButtonPreference(Context context) {
super(context, null, android.R.attr.checkBoxPreferenceStyle);
setWidgetLayoutResource(R.layout.preference_widget_radiobutton);
}
@Override
public boolean onLongClick(View v) {
return true;
}
}
@@ -30,6 +30,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import com.owncloud.android.R;
import com.owncloud.android.utils.ThemeUtils;
import androidx.annotation.RequiresApi;
@@ -76,12 +77,14 @@ public class ThemeableSwitchPreference extends SwitchPreference {
if(thumbColorStateList == null && trackColorStateList == null) {
int color = ThemeUtils.primaryAccentColor(getContext());
int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color));
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[]{color, Color.WHITE});
trackColorStateList = new ColorStateList(
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
new int[]{trackColor, Color.parseColor("#4D000000")});
new int[][]{new int[]{android.R.attr.state_checked},
new int[]{}},
new int[]{trackColor, trackColorUnchecked});
}
// setting the thumb color
@@ -169,7 +169,8 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
PorterDuff.Mode.SRC_IN);
FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
adapter = new ActivityListAdapter(this, getUserAccountManager(), this, storageManager, getCapabilities(), false);
adapter = new ActivityListAdapter(this, getUserAccountManager(), this, storageManager,
getCapabilities(), false);
recyclerView.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
@@ -99,7 +99,6 @@ public class StickyHeaderItemDecoration extends RecyclerView.ItemDecoration {
int headerPosition = adapter.getHeaderPositionForItem(itemPosition);
int layoutId = adapter.getHeaderLayout(itemPosition);
View header = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
header.setBackgroundColor(Color.WHITE);
adapter.bindHeaderData(header, headerPosition);
return header;
}
@@ -28,6 +28,7 @@ import android.accounts.OperationCanceledException;
import android.content.Context;
import android.os.AsyncTask;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
@@ -58,8 +59,11 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
@Override
public void getAllActivities(int lastGiven, ActivitiesServiceCallback<List<Object>> callback) {
Account account = accountManager.getCurrentAccount();
GetActivityListTask getActivityListTask = new GetActivityListTask(account, accountManager, lastGiven, callback);
User user = accountManager.getUser();
GetActivityListTask getActivityListTask = new GetActivityListTask(user.toPlatformAccount(),
accountManager,
lastGiven,
callback);
getActivityListTask.execute();
}
@@ -22,19 +22,16 @@
*/
package com.owncloud.android.ui.activities.data.files;
import android.accounts.Account;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.Context;
import android.os.AsyncTask;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
@@ -44,8 +41,6 @@ import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.ui.activity.BaseActivity;
import com.owncloud.android.utils.FileStorageUtils;
import java.io.IOException;
/**
* Implementation of the Files service API that communicates with the NextCloud remote server.
*/
@@ -54,15 +49,18 @@ public class FilesServiceApiImpl implements FilesServiceApi {
private static final String TAG = FilesServiceApiImpl.class.getSimpleName();
private UserAccountManager accountManager;
private ClientFactory clientFactory;
public FilesServiceApiImpl(UserAccountManager accountManager) {
public FilesServiceApiImpl(UserAccountManager accountManager, ClientFactory clientFactory) {
this.accountManager = accountManager;
this.clientFactory = clientFactory;
}
@Override
public void readRemoteFile(String fileUrl, BaseActivity activity, FilesServiceCallback<OCFile> callback) {
ReadRemoteFileTask readRemoteFileTask = new ReadRemoteFileTask(
accountManager,
clientFactory,
fileUrl,
activity,
callback
@@ -77,30 +75,29 @@ public class FilesServiceApiImpl implements FilesServiceApi {
// TODO: Figure out a better way to do this than passing a BaseActivity reference.
private final BaseActivity baseActivity;
private final String fileUrl;
private final Account account;
private final User user;
private final UserAccountManager accountManager;
private final ClientFactory clientFactory;
private ReadRemoteFileTask(UserAccountManager accountManager,
ClientFactory clientFactory,
String fileUrl,
BaseActivity baseActivity,
FilesServiceCallback<OCFile> callback) {
this.callback = callback;
this.baseActivity = baseActivity;
this.fileUrl = fileUrl;
this.account = accountManager.getCurrentAccount();
this.user = accountManager.getUser();
this.accountManager = accountManager;
this.clientFactory = clientFactory;
}
@Override
protected Boolean doInBackground(Void... voids) {
final Context context = MainApp.getAppContext();
OwnCloudAccount ocAccount;
OwnCloudClient ownCloudClient;
try {
ocAccount = new OwnCloudAccount(account, context);
ownCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
ownCloudClient.setOwnCloudVersion(accountManager.getServerVersion(account));
OwnCloudClient ownCloudClient = clientFactory.create(user);
ownCloudClient.setOwnCloudVersion(user.getServer().getVersion());
// always update file as it could be an old state saved in database
RemoteOperationResult resultRemoteFileOp = new ReadFileRemoteOperation(fileUrl).execute(ownCloudClient);
@@ -111,28 +108,19 @@ public class FilesServiceApiImpl implements FilesServiceApi {
if (remoteOcFile.isFolder()) {
// perform folder synchronization
RemoteOperation synchFolderOp = new RefreshFolderOperation(remoteOcFile,
System.currentTimeMillis(),
false,
true,
baseActivity.getStorageManager(),
baseActivity.getAccount(),
context);
System.currentTimeMillis(),
false,
true,
baseActivity.getStorageManager(),
baseActivity.getAccount(),
context);
synchFolderOp.execute(ownCloudClient);
}
}
return true;
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Account not found", e);
errorMessage = baseActivity.getString(R.string.account_not_found);
} catch (IOException e) {
Log_OC.e(TAG, "IO error", e);
errorMessage = baseActivity.getString(R.string.io_error);
} catch (OperationCanceledException e) {
Log_OC.e(TAG, "Operation has been canceled", e);
errorMessage = baseActivity.getString(R.string.operation_canceled);
} catch (AuthenticatorException e) {
Log_OC.e(TAG, "Authentication Exception", e);
errorMessage = baseActivity.getString(R.string.authentication_exception);
}
return false;
@@ -8,9 +8,13 @@ import android.accounts.OperationCanceledException;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.PersistableBundle;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
@@ -19,43 +23,93 @@ import com.owncloud.android.lib.resources.status.OCCapability;
import javax.inject.Inject;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
* Base activity with common behaviour for activities dealing with ownCloud {@link Account}s .
*/
public abstract class BaseActivity extends AppCompatActivity implements Injectable {
private static final String TAG = BaseActivity.class.getSimpleName();
/**
* ownCloud {@link Account} where the main {@link OCFile} handled by the activity is located.
*/
private Account mCurrentAccount;
private Account currentAccount;
/**
* Capabilities of the server where {@link #mCurrentAccount} lives.
* Capabilities of the server where {@link #currentAccount} lives.
*/
private OCCapability mCapabilities;
private OCCapability capabilities;
/**
* Access point to the cached database for the current ownCloud {@link Account}.
*/
private FileDataStorageManager mStorageManager;
private FileDataStorageManager storageManager;
/**
* Tracks whether the activity should be recreate()'d after a theme change
*/
private boolean themeChangePending;
private boolean paused;
@Inject UserAccountManager accountManager;
@Inject AppPreferences preferences;
private AppPreferences.Listener onPreferencesChanged = new AppPreferences.Listener() {
@Override
public void onDarkThemeEnabledChanged(boolean enabled) {
BaseActivity.this.onThemeSettingsChanged();
}
};
public UserAccountManager getUserAccountManager() {
return accountManager;
}
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
preferences.addListener(onPreferencesChanged);
}
@Override
protected void onDestroy() {
super.onDestroy();
preferences.removeListener(onPreferencesChanged);
}
@Override
protected void onPause() {
super.onPause();
paused = true;
}
@Override
protected void onResume() {
super.onResume();
paused = false;
if(themeChangePending) {
recreate();
}
}
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
Account account = accountManager.getCurrentAccount();
setAccount(account, false);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log_OC.v(TAG, "onNewIntent() start");
Account current = accountManager.getCurrentAccount();
if (current != null && mCurrentAccount != null && !mCurrentAccount.name.equals(current.name)) {
mCurrentAccount = current;
if (current != null && currentAccount != null && !currentAccount.name.equals(current.name)) {
currentAccount = current;
}
Log_OC.v(TAG, "onNewIntent() stop");
}
@@ -68,13 +122,21 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
protected void onRestart() {
Log_OC.v(TAG, "onRestart() start");
super.onRestart();
boolean validAccount = mCurrentAccount != null && accountManager.exists(mCurrentAccount);
boolean validAccount = currentAccount != null && accountManager.exists(currentAccount);
if (!validAccount) {
swapToDefaultAccount();
}
Log_OC.v(TAG, "onRestart() end");
}
private void onThemeSettingsChanged() {
if(paused) {
themeChangePending = true;
} else {
recreate();
}
}
/**
* Sets and validates the ownCloud {@link Account} associated to the Activity.
*
@@ -87,10 +149,19 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
protected void setAccount(Account account, boolean savedAccount) {
boolean validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name);
if (validAccount) {
mCurrentAccount = account;
currentAccount = account;
} else {
swapToDefaultAccount();
}
if(currentAccount != null) {
storageManager = new FileDataStorageManager(currentAccount, getContentResolver());
capabilities = storageManager.getCapability(currentAccount.name);
}
}
protected void setUser(User user) {
setAccount(user.toPlatformAccount(), false);
}
/**
@@ -106,7 +177,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
/// no account available: force account creation
createAccount(true);
} else {
mCurrentAccount = newAccount;
currentAccount = newAccount;
}
}
@@ -127,26 +198,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
new Handler());
}
/**
* Called when the ownCloud {@link Account} associated to the Activity was just updated.
*
* Child classes must grant that state depending on the {@link Account} is updated.
*/
@Deprecated
protected void onAccountSet() {
if (getAccount() != null) {
mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
mCapabilities = mStorageManager.getCapability(mCurrentAccount.name);
} else {
Log_OC.e(TAG, "onAccountChanged was called with NULL account associated!");
}
}
@Deprecated
protected void setAccount(Account account) {
mCurrentAccount = account;
}
/**
* Getter for the capabilities of the server where the current OC account lives.
*
@@ -154,7 +205,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
* set yet.
*/
public OCCapability getCapabilities() {
return mCapabilities;
return capabilities;
}
/**
@@ -165,20 +216,19 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
* is located.
*/
public Account getAccount() {
return mCurrentAccount;
return currentAccount;
}
@Override
protected void onStart() {
super.onStart();
if(mCurrentAccount != null) {
onAccountSet();
public Optional<User> getUser() {
if (currentAccount != null) {
return accountManager.getUser(currentAccount.name);
} else {
return Optional.empty();
}
}
public FileDataStorageManager getStorageManager() {
return mStorageManager;
return storageManager;
}
/**
@@ -22,7 +22,6 @@
package com.owncloud.android.ui.activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
@@ -93,7 +92,7 @@ public class CommunityActivity extends FileActivity {
getString(R.string.contributing_link)))));
MaterialButton reportButton = findViewById(R.id.community_testing_report);
reportButton.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
reportButton.setBackgroundColor(ThemeUtils.primaryColor(this,true));
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
}
@@ -56,8 +56,10 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.google.android.material.navigation.NavigationView;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.network.ClientFactory;
import com.nextcloud.client.onboarding.FirstRunActivity;
import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.MainApp;
@@ -109,7 +111,9 @@ import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
@@ -215,6 +219,9 @@ public abstract class DrawerActivity extends ToolbarActivity
@Inject
AppPreferences preferences;
@Inject
ClientFactory clientFactory;
/**
* 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.
@@ -355,21 +362,19 @@ public abstract class DrawerActivity extends ToolbarActivity
navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false);
}
Account account = accountManager.getCurrentAccount();
User account = accountManager.getUser();
filterDrawerMenu(navigationView.getMenu(), account);
}
private void filterDrawerMenu(Menu menu, Account account) {
OCCapability capability = null;
if (account != null) {
FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());
capability = storageManager.getCapability(account.name);
}
private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
getContentResolver());
OCCapability capability = storageManager.getCapability(user.getAccountName());
boolean hasSearchSupport = accountManager.getServerVersion(account).isSearchSupported();
boolean hasSearchSupport = user.getServer().getVersion().isSearchSupported();
DrawerMenuUtil.filterSearchMenuItems(menu, account, getResources(), hasSearchSupport);
DrawerMenuUtil.filterTrashbinMenuItem(menu, account, capability, accountManager);
DrawerMenuUtil.filterSearchMenuItems(menu, user.toPlatformAccount(), getResources(), hasSearchSupport);
DrawerMenuUtil.filterTrashbinMenuItem(menu, user.toPlatformAccount(), capability, accountManager);
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
@@ -683,7 +688,7 @@ public abstract class DrawerActivity extends ToolbarActivity
if (mNavigationView != null && mDrawerLayout != null) {
if (persistingAccounts.size() > 0) {
repopulateAccountList(persistingAccounts);
setAccountInDrawer(accountManager.getCurrentAccount());
setAccountInDrawer(accountManager.getUser());
populateDrawerOwnCloudAccounts();
// activate second/end account avatar
@@ -789,30 +794,25 @@ public abstract class DrawerActivity extends ToolbarActivity
* sets the given account name in the drawer in case the drawer is available. The account name is shortened
* beginning from the @-sign in the username.
*
* @param account the account to be set in the drawer
* @param user the account to be set in the drawer
*/
protected void setAccountInDrawer(Account account) {
if (mDrawerLayout != null && account != null) {
protected void setAccountInDrawer(User user) {
if (mDrawerLayout != null && user != null) {
TextView username = (TextView) findNavigationViewChildById(R.id.drawer_username);
TextView usernameFull = (TextView) findNavigationViewChildById(R.id.drawer_username_full);
usernameFull.setText(DisplayUtils.convertIdn(account.name.substring(account.name.lastIndexOf('@') + 1),
String name = user.getAccountName();
usernameFull.setText(DisplayUtils.convertIdn(name.substring(name.lastIndexOf('@') + 1),
false));
usernameFull.setTextColor(ThemeUtils.fontColor(this));
try {
OwnCloudAccount oca = new OwnCloudAccount(account, this);
username.setText(oca.getDisplayName());
username.setTextColor(ThemeUtils.fontColor(this));
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.w(TAG, "Couldn't read display name of account fallback to account name");
username.setText(UserAccountManager.getUsername(account));
}
username.setText(user.toOwnCloudAccount().getDisplayName());
username.setTextColor(ThemeUtils.fontColor(this));
View currentAccountView = findNavigationViewChildById(R.id.drawer_current_account);
currentAccountView.setTag(account.name);
currentAccountView.setTag(name);
DisplayUtils.setAvatar(account, this, mCurrentAccountAvatarRadiusDimension, getResources(),
DisplayUtils.setAvatar(user.toPlatformAccount(), this, mCurrentAccountAvatarRadiusDimension, getResources(),
currentAccountView, this);
// check and show quota info if available
@@ -956,6 +956,7 @@ public abstract class DrawerActivity extends ToolbarActivity
};
DisplayUtils.downloadIcon(getUserAccountManager(),
clientFactory,
this,
firstQuota.iconUrl,
target,
@@ -989,7 +990,17 @@ public abstract class DrawerActivity extends ToolbarActivity
MenuItem menuItem = mNavigationView.getMenu().getItem(i);
if (menuItem.getIcon() != null) {
menuItem.getIcon().clearColorFilter();
menuItem.setTitle(Html.fromHtml("<font color='#000000'>" + menuItem.getTitle() + "</font>"));
if (menuItem.getGroupId() != R.id.drawer_menu_accounts
|| menuItem.getItemId() == R.id.drawer_menu_account_add
|| menuItem.getItemId() == R.id.drawer_menu_account_manage) {
ThemeUtils.tintDrawable(
menuItem.getIcon(), ContextCompat.getColor(this, R.color.drawer_menu_icon));
}
menuItem.setTitle(Html.fromHtml(
"<font color='"
+ ThemeUtils.colorToHexString(ContextCompat.getColor(this, R.color.text_color))
+ "'>" + menuItem.getTitle()
+ "</font>"));
}
}
@@ -1012,14 +1023,14 @@ public abstract class DrawerActivity extends ToolbarActivity
// set user space information
Thread t = new Thread(new Runnable() {
public void run() {
final Account currentAccount = accountManager.getCurrentAccount();
final User user = accountManager.getUser();
if (currentAccount == null) {
if (user.isAnonymous()) {
return;
}
final Context context = MainApp.getAppContext();
RemoteOperationResult result = new GetUserInfoRemoteOperation().execute(currentAccount, context);
RemoteOperationResult result = new GetUserInfoRemoteOperation().execute(user.toPlatformAccount(), context);
if (result.isSuccess() && result.getData() != null) {
final UserInfo userInfo = (UserInfo) result.getData().get(0);
@@ -1068,7 +1079,7 @@ public abstract class DrawerActivity extends ToolbarActivity
float density = getResources().getDisplayMetrics().density;
final int size = Math.round(24 * density);
int greyColor = getResources().getColor(R.color.standard_grey);
int greyColor = ContextCompat.getColor(this, R.color.drawer_menu_icon);
for (final ExternalLink link : externalLinksProvider.getExternalLink(ExternalLinkType.LINK)) {
int id = mNavigationView.getMenu().add(R.id.drawer_menu_external_links,
@@ -1089,6 +1100,7 @@ public abstract class DrawerActivity extends ToolbarActivity
};
DisplayUtils.downloadIcon(getUserAccountManager(),
clientFactory,
this,
link.iconUrl,
target,
@@ -1263,6 +1275,9 @@ public abstract class DrawerActivity extends ToolbarActivity
@Override
protected void onResume() {
super.onResume();
getDelegate().setLocalNightMode(preferences.isDarkThemeEnabled() ?
AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
getDelegate().applyDayNight();
setDrawerMenuItemChecked(mCheckedMenuItem);
}
@@ -1278,7 +1293,7 @@ public abstract class DrawerActivity extends ToolbarActivity
// current account has changed
if (data.getBooleanExtra(ManageAccountsActivity.KEY_CURRENT_ACCOUNT_CHANGED, false)) {
setAccount(accountManager.getCurrentAccount());
setAccount(accountManager.getCurrentAccount(), false);
updateAccountList();
restart();
} else {
@@ -1360,12 +1375,11 @@ public abstract class DrawerActivity extends ToolbarActivity
}
}
Account currentAccount = accountManager.getCurrentAccount();
mAvatars[0] = currentAccount;
User user = accountManager.getUser();
mAvatars[0] = user.toPlatformAccount();
int j = 0;
for (int i = 1; i <= 2 && i < persistingAccounts.size() && j < persistingAccounts.size(); j++) {
if (!currentAccount.equals(persistingAccounts.get(j))) {
if (!user.equals(persistingAccounts.get(j))) {
mAvatars[i] = persistingAccounts.get(j);
i++;
}
@@ -1447,11 +1461,10 @@ public abstract class DrawerActivity extends ToolbarActivity
getCapabilities.execute(getStorageManager(), getBaseContext());
}
Account account = accountManager.getCurrentAccount();
if (account != null && getStorageManager() != null &&
getStorageManager().getCapability(account.name) != null &&
getStorageManager().getCapability(account.name).getExternalLinks().isTrue()) {
User user = accountManager.getUser();
String name = user.getAccountName();
if (getStorageManager() != null && getStorageManager().getCapability(name) != null &&
getStorageManager().getCapability(name).getExternalLinks().isTrue()) {
int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
FileActivity.APP_OPENED_COUNT);
@@ -1466,7 +1479,7 @@ public abstract class DrawerActivity extends ToolbarActivity
Log_OC.d("ExternalLinks", "update via api");
RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
RemoteOperationResult result = getExternalLinksOperation.execute(account, this);
RemoteOperationResult result = getExternalLinksOperation.execute(user.toPlatformAccount(), this);
if (result.isSuccess() && result.getData() != null) {
externalLinksProvider.deleteAllExternalLinks();
@@ -65,7 +65,6 @@ public class ExternalSiteWebView extends FileActivity {
private boolean showSidebar;
String url;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start");
@@ -93,7 +92,6 @@ public class ExternalSiteWebView extends FileActivity {
webview.setFocusableInTouchMode(true);
webview.setClickable(true);
// allow debugging (when building the debug version); see details in
// https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
@@ -114,39 +112,8 @@ public class ExternalSiteWebView extends FileActivity {
setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
ThemeUtils.setColoredTitle(actionBar, title, this);
if (showSidebar) {
actionBar.setDisplayHomeAsUpEnabled(true);
} else {
setDrawerIndicatorEnabled(false);
}
}
// enable zoom
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);
// Non-responsive webs are zoomed out when loaded
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
// user agent
webSettings.setUserAgentString(MainApp.getUserAgent());
// no private data storing
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
// disable local file access
webSettings.setAllowFileAccess(false);
// enable javascript
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
setupActionBar(title);
setupWebSettings(webSettings);
final ProgressBar progressBar = findViewById(R.id.progressBar);
@@ -172,6 +139,45 @@ public class ExternalSiteWebView extends FileActivity {
webview.loadUrl(url);
}
@SuppressLint("SetJavaScriptEnabled")
private void setupWebSettings(WebSettings webSettings) {
// enable zoom
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);
// Non-responsive webs are zoomed out when loaded
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
// user agent
webSettings.setUserAgentString(MainApp.getUserAgent());
// no private data storing
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
// disable local file access
webSettings.setAllowFileAccess(false);
// enable javascript
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
}
private void setupActionBar(String title) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
ThemeUtils.setColoredTitle(actionBar, title, this);
if (showSidebar) {
actionBar.setDisplayHomeAsUpEnabled(true);
} else {
setDrawerIndicatorEnabled(false);
}
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean retval;
@@ -54,11 +54,13 @@ import android.view.View;
import android.view.ViewTreeObserver;
import com.google.android.material.snackbar.Snackbar;
import com.nextcloud.client.account.User;
import com.nextcloud.client.appinfo.AppInfo;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.media.PlayerServiceConnection;
import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -765,7 +767,7 @@ public class FileDisplayActivity extends FileActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
inflater.inflate(R.menu.activity_file_display, menu);
menu.findItem(R.id.action_create_dir).setVisible(false);
menu.findItem(R.id.action_select_all).setVisible(false);
@@ -2545,8 +2547,8 @@ public class FileDisplayActivity extends FileActivity
@Override
public void onStart() {
super.onStart();
final Account account = getAccount();
if (account != null) {
Optional<User> optionalUser = getUser();
if (optionalUser.isPresent()) {
/// Check whether the 'main' OCFile handled by the Activity is contained in the
// current Account
OCFile file = getFile();
@@ -2572,10 +2574,12 @@ public class FileDisplayActivity extends FileActivity
}
setFile(file);
setAccountInDrawer(account);
User user = optionalUser.get();
setAccountInDrawer(user);
setupDrawer();
final boolean accountChanged = !account.equals(mLastDisplayedAccount);
final String lastDisplayedAccountName = mLastDisplayedAccount != null ? mLastDisplayedAccount.name : null;
final boolean accountChanged = !user.getAccountName().equals(lastDisplayedAccountName);
if (accountChanged) {
Log_OC.d(TAG, "Initializing Fragments in onAccountChanged..");
initFragmentsWithFile();
@@ -2587,7 +2591,11 @@ public class FileDisplayActivity extends FileActivity
updateActionBarTitleAndHomeButton(file.isFolder() ? null : file);
}
}
mLastDisplayedAccount = account;
if (optionalUser.isPresent()) {
mLastDisplayedAccount = optionalUser.get().toPlatformAccount();
} else {
mLastDisplayedAccount = null;
}
EventBus.getDefault().post(new TokenPushEvent());
checkForNewDevVersionNecessary(findViewById(R.id.root_layout), getApplicationContext());
@@ -2621,7 +2629,8 @@ public class FileDisplayActivity extends FileActivity
return;
}
setAccount(newAccount);
setAccount(newAccount, false);
updateAccountList();
}
String fileId = String.valueOf(intent.getStringExtra(KEY_FILE_ID));
@@ -19,13 +19,13 @@
package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.accounts.AuthenticatorException;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.ColorStateList;
import android.content.res.Resources.NotFoundException;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
@@ -38,10 +38,10 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
import com.google.android.material.button.MaterialButton;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.operations.RemoteOperation;
@@ -91,8 +91,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
private boolean mSearchOnlyFolders;
private boolean mDoNotEnterEncryptedFolder;
protected Button mCancelBtn;
protected Button mChooseBtn;
protected MaterialButton mCancelBtn;
protected MaterialButton mChooseBtn;
private String caption;
@Inject AppPreferences preferences;
@@ -293,11 +293,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
menu.findItem(R.id.action_switch_view).setVisible(false);
menu.findItem(R.id.action_sync_account).setVisible(false);
menu.findItem(R.id.action_select_all).setVisible(false);
// menu.findItem(R.id.action_sort).setVisible(false);
inflater.inflate(R.menu.activity_folder_picker, menu);
return true;
}
@@ -406,7 +402,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
if (mChooseBtn != null) {
mChooseBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
mChooseBtn.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
mChooseBtn.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
mChooseBtn.setOnClickListener(this);
}
@@ -38,6 +38,7 @@ import android.view.MenuItem;
import com.evernote.android.job.JobRequest;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.onboarding.FirstRunActivity;
import com.owncloud.android.MainApp;
@@ -126,15 +127,12 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
Account[] accountList = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
originalAccounts = DisplayUtils.toAccountNameSet(Arrays.asList(accountList));
Account currentAccount = getUserAccountManager().getCurrentAccount();
Account currentAccount = getAccount();
if (currentAccount != null) {
originalCurrentAccount = currentAccount.name;
}
setAccount(currentAccount);
onAccountSet();
arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
multipleAccountsSupported = getResources().getBoolean(R.bool.multiaccount_support);
@@ -201,11 +199,11 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
* @return true if account list has changed, false if not
*/
private boolean hasCurrentAccountChanged() {
Account account = getUserAccountManager().getCurrentAccount();
if (account == null) {
User account = getUserAccountManager().getUser();
if (account.isAnonymous()) {
return true;
} else {
return !account.name.equals(originalCurrentAccount);
return !account.getAccountName().equals(originalCurrentAccount);
}
}
@@ -323,7 +321,8 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
}
}
if (getUserAccountManager().getCurrentAccount() == null) {
User user = getUserAccountManager().getUser();
if (user.isAnonymous()) {
String accountName = "";
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
if (accounts.length != 0) {
@@ -24,9 +24,6 @@
package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
@@ -39,13 +36,14 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.google.android.material.snackbar.Snackbar;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.network.ClientFactory;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.jobs.NotificationJob;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
@@ -58,9 +56,10 @@ import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PushUtils;
import com.owncloud.android.utils.ThemeUtils;
import java.io.IOException;
import java.util.List;
import javax.inject.Inject;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@@ -109,7 +108,9 @@ public class NotificationsActivity extends FileActivity implements Notifications
private NotificationListAdapter adapter;
private Snackbar snackbar;
private OwnCloudClient client;
private Account currentAccount;
private Optional<User> optionalUser;
@Inject ClientFactory clientFactory;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -119,16 +120,18 @@ public class NotificationsActivity extends FileActivity implements Notifications
setContentView(R.layout.notifications_layout);
unbinder = ButterKnife.bind(this);
currentAccount = getAccount();
optionalUser = getUser();
// use account from intent (opened via android notification can have a different account than current one)
if (getIntent() != null && getIntent().getExtras() != null) {
String account = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
if (account != null && (currentAccount == null || !account.equalsIgnoreCase(currentAccount.name))) {
accountManager.setCurrentOwnCloudAccount(account);
setAccount(getUserAccountManager().getCurrentAccount());
currentAccount = getAccount();
String accountName = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
if(accountName != null && optionalUser.isPresent()) {
User user = optionalUser.get();
if (user.getAccountName().equalsIgnoreCase(accountName)) {
accountManager.setCurrentOwnCloudAccount(accountName);
setUser(getUserAccountManager().getUser());
optionalUser = getUser();
}
}
}
@@ -142,7 +145,7 @@ public class NotificationsActivity extends FileActivity implements Notifications
setupDrawer(R.id.nav_notifications);
ThemeUtils.setColoredTitle(getSupportActionBar(), getString(R.string.drawer_item_notifications), this);
if (currentAccount == null) {
if (!optionalUser.isPresent()) {
// show error
runOnUiThread(() -> setEmptyContent(noResultsHeadline, getString(R.string.account_not_found)));
return;
@@ -156,7 +159,6 @@ public class NotificationsActivity extends FileActivity implements Notifications
swipeEmptyListRefreshLayout.setOnRefreshListener(() -> {
setLoadingMessage();
fetchAndSetData();
});
setupPushWarning();
@@ -175,16 +177,16 @@ public class NotificationsActivity extends FileActivity implements Notifications
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_not_implemented,
Snackbar.LENGTH_INDEFINITE);
} else {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(currentAccount.name,
final ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
final String accountName = optionalUser.isPresent() ? optionalUser.get().getAccountName() : "";
final boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(accountName,
UserAccountManager.ACCOUNT_USES_STANDARD_PASSWORD);
if (usesOldLogin) {
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_old_login,
Snackbar.LENGTH_INDEFINITE);
} else {
String pushValue = arbitraryDataProvider.getValue(currentAccount.name, PushUtils.KEY_PUSH);
String pushValue = arbitraryDataProvider.getValue(accountName, PushUtils.KEY_PUSH);
if (pushValue == null || pushValue.isEmpty()) {
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_temp_error,
@@ -250,13 +252,12 @@ public class NotificationsActivity extends FileActivity implements Notifications
private void fetchAndSetData() {
Thread t = new Thread(() -> {
if (client == null) {
if (client == null && optionalUser.isPresent()) {
try {
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, this);
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this);
client.setOwnCloudVersion(accountManager.getServerVersion(currentAccount));
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException |
IOException | OperationCanceledException | AuthenticatorException e) {
User user = optionalUser.get();
client = clientFactory.create(user);
client.setOwnCloudVersion(user.getServer().getVersion());
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Error initializing client", e);
}
}
@@ -303,7 +304,7 @@ public class NotificationsActivity extends FileActivity implements Notifications
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.notifications_actions_menu, menu);
getMenuInflater().inflate(R.menu.activity_notifications, menu);
return true;
}
@@ -392,11 +393,13 @@ public class NotificationsActivity extends FileActivity implements Notifications
}
@Override
public void onActionCallback(boolean isSuccess, NotificationListAdapter.NotificationViewHolder holder) {
public void onActionCallback(boolean isSuccess,
Notification notification,
NotificationListAdapter.NotificationViewHolder holder) {
if (isSuccess) {
adapter.removeNotification(holder);
} else {
adapter.setButtonEnabled(holder, true);
adapter.setButtons(holder, notification);
DisplayUtils.showSnackMessage(this, getString(R.string.notification_action_failed));
}
}
@@ -23,7 +23,6 @@
package com.owncloud.android.ui.activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
@@ -97,7 +96,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
int elementColor = ThemeUtils.elementColor(this);
mBCancel = findViewById(R.id.cancel);
mBCancel.getBackground().setColorFilter(elementColor, PorterDuff.Mode.SRC_ATOP);
mBCancel.setBackgroundColor(ThemeUtils.primaryColor(this));
mPassCodeHdr = findViewById(R.id.header);
mPassCodeHdrExplanation = findViewById(R.id.explanation);
@@ -34,6 +34,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.ColorStateList;
import android.content.res.Resources.NotFoundException;
import android.graphics.Color;
import android.graphics.PorterDuff;
@@ -63,6 +64,7 @@ import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import com.google.android.material.button.MaterialButton;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.MainApp;
@@ -206,8 +208,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
Log_OC.i(TAG, "No ownCloud account is available");
DialogNoAccount dialog = new DialogNoAccount();
dialog.show(getSupportFragmentManager(), null);
} else if (!savedAccount) {
setAccount(accounts[0]);
}
if (!somethingToUpload()) {
@@ -400,6 +400,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
final EditText userInput = view.findViewById(R.id.user_input);
setFilename(userInput, selectPos);
userInput.setHighlightColor(ThemeUtils.primaryColor(getContext()));
userInput.requestFocus();
final Spinner spinner = view.findViewById(R.id.file_type);
@@ -677,7 +678,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
// there is no need for checking for is there more then one
// account at this point
// since account setup can set only one account at time
setAccount(accounts[0]);
setAccount(accounts[0], false);
populateDirectoryList();
}
}
@@ -748,10 +749,10 @@ public class ReceiveExternalFilesActivity extends FileActivity
mListView.setAdapter(sa);
}
Button btnChooseFolder = findViewById(R.id.uploader_choose_folder);
btnChooseFolder.setOnClickListener(this);
btnChooseFolder.getBackground().setColorFilter(ThemeUtils.primaryColor(getAccount(), true, this),
PorterDuff.Mode.SRC_ATOP);
MaterialButton btnChooseFolder = findViewById(R.id.uploader_choose_folder);
btnChooseFolder.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
btnChooseFolder.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
btnChooseFolder.setOnClickListener(this);
btnChooseFolder.setTextColor(ThemeUtils.fontColor(this));
if (mFile.canWrite()) {
@@ -1015,7 +1016,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.receive_file_menu, menu);
inflater.inflate(R.menu.activity_receive_external_files, menu);
if (!isHaveMultipleAccount()) {
MenuItem switchAccountMenu = menu.findItem(R.id.action_switch_account);
@@ -49,6 +49,7 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.google.android.material.snackbar.Snackbar;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.account.User;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
@@ -155,7 +156,8 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
break;
}
Glide.with(this).using(new CustomGlideStreamLoader(currentAccountProvider)).load(template.getThumbnailLink())
Glide.with(this).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
.load(template.getThumbnailLink())
.placeholder(placeholder)
.error(placeholder)
.into(thumbnail);
@@ -250,7 +252,7 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
}
if ("image/png".equalsIgnoreCase(file.getMimeType())) {
thumbnailView.setBackgroundColor(getResources().getColor(R.color.background_color));
thumbnailView.setBackgroundColor(getResources().getColor(R.color.bg_default));
}
} else {
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
@@ -314,9 +316,9 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
OCFile file = data.getParcelableExtra(FolderPickerActivity.EXTRA_FILES);
new Thread(() -> {
Account account = currentAccountProvider.getCurrentAccount();
User user = currentAccountProvider.getUser();
RichDocumentsCreateAssetOperation operation = new RichDocumentsCreateAssetOperation(file.getRemotePath());
RemoteOperationResult result = operation.execute(account, this);
RemoteOperationResult result = operation.execute(user.toPlatformAccount(), this);
if (result.isSuccess()) {
String asset = (String) result.getSingleData();
@@ -25,7 +25,6 @@
*/
package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -39,7 +38,6 @@ import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
@@ -53,15 +51,18 @@ import android.view.ViewGroup;
import android.view.Window;
import android.webkit.URLUtil;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.etm.EtmActivity;
import com.nextcloud.client.logger.ui.LogsActivity;
import com.nextcloud.client.network.ClientFactory;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.authentication.PassCodeManager;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.ExternalLinksProvider;
@@ -69,8 +70,6 @@ import com.owncloud.android.datastorage.DataStorageProvider;
import com.owncloud.android.datastorage.StoragePoint;
import com.owncloud.android.lib.common.ExternalLink;
import com.owncloud.android.lib.common.ExternalLinkType;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask;
import com.owncloud.android.utils.DeviceCredentialUtils;
@@ -95,7 +94,7 @@ import androidx.core.content.res.ResourcesCompat;
*
* It proxies the necessary calls via {@link androidx.appcompat.app.AppCompatDelegate} to be used with AppCompat.
*/
public class SettingsActivity extends PreferenceActivity
public class SettingsActivity extends ThemedPreferenceActivity
implements StorageMigration.StorageMigrationProgressListener, LoadingVersionNumberTask.VersionDevInterface,
Injectable {
@@ -114,6 +113,7 @@ public class SettingsActivity extends PreferenceActivity
private static final int ACTION_CONFIRM_PASSCODE = 6;
private static final int ACTION_CONFIRM_DEVICE_CREDENTIALS = 7;
private static final int ACTION_REQUEST_CODE_DAVDROID_SETUP = 10;
private static final int TRUE_VALUE = 1;
private static final String DAV_PATH = "/remote.php/dav";
@@ -129,10 +129,11 @@ public class SettingsActivity extends PreferenceActivity
private String storagePath;
private String pendingLock;
private Account account;
private User user;
@Inject ArbitraryDataProvider arbitraryDataProvider;
@Inject AppPreferences preferences;
@Inject UserAccountManager accountManager;
@Inject ClientFactory clientFactory;
@SuppressWarnings("deprecation")
@Override
@@ -155,7 +156,7 @@ public class SettingsActivity extends PreferenceActivity
String appVersion = getAppVersion();
PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("preference_screen");
account = accountManager.getCurrentAccount();
user = accountManager.getUser();
// retrieve user's base uri
setupBaseUri();
@@ -407,7 +408,7 @@ public class SettingsActivity extends PreferenceActivity
}
private void setupE2EMnemonicPreference(PreferenceCategory preferenceCategoryMore) {
String mnemonic = arbitraryDataProvider.getValue(account.name, EncryptionUtils.MNEMONIC);
String mnemonic = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.MNEMONIC);
Preference pMnemonic = findPreference("mnemonic");
if (pMnemonic != null) {
@@ -602,11 +603,11 @@ public class SettingsActivity extends PreferenceActivity
final SwitchPreference pUploadOnWifiCheckbox = (SwitchPreference) findPreference("synced_folder_on_wifi");
pUploadOnWifiCheckbox.setChecked(
arbitraryDataProvider.getBooleanValue(account, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
arbitraryDataProvider.getBooleanValue(user.toPlatformAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
pUploadOnWifiCheckbox.setOnPreferenceClickListener(preference -> {
arbitraryDataProvider.storeOrUpdateKeyValue(account.name, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
String.valueOf(pUploadOnWifiCheckbox.isChecked()));
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
String.valueOf(pUploadOnWifiCheckbox.isChecked()));
return true;
});
@@ -690,6 +691,16 @@ public class SettingsActivity extends PreferenceActivity
}
loadStoragePath();
SwitchPreference themePref = (SwitchPreference) findPreference("dark_theme_enabled");
boolean darkThemeEnabled = preferences.isDarkThemeEnabled();
int summaryResId = darkThemeEnabled ? R.string.prefs_value_theme_dark : R.string.prefs_value_theme_light;
themePref.setSummary(summaryResId);
themePref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (Boolean)newValue;
MainApp.setAppTheme(enabled);
return true;
});
}
private String getAppVersion() {
@@ -725,7 +736,7 @@ public class SettingsActivity extends PreferenceActivity
Window window = getWindow();
if (window != null) {
window.getDecorView().setBackgroundDrawable(new ColorDrawable(ResourcesCompat
.getColor(getResources(), R.color.background_color, null)));
.getColor(getResources(), R.color.bg_default, null)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(ThemeUtils.primaryColor(this));
@@ -748,8 +759,13 @@ public class SettingsActivity extends PreferenceActivity
// arguments
if (serverBaseUri != null) {
davDroidLoginIntent.putExtra("url", serverBaseUri.toString() + DAV_PATH);
davDroidLoginIntent.putExtra("loginFlow", TRUE_VALUE);
davDroidLoginIntent.setData(Uri.parse(serverBaseUri.toString() + AuthenticatorActivity.WEB_LOGIN));
davDroidLoginIntent.putExtra("davPath", DAV_PATH);
}
davDroidLoginIntent.putExtra("username", UserAccountManager.getUsername(account));
davDroidLoginIntent.putExtra("username", UserAccountManager.getUsername(user.toPlatformAccount()));
startActivityForResult(davDroidLoginIntent, ACTION_REQUEST_CODE_DAVDROID_SETUP);
} else {
// DAVdroid not installed
@@ -773,9 +789,7 @@ public class SettingsActivity extends PreferenceActivity
// retrieve and set user's base URI
Thread t = new Thread(() -> {
try {
OwnCloudAccount ocAccount = new OwnCloudAccount(account, MainApp.getAppContext());
serverBaseUri = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount,
getApplicationContext()).getBaseUri();
serverBaseUri = clientFactory.create(user).getBaseUri();
} catch (Exception e) {
Log_OC.e(TAG, "Error retrieving user's base URI", e);
}
@@ -841,7 +855,7 @@ public class SettingsActivity extends PreferenceActivity
RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
String mnemonic = arbitraryDataProvider.getValue(account.name, EncryptionUtils.MNEMONIC);
String mnemonic = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.MNEMONIC);
int accentColor = ThemeUtils.primaryAccentColor(this);
@@ -1001,5 +1015,4 @@ public class SettingsActivity extends PreferenceActivity
public void returnVersion(Integer latestVersion) {
FileActivity.showDevSnackbar(this, latestVersion, true);
}
}
@@ -30,7 +30,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -144,7 +143,8 @@ public class SsoGrantPermissionActivity extends BaseActivity {
int start = text.indexOf(textBlock);
int end = start + textBlock.length();
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, end, 0);
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.text_color)), start, end,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return ssb;
@@ -21,7 +21,6 @@
package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.NotificationManager;
@@ -38,12 +37,18 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.google.android.material.button.MaterialButton;
import com.nextcloud.client.account.User;
import com.nextcloud.client.core.Clock;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
@@ -86,6 +91,9 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import static android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS;
import static com.owncloud.android.datamodel.SyncedFolderDisplayItem.UNPERSISTED_ID;
@@ -101,18 +109,37 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
private static final String SYNCED_FOLDER_PREFERENCES_DIALOG_TAG = "SYNCED_FOLDER_PREFERENCES_DIALOG";
private static final String TAG = SyncedFoldersActivity.class.getSimpleName();
private RecyclerView mRecyclerView;
private SyncedFolderAdapter mAdapter;
private LinearLayout mProgress;
private TextView mEmpty;
private SyncedFolderProvider mSyncedFolderProvider;
private SyncedFolderPreferencesDialogFragment mSyncedFolderPreferencesDialogFragment;
@BindView(R.id.empty_list_view)
public LinearLayout emptyContentContainer;
@BindView(R.id.empty_list_icon)
public ImageView emptyContentIcon;
@BindView(R.id.empty_list_progress)
public ProgressBar emptyContentProgressBar;
@BindView(R.id.empty_list_view_headline)
public TextView emptyContentHeadline;
@BindView(R.id.empty_list_view_text)
public TextView emptyContentMessage;
@BindView(R.id.empty_list_view_action)
public MaterialButton emptyContentActionButton;
@BindView(android.R.id.list)
public RecyclerView mRecyclerView;
private SyncedFolderAdapter adapter;
private SyncedFolderProvider syncedFolderProvider;
private SyncedFolderPreferencesDialogFragment syncedFolderPreferencesDialogFragment;
private boolean showSidebar = true;
private String path;
private int type;
@Inject AppPreferences preferences;
@Inject PowerManagementService powerManagementService;
@Inject Clock clock;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -123,16 +150,17 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
}
setContentView(R.layout.synced_folders_layout);
ButterKnife.bind(this);
String account;
Account currentAccount;
if (getIntent() != null && getIntent().getExtras() != null) {
account = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
currentAccount = getAccount();
if (account != null && currentAccount != null && !account.equalsIgnoreCase(currentAccount.name)) {
accountManager.setCurrentOwnCloudAccount(account);
setAccount(getUserAccountManager().getCurrentAccount());
final String accountName = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
Optional<User> optionalUser = getUser();
if (optionalUser.isPresent() && accountName != null) {
User user = optionalUser.get();
if (!accountName.equalsIgnoreCase(user.getAccountName())) {
accountManager.setCurrentOwnCloudAccount(accountName);
setUser(getUserAccountManager().getUser());
}
}
path = getIntent().getStringExtra(MediaFoldersDetectionJob.KEY_MEDIA_FOLDER_PATH);
@@ -175,7 +203,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.synced_folders_menu, menu);
inflater.inflate(R.menu.activity_synced_folders, menu);
if (powerManagementService.isPowerSavingExclusionAvailable()) {
MenuItem item = menu.findItem(R.id.action_disable_power_save_check);
@@ -216,50 +244,56 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
* sets up the UI elements and loads all media/synced folders.
*/
private void setupContent() {
mRecyclerView = findViewById(android.R.id.list);
mProgress = findViewById(android.R.id.progress);
mEmpty = findViewById(android.R.id.empty);
final int gridWidth = getResources().getInteger(R.integer.media_grid_width);
boolean lightVersion = getResources().getBoolean(R.bool.syncedFolder_light);
mAdapter = new SyncedFolderAdapter(this, gridWidth, this, lightVersion);
mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences);
adapter = new SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion);
syncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences, clock);
emptyContentIcon.setImageResource(R.drawable.nav_synced_folders);
emptyContentActionButton.setBackgroundColor(ThemeUtils.primaryColor(this));
emptyContentActionButton.setTextColor(ThemeUtils.fontColor(this));
final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
mAdapter.setLayoutManager(lm);
adapter.setLayoutManager(lm);
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
mRecyclerView.addItemDecoration(new MediaGridItemDecoration(spacing));
mRecyclerView.setLayoutManager(lm);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setAdapter(adapter);
load(gridWidth * 2, false);
}
@OnClick(R.id.empty_list_view_action)
public void showHiddenItems() {
if (adapter.getSectionCount() == 0 && adapter.getUnfilteredSectionCount() > adapter.getSectionCount()) {
adapter.toggleHiddenItemsVisibility();
emptyContentContainer.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
}
}
/**
* loads all media/synced folders, adds them to the recycler view adapter and shows the list.
*
* @param perFolderMediaItemLimit the amount of media items to be loaded/shown per media folder
*/
private void load(final int perFolderMediaItemLimit, boolean force) {
if (mAdapter.getItemCount() > 0 && !force) {
if (adapter.getItemCount() > 0 && !force) {
return;
}
setListShown(false);
showLoadingContent();
final List<MediaFolder> mediaFolders = MediaProvider.getImageFolders(getContentResolver(),
perFolderMediaItemLimit, this, false);
mediaFolders.addAll(MediaProvider.getVideoFolders(getContentResolver(), perFolderMediaItemLimit,
this, false));
List<SyncedFolder> syncedFolderArrayList = mSyncedFolderProvider.getSyncedFolders();
List<SyncedFolder> syncedFolderArrayList = syncedFolderProvider.getSyncedFolders();
List<SyncedFolder> currentAccountSyncedFoldersList = new ArrayList<>();
Account currentAccount = getUserAccountManager().getCurrentAccount();
User user = getUserAccountManager().getUser();
for (SyncedFolder syncedFolder : syncedFolderArrayList) {
if (currentAccount != null && syncedFolder.getAccount().equals(currentAccount.name)) {
if (syncedFolder.getAccount().equals(user.getAccountName())) {
// delete non-existing & disabled synced folders
if (!new File(syncedFolder.getLocalPath()).exists() && !syncedFolder.isEnabled()) {
mSyncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
syncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
} else {
currentAccountSyncedFoldersList.add(syncedFolder);
}
@@ -269,14 +303,14 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
List<SyncedFolderDisplayItem> syncFolderItems = sortSyncedFolderItems(
mergeFolderData(currentAccountSyncedFoldersList, mediaFolders));
mAdapter.setSyncFolderItems(syncFolderItems);
mAdapter.notifyDataSetChanged();
setListShown(true);
adapter.setSyncFolderItems(syncFolderItems);
adapter.notifyDataSetChanged();
showList();
if (!TextUtils.isEmpty(path)) {
int section = mAdapter.getSectionByLocalPathAndType(path, type);
int section = adapter.getSectionByLocalPathAndType(path, type);
if (section >= 0) {
onSyncFolderSettingsClick(section, mAdapter.get(section));
onSyncFolderSettingsClick(section, adapter.get(section));
}
}
}
@@ -380,16 +414,18 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
syncedFolder.getId(),
syncedFolder.getLocalPath(),
syncedFolder.getRemotePath(),
syncedFolder.getWifiOnly(),
syncedFolder.getChargingOnly(),
syncedFolder.getSubfolderByDate(),
syncedFolder.isWifiOnly(),
syncedFolder.isChargingOnly(),
syncedFolder.isSubfolderByDate(),
syncedFolder.getAccount(),
syncedFolder.getUploadAction(),
syncedFolder.isEnabled(),
clock.getCurrentTime(),
filePaths,
localFolder.getName(),
files.length,
syncedFolder.getType());
syncedFolder.getType(),
syncedFolder.isHidden());
}
/**
@@ -405,16 +441,18 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
syncedFolder.getId(),
syncedFolder.getLocalPath(),
syncedFolder.getRemotePath(),
syncedFolder.getWifiOnly(),
syncedFolder.getChargingOnly(),
syncedFolder.getSubfolderByDate(),
syncedFolder.isWifiOnly(),
syncedFolder.isChargingOnly(),
syncedFolder.isSubfolderByDate(),
syncedFolder.getAccount(),
syncedFolder.getUploadAction(),
syncedFolder.isEnabled(),
clock.getCurrentTime(),
mediaFolder.filePaths,
mediaFolder.folderName,
mediaFolder.numberOfFiles,
mediaFolder.type);
mediaFolder.type,
syncedFolder.isHidden());
}
/**
@@ -432,13 +470,15 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
true,
false,
false,
getAccount().name,
getAccount().name,
FileUploader.LOCAL_BEHAVIOUR_FORGET,
false,
clock.getCurrentTime(),
mediaFolder.filePaths,
mediaFolder.folderName,
mediaFolder.numberOfFiles,
mediaFolder.type);
mediaFolder.type,
false);
}
private File[] getFileList(File localFolder) {
@@ -484,15 +524,35 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
}
/**
* show/hide recycler view list or the empty message / progress info.
*
* @param shown flag if list should be shown
* show recycler view list or the empty message info (in case list is empty).
*/
private void setListShown(boolean shown) {
private void showList() {
if (mRecyclerView != null) {
mRecyclerView.setVisibility(shown ? View.VISIBLE : View.GONE);
mProgress.setVisibility(shown ? View.GONE : View.VISIBLE);
mEmpty.setVisibility(shown && mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
emptyContentProgressBar.setVisibility(View.GONE);
checkAndShowEmptyListContent();
}
}
private void checkAndShowEmptyListContent() {
if (adapter.getSectionCount() == 0 && adapter.getUnfilteredSectionCount() > adapter.getSectionCount()) {
emptyContentContainer.setVisibility(View.VISIBLE);
int hiddenFoldersCount = adapter.getHiddenFolderCount();
showEmptyContent(getString(R.string.drawer_synced_folders),
getResources().getQuantityString(R.plurals.synced_folders_show_hidden_folders,
hiddenFoldersCount,
hiddenFoldersCount),
getResources().getQuantityString(R.plurals.synced_folders_show_hidden_folders,
hiddenFoldersCount,
hiddenFoldersCount));
} else if (adapter.getSectionCount() == 0 && adapter.getUnfilteredSectionCount() == 0) {
emptyContentContainer.setVisibility(View.VISIBLE);
showEmptyContent(getString(R.string.drawer_synced_folders),
getString(R.string.synced_folders_no_results));
} else {
emptyContentContainer.setVisibility(View.GONE);
}
}
@@ -518,8 +578,8 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
Log.d(TAG, "Show custom folder dialog");
SyncedFolderDisplayItem emptyCustomFolder = new SyncedFolderDisplayItem(
SyncedFolder.UNPERSISTED_ID, null, null, true, false,
false, getAccount().name,
FileUploader.LOCAL_BEHAVIOUR_FORGET, false, null, MediaFolderType.CUSTOM);
false, getAccount().name, FileUploader.LOCAL_BEHAVIOUR_FORGET, false,
clock.getCurrentTime(), null, MediaFolderType.CUSTOM, false);
onSyncFolderSettingsClick(0, emptyCustomFolder);
}
@@ -548,14 +608,11 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
@Override
public void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
getContentResolver());
if (syncedFolderDisplayItem.getId() > UNPERSISTED_ID) {
mSyncedFolderProvider.updateSyncedFolderEnabled(syncedFolderDisplayItem.getId(),
syncedFolderDisplayItem.isEnabled());
syncedFolderProvider.updateSyncedFolderEnabled(syncedFolderDisplayItem.getId(),
syncedFolderDisplayItem.isEnabled());
} else {
long storedId = mSyncedFolderProvider.storeSyncedFolder(syncedFolderDisplayItem);
long storedId = syncedFolderProvider.storeSyncedFolder(syncedFolderDisplayItem);
if (storedId != -1) {
syncedFolderDisplayItem.setId(storedId);
}
@@ -565,9 +622,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolderDisplayItem);
showBatteryOptimizationInfo();
} else {
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + syncedFolderDisplayItem.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
}
@@ -577,22 +631,72 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(null);
mSyncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
syncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
syncedFolderDisplayItem, section);
mSyncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
syncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
}
@Override
public void onVisibilityToggleClick(int section, SyncedFolderDisplayItem syncedFolder) {
syncedFolder.setHidden(!syncedFolder.isHidden());
saveOrUpdateSyncedFolder(syncedFolder);
adapter.setSyncFolderItem(section, syncedFolder);
checkAndShowEmptyListContent();
}
private void showEmptyContent(String headline, String message) {
showEmptyContent(headline, message, false);
emptyContentActionButton.setVisibility(View.GONE);
}
private void showEmptyContent(String headline, String message, String action) {
showEmptyContent(headline, message, false);
emptyContentActionButton.setText(action);
emptyContentActionButton.setVisibility(View.VISIBLE);
emptyContentMessage.setVisibility(View.GONE);
}
private void showLoadingContent() {
showEmptyContent(
getString(R.string.drawer_synced_folders),
getString(R.string.synced_folders_loading_folders),
true
);
emptyContentActionButton.setVisibility(View.GONE);
}
private void showEmptyContent(String headline, String message, boolean loading) {
if (emptyContentContainer != null) {
emptyContentContainer.setVisibility(View.VISIBLE);
mRecyclerView.setVisibility(View.GONE);
emptyContentHeadline.setText(headline);
emptyContentMessage.setText(message);
emptyContentMessage.setVisibility(View.VISIBLE);
if (loading) {
emptyContentProgressBar.setVisibility(View.VISIBLE);
emptyContentIcon.setVisibility(View.GONE);
} else {
emptyContentProgressBar.setVisibility(View.GONE);
emptyContentIcon.setVisibility(View.VISIBLE);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER
&& resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) {
&& resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null) {
OCFile chosenFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
mSyncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
syncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
}
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_LOCAL_FOLDER
&& resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) {
&& resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null) {
String localPath = data.getStringExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES);
mSyncedFolderPreferencesDialogFragment.setLocalFolderSummary(localPath);
syncedFolderPreferencesDialogFragment.setLocalFolderSummary(localPath);
} else {
super.onActivityResult(requestCode, resultCode, data);
}
@@ -600,76 +704,80 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
@Override
public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
getContentResolver());
// custom folders newly created aren't in the list already,
// so triggering a refresh
if (MediaFolderType.CUSTOM == syncedFolder.getType() && syncedFolder.getId() == UNPERSISTED_ID) {
SyncedFolderDisplayItem newCustomFolder = new SyncedFolderDisplayItem(
SyncedFolder.UNPERSISTED_ID, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(),
syncedFolder.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(),
syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.getEnabled(),
new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType());
long storedId = mSyncedFolderProvider.storeSyncedFolder(newCustomFolder);
if (storedId != -1) {
newCustomFolder.setId(storedId);
if (newCustomFolder.isEnabled()) {
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(newCustomFolder);
} else {
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + newCustomFolder.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
}
mAdapter.addSyncFolderItem(newCustomFolder);
syncedFolder.isWifiOnly(), syncedFolder.isChargingOnly(), syncedFolder.isSubfolderByDate(),
syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.isEnabled(),
clock.getCurrentTime(), new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType(), syncedFolder.isHidden());
saveOrUpdateSyncedFolder(newCustomFolder);
adapter.addSyncFolderItem(newCustomFolder);
} else {
SyncedFolderDisplayItem item = mAdapter.get(syncedFolder.getSection());
item = updateSyncedFolderItem(item, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(), syncedFolder
.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(), syncedFolder
.getUploadAction(), syncedFolder.getEnabled());
SyncedFolderDisplayItem item = adapter.get(syncedFolder.getSection());
updateSyncedFolderItem(item, syncedFolder.getId(), syncedFolder.getLocalPath(),
syncedFolder.getRemotePath(), syncedFolder
.isWifiOnly(), syncedFolder.isChargingOnly(), syncedFolder.isSubfolderByDate(), syncedFolder
.getUploadAction(), syncedFolder.isEnabled());
if (syncedFolder.getId() == UNPERSISTED_ID) {
// newly set up folder sync config
long storedId = mSyncedFolderProvider.storeSyncedFolder(item);
if (storedId != -1) {
item.setId(storedId);
if (item.isEnabled()) {
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
} else {
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
}
} else {
// existing synced folder setup to be updated
mSyncedFolderProvider.updateSyncFolder(item);
if (item.isEnabled()) {
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
} else {
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
}
saveOrUpdateSyncedFolder(item);
mAdapter.setSyncFolderItem(syncedFolder.getSection(), item);
// TODO test if notifiyItemChanged is suffiecient (should improve performance)
adapter.notifyDataSetChanged();
}
mSyncedFolderPreferencesDialogFragment = null;
syncedFolderPreferencesDialogFragment = null;
if (syncedFolder.getEnabled()) {
if (syncedFolder.isEnabled()) {
showBatteryOptimizationInfo();
}
}
private void saveOrUpdateSyncedFolder(SyncedFolderDisplayItem item) {
if (item.getId() == UNPERSISTED_ID) {
// newly set up folder sync config
storeSyncedFolder(item);
} else {
// existing synced folder setup to be updated
syncedFolderProvider.updateSyncFolder(item);
if (item.isEnabled()) {
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
} else {
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
getContentResolver());
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
}
}
private void storeSyncedFolder(SyncedFolderDisplayItem item) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
getContentResolver());
long storedId = syncedFolderProvider.storeSyncedFolder(item);
if (storedId != -1) {
item.setId(storedId);
if (item.isEnabled()) {
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
} else {
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
}
}
@Override
public void onCancelSyncedFolderPreference() {
mSyncedFolderPreferencesDialogFragment = null;
syncedFolderPreferencesDialogFragment = null;
}
@Override
public void onDeleteSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
mSyncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
mAdapter.removeItem(syncedFolder.getSection());
syncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
adapter.removeItem(syncedFolder.getSection());
}
/**
@@ -683,24 +791,24 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
* @param subfolderByDate created sub folders
* @param uploadAction upload action
* @param enabled is sync enabled
* @return the updated item
*/
private SyncedFolderDisplayItem updateSyncedFolderItem(SyncedFolderDisplayItem item,
private void updateSyncedFolderItem(SyncedFolderDisplayItem item,
long id,
String localPath,
String remotePath,
Boolean wifiOnly,
Boolean chargingOnly,
Boolean subfolderByDate,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
Integer uploadAction,
Boolean enabled) {
boolean enabled) {
item.setId(id);
item.setLocalPath(localPath);
item.setRemotePath(remotePath);
item.setWifiOnly(wifiOnly);
item.setChargingOnly(chargingOnly);
item.setSubfolderByDate(subfolderByDate);
item.setUploadAction(uploadAction);
item.setEnabled(enabled);
return item;
item.setEnabled(enabled, clock.getCurrentTime());
}
@Override
@@ -727,7 +835,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
@Override
protected void onResume() {
super.onResume();
setDrawerMenuItemChecked(R.id.nav_synced_folders);
}
@@ -0,0 +1,80 @@
/*
* Nextcloud Android client application
*
* @author Daniel Bailey
* Copyright (C) 2019 Daniel Bailey
*
* 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.os.Bundle;
import android.preference.PreferenceActivity;
import com.nextcloud.client.preferences.AppPreferences;
import javax.inject.Inject;
import androidx.annotation.Nullable;
public class ThemedPreferenceActivity extends PreferenceActivity {
/**
* Tracks whether the activity should be recreate()'d after a theme change
*/
private boolean themeChangePending;
private boolean paused;
@Inject AppPreferences preferences;
private AppPreferences.Listener onThemeChangedListener = new AppPreferences.Listener() {
@Override
public void onDarkThemeEnabledChanged(boolean enabled) {
if(paused) {
themeChangePending = true;
return;
}
recreate();
}
};
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
preferences.addListener(onThemeChangedListener);
}
@Override
protected void onDestroy() {
super.onDestroy();
preferences.removeListener(onThemeChangedListener);
}
@Override
protected void onPause() {
super.onPause();
paused = true;
}
@Override
protected void onResume() {
super.onResume();
paused = false;
if(themeChangePending) {
recreate();
}
}
}
@@ -35,7 +35,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
@@ -92,7 +91,7 @@ public class UploadFilesActivity extends FileActivity implements
private boolean mSelectAll;
private boolean mLocalFolderPickerMode;
private LocalFileListFragment mFileListFragment;
protected Button mUploadBtn;
protected MaterialButton mUploadBtn;
private Spinner mBehaviourSpinner;
private Account mAccountOnCreation;
private DialogFragment mCurrentDialog;
@@ -178,7 +177,8 @@ public class UploadFilesActivity extends FileActivity implements
mCancelButton.setOnClickListener(this);
mUploadBtn = findViewById(R.id.upload_files_btn_upload);
mUploadBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
mUploadBtn.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
mUploadBtn.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
mUploadBtn.setOnClickListener(this);
int localBehaviour = preferences.getUploaderBehaviour();
@@ -254,7 +254,7 @@ public class UploadFilesActivity extends FileActivity implements
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mOptionsMenu = menu;
getMenuInflater().inflate(R.menu.upload_files_picker, menu);
getMenuInflater().inflate(R.menu.activity_upload_files, menu);
if(!mLocalFolderPickerMode) {
MenuItem selectAll = menu.findItem(R.id.action_select_all);
@@ -43,9 +43,11 @@ import com.evernote.android.job.Job;
import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.device.PowerManagementService;
import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.files.services.FileUploader;
@@ -230,9 +232,9 @@ public class UploadListActivity extends FileActivity {
protected void onStart() {
super.onStart();
ThemeUtils.setColoredTitle(getSupportActionBar(), R.string.uploads_view_title, this);
final Account account = getAccount();
if (account != null) {
setAccountInDrawer(account);
final Optional<User> optionalUser = getUser();
if (optionalUser.isPresent()) {
setAccountInDrawer(optionalUser.get());
}
}
@@ -269,7 +271,7 @@ public class UploadListActivity extends FileActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.upload_list_menu, menu);
inflater.inflate(R.menu.activity_upload_list, menu);
return true;
}
@@ -26,7 +26,7 @@
package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.app.AlertDialog;
import androidx.appcompat.app.AlertDialog;
import android.app.Dialog;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
@@ -135,9 +135,6 @@ public class UserInfoActivity extends FileActivity implements Injectable {
setContentView(R.layout.user_info_layout);
unbinder = ButterKnife.bind(this);
setAccount(getUserAccountManager().getCurrentAccount());
onAccountSet();
boolean useBackgroundImage = URLUtil.isValidUrl(
getStorageManager().getCapability(account.name).getServerBackground());
@@ -159,7 +156,7 @@ public class UserInfoActivity extends FileActivity implements Injectable {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.user_info_menu, menu);
inflater.inflate(R.menu.activity_user_info, menu);
return true;
}
@@ -24,7 +24,6 @@ package com.owncloud.android.ui.adapter;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.PictureDrawable;
import android.net.Uri;
import android.text.Spannable;
@@ -52,6 +51,7 @@ import com.bumptech.glide.load.model.StreamEncoder;
import com.bumptech.glide.load.resource.file.FileToStreamDecoder;
import com.caverock.androidsvg.SVG;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -95,6 +95,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
protected Context context;
private CurrentAccountProvider currentAccountProvider;
private ClientFactory clientFactory;
private FileDataStorageManager storageManager;
private OCCapability capability;
protected List<Object> values;
@@ -247,8 +248,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
if (MimeTypeUtil.isImageOrVideo(previewObject.getMimeType())) {
int placeholder = R.drawable.file;
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider)).load(previewObject.getSource()).
placeholder(placeholder).error(placeholder).into(imageView);
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
.load(previewObject.getSource())
.placeholder(placeholder)
.error(placeholder)
.into(imageView);
} else {
if (MimeTypeUtil.isFolder(previewObject.getMimeType())) {
imageView.setImageDrawable(
@@ -298,8 +302,10 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
String uri = client.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px +
Uri.encode(file.getRemotePath(), "/");
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider)).load(uri).placeholder(placeholder)
.error(placeholder).into(fileIcon); // using custom fetcher
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
.load(uri).placeholder(placeholder)
.error(placeholder)
.into(fileIcon); // using custom fetcher
} else {
if (isDetailView) {
@@ -369,7 +375,12 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
}, idx1, idx2, 0);
ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), idx1, idx2, 0);
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), idx1, idx2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.setSpan(
new ForegroundColorSpan(context.getResources().getColor(R.color.text_color)),
idx1,
idx2,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
);
}
idx1 = text.indexOf('{', idx2);
}
@@ -23,7 +23,6 @@ package com.owncloud.android.ui.adapter;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -156,7 +155,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
gridViewHolder.checkbox.setImageDrawable(ThemeUtils.tintDrawable(R.drawable.ic_checkbox_marked,
ThemeUtils.primaryColor(mContext)));
} else {
gridViewHolder.itemLayout.setBackgroundColor(Color.WHITE);
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
}
@@ -22,8 +22,6 @@ package com.owncloud.android.ui.adapter;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.PictureDrawable;
import android.net.Uri;
@@ -77,7 +75,7 @@ import butterknife.ButterKnife;
public class NotificationListAdapter extends RecyclerView.Adapter<NotificationListAdapter.NotificationViewHolder> {
private static final String FILE = "file";
private StyleSpan styleSpanBold = new StyleSpan(Typeface.BOLD);
private ForegroundColorSpan foregroundColorSpanBlack = new ForegroundColorSpan(Color.BLACK);
private ForegroundColorSpan foregroundColorSpanBlack;
private List<Notification> notificationsList;
private OwnCloudClient client;
@@ -87,6 +85,8 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
this.notificationsList = new ArrayList<>();
this.client = client;
this.notificationsActivity = notificationsActivity;
foregroundColorSpanBlack = new ForegroundColorSpan(
notificationsActivity.getResources().getColor(R.color.text_color));
}
public void setNotificationItems(List<Notification> notificationItems) {
@@ -140,14 +140,24 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
downloadIcon(notification.getIcon(), holder.icon);
}
setButtons(holder, notification);
holder.dismiss.setOnClickListener(v -> new DeleteNotificationTask(client, notification, holder,
notificationsActivity).execute());
}
public void setButtons(NotificationViewHolder holder, Notification notification) {
// add action buttons
holder.buttons.removeAllViews();
MaterialButton button;
Resources resources = notificationsActivity.getResources();
NotificationExecuteActionTask task = new NotificationExecuteActionTask(client, holder, notificationsActivity);
NotificationExecuteActionTask task = new NotificationExecuteActionTask(client,
holder,
notification,
notificationsActivity);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(20, 0, 20, 0);
for (Action action : notification.getActions()) {
@@ -156,15 +166,14 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
int primaryColor = ThemeUtils.primaryColor(notificationsActivity);
if (action.primary) {
button.getBackground().setColorFilter(primaryColor, PorterDuff.Mode.SRC_ATOP);
button.setBackgroundColor(primaryColor);
button.setTextColor(ThemeUtils.fontColor(notificationsActivity));
button.setTypeface(button.getTypeface(), Typeface.BOLD);
} else {
button.setStrokeColor(ColorStateList.valueOf(resources.getColor(R.color.grey_200)));
button.setStrokeWidth(3);
button.getBackground().setColorFilter(resources.getColor(R.color.transparent),
PorterDuff.Mode.SRC_ATOP);
button.setBackgroundColor(resources.getColor(R.color.transparent));
button.setTextColor(primaryColor);
button.setTypeface(button.getTypeface(), Typeface.BOLD);
}
@@ -184,9 +193,6 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
holder.buttons.addView(button);
}
holder.dismiss.setOnClickListener(v -> new DeleteNotificationTask(client, notification, holder,
notificationsActivity).execute());
}
private SpannableStringBuilder makeSpecialPartsBold(Notification notification) {
@@ -30,7 +30,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Handler;
@@ -48,6 +47,7 @@ import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.R;
@@ -118,7 +118,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private Set<OCFile> checkedFiles;
private FileDataStorageManager mStorageManager;
private Account account;
private User user;
private OCFileListFragmentInterface ocFileListFragmentInterface;
private FilesFilter mFilesFilter;
@@ -136,7 +136,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public OCFileListAdapter(
Context context,
Account account,
User user,
AppPreferences preferences,
UserAccountManager accountManager,
ComponentsGetter transferServiceGetter,
@@ -148,16 +148,16 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
mContext = context;
this.preferences = preferences;
this.accountManager = accountManager;
this.account = account;
this.user = user;
mHideItemOptions = argHideItemOptions;
this.gridView = gridView;
checkedFiles = new HashSet<>();
this.transferServiceGetter = transferServiceGetter;
if (account != null) {
if (this.user != null) {
AccountManager platformAccountManager = AccountManager.get(mContext);
userId = platformAccountManager.getUserData(account,
userId = platformAccountManager.getUserData(this.user.toPlatformAccount(),
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
} else {
userId = "";
@@ -330,7 +330,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
gridViewHolder.checkbox.setImageDrawable(ThemeUtils.tintDrawable(R.drawable.ic_checkbox_marked,
ThemeUtils.primaryColor(mContext)));
} else {
gridViewHolder.itemLayout.setBackgroundColor(Color.WHITE);
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
}
@@ -400,7 +400,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
showFederatedShareAvatar(sharee.getUserId(), avatarRadius, resources, avatar);
} else {
avatar.setTag(sharee);
DisplayUtils.setAvatar(account,
DisplayUtils.setAvatar(user.toPlatformAccount(),
sharee.getUserId(),
sharee.getDisplayName(),
this,
@@ -461,17 +461,17 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
OperationsService.OperationsServiceBinder operationsServiceBinder = transferServiceGetter.getOperationsServiceBinder();
FileDownloader.FileDownloaderBinder fileDownloaderBinder = transferServiceGetter.getFileDownloaderBinder();
FileUploader.FileUploaderBinder fileUploaderBinder = transferServiceGetter.getFileUploaderBinder();
if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(account, file)) {
if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(user.toPlatformAccount(), file)) {
//synchronizing
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
} else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(account, file)) {
} else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(user.toPlatformAccount(), file)) {
// downloading
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
} else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(account, file)) {
} else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(user.toPlatformAccount(), file)) {
//uploading
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
@@ -576,13 +576,17 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
try {
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView, mStorageManager,
account, asyncTasks);
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
mStorageManager,
user.toPlatformAccount(),
asyncTasks);
if (thumbnail == null) {
thumbnail = BitmapUtils.drawableToBitmap(
MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
account, mContext));
MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
file.getFileName(),
user.toPlatformAccount(),
mContext));
}
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(),
@@ -598,12 +602,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
if ("image/png".equalsIgnoreCase(file.getMimeType())) {
thumbnailView.setBackgroundColor(mContext.getResources().getColor(R.color.background_color));
thumbnailView.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
}
} else {
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
file.getFileName(),
account,
user.toPlatformAccount(),
mContext));
}
}
@@ -686,7 +690,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
sharedIconView.setImageResource(R.drawable.ic_unshared);
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_share));
}
if (accountManager.accountOwnsFile(file, account)) {
if (accountManager.accountOwnsFile(file, user.toPlatformAccount())) {
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
} else {
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.showShareDetailView(file));
@@ -704,7 +708,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
* @param limitToMimeType show only files of this mimeType
*/
public void swapDirectory(
Account account,
User account,
OCFile directory,
FileDataStorageManager updatedStorageManager,
boolean onlyOnDevice, String limitToMimeType
@@ -713,8 +717,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
mStorageManager = updatedStorageManager;
showShareAvatar = mStorageManager.getCapability(account.name).getVersion().isShareesOnDavSupported();
this.account = account;
showShareAvatar = mStorageManager.getCapability(account.getAccountName()).getVersion().isShareesOnDavSupported();
this.user = account;
}
if (mStorageManager != null) {
mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
@@ -745,11 +749,11 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
FileDataStorageManager storageManager, OCFile folder, boolean clear) {
if (storageManager != null && mStorageManager == null) {
mStorageManager = storageManager;
showShareAvatar = mStorageManager.getCapability(account.name).getVersion().isShareesOnDavSupported();
showShareAvatar = mStorageManager.getCapability(user.getAccountName()).getVersion().isShareesOnDavSupported();
}
if (mStorageManager == null) {
mStorageManager = new FileDataStorageManager(account, mContext.getContentResolver());
mStorageManager = new FileDataStorageManager(user.toPlatformAccount(), mContext.getContentResolver());
}
if (clear) {
@@ -809,12 +813,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
shares.add(ocShare);
// get ocFile from Server to have an up-to-date copy
RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(account,
RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(user.toPlatformAccount(),
mContext);
if (result.isSuccess()) {
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
FileStorageUtils.searchForLocalFileInDefaultPath(file, account);
FileStorageUtils.searchForLocalFileInDefaultPath(file, user.toPlatformAccount());
file = mStorageManager.saveFileWithParent(file, mContext);
ShareType newShareType = ocShare.getShareType();
@@ -869,7 +873,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
for (Object remoteFile : objects) {
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) remoteFile);
FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, account);
FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, user.toPlatformAccount());
try {
if (ExtendedListFragment.SearchType.PHOTO_SEARCH == searchType) {
@@ -886,9 +890,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
true,
false,
mStorageManager,
account,
user.toPlatformAccount(),
mContext);
refreshFolderOperation.execute(account, mContext);
refreshFolderOperation.execute(user.toPlatformAccount(), mContext);
}
}
@@ -23,16 +23,20 @@ package com.owncloud.android.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
import com.afollestad.sectionedrecyclerview.SectionedViewHolder;
import com.nextcloud.client.core.Clock;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.MediaFolderType;
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
@@ -53,62 +57,174 @@ import butterknife.ButterKnife;
*/
public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedViewHolder> {
private final Context mContext;
private final int mGridWidth;
private final int mGridTotal;
private final ClickListener mListener;
private final List<SyncedFolderDisplayItem> mSyncFolderItems;
private final boolean mLight;
private final Context context;
private final Clock clock;
private final int gridWidth;
private final int gridTotal;
private final ClickListener clickListener;
private final List<SyncedFolderDisplayItem> syncFolderItems;
private final List<SyncedFolderDisplayItem> filteredSyncFolderItems;
private final boolean light;
private final int VIEW_TYPE_EMPTY = Integer.MAX_VALUE;
private boolean hideItems;
public SyncedFolderAdapter(Context context, int gridWidth, ClickListener listener, boolean light) {
mContext = context;
mGridWidth = gridWidth;
mGridTotal = gridWidth * 2;
mListener = listener;
mSyncFolderItems = new ArrayList<>();
mLight = light;
public SyncedFolderAdapter(Context context, Clock clock, int gridWidth, ClickListener listener, boolean light) {
this.context = context;
this.clock = clock;
this.gridWidth = gridWidth;
gridTotal = gridWidth * 2;
clickListener = listener;
syncFolderItems = new ArrayList<>();
filteredSyncFolderItems = new ArrayList<>();
this.light = light;
this.hideItems = true;
shouldShowHeadersForEmptySections(true);
shouldShowFooters(true);
}
public void toggleHiddenItemsVisibility() {
hideItems = !hideItems;
filteredSyncFolderItems.clear();
filteredSyncFolderItems.addAll(filterHiddenItems(syncFolderItems, hideItems));
notifyDataSetChanged();
}
public void setSyncFolderItems(List<SyncedFolderDisplayItem> syncFolderItems) {
mSyncFolderItems.clear();
mSyncFolderItems.addAll(syncFolderItems);
this.syncFolderItems.clear();
this.syncFolderItems.addAll(syncFolderItems);
this.filteredSyncFolderItems.clear();
this.filteredSyncFolderItems.addAll(filterHiddenItems(this.syncFolderItems, hideItems));
}
public void setSyncFolderItem(int location, SyncedFolderDisplayItem syncFolderItem) {
mSyncFolderItems.set(location, syncFolderItem);
if (hideItems && syncFolderItem.isHidden() && filteredSyncFolderItems.contains(syncFolderItem)) {
filteredSyncFolderItems.remove(location);
} else {
if (filteredSyncFolderItems.contains(syncFolderItem)) {
filteredSyncFolderItems.set(filteredSyncFolderItems.indexOf(syncFolderItem), syncFolderItem);
} else {
filteredSyncFolderItems.add(syncFolderItem);
}
}
if (syncFolderItems.contains(syncFolderItem)) {
syncFolderItems.set(syncFolderItems.indexOf(syncFolderItem), syncFolderItem);
} else {
syncFolderItems.add(syncFolderItem);
}
notifyDataSetChanged();
}
public void addSyncFolderItem(SyncedFolderDisplayItem syncFolderItem) {
mSyncFolderItems.add(syncFolderItem);
notifyDataSetChanged();
syncFolderItems.add(syncFolderItem);
// add item for display when either all items should be shown (!hideItems)
// or if item should be shown (!.isHidden())
if (!hideItems || !syncFolderItem.isHidden()) {
filteredSyncFolderItems.add(syncFolderItem);
notifyDataSetChanged();
}
}
public void removeItem(int section) {
mSyncFolderItems.remove(section);
notifyDataSetChanged();
if (filteredSyncFolderItems.contains(syncFolderItems.get(section))) {
filteredSyncFolderItems.remove(syncFolderItems.get(section));
notifyDataSetChanged();
}
syncFolderItems.remove(section);
}
/**
* Filter for hidden items
*
* @param items Collection of items to filter
* @return Non-hidden items
*/
private List<SyncedFolderDisplayItem> filterHiddenItems(List<SyncedFolderDisplayItem> items, boolean hide) {
if (!hide) {
return items;
} else {
List<SyncedFolderDisplayItem> result = new ArrayList<>();
for (SyncedFolderDisplayItem item : items) {
if (!item.isHidden() && !result.contains(item)) {
result.add(item);
}
}
return result;
}
}
@Override
public int getSectionCount() {
return mSyncFolderItems.size();
if (filteredSyncFolderItems.size() > 0) {
return filteredSyncFolderItems.size() + 1;
} else {
return 0;
}
}
public int getUnfilteredSectionCount() {
if (syncFolderItems.size() > 0) {
return syncFolderItems.size() + 1;
} else {
return 0;
}
}
@Override
public int getItemCount(int section) {
List<String> filePaths = mSyncFolderItems.get(section).getFilePaths();
if (section < filteredSyncFolderItems.size()) {
List<String> filePaths = filteredSyncFolderItems.get(section).getFilePaths();
if (filePaths != null) {
return mSyncFolderItems.get(section).getFilePaths().size();
if (filePaths != null) {
return filteredSyncFolderItems.get(section).getFilePaths().size();
} else {
return 1;
}
} else {
return 1;
}
}
public SyncedFolderDisplayItem get(int section) {
return mSyncFolderItems.get(section);
return filteredSyncFolderItems.get(section);
}
@Override
public int getItemViewType(int section, int relativePosition, int absolutePosition) {
if (isLastSection(section)) {
return VIEW_TYPE_EMPTY;
} else {
return VIEW_TYPE_ITEM;
}
}
@Override
public int getHeaderViewType(int section) {
if (isLastSection(section)) {
return VIEW_TYPE_EMPTY;
} else {
return VIEW_TYPE_HEADER;
}
}
@Override
public int getFooterViewType(int section) {
if (isLastSection(section) && showFooter()) {
return VIEW_TYPE_FOOTER;
} else {
// only show footer after last item and only if folders have been hidden
return VIEW_TYPE_EMPTY;
}
}
private boolean showFooter() {
return syncFolderItems.size() > filteredSyncFolderItems.size();
}
/**
@@ -119,9 +235,9 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
* @return the section index of the looked up synced folder, <code>-1</code> if not present
*/
public int getSectionByLocalPathAndType(String localPath, int type) {
for (int i = 0; i < mSyncFolderItems.size(); i++) {
if (mSyncFolderItems.get(i).getLocalPath().equalsIgnoreCase(localPath) &&
mSyncFolderItems.get(i).getType().getId().equals(type)) {
for (int i = 0; i < filteredSyncFolderItems.size(); i++) {
if (filteredSyncFolderItems.get(i).getLocalPath().equalsIgnoreCase(localPath) &&
filteredSyncFolderItems.get(i).getType().getId().equals(type)) {
return i;
}
}
@@ -131,70 +247,96 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
@Override
public void onBindHeaderViewHolder(SectionedViewHolder commonHolder, final int section, boolean expanded) {
HeaderViewHolder holder = (HeaderViewHolder) commonHolder;
if (section < filteredSyncFolderItems.size()) {
HeaderViewHolder holder = (HeaderViewHolder) commonHolder;
holder.mainHeaderContainer.setVisibility(View.VISIBLE);
holder.mainHeaderContainer.setVisibility(View.VISIBLE);
holder.title.setText(filteredSyncFolderItems.get(section).getFolderName());
holder.title.setText(mSyncFolderItems.get(section).getFolderName());
if (MediaFolderType.VIDEO == filteredSyncFolderItems.get(section).getType()) {
holder.type.setImageResource(R.drawable.video_32dp);
} else if (MediaFolderType.IMAGE == filteredSyncFolderItems.get(section).getType()) {
holder.type.setImageResource(R.drawable.image_32dp);
} else {
holder.type.setImageResource(R.drawable.folder_star_32dp);
}
if (MediaFolderType.VIDEO == mSyncFolderItems.get(section).getType()) {
holder.type.setImageResource(R.drawable.video_32dp);
} else if (MediaFolderType.IMAGE == mSyncFolderItems.get(section).getType()) {
holder.type.setImageResource(R.drawable.image_32dp);
} else {
holder.type.setImageResource(R.drawable.folder_star_32dp);
holder.syncStatusButton.setVisibility(View.VISIBLE);
holder.syncStatusButton.setTag(section);
holder.syncStatusButton.setOnClickListener(v -> {
filteredSyncFolderItems.get(section).setEnabled(
!filteredSyncFolderItems.get(section).isEnabled(),
clock.getCurrentTime()
);
setSyncButtonActiveIcon(holder.syncStatusButton, filteredSyncFolderItems.get(section).isEnabled());
clickListener.onSyncStatusToggleClick(section, filteredSyncFolderItems.get(section));
});
setSyncButtonActiveIcon(holder.syncStatusButton, filteredSyncFolderItems.get(section).isEnabled());
if (light) {
holder.menuButton.setVisibility(View.GONE);
} else {
holder.menuButton.setVisibility(View.VISIBLE);
holder.menuButton.setTag(section);
holder.menuButton.setOnClickListener(v -> onOverflowIconClicked(section,
filteredSyncFolderItems.get(section),
v));
}
}
}
holder.syncStatusButton.setVisibility(View.VISIBLE);
holder.syncStatusButton.setTag(section);
holder.syncStatusButton.setOnClickListener(v -> {
mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled());
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
});
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
private void onOverflowIconClicked(int section, SyncedFolderDisplayItem item, View view) {
PopupMenu popup = new PopupMenu(context, view);
popup.inflate(R.menu.synced_folders_adapter);
popup.setOnMenuItemClickListener(i -> optionsItemSelected(i, section, item));
popup.getMenu()
.findItem(R.id.action_auto_upload_folder_toggle_visibility)
.setChecked(item.isHidden());
holder.syncStatusButton.setVisibility(View.VISIBLE);
holder.syncStatusButton.setTag(section);
holder.syncStatusButton.setOnClickListener(v -> {
mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled());
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
});
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
popup.show();
}
if (mLight) {
holder.menuButton.setVisibility(View.GONE);
private boolean optionsItemSelected(MenuItem menuItem, int section, SyncedFolderDisplayItem item) {
if (menuItem.getItemId() == R.id.action_auto_upload_folder_toggle_visibility) {
clickListener.onVisibilityToggleClick(section, item);
} else {
holder.menuButton.setVisibility(View.VISIBLE);
holder.menuButton.setTag(section);
holder.menuButton.setOnClickListener(v -> mListener.onSyncFolderSettingsClick(section,
mSyncFolderItems.get(section)));
// default: R.id.action_create_custom_folder
clickListener.onSyncFolderSettingsClick(section, item);
}
return true;
}
@Override
public void onBindFooterViewHolder(SectionedViewHolder holder, int section) {
// not needed
if (isLastSection(section) && showFooter()) {
FooterViewHolder footerHolder = (FooterViewHolder) holder;
footerHolder.title.setOnClickListener(v -> toggleHiddenItemsVisibility());
footerHolder.title.setText(
context.getResources().getQuantityString(
R.plurals.synced_folders_show_hidden_folders,
getHiddenFolderCount(),
getHiddenFolderCount()
)
);
}
}
@Override
public void onBindViewHolder(SectionedViewHolder commonHolder, int section, int relativePosition,
int absolutePosition) {
if (mSyncFolderItems.get(section).getFilePaths() != null) {
if (section < filteredSyncFolderItems.size() && filteredSyncFolderItems.get(section).getFilePaths() != null) {
MainViewHolder holder = (MainViewHolder) commonHolder;
File file = new File(mSyncFolderItems.get(section).getFilePaths().get(relativePosition));
File file = new File(filteredSyncFolderItems.get(section).getFilePaths().get(relativePosition));
ThumbnailsCacheManager.MediaThumbnailGenerationTask task =
new ThumbnailsCacheManager.MediaThumbnailGenerationTask(holder.image, mContext);
new ThumbnailsCacheManager.MediaThumbnailGenerationTask(holder.image, context);
ThumbnailsCacheManager.AsyncMediaThumbnailDrawable asyncDrawable =
new ThumbnailsCacheManager.AsyncMediaThumbnailDrawable(
mContext.getResources(),
ThumbnailsCacheManager.mDefaultImg,
task
context.getResources(),
ThumbnailsCacheManager.mDefaultImg,
task
);
holder.image.setImageDrawable(asyncDrawable);
@@ -203,11 +345,11 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
// set proper tag
holder.image.setTag(file.hashCode());
holder.itemView.setTag(relativePosition % mGridWidth);
holder.itemView.setTag(relativePosition % gridWidth);
if (mSyncFolderItems.get(section).getNumberOfFiles() > mGridTotal && relativePosition >= mGridTotal - 1) {
if (filteredSyncFolderItems.get(section).getNumberOfFiles() > gridTotal && relativePosition >= gridTotal - 1) {
holder.counterValue.setText(String.format(Locale.US, "%d",
mSyncFolderItems.get(section).getNumberOfFiles() - mGridTotal));
filteredSyncFolderItems.get(section).getNumberOfFiles() - gridTotal));
holder.counterBar.setVisibility(View.VISIBLE);
holder.thumbnailDarkener.setVisibility(View.VISIBLE);
} else {
@@ -223,15 +365,34 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
if (viewType == VIEW_TYPE_HEADER) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.synced_folders_item_header, parent, false);
return new HeaderViewHolder(v);
} else if (viewType == VIEW_TYPE_FOOTER) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.synced_folders_footer, parent, false);
return new FooterViewHolder(v);
} else if (viewType == VIEW_TYPE_EMPTY) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.synced_folders_empty, parent, false);
return new EmptyViewHolder(v);
} else {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.grid_sync_item, parent, false);
return new MainViewHolder(v);
}
}
private boolean isLastSection(int section) {
return section >= getSectionCount() - 1;
}
public int getHiddenFolderCount() {
if (syncFolderItems != null && filteredSyncFolderItems != null) {
return syncFolderItems.size() - filteredSyncFolderItems.size();
} else {
return 0;
}
}
public interface ClickListener {
void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem);
void onSyncFolderSettingsClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem);
void onVisibilityToggleClick(int section, SyncedFolderDisplayItem item);
}
static class HeaderViewHolder extends SectionedViewHolder {
@@ -256,7 +417,29 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
}
}
static class FooterViewHolder extends SectionedViewHolder {
@BindView(R.id.footer_container)
public LinearLayout mainFooterContainer;
@BindView(R.id.footer_text)
public TextView title;
private FooterViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
static class EmptyViewHolder extends SectionedViewHolder {
private EmptyViewHolder(View itemView) {
super(itemView);
}
}
static class MainViewHolder extends SectionedViewHolder {
@BindView(R.id.grid_item_container)
public FrameLayout item_container;
@BindView(R.id.thumbnail)
public ImageView image;
@@ -278,7 +461,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
private void setSyncButtonActiveIcon(ImageButton syncStatusButton, boolean enabled) {
if (enabled) {
syncStatusButton.setImageDrawable(ThemeUtils.tintDrawable(R.drawable.ic_cloud_sync_on,
ThemeUtils.primaryColor(mContext)));
ThemeUtils.primaryColor(context)));
} else {
syncStatusButton.setImageResource(R.drawable.ic_cloud_sync_off);
}
@@ -33,6 +33,7 @@ import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.Template;
import com.owncloud.android.ui.dialog.ChooseTemplateDialogFragment;
@@ -56,17 +57,20 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
private Context context;
private ChooseTemplateDialogFragment.Type type;
private CurrentAccountProvider currentAccountProvider;
private ClientFactory clientFactory;
public TemplateAdapter(
ChooseTemplateDialogFragment.Type type,
ClickListener clickListener,
Context context,
CurrentAccountProvider currentAccountProvider
CurrentAccountProvider currentAccountProvider,
ClientFactory clientFactory
) {
this.clickListener = clickListener;
this.type = type;
this.context = context;
this.currentAccountProvider = currentAccountProvider;
this.clientFactory = clientFactory;
}
@NonNull
@@ -135,7 +139,8 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
break;
}
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider)).load(template.getThumbnailLink())
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
.load(template.getThumbnailLink())
.placeholder(placeholder)
.error(placeholder)
.into(thumbnail);
@@ -20,7 +20,6 @@
*/
package com.owncloud.android.ui.adapter;
import android.accounts.Account;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -31,6 +30,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nextcloud.client.account.User;
import com.nextcloud.client.preferences.AppPreferences;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -65,7 +65,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private final TrashbinActivityInterface trashbinActivityInterface;
private List<TrashbinFile> files;
private final Context context;
private final Account account;
private final User user;
private final FileDataStorageManager storageManager;
private final AppPreferences preferences;
@@ -76,11 +76,11 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
FileDataStorageManager storageManager,
AppPreferences preferences,
Context context,
Account account
User user
) {
this.files = new ArrayList<>();
this.trashbinActivityInterface = trashbinActivityInterface;
this.account = account;
this.user = user;
this.storageManager = storageManager;
this.preferences = preferences;
this.context = context;
@@ -237,7 +237,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
try {
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView, storageManager,
account, asyncTasks);
user.toPlatformAccount(), asyncTasks);
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
new ThumbnailsCacheManager.AsyncThumbnailDrawable(context.getResources(),
@@ -253,11 +253,11 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
if ("image/png".equalsIgnoreCase(file.getMimeType())) {
thumbnailView.setBackgroundColor(context.getResources().getColor(R.color.background_color));
thumbnailView.setBackgroundColor(context.getResources().getColor(R.color.bg_default));
}
} else {
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
account, context));
user.toPlatformAccount(), context));
}
}
}
@@ -416,7 +416,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
if ("image/png".equals(item.getMimeType())) {
itemViewHolder.thumbnail.setBackgroundColor(parentActivity.getResources()
.getColor(R.color.background_color));
.getColor(R.color.bg_default));
}
@@ -451,7 +451,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
if ("image/png".equalsIgnoreCase(item.getMimeType())) {
itemViewHolder.thumbnail.setBackgroundColor(parentActivity.getResources()
.getColor(R.color.background_color));
.getColor(R.color.bg_default));
}
} else {
itemViewHolder.thumbnail.setImageDrawable(MimeTypeUtil.getFileTypeIcon(item.getMimeType(), fileName,
@@ -183,7 +183,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
context.getTheme().applyStyle(R.style.FallbackThemingTheme, true);
}
PopupMenu popup = new PopupMenu(context, view);
popup.inflate(R.menu.file_detail_sharing_menu);
popup.inflate(R.menu.item_user_sharing_settings);
prepareOptionsMenu(popup.getMenu(), share);
@@ -33,6 +33,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.operations.RichDocumentsUrlOperation;
import com.owncloud.android.ui.activity.RichDocumentsWebView;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.ThemeUtils;
import java.lang.ref.WeakReference;
@@ -80,9 +81,9 @@ public class LoadUrlTask extends AsyncTask<String, Void, String> {
if (richDocumentsWebView.getWebview().getVisibility() != View.VISIBLE) {
Snackbar snackbar = DisplayUtils.createSnackbar(richDocumentsWebView.findViewById(android.R.id.content),
R.string.timeout_richDocuments, Snackbar.LENGTH_INDEFINITE)
.setActionTextColor(richDocumentsWebView.getResources().getColor(R.color.white))
.setAction(R.string.fallback_weblogin_back, v -> richDocumentsWebView.closeView());
ThemeUtils.colorSnackbar(richDocumentsWebView.getApplicationContext(),snackbar);
richDocumentsWebView.setLoadingSnackbar(snackbar);
snackbar.show();
}
@@ -6,6 +6,7 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.notifications.models.Action;
import com.owncloud.android.lib.resources.notifications.models.Notification;
import com.owncloud.android.ui.activity.NotificationsActivity;
import com.owncloud.android.ui.adapter.NotificationListAdapter;
@@ -22,12 +23,16 @@ public class NotificationExecuteActionTask extends AsyncTask<Action, Void, Boole
private NotificationListAdapter.NotificationViewHolder holder;
private OwnCloudClient client;
private Notification notification;
private NotificationsActivity notificationsActivity;
public NotificationExecuteActionTask(OwnCloudClient client, NotificationListAdapter.NotificationViewHolder holder,
public NotificationExecuteActionTask(OwnCloudClient client,
NotificationListAdapter.NotificationViewHolder holder,
Notification notification,
NotificationsActivity notificationsActivity) {
this.client = client;
this.holder = holder;
this.notification = notification;
this.notificationsActivity = notificationsActivity;
}
@@ -73,6 +78,6 @@ public class NotificationExecuteActionTask extends AsyncTask<Action, Void, Boole
@Override
protected void onPostExecute(Boolean isSuccess) {
notificationsActivity.onActionCallback(isSuccess, holder);
notificationsActivity.onActionCallback(isSuccess, notification, holder);
}
}
@@ -21,9 +21,9 @@
package com.owncloud.android.ui.asynctasks;
import android.accounts.Account;
import android.os.AsyncTask;
import com.nextcloud.client.account.User;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
@@ -38,18 +38,18 @@ import java.lang.ref.WeakReference;
public class PhotoSearchTask extends AsyncTask<Void, Void, RemoteOperationResult> {
private int columnCount;
private Account account;
private User user;
private WeakReference<PhotoFragment> photoFragmentWeakReference;
private SearchRemoteOperation searchRemoteOperation;
private FileDataStorageManager storageManager;
public PhotoSearchTask(int columnsCount,
PhotoFragment photoFragment,
Account account,
User user,
SearchRemoteOperation searchRemoteOperation,
FileDataStorageManager storageManager) {
this.columnCount = columnsCount;
this.account = account;
this.user = user;
this.photoFragmentWeakReference = new WeakReference<>(photoFragment);
this.searchRemoteOperation = searchRemoteOperation;
this.storageManager = storageManager;
@@ -88,7 +88,7 @@ public class PhotoSearchTask extends AsyncTask<Void, Void, RemoteOperationResult
searchRemoteOperation.setTimestamp(timestamp);
if (photoFragment.getContext() != null) {
return searchRemoteOperation.execute(account, photoFragment.getContext());
return searchRemoteOperation.execute(user.toPlatformAccount(), photoFragment.getContext());
} else {
return new RemoteOperationResult(new IllegalStateException("No context available"));
}
@@ -24,7 +24,6 @@
package com.owncloud.android.ui.dialog;
import android.accounts.Account;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
@@ -40,16 +39,16 @@ import android.view.WindowManager.LayoutParams;
import android.widget.EditText;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.account.User;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.Template;
import com.owncloud.android.files.CreateFileFromTemplateOperation;
import com.owncloud.android.files.FetchTemplateOperation;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.activity.ExternalSiteWebView;
@@ -88,7 +87,8 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
private TemplateAdapter adapter;
private OCFile parentFolder;
private OwnCloudClient client;
@Inject CurrentAccountProvider currentAccount;
@Inject CurrentAccountProvider currentUser;
@Inject ClientFactory clientFactory;
public enum Type {
DOCUMENT,
@@ -151,9 +151,8 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
fileName.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
try {
Account account = currentAccount.getCurrentAccount();
OwnCloudAccount ocAccount = new OwnCloudAccount(account, activity);
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, getContext());
User user = currentUser.getUser();
client = clientFactory.create(user);
new FetchTemplateTask(this, client).execute(type);
} catch (Exception e) {
@@ -162,7 +161,7 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial
listView.setHasFixedSize(true);
listView.setLayoutManager(new GridLayoutManager(activity, 2));
adapter = new TemplateAdapter(type, this, getContext(), currentAccount);
adapter = new TemplateAdapter(type, this, getContext(), currentUser, clientFactory);
listView.setAdapter(adapter);
// Build the dialog
@@ -99,6 +99,7 @@ public class CreateFolderDialogFragment
inputText.setText("");
inputText.requestFocus();
inputText.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
inputText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
// Build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
@@ -32,6 +32,7 @@ import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.utils.ThemeUtils;
import java.util.Calendar;
@@ -140,6 +141,11 @@ public class ExpirationDatePickerDialogFragment
}
});
dialog.show();
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(ThemeUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(ThemeUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(ThemeUtils.primaryColor(getContext(), true));
// Prevent days in the past may be chosen
DatePicker picker = dialog.getDatePicker();
picker.setMinDate(tomorrowInMillis - 1000);
@@ -109,6 +109,7 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
// Setup layout
noteEditText.setText(share.getNote());
noteEditText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
noteEditText.requestFocus();
ThemeUtils.colorTextInputLayout(noteEditTextInputLayout, accentColor);
@@ -136,8 +137,13 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
ComponentsGetter componentsGetter = (ComponentsGetter) getActivity();
if (componentsGetter != null) {
componentsGetter.getFileOperationsHelper().updateNoteToShare(share,
noteEditText.getText().toString().trim());
String note = "";
if (noteEditText.getText() != null) {
note = noteEditText.getText().toString().trim();
}
componentsGetter.getFileOperationsHelper().updateNoteToShare(share, note);
} else {
DisplayUtils.showSnackMessage(requireActivity(), R.string.note_could_not_sent);
}
@@ -102,6 +102,7 @@ public class RenameFileDialogFragment
// Setup layout
String currentName = mTargetFile.getFileName();
EditText inputText = v.findViewById(R.id.user_input);
inputText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
inputText.setText(currentName);
ThemeUtils.themeEditText(getContext(), inputText, false);
int selectionStart = 0;
@@ -144,6 +144,7 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
// Build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
R.style.Theme_ownCloud_Dialog_NoButtonBarStyle);
builder.setView(v)
.setPositiveButton(R.string.common_ok, this)
.setNegativeButton(R.string.common_cancel, this)
@@ -202,7 +202,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
ThemeUtils.themeDialogActionButton(mSave);
// Set values
setEnabled(mSyncedFolder.getEnabled());
setEnabled(mSyncedFolder.isEnabled());
if (!TextUtils.isEmpty(mSyncedFolder.getLocalPath())) {
mLocalFolderPath.setText(
@@ -223,11 +223,11 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
mRemoteFolderSummary.setText(R.string.choose_remote_folder);
}
mUploadOnWifiCheckbox.setChecked(mSyncedFolder.getWifiOnly());
mUploadOnWifiCheckbox.setChecked(mSyncedFolder.isWifiOnly());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mUploadOnChargingCheckbox.setChecked(mSyncedFolder.getChargingOnly());
mUploadOnChargingCheckbox.setChecked(mSyncedFolder.isChargingOnly());
}
mUploadUseSubfoldersCheckbox.setChecked(mSyncedFolder.getSubfolderByDate());
mUploadUseSubfoldersCheckbox.setChecked(mSyncedFolder.isSubfolderByDate());
mUploadBehaviorSummary.setText(mUploadBehaviorItemStrings[mSyncedFolder.getUploadActionInteger()]);
}
@@ -344,7 +344,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
new OnClickListener() {
@Override
public void onClick(View v) {
mSyncedFolder.setWifiOnly(!mSyncedFolder.getWifiOnly());
mSyncedFolder.setWifiOnly(!mSyncedFolder.isWifiOnly());
mUploadOnWifiCheckbox.toggle();
}
});
@@ -355,7 +355,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
new OnClickListener() {
@Override
public void onClick(View v) {
mSyncedFolder.setChargingOnly(!mSyncedFolder.getChargingOnly());
mSyncedFolder.setChargingOnly(!mSyncedFolder.isChargingOnly());
mUploadOnChargingCheckbox.toggle();
}
});
@@ -365,7 +365,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
new OnClickListener() {
@Override
public void onClick(View v) {
mSyncedFolder.setSubfolderByDate(!mSyncedFolder.getSubfolderByDate());
mSyncedFolder.setSubfolderByDate(!mSyncedFolder.isSubfolderByDate());
mUploadUseSubfoldersCheckbox.toggle();
}
});
@@ -401,7 +401,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
view.findViewById(R.id.sync_enabled).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setEnabled(!mSyncedFolder.getEnabled());
setEnabled(!mSyncedFolder.isEnabled());
}
});
@@ -27,70 +27,76 @@ import com.owncloud.android.datamodel.MediaFolderType;
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
import com.owncloud.android.files.services.FileUploader;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* Parcelable for {@link SyncedFolderDisplayItem} objects to transport them from/to dialog fragments.
*/
@NoArgsConstructor
public class SyncedFolderParcelable implements Parcelable {
private String mFolderName;
private String mLocalPath;
private String mRemotePath;
private Boolean mWifiOnly = false;
private Boolean mChargingOnly = false;
private Boolean mEnabled = false;
private Boolean mSubfolderByDate = false;
private Integer mUploadAction;
private MediaFolderType mType;
private long mId;
private String mAccount;
private int mSection;
@Getter @Setter private String folderName;
@Getter @Setter private String localPath;
@Getter @Setter private String remotePath;
@Getter @Setter private boolean wifiOnly = false;
@Getter @Setter private boolean chargingOnly = false;
@Getter @Setter private boolean enabled = false;
@Getter @Setter private boolean subfolderByDate = false;
@Getter private Integer uploadAction;
@Getter @Setter private MediaFolderType type;
@Getter @Setter private boolean hidden = false;
@Getter @Setter private long id;
@Getter @Setter private String account;
@Getter @Setter private int section;
public SyncedFolderParcelable(SyncedFolderDisplayItem syncedFolderDisplayItem, int section) {
mId = syncedFolderDisplayItem.getId();
mFolderName = syncedFolderDisplayItem.getFolderName();
mLocalPath = syncedFolderDisplayItem.getLocalPath();
mRemotePath = syncedFolderDisplayItem.getRemotePath();
mWifiOnly = syncedFolderDisplayItem.getWifiOnly();
mChargingOnly = syncedFolderDisplayItem.getChargingOnly();
mEnabled = syncedFolderDisplayItem.isEnabled();
mSubfolderByDate = syncedFolderDisplayItem.getSubfolderByDate();
mType = syncedFolderDisplayItem.getType();
mAccount = syncedFolderDisplayItem.getAccount();
mUploadAction = syncedFolderDisplayItem.getUploadAction();
mSection = section;
id = syncedFolderDisplayItem.getId();
folderName = syncedFolderDisplayItem.getFolderName();
localPath = syncedFolderDisplayItem.getLocalPath();
remotePath = syncedFolderDisplayItem.getRemotePath();
wifiOnly = syncedFolderDisplayItem.isWifiOnly();
chargingOnly = syncedFolderDisplayItem.isChargingOnly();
enabled = syncedFolderDisplayItem.isEnabled();
subfolderByDate = syncedFolderDisplayItem.isSubfolderByDate();
type = syncedFolderDisplayItem.getType();
account = syncedFolderDisplayItem.getAccount();
uploadAction = syncedFolderDisplayItem.getUploadAction();
this.section = section;
hidden = syncedFolderDisplayItem.isHidden();
}
private SyncedFolderParcelable(Parcel read) {
mId = read.readLong();
mFolderName = read.readString();
mLocalPath = read.readString();
mRemotePath = read.readString();
mWifiOnly = read.readInt()!= 0;
mChargingOnly = read.readInt() != 0;
mEnabled = read.readInt() != 0;
mSubfolderByDate = read.readInt() != 0;
mType = MediaFolderType.getById(read.readInt());
mAccount = read.readString();
mUploadAction = read.readInt();
mSection = read.readInt();
id = read.readLong();
folderName = read.readString();
localPath = read.readString();
remotePath = read.readString();
wifiOnly = read.readInt()!= 0;
chargingOnly = read.readInt() != 0;
enabled = read.readInt() != 0;
subfolderByDate = read.readInt() != 0;
type = MediaFolderType.getById(read.readInt());
account = read.readString();
uploadAction = read.readInt();
section = read.readInt();
hidden = read.readInt() != 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mId);
dest.writeString(mFolderName);
dest.writeString(mLocalPath);
dest.writeString(mRemotePath);
dest.writeInt(mWifiOnly ? 1 : 0);
dest.writeInt(mChargingOnly ? 1 : 0);
dest.writeInt(mEnabled ? 1 : 0);
dest.writeInt(mSubfolderByDate ? 1 : 0);
dest.writeInt(mType.getId());
dest.writeString(mAccount);
dest.writeInt(mUploadAction);
dest.writeInt(mSection);
dest.writeLong(id);
dest.writeString(folderName);
dest.writeString(localPath);
dest.writeString(remotePath);
dest.writeInt(wifiOnly ? 1 : 0);
dest.writeInt(chargingOnly ? 1 : 0);
dest.writeInt(enabled ? 1 : 0);
dest.writeInt(subfolderByDate ? 1 : 0);
dest.writeInt(type.getId());
dest.writeString(account);
dest.writeInt(uploadAction);
dest.writeInt(section);
dest.writeInt(hidden ? 1 : 0);
}
public static final Creator<SyncedFolderParcelable> CREATOR =
@@ -112,76 +118,8 @@ public class SyncedFolderParcelable implements Parcelable {
return 0;
}
public String getFolderName() {
return mFolderName;
}
public void setFolderName(String mFolderName) {
this.mFolderName = mFolderName;
}
public String getLocalPath() {
return mLocalPath;
}
public void setLocalPath(String mLocalPath) {
this.mLocalPath = mLocalPath;
}
public String getRemotePath() {
return mRemotePath;
}
public void setRemotePath(String mRemotePath) {
this.mRemotePath = mRemotePath;
}
public Boolean getWifiOnly() {
return mWifiOnly;
}
public void setWifiOnly(Boolean mWifiOnly) {
this.mWifiOnly = mWifiOnly;
}
public Boolean getChargingOnly() {
return mChargingOnly;
}
public void setChargingOnly(Boolean mChargingOnly) {
this.mChargingOnly = mChargingOnly;
}
public Boolean getEnabled() {
return mEnabled;
}
public void setEnabled(boolean mEnabled) {
this.mEnabled = mEnabled;
}
public Boolean getSubfolderByDate() {
return mSubfolderByDate;
}
public void setSubfolderByDate(Boolean mSubfolderByDate) {
this.mSubfolderByDate = mSubfolderByDate;
}
public MediaFolderType getType() {
return mType;
}
public void setType(MediaFolderType mType) {
this.mType = mType;
}
public Integer getUploadAction() {
return mUploadAction;
}
public Integer getUploadActionInteger() {
switch (mUploadAction) {
switch (uploadAction) {
case FileUploader.LOCAL_BEHAVIOUR_FORGET:
return 0;
case FileUploader.LOCAL_BEHAVIOUR_MOVE:
@@ -192,41 +130,17 @@ public class SyncedFolderParcelable implements Parcelable {
return 0;
}
public void setUploadAction(String mUploadAction) {
switch (mUploadAction) {
public void setUploadAction(String uploadAction) {
switch (uploadAction) {
case "LOCAL_BEHAVIOUR_FORGET":
this.mUploadAction = FileUploader.LOCAL_BEHAVIOUR_FORGET;
this.uploadAction = FileUploader.LOCAL_BEHAVIOUR_FORGET;
break;
case "LOCAL_BEHAVIOUR_MOVE":
this.mUploadAction = FileUploader.LOCAL_BEHAVIOUR_MOVE;
this.uploadAction = FileUploader.LOCAL_BEHAVIOUR_MOVE;
break;
case "LOCAL_BEHAVIOUR_DELETE":
this.mUploadAction = FileUploader.LOCAL_BEHAVIOUR_DELETE;
this.uploadAction = FileUploader.LOCAL_BEHAVIOUR_DELETE;
break;
}
}
public long getId() {
return mId;
}
public void setId(long mId) {
this.mId = mId;
}
public String getAccount() {
return mAccount;
}
public void setAccount(String mAccount) {
this.mAccount = mAccount;
}
public int getSection() {
return mSection;
}
public void setSection(int mSection) {
this.mSection = mSection;
}
}
@@ -53,6 +53,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
@@ -194,6 +195,9 @@ public class ExtendedListFragment extends Fragment implements
searchView.setOnCloseListener(this);
ThemeUtils.themeSearchView(searchView, true, requireContext());
SearchView.SearchAutoComplete theTextArea = searchView.findViewById(R.id.search_src_text);
theTextArea.setHighlightColor(ThemeUtils.primaryAccentColor(getContext()));
final Handler handler = new Handler();
DisplayMetrics displaymetrics = new DisplayMetrics();
@@ -301,7 +305,8 @@ public class ExtendedListFragment extends Fragment implements
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (accountManager.isSearchSupported(accountManager.getCurrentAccount())) {
User user = accountManager.getUser();
if (user.getServer().getVersion().isSearchSupported()) {
EventBus.getDefault().post(new SearchEvent(query,
SearchRemoteOperation.SearchType.FILE_SEARCH, SearchEvent.UnsetType.NO_UNSET));
} else {
@@ -24,9 +24,6 @@
package com.owncloud.android.ui.fragment;
import android.accounts.Account;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.Context;
import android.graphics.PorterDuff;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -41,15 +38,14 @@ import android.widget.TextView;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputEditText;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.owncloud.android.MainApp;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.activities.GetActivitiesRemoteOperation;
@@ -72,7 +68,6 @@ import com.owncloud.android.utils.ThemeUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -149,6 +144,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
private VersionListInterface.CommentCallback callback;
@Inject UserAccountManager accountManager;
@Inject ClientFactory clientFactory;
public static FileDetailActivitiesFragment newInstance(OCFile file, Account account) {
FileDetailActivitiesFragment fragment = new FileDetailActivitiesFragment();
@@ -258,7 +254,9 @@ public class FileDetailActivitiesFragment extends Fragment implements
PorterDuff.Mode.SRC_IN);
emptyContentIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_activity_light_grey));
adapter = new ActivityAndVersionListAdapter(getContext(), accountManager, this, this, storageManager, capability);
adapter = new ActivityAndVersionListAdapter(getContext(), accountManager, this, this,
storageManager,
capability);
recyclerView.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
@@ -301,9 +299,9 @@ public class FileDetailActivitiesFragment extends Fragment implements
final SwipeRefreshLayout empty = swipeEmptyListRefreshLayout;
final SwipeRefreshLayout list = swipeListRefreshLayout;
final Account currentAccount = accountManager.getCurrentAccount();
final User user = accountManager.getUser();
if (currentAccount == null) {
if (user.isAnonymous()) {
activity.runOnUiThread(() -> {
setEmptyContent(getString(R.string.common_error), getString(R.string.file_detail_activity_error));
list.setVisibility(View.GONE);
@@ -312,15 +310,10 @@ public class FileDetailActivitiesFragment extends Fragment implements
return;
}
final Context context = MainApp.getAppContext();
Thread t = new Thread(() -> {
OwnCloudAccount ocAccount;
try {
ocAccount = new OwnCloudAccount(currentAccount, context);
ownCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
ownCloudClient.setOwnCloudVersion(accountManager.getServerVersion(currentAccount));
ownCloudClient = clientFactory.create(user);
ownCloudClient.setOwnCloudVersion(user.getServer().getVersion());
isLoadingActivities = true;
GetActivitiesRemoteOperation getRemoteNotificationOperation;
@@ -385,8 +378,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
}
hideRefreshLayoutLoader(activity);
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | IOException |
OperationCanceledException | AuthenticatorException | NullPointerException e) {
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "Error fetching file details activities", e);
}
});
Loaded 100 of 320 files, more files were not shown because too many files have changed in this diff. Show more