Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef92ca7db8 | ||
|
|
640e70e6f3 | ||
|
|
0f1da5238b | ||
|
|
5d428fe9a2 | ||
|
|
49f3a67251 | ||
|
|
6540e3ef71 | ||
|
|
a4ff1f11d7 | ||
|
|
e77ffa00a8 | ||
|
|
91ef307e7a | ||
|
|
52d089b18a | ||
|
|
ec27f840a6 | ||
|
|
7713a28a4f | ||
|
|
6783e8ab4c | ||
|
|
213002f44e | ||
|
|
1b7bd72c49 | ||
|
|
c243453168 | ||
|
|
a93313ca19 | ||
|
|
467104c455 | ||
|
|
c59f9c0b91 | ||
|
|
c821f192d6 | ||
|
|
389090d3e8 | ||
|
|
511a16612d | ||
|
|
4616b0d40b | ||
|
|
20b910a646 | ||
|
|
0977c37916 | ||
|
|
5c74f2b1be | ||
|
|
27fabe745b | ||
|
|
490b292ad9 | ||
|
|
61027524f7 | ||
|
|
7b4e1b82e3 | ||
|
|
af93382c66 | ||
|
|
0afc2645c4 | ||
|
|
68f06ea158 | ||
|
|
045a7aa9e7 | ||
|
|
5cc0360855 | ||
|
|
eefeda930c | ||
|
|
7156aaff2a | ||
|
|
67880e2758 | ||
|
|
a063f32d25 | ||
|
|
d841f64254 | ||
|
|
0569b0de65 | ||
|
|
53024d1cd1 | ||
|
|
e716c99a9b | ||
|
|
f520f2f9a2 | ||
|
|
25cbeb4bd8 | ||
|
|
26d7b9c692 | ||
|
|
c2750aabda | ||
|
|
87eb8e0d16 | ||
|
|
4ce54bc21e | ||
|
|
5905b1c5a5 | ||
|
|
4be18adc2d | ||
|
|
2b3e69e80a | ||
|
|
619b5d05d2 | ||
|
|
2d6e73dd31 | ||
|
|
1bb04aa29e | ||
|
|
6048243f41 | ||
|
|
0027df9d0c | ||
|
|
6dd5d925ab | ||
|
|
b4db9d07af | ||
|
|
b5fb9c1374 | ||
|
|
f415cd966f | ||
|
|
a114080348 | ||
|
|
2b2800bc74 | ||
|
|
98d7518808 | ||
|
|
8ce35e3f59 | ||
|
|
c4a0a09c74 | ||
|
|
b13cba02c2 | ||
|
|
dc1a3f1f06 | ||
|
|
aa3727e031 | ||
|
|
7dbf43b2fb | ||
|
|
4a1e1b1ca8 | ||
|
|
26f2d52a5a | ||
|
|
94abac7f79 | ||
|
|
8890770fb2 | ||
|
|
823808e37a | ||
|
|
c7669fe9db | ||
|
|
e8d00fd81c | ||
|
|
c5be0ad7e4 | ||
|
|
a0de3e5ad1 | ||
|
|
0936945b3c | ||
|
|
c7d2b0e808 | ||
|
|
7e4711a23c | ||
|
|
778fec9e21 | ||
|
|
3a78c1b9db | ||
|
|
e118f9a516 | ||
|
|
c7ea6458bf | ||
|
|
7c84a9f929 | ||
|
|
f9a47e6b3b | ||
|
|
c64e90e8cc | ||
|
|
84adb9eaa0 | ||
|
|
0d0a4a3198 | ||
|
|
d7918c59c6 | ||
|
|
1bf079d2cd | ||
|
|
e19b58178b | ||
|
|
75c0871e65 | ||
|
|
ebba5ea4eb | ||
|
|
a2e327bdcd | ||
|
|
d1b54e1ab7 | ||
|
|
829c705e90 | ||
|
|
4e16e0431a | ||
|
|
8184dbf1ff | ||
|
|
f9af611a27 | ||
|
|
88c4d6d2ab | ||
|
|
b74c9f2517 | ||
|
|
fab19e8f78 | ||
|
|
460389579b | ||
|
|
f7d7a0c7a2 | ||
|
|
f7220f4618 | ||
|
|
3d5a40fa0b | ||
|
|
eb903ab486 | ||
|
|
f794f230b5 | ||
|
|
64c253be66 | ||
|
|
ff400e16bf | ||
|
|
5d868e47fc | ||
|
|
0c272ad1d7 | ||
|
|
b787284ab6 | ||
|
|
6e202dd942 | ||
|
|
66b78e0eb7 | ||
|
|
5ac25d545d | ||
|
|
176c7f8938 | ||
|
|
120a6ca871 | ||
|
|
81c3bcef34 | ||
|
|
622f1f9f6c | ||
|
|
f8ff0e106a | ||
|
|
aeee4beba7 | ||
|
|
987b728464 | ||
|
|
d60133bb86 | ||
|
|
c3be968843 | ||
|
|
d512b80331 | ||
|
|
badc7c92da | ||
|
|
4ec55ea677 | ||
|
|
00e3ce6217 | ||
|
|
9c12102d28 | ||
|
|
b8d042e171 | ||
|
|
e617e57083 | ||
|
|
73697963c3 | ||
|
|
bd99ee9959 | ||
|
|
d6275c4833 | ||
|
|
763ee606d1 | ||
|
|
82dd14f6bc | ||
|
|
82baea3062 | ||
|
|
8dc162960b | ||
|
|
7f558a14a2 | ||
|
|
1ac4e1394b | ||
|
|
6dbce81c1d | ||
|
|
1db777d41d | ||
|
|
4bed2adc2f | ||
|
|
52edda73f6 | ||
|
|
4a9fc087a6 | ||
|
|
cfb8306681 | ||
|
|
9d5e3da126 | ||
|
|
e03b819ef3 | ||
|
|
8737d9b835 | ||
|
|
e3c19410c8 | ||
|
|
1c44f2003d | ||
|
|
54f30670dd | ||
|
|
56076dfd96 | ||
|
|
9fa16494b4 | ||
|
|
2040a35071 | ||
|
|
55c1a89196 | ||
|
|
6fbf451f28 | ||
|
|
03a307825d | ||
|
|
c0991da098 | ||
|
|
a1f489af08 | ||
|
|
dd5c6043cd | ||
|
|
b53c96cba0 | ||
|
|
fc68892919 | ||
|
|
b0003f04be | ||
|
|
a5acbbfe06 | ||
|
|
01ba3bef96 | ||
|
|
9fac55da6b | ||
|
|
5c146d4f08 | ||
|
|
8e09c99f1f | ||
|
|
3b49f56d15 | ||
|
|
e4f099237c | ||
|
|
579140b7c4 | ||
|
|
c14725fdbc | ||
|
|
04b5b6ae39 | ||
|
|
fc8c9b7bba | ||
|
|
b280387188 | ||
|
|
63b5276c84 | ||
|
|
ed2e90bf30 | ||
|
|
ce6ce06636 | ||
|
|
b62d291940 | ||
|
|
d42566be72 | ||
|
|
938e4a6f44 | ||
|
|
4fb140d275 | ||
|
|
f783eed9b5 | ||
|
|
642682b21f | ||
|
|
7757539309 | ||
|
|
c684ec6922 | ||
|
|
ce2971386d | ||
|
|
10b661744a | ||
|
|
cd6acdd05e | ||
|
|
fc8a5dd43e | ||
|
|
289a83635d | ||
|
|
4532c5b1c0 | ||
|
|
368bd325a8 | ||
|
|
94f17a7797 | ||
|
|
491de101ac | ||
|
|
066a1a3424 | ||
|
|
e9d1c51d70 | ||
|
|
a07a165fb8 | ||
|
|
531c0187a8 | ||
|
|
2f02f6bdf4 | ||
|
|
f52840bcd6 | ||
|
|
465b209ec9 | ||
|
|
254b2a9347 | ||
|
|
b2fb207a1a | ||
|
|
521c89d830 | ||
|
|
d31223b59c | ||
|
|
4ac216dd30 | ||
|
|
d0413af7bd | ||
|
|
f3ccaa4d17 | ||
|
|
48a9d752b3 | ||
|
|
1c483e140d | ||
|
|
ef0b0fe9ee | ||
|
|
8d9148f5fa | ||
|
|
9e8f0fda7a | ||
|
|
8b1fd4f515 | ||
|
|
82de38179f | ||
|
|
8f929ab332 | ||
|
|
ae6251bf6f | ||
|
|
9bf2cbd26f | ||
|
|
97eda02db6 | ||
|
|
113575b7bf | ||
|
|
dc3c030e94 | ||
|
|
5d15aa4add | ||
|
|
af24dafd7b | ||
|
|
4eec8905ae | ||
|
|
3753a184b6 | ||
|
|
5849ba2576 | ||
|
|
6f86e497fc | ||
|
|
5ddc5a890f | ||
|
|
2011f5211b | ||
|
|
4cb800ea13 | ||
|
|
447cac9af9 | ||
|
|
8b7d39c289 | ||
|
|
7ba3bf0cf9 | ||
|
|
f68e9e06d7 | ||
|
|
a8f41615d6 | ||
|
|
b2a1245c6d | ||
|
|
e2c3613756 | ||
|
|
09183fec15 | ||
|
|
f8c9af44a0 | ||
|
|
33b0861955 | ||
|
|
f01cdd65ae | ||
|
|
b1f198ff65 | ||
|
|
3007477d90 | ||
|
|
a4287380ac | ||
|
|
09d98e16c5 | ||
|
|
19f2a5024d | ||
|
|
fe404f0e25 | ||
|
|
ec515d0aad | ||
|
|
422a61d8de | ||
|
|
6e96e99dea | ||
|
|
603825e36f | ||
|
|
c6d89edf85 | ||
|
|
91252852c7 | ||
|
|
4b2002a9a3 | ||
|
|
1977267826 | ||
|
|
15ac231818 | ||
|
|
0e5a772e63 | ||
|
|
4e91c23bb5 |
No files matched your search
@@ -67,6 +67,7 @@ steps:
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
@@ -101,7 +102,21 @@ steps:
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
commands:
|
||||
- /usr/local/bin/initnc.sh
|
||||
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
|
||||
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
|
||||
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
|
||||
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
|
||||
- su www-data -c "php /var/www/html/occ group:add users"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user1"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user2"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable activity"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable text"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
### Testing
|
||||
Writing tests is very important. Please try to write some tests for your PR.
|
||||
|
||||
If you need help, please do not hesitate to ask in this PR for help.
|
||||
|
||||
- [ ] [unit tests](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#unit-tests)
|
||||
- [ ] [instrumented tests](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#instrumented-tests)
|
||||
- [ ] [UI tests](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#ui-tests)
|
||||
@@ -193,4 +193,4 @@
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
</component>
|
||||
@@ -1,17 +1,39 @@
|
||||
3.9.2 (December, 05, 2019)
|
||||
## 3.10.1 (February, 05, 2020)
|
||||
|
||||
- fix crash on self-signed certificates
|
||||
- fix openOffice open files with special chars
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/45
|
||||
|
||||
## 3.10.0 (January, 17, 2020)
|
||||
|
||||
- Dark theme (@dan0xii, @AndyScherzinger)
|
||||
- Rich workspace (NC18+)
|
||||
- collaborative text editor (NC18+)
|
||||
- links in Markdown previews clickable (@AndyScherzinger)
|
||||
- Show/Hide auto upload list items (@AndyScherzinger)
|
||||
- drop 4.0.x support
|
||||
- outdated server warning set to NC15
|
||||
- latest supported version NC13
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/40
|
||||
|
||||
## 3.9.2 (December, 05, 2019)
|
||||
|
||||
- HOTFIX: fix login loop
|
||||
- Fix crash on opening png images
|
||||
- Translation updates
|
||||
|
||||
3.9.1 (December, 04, 2019)
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/44
|
||||
|
||||
## 3.9.1 (December, 04, 2019)
|
||||
|
||||
- Fix crash on opening png images
|
||||
- Translation updates
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/43
|
||||
|
||||
3.9.0 (November, 12, 2019)
|
||||
## 3.9.0 (November, 12, 2019)
|
||||
|
||||
- preview Markdown with syntax highlighting @AndyScherzinger
|
||||
- improved DavX5 integration @bitfireAT
|
||||
|
||||
@@ -5,40 +5,46 @@
|
||||
|
||||
|
||||
# Index
|
||||
1. Guidelines
|
||||
1. Issue reporting
|
||||
1. Labels
|
||||
1. Pull request (PR)
|
||||
1. Issue
|
||||
1. Bug workflow
|
||||
1. Contributing to Source Code
|
||||
1. Developing process
|
||||
1. Branching model
|
||||
1. Android Studio formatter setup
|
||||
1. Build variants
|
||||
1. Contribution process
|
||||
1. Fork and download android/master repository
|
||||
1. Create pull request
|
||||
1. Create another pull request
|
||||
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
|
||||
1. Stable
|
||||
1. Release Candidate
|
||||
1. Dev
|
||||
1. Version Name and number
|
||||
1. Stable / Release candidate
|
||||
1. Dev
|
||||
1. Release cycle
|
||||
1. Release Process
|
||||
1. Stable Release
|
||||
1. Release Candidate Release
|
||||
1. Development Dev
|
||||
1. [Guidelines](#guidelines)
|
||||
1. [Issue reporting](#issue-reporting)
|
||||
1. [Labels](#labels)
|
||||
1. [Pull request](#pull-request)
|
||||
1. [Issue](#issue)
|
||||
1. [Bug workflow](#bug-workflow)
|
||||
1. [Contributing to Source Code](#contributing-to-source-code)
|
||||
1. [Developing process](#developing-process)
|
||||
1. [Branching model](#branching-model)
|
||||
1. [Android Studio formatter setup](#android-studio-formatter-setup)
|
||||
1. [Build variants](#build-variants)
|
||||
1. [Contribution process](#contribution-process)
|
||||
1. [Fork and download android repository](#fork-and-download-android-repository)
|
||||
1. [Create pull request](#create-pull-request)
|
||||
1. [Create another pull request](#create-another-pull-request)
|
||||
1. [Backport pull request](#backport-pull-request)
|
||||
1. [Pull requests that also need changes on library](#pull-requests-that-also-need-changes-on-library)
|
||||
1. [Adding new files](#adding-new-files)
|
||||
1. [Testing](#testing)
|
||||
1. [File naming](#file-naming)
|
||||
1. [Menu files](#menu-files)
|
||||
1. [Translations](#translations)
|
||||
1. [Engineering practices](#engineering-practices)
|
||||
1. [Approach to technical debt](#approach-to-technical-debt)
|
||||
1. [Dependency injection](#dependency-injection)
|
||||
1. [Custom platform APIs](#custom-platform-apis)
|
||||
1. [Testing](#testing)
|
||||
1. [Releases](#releases)
|
||||
1. [Types](#types)
|
||||
1. [Stable](#stable)
|
||||
1. [Release Candidate](#release-candidate)
|
||||
1. [Dev](#dev)
|
||||
1. [Version Name and number](#version-name-and-number)
|
||||
1. [Stable / Release candidate](#stable-release-candidate)
|
||||
1. [Dev](#dev)
|
||||
1. [Release cycle](#release-cycle)
|
||||
1. [Release Process](#release-process)
|
||||
1. [Stable Release](#stable-release)
|
||||
1. [Release Candidate Release](#release-candidate-release)
|
||||
1. [Development Dev](#development-dev)
|
||||
|
||||
|
||||
# Guidelines
|
||||
@@ -117,18 +123,18 @@ There are three build variants
|
||||
* For your first contribution start a pull request on master.
|
||||
|
||||
|
||||
### 1. Fork and download android/master repository:
|
||||
### Fork and download android repository:
|
||||
* Please follow [SETUP.md](https://github.com/nextcloud/android/blob/master/SETUP.md) to setup Nextcloud Android app work environment.
|
||||
|
||||
|
||||
### 2. Create pull request:
|
||||
### Create pull request:
|
||||
* Commit your changes locally: ```git commit -a```
|
||||
* Push your changes to your GitHub repo: ```git push```
|
||||
* Browse to <https://github.com/YOURGITHUBNAME/android/pulls> and issue pull request
|
||||
* Enter description and send pull request.
|
||||
|
||||
|
||||
### 3. Create another pull request:
|
||||
### Create another pull request:
|
||||
To make sure your new pull request does not contain commits which are already contained in previous PRs, create a new branch which is a clone of upstream/master.
|
||||
|
||||
* ```git fetch upstream```
|
||||
@@ -137,12 +143,12 @@ To make sure your new pull request does not contain commits which are already co
|
||||
* Push branch to server: ```git push -u origin name_of_local_master_branch```
|
||||
* Use GitHub to issue PR
|
||||
|
||||
### 4. Backport pull request:
|
||||
### Backport pull request:
|
||||
Use backport-bot via "/backport to stable-version", e.g. "/backport to stable-3.7".
|
||||
This will automatically add "backport-request" label to PR and bot will create a new PR to targeted branch once the base PR is merged.
|
||||
If automatic backport fails, it will create a comment.
|
||||
|
||||
### 5. Pull requests that also need changes on library
|
||||
### Pull requests that also need changes on library
|
||||
For speeding up developing, we do use a master snapshot of nextcloud-library, provided by jitpack.io.
|
||||
This means that if a breaking change is merged on library, master branch of the app will fail.
|
||||
To limit this risk please follow this approach:
|
||||
@@ -156,7 +162,7 @@ Once both PRs are reviewed and ready to merge:
|
||||
|
||||
With this approach the "downtime" of not building master is limited to the timestamp between merge lib PR and merging app PR, which is only limited by CI.
|
||||
|
||||
### 6. Adding new files
|
||||
### Adding new files
|
||||
If you create a new file it needs to contain a license header. We encourage you to use the same license (AGPL3+) as we do.
|
||||
Copyright of Nextcloud GmbH is optional.
|
||||
|
||||
@@ -238,6 +244,52 @@ Source code of app:
|
||||
-->
|
||||
```
|
||||
|
||||
### Testing
|
||||
- testing is very important, but is lacking a lot on this project. Starting with 2020 we aim to write tests for every
|
||||
new pull request.
|
||||
- Code coverage can be found [here](https://codecov.io/gh/nextcloud/android).
|
||||
|
||||
#### Unit tests
|
||||
- small, isolated tests, with no need of Android SDK
|
||||
- code coverage can be directly shown via right click on test and select "Run Test with Coverage"
|
||||
|
||||
#### Instrumented tests
|
||||
- tests to see larger code working in correct way
|
||||
- tests that require parts of Android SDK
|
||||
- best to avoid server communication, see https://github.com/nextcloud/android/pull/3624
|
||||
|
||||
- run all tests ```./gradlew createGplayDebugCoverageReport -Pcoverage=true```
|
||||
- run selective test class: ```./gradlew createGplayDebugCoverageReport -Pcoverage=true
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest```
|
||||
- run multiple test classes:
|
||||
- separate by ","
|
||||
- ```./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest,com.nextcloud.client.FileDisplayActivityIT```
|
||||
- run one test in class: ```./gradlew createGplayDebugCoverageReport -Pcoverage=true
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest#saveNewFile```
|
||||
- JaCoCo results are shown as html: firefox ./build/reports/coverage/gplay/debug/index.html
|
||||
|
||||
|
||||
#### UI tests
|
||||
We use [shot](https://github.com/Karumi/Shot) for taking screenshots and compare them
|
||||
- check screenshots: ```./gradlew executeScreenshotTests ```
|
||||
- update/generate new screenshots: ```scripts/updateScreenshots.sh ```
|
||||
- in this script are samples how to only execute a given class/test
|
||||
- this will fire up docker & emulator to ensure that screenshots look the same
|
||||
- creating own UI comparision tests:
|
||||
- add IntentsTestRule for launching activity directly:
|
||||
```java
|
||||
@Rule public IntentsTestRule<SettingsActivity> activityRule = new IntentsTestRule<>(SettingsActivity.class,
|
||||
true,
|
||||
false);
|
||||
```
|
||||
- in test method:
|
||||
```java
|
||||
Activity activity = activityRule.launchActivity(null);
|
||||
…do something, e.g. navigate, create folder, etc. …
|
||||
Screenshot.snapActivity(activity).record();
|
||||
```
|
||||
- best practise is to first create test with emulator too see behaviour and then create screenshots
|
||||
|
||||
## 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).
|
||||
@@ -257,12 +309,95 @@ Similar to layout files, menu files should match the name of the component. For
|
||||
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.
|
||||
|
||||
If you need to change a translation, do not change it, but give it new key. This way the translation stays backward compatible as we automatically backport translated strings to last versions.
|
||||
|
||||
When submitting PRs with changed translations, please only submit changes to values/strings.xml and not changes to translated files. These will be overwritten by next merge of transifex-but and increase PR review.
|
||||
|
||||
## Engineering practices
|
||||
|
||||
This section contains some general guideliens for new contributors, based on common issues flagged during code review.
|
||||
|
||||
### Approach to technical debt
|
||||
|
||||
TL;DR Non-Stop Litter Picking Party!
|
||||
|
||||
We recognize the importance of technical debt that can slow down development, make bufixing difficult and
|
||||
discourage future contributors.
|
||||
|
||||
We are mindful of the [Broken Windows Theory](https://en.wikipedia.org/wiki/Broken_windows_theory) and we'd like
|
||||
actively promote and encourage contributors to apply The Scout's Rule: *"Always leave the campground cleaner than
|
||||
you found it"*. Simple, little improvements will sum up and will be very appreciated by Nextcloud team.
|
||||
|
||||
We also promise to actively support and mentor contributors that help us to improve code quality, as we understand
|
||||
that this process is challenging and requires deep understanding of the application codebase.
|
||||
|
||||
### Dependency injection
|
||||
|
||||
TL;DR Avoid calling constructors inside constructors.
|
||||
|
||||
In effort to modernize the codebase we are applying [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection)
|
||||
whenever possible. We use 2 approaches: automatic and manual.
|
||||
|
||||
We are using [Dagger 2](https://dagger.dev/) to inject dependencies into major Android components only:
|
||||
|
||||
* `Activity`
|
||||
* `Fragment`
|
||||
* `Service`
|
||||
* `BroadcastReceiver`
|
||||
* `ContentProvider`
|
||||
|
||||
This process is fairly automatic, with `@Inject` annotation being sufficient to supply properly initialized
|
||||
objects. Android lifecycle callbacks allow us to do most of the work without effort.
|
||||
|
||||
For other application sub-components we prefer to use constructor injection and manually provide required dependencies.
|
||||
|
||||
This combination allows us to benefit from automation when it provides most value, does not tie rest of the code
|
||||
to any specific framework and stimulates continuous code modernization through iterative refactoring of all minor
|
||||
elements.
|
||||
|
||||
### Custom platform APIs
|
||||
|
||||
TL;DR Avoid Android platform APIs.
|
||||
|
||||
Nextcloud Android application provides some replacements for native Android APIs to facilitate testing
|
||||
and expose higher-level, business-specific APIs.
|
||||
|
||||
Generally, whenever you need:
|
||||
|
||||
* account management
|
||||
* application preferences
|
||||
* background task scheduling
|
||||
* device hardware information
|
||||
* media playback
|
||||
* networking
|
||||
* logging
|
||||
|
||||
we have something more suitable.
|
||||
|
||||
Our transition to new APIs is a continuous process. Contributors might be asked by code reviewers to
|
||||
refrain from using specific Android APIs considered problematic and to use Nextcloud APIs instead.
|
||||
In extreme cases we might decide to put specific features on hold until we provide platform API
|
||||
replacement.
|
||||
|
||||
If in doubt, ask Nextcloud developers. App undergoes a process of intense refactoring and situation
|
||||
changes frequently.
|
||||
|
||||
### Testing
|
||||
|
||||
TL;DR If we can't write a test for it, it's not good.
|
||||
|
||||
Test automation is challenging in mobile applications in general. We try to improve in this area
|
||||
and thereof we'd ask contributors to be mindful of their code testability:
|
||||
|
||||
1. new code submitted to Nextcloud project should be provided with automatic tests
|
||||
2. contributions to existing code that is currently not covered by automatic tests
|
||||
should at least not make future efforts more challenging
|
||||
3. whenever possible, testability should be improved even if the code is not covered by tests
|
||||
|
||||
|
||||
# Releases
|
||||
At the moment we are releasing the app in two app stores:
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ buildscript {
|
||||
}
|
||||
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.3.0"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.5.1"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:3.1.0'
|
||||
}
|
||||
@@ -60,8 +60,8 @@ configurations {
|
||||
|
||||
ext {
|
||||
jacocoVersion = "0.8.2"
|
||||
daggerVersion = "2.25.4"
|
||||
markwonVersion = "4.2.0"
|
||||
daggerVersion = "2.26"
|
||||
markwonVersion = "4.2.1"
|
||||
prismVersion = "2.0.0"
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
|
||||
@@ -91,7 +91,7 @@ def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()) {
|
||||
for (String arg : tr.args) {
|
||||
// any gplay, but only exact "build", as e.g. buildGeneric shall not apply gplay.grade
|
||||
if (arg.contains("Gplay") || arg.contains("lint") || arg == "build") {
|
||||
if (arg.contains("Gplay") || arg.contains("lint") || arg.contains("executeScreenshot") || arg == "build") {
|
||||
apply from: 'gplay.gradle'
|
||||
System.console().println("Applying gplay.gradle")
|
||||
break
|
||||
@@ -105,10 +105,14 @@ spotbugs {
|
||||
|
||||
shot {
|
||||
appId = 'com.nextcloud.client'
|
||||
instrumentationTestTask = 'connectedGenericDebugAndroidTest'
|
||||
instrumentationTestTask = 'connectedGplayDebugAndroidTest'
|
||||
}
|
||||
|
||||
android {
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
htmlReport true
|
||||
@@ -158,7 +162,7 @@ android {
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled true
|
||||
testCoverageEnabled (project.hasProperty('coverage'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +181,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20200110
|
||||
versionName "20200110"
|
||||
versionCode 20200129
|
||||
versionName "20200129"
|
||||
}
|
||||
|
||||
qa {
|
||||
@@ -192,6 +196,7 @@ android {
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
execution 'ANDROIDX_TEST_ORCHESTRATOR'
|
||||
animationsDisabled true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,21 +293,21 @@ dependencies {
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.1' // remove after entire switch to lib v2
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-beta02'
|
||||
implementation 'com.google.android.material:material:1.1.0-rc02'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0-alpha02'
|
||||
implementation 'androidx.cardview:cardview: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"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
|
||||
implementation "androidx.work:work-runtime:2.3.0"
|
||||
implementation "androidx.work:work-runtime-ktx:2.3.1"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'com.github.tobiaskaminsky:android-job:v1.2.6.1' // 'com.github.evernote:android-job:v1.2.5'
|
||||
implementation 'com.jakewharton:butterknife:10.2.1'
|
||||
kapt 'com.jakewharton:butterknife-compiler:10.2.1'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
|
||||
implementation 'org.lukhnos:nnio:0.2'
|
||||
implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
|
||||
@@ -311,9 +316,9 @@ 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:2.0.0'
|
||||
implementation 'org.parceler:parceler-api:1.1.12'
|
||||
kapt 'org.parceler:parceler:1.1.12'
|
||||
implementation 'com.google.android:flexbox:2.0.1'
|
||||
implementation 'org.parceler:parceler-api:1.1.13'
|
||||
kapt 'org.parceler:parceler:1.1.13'
|
||||
implementation('com.github.bumptech.glide:glide:3.8.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
@@ -332,8 +337,8 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
compileOnly "org.projectlombok:lombok:1.18.10"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.10"
|
||||
compileOnly "org.projectlombok:lombok:1.18.12"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.12"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.36.0"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.2.1'
|
||||
@@ -353,9 +358,9 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13'
|
||||
testImplementation 'org.mockito:mockito-core:3.2.4'
|
||||
testImplementation 'androidx.test:core:1.2.0'
|
||||
testImplementation 'org.powermock:powermock-core:2.0.4'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.4'
|
||||
testImplementation 'org.powermock:powermock-api-mockito2:2.0.4'
|
||||
testImplementation 'org.powermock:powermock-core:2.0.5'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.5'
|
||||
testImplementation 'org.powermock:powermock-api-mockito2:2.0.5'
|
||||
testImplementation 'org.json:json:20190722'
|
||||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||
@@ -378,7 +383,7 @@ dependencies {
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation 'tools.fastlane:screengrab:2.0.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-intents:3.0.2')
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-intents:3.0.2')
|
||||
|
||||
// jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
|
||||
// jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
|
||||
@@ -1,30 +1,3 @@
|
||||
autoCorrect: true
|
||||
|
||||
test-pattern: # Configure exclusions for test sources
|
||||
active: true
|
||||
patterns: # Test file regexes
|
||||
- '.*/test/.*'
|
||||
- '.*/androidTest/.*'
|
||||
- '.*Test.kt'
|
||||
- '.*Spec.kt'
|
||||
- '.*Spek.kt'
|
||||
exclude-rule-sets:
|
||||
- 'comments'
|
||||
exclude-rules:
|
||||
- 'NamingRules'
|
||||
- 'WildcardImport'
|
||||
- 'MagicNumber'
|
||||
- 'MaxLineLength'
|
||||
- 'LateinitUsage'
|
||||
- 'StringLiteralDuplication'
|
||||
- 'SpreadOperator'
|
||||
- 'TooManyFunctions'
|
||||
- 'ForEachOnRange'
|
||||
- 'FunctionMaxLength'
|
||||
- 'TooGenericExceptionCaught'
|
||||
- 'TooGenericExceptionThrown'
|
||||
- 'InstanceOfCheckForException'
|
||||
|
||||
build:
|
||||
maxIssues: 10
|
||||
weights:
|
||||
@@ -138,7 +111,7 @@ empty-blocks:
|
||||
active: true
|
||||
EmptyFunctionBlock:
|
||||
active: true
|
||||
ignoreOverriddenFunctions: false
|
||||
ignoreOverridden: false
|
||||
EmptyIfBlock:
|
||||
active: true
|
||||
EmptyInitBlock:
|
||||
@@ -202,23 +175,18 @@ exceptions:
|
||||
formatting:
|
||||
active: true
|
||||
android: false
|
||||
autoCorrect: true
|
||||
ChainWrapping:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
CommentSpacing:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
Filename:
|
||||
active: true
|
||||
FinalNewline:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
ImportOrdering:
|
||||
active: false
|
||||
Indentation:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
indentSize: 4
|
||||
continuationIndentSize: 4
|
||||
MaximumLineLength:
|
||||
@@ -226,73 +194,49 @@ formatting:
|
||||
maxLineLength: 120
|
||||
ModifierOrdering:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoBlankLineBeforeRbrace:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoConsecutiveBlankLines:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoEmptyClassBody:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoItParamInMultilineLambda:
|
||||
active: false
|
||||
NoLineBreakAfterElse:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoLineBreakBeforeAssignment:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoMultipleSpaces:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoSemicolons:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoTrailingSpaces:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoUnitReturn:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoUnusedImports:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoWildcardImports:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
PackageName:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
ParameterListWrapping:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
indentSize: 4
|
||||
SpacingAroundColon:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
SpacingAroundComma:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
SpacingAroundCurly:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
SpacingAroundKeyword:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
SpacingAroundOperators:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
SpacingAroundParens:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
SpacingAroundRangeOperator:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
StringTemplate:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
|
||||
naming:
|
||||
active: true
|
||||
@@ -325,12 +269,12 @@ naming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
ignoreOverriddenFunctions: true
|
||||
ignoreOverridden: true
|
||||
MatchingDeclarationName:
|
||||
active: true
|
||||
MemberNameEqualsClassName:
|
||||
active: false
|
||||
ignoreOverriddenFunction: true
|
||||
ignoreOverridden: true
|
||||
ObjectPropertyNaming:
|
||||
active: true
|
||||
constantPattern: '[A-Za-z][_A-Za-z0-9]*'
|
||||
@@ -442,6 +386,7 @@ style:
|
||||
ignoreAnnotation: false
|
||||
ignoreNamedArgument: true
|
||||
ignoreEnums: false
|
||||
excludes: "**/*Test.kt"
|
||||
MandatoryBracesIfStatements:
|
||||
active: false
|
||||
MaxLineLength:
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"
|
||||
enable-background="new 0 0 24 24" xml:space="preserve">
|
||||
<g id="Bounding_Box">
|
||||
<rect fill="none" width="24" height="24" />
|
||||
</g>
|
||||
<g id="Flat">
|
||||
<g id="ui_x5F_spec_x5F_header_copy_2">
|
||||
</g>
|
||||
<g>
|
||||
<path d="M17,19.22H5V7h7V5H5C3.9,5,3,5.9,3,7v12c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-7h-2V19.22z" />
|
||||
<path d="M19,2h-2v3h-3c0.01,0.01,0,2,0,2h3v2.99c0.01,0.01,2,0,2,0V7h3V5h-3V2z" />
|
||||
<rect x="7" y="9" width="8" height="2" />
|
||||
<polygon points="7,12 7,14 15,14 15,12 12,12 " />
|
||||
<rect x="7" y="15" width="8" height="2" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 845 B |
@@ -5,4 +5,3 @@ NC_TEST_SERVER_PASSWORD=test
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.debug.obsoleteApi=true
|
||||
|
||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
|
After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 12 KiB |
@@ -1 +1 @@
|
||||
414
|
||||
383
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 74 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 77 warnings</span>
|
||||
@@ -35,17 +35,18 @@ mv latest.apk ~/apks/
|
||||
lastBuildTime=$(date --date="$(git log -1 --format=%ai $(git tag | grep dev | tail -n1))" +%s)
|
||||
changelog=$(git log --after=$lastBuildTime --pretty=oneline --abbrev-commit)
|
||||
|
||||
echo "$changelog" > src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
|
||||
echo "library commit: $(curl https://api.github.com/repos/nextcloud/android-library/commits/master | jq .sha | sed s'/\"//g')" >> src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
|
||||
libraryCommit=$(curl https://api.github.com/repos/nextcloud/android-library/commits/master | jq .sha | sed s'/\"//g')
|
||||
|
||||
git add build.gradle
|
||||
git add src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
|
||||
# changelog
|
||||
echo "$changelog" > src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
|
||||
echo "library commit: $libraryCommit" >> src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
|
||||
|
||||
# build
|
||||
sed -i s"# androidLibraryVersion.*#androidLibraryVersion =\"$libraryCommit\"#" build.gradle
|
||||
|
||||
git add .
|
||||
git commit -m "daily dev $date" -m "$changelog"
|
||||
git push
|
||||
|
||||
git tag dev-$date
|
||||
git push origin dev-$date
|
||||
|
||||
# remove all but the latest 5 tags
|
||||
git tag|grep dev | sort -r | awk 'NR>5' | xargs -n 1 git push --delete origin
|
||||
git tag|grep dev | sort -r | awk 'NR>5' | xargs -n 1 git tag -d
|
||||
@@ -1,7 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if ( [[ $(grep NC_TEST_SERVER_BASEURL ~/.gradle/gradle.properties | grep -v "#" -c) -gt 0 ]] ); then
|
||||
echo "This will not use server in docker. Please comment in .gradle/gradle.properties. Aborting!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## emulator
|
||||
if ( [[ $(emulator -list-avds | grep uiComparison -c) -eq 0 ]] ); then
|
||||
avdmanager delete avd -n uiComparison
|
||||
(sleep 5; echo "no") | avdmanager create avd -n uiComparison -c 100M -k "system-images;android-27;google_apis;x86" --abi "google_apis/x86"
|
||||
fi
|
||||
|
||||
@@ -9,7 +15,7 @@ emulator -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-window -no
|
||||
PID=$(echo $!)
|
||||
|
||||
## server
|
||||
docker run --name=uiComparison nextcloudci/server:server-3 1>/dev/null &
|
||||
docker run --name=uiComparison nextcloudci/server:server-17 1>/dev/null &
|
||||
sleep 5
|
||||
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' uiComparison)
|
||||
|
||||
@@ -22,8 +28,33 @@ fi
|
||||
cp gradle.properties gradle.properties_
|
||||
sed -i s"/server/$IP/" gradle.properties
|
||||
scripts/wait_for_emulator.sh
|
||||
scripts/wait_for_server.sh ${IP}
|
||||
|
||||
# setup test server
|
||||
docker exec uiComparison /bin/sh -c "/usr/local/bin/initnc.sh"
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1\""
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2\""
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3\""
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ user:setting user2 files quota 1G\""
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:add users\""
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user1\""
|
||||
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user2\""
|
||||
docker exec uiComparison /bin/sh -c "/usr/local/bin/run.sh"
|
||||
|
||||
## update/create all screenshots
|
||||
./gradlew executeScreenshotTests -Precord
|
||||
|
||||
## update screenshots in a class
|
||||
#./gradlew executeScreenshotTests \
|
||||
#-Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.class=\
|
||||
#com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest
|
||||
|
||||
## update single screenshot within a class
|
||||
#./gradlew executeScreenshotTests \
|
||||
#-Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.class=\
|
||||
#com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest#showNotEnoughSpaceDialogForFile
|
||||
|
||||
mv gradle.properties_ gradle.properties
|
||||
|
||||
# tidy up
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
upload() {
|
||||
cd $1
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
|
||||
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
|
||||
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
|
||||
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
#1: LOG_USERNAME
|
||||
#2: LOG_PASSWORD
|
||||
#3: DRONE_BUILD_NUMBER
|
||||
@@ -13,23 +27,42 @@ ID=$3
|
||||
USER=$1
|
||||
PASS=$2
|
||||
TYPE=$4
|
||||
FOLDER=$ID-$TYPE
|
||||
PR=$5
|
||||
GITHUB_USER=$6
|
||||
GITHUB_PASSWORD=$7
|
||||
REMOTE_FOLDER=$ID-$TYPE
|
||||
|
||||
set -e
|
||||
|
||||
if [ $TYPE = "IT" ]; then
|
||||
cd build/reports/androidTests/connected/flavors/GPLAY
|
||||
FOLDER=build/reports/androidTests/connected/flavors/GPLAY
|
||||
elif [ $TYPE = "Unit" ]; then
|
||||
cd build/reports/tests/testGplayDebugUnitTest
|
||||
FOLDER=build/reports/tests/testGplayDebugUnitTest
|
||||
else
|
||||
cd build/reports/shot/verification/
|
||||
FOLDER=build/reports/shot/verification
|
||||
fi
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$FOLDER/$(echo {} | sed s#\./##) \;
|
||||
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
|
||||
if [ -e $FOLDER ]; then
|
||||
upload $FOLDER
|
||||
else
|
||||
echo "$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$FOLDER"
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD \
|
||||
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
|
||||
curl -u $6:$7 -X POST https://api.github.com/repos/nextcloud/android/issues/$5/comments -d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$FOLDER \" }"
|
||||
if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
|
||||
TYPE="IT"
|
||||
upload "build/reports/androidTests/connected/flavors/GPLAY"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
|
||||
TYPE="Unit"
|
||||
upload "build/reports/tests/testGplayDebugUnitTest"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/shot/verification ] ; then
|
||||
TYPE="Screenshot"
|
||||
upload "build/reports/shot/verification"
|
||||
fi
|
||||
fi
|
||||
@@ -8,7 +8,7 @@ until [[ $status = "false" ]]; do
|
||||
|
||||
if [[ "$status" =~ "false" || "$status" = "" ]]; then
|
||||
let "counter += 1"
|
||||
if [[ $counter -gt 2 ]]; then
|
||||
if [[ $counter -gt 10 ]]; then
|
||||
echo "Failed to wait for server"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
Java:
|
||||
|
||||
```java
|
||||
private String getAppProcessName() {
|
||||
String processName = "";
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
final int ownPid = android.os.Process.myPid();
|
||||
final List<ActivityManager.RunningAppProcessInfo> processes = manager.getRunningAppProcesses();
|
||||
if (processes != null) {
|
||||
for (ActivityManager.RunningAppProcessInfo info : processes) {
|
||||
if (info.pid == ownPid) {
|
||||
processName = info.processName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
processName = Application.getProcessName();
|
||||
}
|
||||
return processName;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activities.ActivitiesActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
|
||||
public class ActivitiesActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<ActivitiesActivity> activityRule = new IntentsTestRule<>(ActivitiesActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
public void openDrawer() throws InterruptedException {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,17 @@ import android.app.Activity;
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.events.SearchEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -40,6 +49,8 @@ import androidx.test.rule.GrantPermissionRule;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
|
||||
public class FileDisplayActivityIT extends AbstractIT {
|
||||
@@ -69,6 +80,53 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showShares() {
|
||||
assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(client).isSuccess());
|
||||
assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(client).isSuccess());
|
||||
assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(client).isSuccess());
|
||||
|
||||
// share folder to user "admin"
|
||||
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/",
|
||||
ShareType.USER,
|
||||
"admin",
|
||||
false,
|
||||
"",
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
|
||||
.execute(client).isSuccess());
|
||||
|
||||
// share folder via public link
|
||||
assertTrue(new CreateShareRemoteOperation("/shareViaLink/",
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
true,
|
||||
"",
|
||||
OCShare.READ_PERMISSION_FLAG)
|
||||
.execute(client).isSuccess());
|
||||
|
||||
// share folder to group
|
||||
Assert.assertTrue(new CreateShareRemoteOperation("/shareToGroup/",
|
||||
ShareType.GROUP,
|
||||
"users",
|
||||
false,
|
||||
"",
|
||||
OCShare.DEFAULT_PERMISSION)
|
||||
.execute(client).isSuccess());
|
||||
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
EventBus.getDefault().post(new SearchEvent("",
|
||||
SearchRemoteOperation.SearchType.SHARED_FILTER));
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showAccounts() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.NotificationsActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
|
||||
public class NotificationsActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<NotificationsActivity> activityRule = new IntentsTestRule<>(NotificationsActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
public void openDrawer() throws InterruptedException {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
|
||||
public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
public void openDrawer() throws InterruptedException {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.UploadListActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
|
||||
public class UploadListActivityActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<UploadListActivity> activityRule = new IntentsTestRule<>(UploadListActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
public void openDrawer() throws InterruptedException {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 Chris Narkiewicz
|
||||
* Copyright (C) 2020 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.os.Parcel
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class AnonymousUserTest {
|
||||
@Test
|
||||
fun anonymousUserImplementsParcelable() {
|
||||
// GIVEN
|
||||
// anonymous user instance
|
||||
val original = AnonymousUser("test_account")
|
||||
|
||||
// WHEN
|
||||
// instance is serialized into Parcel
|
||||
// instance is retrieved from Parcel
|
||||
val parcel = Parcel.obtain()
|
||||
parcel.setDataPosition(0)
|
||||
parcel.writeParcelable(original, 0)
|
||||
parcel.setDataPosition(0)
|
||||
val retrieved = parcel.readParcelable<User>(User::class.java.classLoader)
|
||||
|
||||
// THEN
|
||||
// retrieved instance in distinct
|
||||
// instances are equal
|
||||
Assert.assertNotSame(original, retrieved)
|
||||
Assert.assertTrue(retrieved is AnonymousUser)
|
||||
Assert.assertEquals(original, retrieved)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 Chris Narkiewicz
|
||||
* Copyright (C) 2020 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.net.Uri
|
||||
import android.os.Parcel
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
import com.owncloud.android.lib.common.OwnCloudBasicCredentials
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotSame
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.net.URI
|
||||
|
||||
class RegisteredUserTest {
|
||||
|
||||
private companion object {
|
||||
fun buildTestUser(accountName: String): RegisteredUser {
|
||||
val uri = Uri.parse("https://nextcloud.localhost.localdomain")
|
||||
val credentials = OwnCloudBasicCredentials("user", "pass")
|
||||
val account = Account(accountName, "test-type")
|
||||
val ownCloudAccount = OwnCloudAccount(uri, credentials)
|
||||
val server = Server(
|
||||
uri = URI(uri.toString()),
|
||||
version = OwnCloudVersion.nextcloud_17
|
||||
)
|
||||
return RegisteredUser(
|
||||
account = account,
|
||||
ownCloudAccount = ownCloudAccount,
|
||||
server = server
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var user: RegisteredUser
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
user = buildTestUser("[email protected]")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun registeredUserImplementsParcelable() {
|
||||
// GIVEN
|
||||
// registered user instance
|
||||
|
||||
// WHEN
|
||||
// instance is serialized into Parcel
|
||||
// instance is retrieved from Parcel
|
||||
val parcel = Parcel.obtain()
|
||||
parcel.setDataPosition(0)
|
||||
parcel.writeParcelable(user, 0)
|
||||
parcel.setDataPosition(0)
|
||||
val deserialized = parcel.readParcelable<User>(User::class.java.classLoader)
|
||||
|
||||
// THEN
|
||||
// retrieved instance in distinct
|
||||
// instances are equal
|
||||
assertNotSame(user, deserialized)
|
||||
assertTrue(deserialized is RegisteredUser)
|
||||
assertEquals(user, deserialized)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accountNamesEquality() {
|
||||
// GIVEN
|
||||
// registered user instance with lower-case account name
|
||||
// registered user instance with mixed-case account name
|
||||
val user1 = buildTestUser("account_name")
|
||||
val user2 = buildTestUser("Account_Name")
|
||||
|
||||
// WHEN
|
||||
// account names are checked for equality
|
||||
val equal = user1.nameEquals(user2)
|
||||
|
||||
// THEN
|
||||
// account names are equal
|
||||
assertTrue(equal)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accountNamesEqualityCheckIsNullSafe() {
|
||||
// GIVEN
|
||||
// registered user instance with lower-case account name
|
||||
// null account
|
||||
val user1 = buildTestUser("account_name")
|
||||
val user2: User? = null
|
||||
|
||||
// WHEN
|
||||
// account names are checked for equality against null
|
||||
val equal = user1.nameEquals(user2)
|
||||
|
||||
// THEN
|
||||
// account names are not equal
|
||||
assertFalse(equal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.etm
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
|
||||
import com.facebook.testing.screenshot.Screenshot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class EtmActivityTest : AbstractIT() {
|
||||
@get:Rule
|
||||
var activityRule = IntentsTestRule(EtmActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
fun overview() {
|
||||
val sut: Activity = activityRule.launchActivity(null)
|
||||
|
||||
waitForIdleSync()
|
||||
|
||||
Screenshot.snapActivity(sut).record()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun preferences() {
|
||||
val sut: EtmActivity = activityRule.launchActivity(null)
|
||||
|
||||
UiThreadStatement.runOnUiThread { sut.vm.onPageSelected(0) }
|
||||
|
||||
Screenshot.snapActivity(sut).record()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accounts() {
|
||||
val sut: EtmActivity = activityRule.launchActivity(null)
|
||||
|
||||
UiThreadStatement.runOnUiThread { sut.vm.onPageSelected(1) }
|
||||
|
||||
Screenshot.snapActivity(sut).record()
|
||||
}
|
||||
}
|
||||
@@ -4,22 +4,29 @@ import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -27,9 +34,20 @@ import org.junit.runner.RunWith;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
|
||||
import androidx.test.runner.lifecycle.Stage;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,9 +58,11 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
public abstract class AbstractIT {
|
||||
|
||||
protected static OwnCloudClient client;
|
||||
static Account account;
|
||||
protected static Account account;
|
||||
protected static Context targetContext;
|
||||
|
||||
private Activity currentActivity;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
try {
|
||||
@@ -88,8 +108,24 @@ public abstract class AbstractIT {
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
|
||||
for (Object object : result.getData()) {
|
||||
RemoteFile remoteFile = (RemoteFile) object;
|
||||
|
||||
if (!remoteFile.getRemotePath().equals("/")) {
|
||||
assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath())
|
||||
.execute(client).isSuccess());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FileDataStorageManager getStorageManager() {
|
||||
return new FileDataStorageManagerImpl(account, targetContext.getContentResolver());
|
||||
return new FileDataStorageManager(account, targetContext.getContentResolver());
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
@@ -134,4 +170,42 @@ public abstract class AbstractIT {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected File getFile(String filename) throws IOException {
|
||||
InputStream inputStream = getInstrumentation().getContext().getAssets().open(filename);
|
||||
File temp = File.createTempFile("file", "file");
|
||||
FileUtils.copyInputStreamToFile(inputStream, temp);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
protected void waitForIdleSync() {
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
|
||||
protected void openDrawer(IntentsTestRule activityRule) throws InterruptedException {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
protected Activity getCurrentActivity() {
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
Collection<Activity> resumedActivities = ActivityLifecycleMonitorRegistry
|
||||
.getInstance()
|
||||
.getActivitiesInStage(Stage.RESUMED);
|
||||
|
||||
if (resumedActivities.iterator().hasNext()) {
|
||||
currentActivity = resumedActivities.iterator().next();
|
||||
}
|
||||
});
|
||||
|
||||
return currentActivity;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class UploadIT extends AbstractIT {
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
@@ -140,17 +140,17 @@ public class UploadIT extends AbstractIT {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
"/testUpload/2/3/4/1.txt", account.name);
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
storageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
storageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Kilian Périsset
|
||||
* Copyright (C) 2019 Kilian Périsset (Infomaniak Network SA)
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class FolderPickerActivityIT {
|
||||
@Rule
|
||||
public ActivityTestRule<FolderPickerActivity> activityRule =
|
||||
new ActivityTestRule<>(FolderPickerActivity.class);
|
||||
|
||||
@Test
|
||||
public void getActivityFile() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/file.test");
|
||||
origin.setRemotePath("/remotePath/test");
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
OCFile target = targetActivity.getFile();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder_isNotRootFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/");
|
||||
origin.setFileId(1);
|
||||
origin.setRemotePath("/test/");
|
||||
origin.setStoragePath("/test/");
|
||||
origin.setFolder();
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
OCFile target = targetActivity.getCurrentFolder();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder_isRootFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/");
|
||||
origin.setFileId(1);
|
||||
origin.setRemotePath("/");
|
||||
origin.setStoragePath("/");
|
||||
origin.setFolder();
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
OCFile target = targetActivity.getCurrentFolder();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullFile() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile rootFolder = targetActivity.getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(null);
|
||||
OCFile target = targetActivity.getCurrentFolder();
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(rootFolder, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getParentFolder() {
|
||||
// Arrange
|
||||
FolderPickerActivity targetActivity = activityRule.getActivity();
|
||||
OCFile origin = new OCFile("/test/file.test");
|
||||
origin.setRemotePath("/test/file.test");
|
||||
|
||||
OCFile target = new OCFile("/test/");
|
||||
|
||||
// Act
|
||||
targetActivity.setFile(origin);
|
||||
|
||||
// Assert
|
||||
Assert.assertEquals(origin, target);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
public class ManageAccountsActivityIT extends AbstractIT {
|
||||
@Rule
|
||||
public IntentsTestRule<ManageAccountsActivity> activityRule = new IntentsTestRule<>(ManageAccountsActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
public void open() throws InterruptedException {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userInfoDetail() throws InterruptedException {
|
||||
ManageAccountsActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
User user = sut.accountManager.getUser();
|
||||
sut.onClick(user);
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
Screenshot.snapActivity(getCurrentActivity()).record();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
public class SyncFileNotEnoughSpaceDialogFragmentTest extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
|
||||
@Test
|
||||
public void showNotEnoughSpaceDialogForFolder() {
|
||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
||||
OCFile ocFile = new OCFile("/Document/");
|
||||
ocFile.setFileLength(5000000);
|
||||
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 1000);
|
||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "1");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
Screenshot.snap(dialog.getDialog().getWindow().getDecorView()).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showNotEnoughSpaceDialogForFile() {
|
||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
||||
OCFile ocFile = new OCFile("/Video.mp4");
|
||||
ocFile.setFileLength(1000000);
|
||||
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 2000);
|
||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "2");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
Screenshot.snap(dialog.getDialog().getWindow().getDecorView()).record();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.preview;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
public class PreviewTextFileFragmentTest extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
public void displaySimpleTextFile() throws InterruptedException {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt");
|
||||
OCFile test = new OCFile("/text.md");
|
||||
test.setMimeType(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN);
|
||||
test.setStoragePath(file.getAbsolutePath());
|
||||
sut.startTextPreview(test, false);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayJavaSnippetFile() throws IOException, InterruptedException {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
File file = getFile("java.md");
|
||||
OCFile test = new OCFile("/java.md");
|
||||
test.setMimeType(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN);
|
||||
test.setStoragePath(file.getAbsolutePath());
|
||||
sut.startTextPreview(test, false);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
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í.
|
||||
U vás hostovaná platforma pro produktivitu, která ponechává kontrolu vám
|
||||
|
||||
Funkce:
|
||||
* 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.
|
||||
* Snadno použitelné moderní rozhraní, s motivem vzhledu sladěným s tím nastaveným na serveru
|
||||
* Nahrávání souborů na vámi využívaný Nextcloud server
|
||||
* Jejich sdílení s ostatními
|
||||
* Udržování vašich oblíbených souborů a složek synchronizovaných
|
||||
* Vyhledávání napříč všemi složkami na vámi využívaném serveru
|
||||
* Automatické nahrávání fotek a videí pořízených vaším zařízením
|
||||
* Budete v obraze díky upozorněním
|
||||
* Podpora vícero účtů
|
||||
* Zabezpečení přístupu k vašim datům otiskem prstu nebo PIN kódem
|
||||
* Propojení s aplikací DAVx5 (dříve známé jako DAVdroid) pro snadné nastavení synchronizace kalendáře a kontaktů
|
||||
|
||||
Díky Nextcloudu budete mít kompletní privátní řešení pro všechy vaše soubory, fotky, kalendáře a kontakty.
|
||||
|
||||
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
|
||||
Veškeré problémy prosíme hlaste na https://github.com/nextcloud/android/issues, diskutovat lze na https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Ještě Nextcloud neznáte? Je to server pro komunikaci, synchronizaci a sdílení vašich dat. Jedná se o svobodný software, který můžete provozovat sami, nebo si jako službu koupit u jiné společnosti. Díky tomu máte kontrolu nad svými fotkami, kalendářem, kontakty i dokumenty a vším ostatním.
|
||||
|
||||
Další informace o Nextcloud naleznete na https://nextcloud.com
|
||||
@@ -0,0 +1 @@
|
||||
Η αυτόνομη πλατφόρμα λειτουργικότητας που σας κρατά υπό έλεγχο.
|
||||
@@ -0,0 +1 @@
|
||||
بستر تولیدی خود میزبان که شما را کنترل می کند. \ n \ n ویژگی ها: \ n * رابط کاربری آسان و مدرن ،
|
||||
@@ -0,0 +1 @@
|
||||
بستر تولیدی خود میزبان که شما را کنترل می کند
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -0,0 +1 @@
|
||||
Samo-gostujoče produkcijsko okolje pod vašim nadzorom.
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
|
After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 23 KiB |
@@ -23,6 +23,8 @@ package com.nextcloud.client.account
|
||||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
@@ -34,7 +36,7 @@ import java.net.URI
|
||||
* 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 {
|
||||
internal data class AnonymousUser(private val accountType: String) : User, Parcelable {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@@ -42,9 +44,19 @@ internal class AnonymousUser(private val accountType: String) : User {
|
||||
val type = context.getString(R.string.account_type)
|
||||
return AnonymousUser(type)
|
||||
}
|
||||
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<AnonymousUser> = object : Parcelable.Creator<AnonymousUser> {
|
||||
override fun createFromParcel(source: Parcel): AnonymousUser = AnonymousUser(source)
|
||||
override fun newArray(size: Int): Array<AnonymousUser?> = arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
override val accountName: String = "anonymous"
|
||||
private constructor(source: Parcel) : this(
|
||||
source.readString() as String
|
||||
)
|
||||
|
||||
override val accountName: String = "anonymous@nohost"
|
||||
override val server = Server(URI.create(""), MainApp.MINIMUM_SUPPORTED_SERVER_VERSION)
|
||||
override val isAnonymous = true
|
||||
|
||||
@@ -55,4 +67,14 @@ internal class AnonymousUser(private val accountType: String) : User {
|
||||
override fun toOwnCloudAccount(): OwnCloudAccount {
|
||||
return OwnCloudAccount(Uri.EMPTY, OwnCloudBasicCredentials("", ""))
|
||||
}
|
||||
|
||||
override fun nameEquals(user: User?): Boolean {
|
||||
return user?.accountName.equals(accountName, true)
|
||||
}
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
|
||||
writeString(accountType)
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,33 @@
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.accounts.Account
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
|
||||
/**
|
||||
* This class represents normal user logged into the Nextcloud server.
|
||||
*/
|
||||
internal class RegisteredUser(
|
||||
internal data class RegisteredUser(
|
||||
private val account: Account,
|
||||
private val ownCloudAccount: OwnCloudAccount,
|
||||
override val server: Server
|
||||
) : User {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<RegisteredUser> = object : Parcelable.Creator<RegisteredUser> {
|
||||
override fun createFromParcel(source: Parcel): RegisteredUser = RegisteredUser(source)
|
||||
override fun newArray(size: Int): Array<RegisteredUser?> = arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
private constructor(source: Parcel) : this(
|
||||
source.readParcelable<Account>(Account::class.java.classLoader) as Account,
|
||||
source.readParcelable<OwnCloudAccount>(OwnCloudAccount::class.java.classLoader) as OwnCloudAccount,
|
||||
source.readParcelable<Server>(Server::class.java.classLoader) as Server
|
||||
)
|
||||
|
||||
override val isAnonymous = false
|
||||
|
||||
override val accountName: String get() {
|
||||
@@ -44,4 +61,16 @@ internal class RegisteredUser(
|
||||
override fun toOwnCloudAccount(): OwnCloudAccount {
|
||||
return ownCloudAccount
|
||||
}
|
||||
|
||||
override fun nameEquals(user: User?): Boolean {
|
||||
return user?.accountName.equals(accountName, true)
|
||||
}
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
|
||||
writeParcelable(account, 0)
|
||||
writeParcelable(ownCloudAccount, 0)
|
||||
writeParcelable(server, 0)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import java.net.URI
|
||||
|
||||
@@ -27,4 +29,25 @@ import java.net.URI
|
||||
* This object provides all information necessary to interact
|
||||
* with backend server.
|
||||
*/
|
||||
data class Server(val uri: URI, val version: OwnCloudVersion)
|
||||
data class Server(val uri: URI, val version: OwnCloudVersion) : Parcelable {
|
||||
|
||||
constructor(source: Parcel) : this(
|
||||
source.readSerializable() as URI,
|
||||
source.readParcelable<Parcelable>(OwnCloudVersion::class.java.classLoader) as OwnCloudVersion
|
||||
)
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
|
||||
writeSerializable(uri)
|
||||
writeParcelable(version, 0)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<Server> = object : Parcelable.Creator<Server> {
|
||||
override fun createFromParcel(source: Parcel): Server = Server(source)
|
||||
override fun newArray(size: Int): Array<Server?> = arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,10 @@
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.accounts.Account
|
||||
import android.os.Parcelable
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
|
||||
interface User {
|
||||
interface User : Parcelable {
|
||||
val accountName: String
|
||||
val server: Server
|
||||
val isAnonymous: Boolean
|
||||
@@ -51,4 +52,11 @@ interface User {
|
||||
*/
|
||||
@Deprecated("Temporary workaround")
|
||||
fun toOwnCloudAccount(): OwnCloudAccount
|
||||
|
||||
/**
|
||||
* Compare account names, case insensitive.
|
||||
*
|
||||
* @return true if account names are same, false otherwise
|
||||
*/
|
||||
fun nameEquals(user: User?): Boolean
|
||||
}
|
||||
@@ -20,6 +20,8 @@
|
||||
package com.nextcloud.client.account;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
@@ -46,6 +48,14 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
*/
|
||||
void removeAllAccounts();
|
||||
|
||||
/**
|
||||
* Remove registered user.
|
||||
*
|
||||
* @param user user to remove
|
||||
* @return true if account was removed successfully, false otherwise
|
||||
*/
|
||||
boolean removeUser(User user);
|
||||
|
||||
/**
|
||||
* Get configured NextCloud's user accounts.
|
||||
*
|
||||
@@ -141,4 +151,12 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch account registration activity.
|
||||
*
|
||||
* This method returns immediately. Authenticator activity will be launched asynchronously.
|
||||
*
|
||||
* @param activity Activity used to launch authenticator flow via {@link Activity#startActivity(Intent)}
|
||||
*/
|
||||
void startAccountCreation(Activity activity);
|
||||
}
|
||||
@@ -22,6 +22,10 @@ package com.nextcloud.client.account;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Activity;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -42,6 +46,7 @@ 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 java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -80,6 +85,18 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeUser(User user) {
|
||||
try {
|
||||
AccountManagerFuture<Boolean> result = accountManager.removeAccount(user.toPlatformAccount(),
|
||||
null,
|
||||
null);
|
||||
return result.getResult();
|
||||
} catch (OperationCanceledException| AuthenticatorException| IOException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Account[] getAccounts() {
|
||||
@@ -227,7 +244,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
public Optional<User> getUser(CharSequence accountName) {
|
||||
Account account = getAccountByName(accountName.toString());
|
||||
User user = createUserFromAccount(account);
|
||||
return Optional.of(user);
|
||||
return Optional.ofNullable(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -376,4 +393,15 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
private String getAccountType() {
|
||||
return context.getString(R.string.account_type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAccountCreation(final Activity activity) {
|
||||
accountManager.addAccount(getAccountType(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
activity,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,14 @@ typealias OnErrorCallback = (Throwable) -> Unit
|
||||
* It is provided as an alternative for heavy, platform specific and virtually untestable [android.os.AsyncTask]
|
||||
*/
|
||||
interface AsyncRunner {
|
||||
|
||||
/**
|
||||
* Post a background task and return immediately returning task cancellation interface.
|
||||
*
|
||||
* @param task Task function returning result T; error shall be signalled by throwing an exception.
|
||||
* @param onResult Callback called when task function returns a result
|
||||
* @param onError Callback called when task function throws an exception
|
||||
* @return Cancellable interface, allowing to cancel running task.
|
||||
*/
|
||||
fun <T> post(task: () -> T, onResult: OnResultCallback<T>? = null, onError: OnErrorCallback? = null): Cancellable
|
||||
}
|
||||
@@ -19,6 +19,20 @@
|
||||
*/
|
||||
package com.nextcloud.client.core
|
||||
|
||||
/**
|
||||
* Interface allowing cancellation of a running task.
|
||||
* Once must be careful when cancelling a non-idempotent task,
|
||||
* as cancellation does not guarantee a task termination.
|
||||
* One trivial case would be a task finished and cancelled
|
||||
* before result delivery.
|
||||
*
|
||||
* @see [com.nextcloud.client.core.AsyncRunner]
|
||||
*/
|
||||
interface Cancellable {
|
||||
|
||||
/**
|
||||
* Cancel running task. Task termination is not guaranteed, but the result
|
||||
* shall not be delivered.
|
||||
*/
|
||||
fun cancel()
|
||||
}
|
||||
@@ -23,7 +23,6 @@ package com.nextcloud.client.di;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import dagger.android.AndroidInjection;
|
||||
@@ -72,4 +71,3 @@ public class ActivityInjector implements Application.ActivityLifecycleCallbacks
|
||||
// not needed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ import com.owncloud.android.ui.activities.data.files.FilesRepository;
|
||||
import com.owncloud.android.ui.activities.data.files.FilesServiceApiImpl;
|
||||
import com.owncloud.android.ui.activities.data.files.RemoteFilesRepository;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
@@ -164,4 +166,10 @@ class AppModule {
|
||||
AudioManager audioManager(Context context) {
|
||||
return (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
EventBus eventBus() {
|
||||
return EventBus.getDefault();
|
||||
}
|
||||
}
|
||||
@@ -19,23 +19,53 @@
|
||||
*/
|
||||
package com.nextcloud.client.etm
|
||||
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Resources
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.nextcloud.client.etm.pages.EtmAccountsFragment
|
||||
import com.nextcloud.client.etm.pages.EtmPreferencesFragment
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import javax.inject.Inject
|
||||
|
||||
class EtmViewModel @Inject constructor(
|
||||
private val defaultPreferences: SharedPreferences
|
||||
private val defaultPreferences: SharedPreferences,
|
||||
private val platformAccountManager: AccountManager,
|
||||
private val resources: Resources
|
||||
) : ViewModel() {
|
||||
|
||||
companion object {
|
||||
val ACCOUNT_USER_DATA_KEYS = listOf(
|
||||
// AccountUtils.Constants.KEY_COOKIES, is disabled
|
||||
AccountUtils.Constants.KEY_DISPLAY_NAME,
|
||||
AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
AccountUtils.Constants.KEY_OC_BASE_URL,
|
||||
AccountUtils.Constants.KEY_OC_VERSION,
|
||||
AccountUtils.Constants.KEY_USER_ID
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This data class holds all relevant account information that is
|
||||
* otherwise kept in separate collections.
|
||||
*/
|
||||
data class AccountData(val account: Account, val userData: Map<String, String?>)
|
||||
|
||||
val currentPage: LiveData<EtmMenuEntry?> = MutableLiveData()
|
||||
val pages: List<EtmMenuEntry> = listOf(
|
||||
EtmMenuEntry(
|
||||
iconRes = R.drawable.ic_settings,
|
||||
titleRes = R.string.etm_preferences,
|
||||
pageClass = EtmPreferencesFragment::class
|
||||
),
|
||||
EtmMenuEntry(
|
||||
iconRes = R.drawable.ic_user,
|
||||
titleRes = R.string.etm_accounts,
|
||||
pageClass = EtmAccountsFragment::class
|
||||
)
|
||||
)
|
||||
|
||||
@@ -46,6 +76,16 @@ class EtmViewModel @Inject constructor(
|
||||
.toMap()
|
||||
}
|
||||
|
||||
val accounts: List<AccountData> get() {
|
||||
val accountType = resources.getString(R.string.account_type)
|
||||
return platformAccountManager.getAccountsByType(accountType).map { account ->
|
||||
val userData: Map<String, String?> = ACCOUNT_USER_DATA_KEYS.map { key ->
|
||||
key to platformAccountManager.getUserData(account, key)
|
||||
}.toMap()
|
||||
AccountData(account, userData)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
(currentPage as MutableLiveData).apply {
|
||||
value = null
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2019 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.etm.pages
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.nextcloud.client.etm.EtmBaseFragment
|
||||
import com.owncloud.android.R
|
||||
import kotlinx.android.synthetic.main.fragment_etm_accounts.*
|
||||
import kotlinx.android.synthetic.main.fragment_etm_preferences.*
|
||||
|
||||
class EtmAccountsFragment : EtmBaseFragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_etm_accounts, container, false)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val builder = StringBuilder()
|
||||
vm.accounts.forEach {
|
||||
builder.append("Account: ${it.account.name}\n")
|
||||
it.userData.forEach {
|
||||
builder.append("\t${it.key}: ${it.value}\n")
|
||||
}
|
||||
}
|
||||
etm_accounts_text.text = builder.toString()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
inflater.inflate(R.menu.fragment_etm_accounts, menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.etm_accounts_share -> {
|
||||
onClickedShare(); true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onClickedShare() {
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "Nextcloud accounts information")
|
||||
intent.putExtra(Intent.EXTRA_TEXT, etm_accounts_text.text)
|
||||
intent.type = "text/plain"
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.mixins
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
||||
/**
|
||||
* Interface allowing to implement part of [android.app.Activity] logic as
|
||||
* a mix-in.
|
||||
*/
|
||||
interface ActivityMixin {
|
||||
fun onNewIntent(intent: Intent) { /* no-op */ }
|
||||
fun onSaveInstanceState(outState: Bundle) { /* no-op */ }
|
||||
fun onCreate(savedInstanceState: Bundle?) { /* no-op */ }
|
||||
fun onRestart() { /* no-op */ }
|
||||
fun onStart() { /* no-op */ }
|
||||
fun onResume() { /* no-op */ }
|
||||
fun onPause() { /* no-op */ }
|
||||
fun onStop() { /* no-op */ }
|
||||
fun onDestroy() { /* no-op */ }
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.mixins
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
||||
/**
|
||||
* Mix-in registry allows forwards lifecycle calls to all
|
||||
* registered mix-ins.
|
||||
*
|
||||
* Once instantiated, all [android.app.Activity] lifecycle methods
|
||||
* must call relevant registry companion methods.
|
||||
*
|
||||
* Calling the registry from [android.app.Application.ActivityLifecycleCallbacks] is
|
||||
* not possible as not all callbacks are supported by this interface.
|
||||
*/
|
||||
class MixinRegistry : ActivityMixin {
|
||||
|
||||
private val mixins = mutableListOf<ActivityMixin>()
|
||||
|
||||
fun add(vararg mixins: ActivityMixin) {
|
||||
mixins.forEach { this.mixins.add(it) }
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
mixins.forEach { it.onNewIntent(intent) }
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mixins.forEach { it.onSaveInstanceState(outState) }
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mixins.forEach { it.onCreate(savedInstanceState) }
|
||||
}
|
||||
|
||||
override fun onRestart() {
|
||||
super.onRestart()
|
||||
mixins.forEach { it.onRestart() }
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mixins.forEach { it.onStart() }
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mixins.forEach { it.onResume() }
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mixins.forEach { it.onPause() }
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mixins.forEach { it.onStop() }
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mixins.forEach { it.onDestroy() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# Package com.nextcloud.client.mixins
|
||||
|
||||
This package provides utilities and interfaces
|
||||
allowing implementation of UI logic as mix-ins.
|
||||
|
||||
Mix-ins allow encapsulation of non-visual logic
|
||||
as classes facilitating composition over inheritance.
|
||||
|
||||
For more information about mix-in concept, please
|
||||
refer to [article on Wikipedia](https://en.wikipedia.org/wiki/Mixin).
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.mixins
|
||||
|
||||
import android.accounts.Account
|
||||
import android.app.Activity
|
||||
import android.content.ContentResolver
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.java.util.Optional
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.ui.activity.BaseActivity
|
||||
|
||||
/**
|
||||
* Session mixin collects all account / user handling logic currently
|
||||
* spread over various activities.
|
||||
*
|
||||
* It is an intermediary step facilitating comprehensive rework of
|
||||
* account handling logic.
|
||||
*/
|
||||
class SessionMixin constructor(
|
||||
private val activity: Activity,
|
||||
private val contentResolver: ContentResolver,
|
||||
private val accountManager: UserAccountManager
|
||||
) : ActivityMixin {
|
||||
|
||||
private companion object {
|
||||
private val TAG = BaseActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
var currentAccount: Account? = null
|
||||
private set
|
||||
var storageManager: FileDataStorageManager? = null
|
||||
private set
|
||||
var capabilities: OCCapability? = null
|
||||
private set
|
||||
|
||||
fun setAccount(account: Account?) {
|
||||
val validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name)
|
||||
if (validAccount) {
|
||||
currentAccount = account
|
||||
} else {
|
||||
swapToDefaultAccount()
|
||||
}
|
||||
|
||||
currentAccount?.let {
|
||||
val storageManager = FileDataStorageManager(currentAccount, contentResolver)
|
||||
this.storageManager = storageManager
|
||||
this.capabilities = storageManager.getCapability(it.name)
|
||||
}
|
||||
}
|
||||
|
||||
fun setUser(user: User) {
|
||||
setAccount(user.toPlatformAccount())
|
||||
}
|
||||
|
||||
fun getUser(): Optional<User> = when (val it = this.currentAccount) {
|
||||
null -> Optional.empty()
|
||||
else -> accountManager.getUser(it.name)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to swap the current ownCloud [Account] for other valid and existing.
|
||||
*
|
||||
* If no valid ownCloud [Account] exists, then the user is requested
|
||||
* to create a new ownCloud [Account].
|
||||
*/
|
||||
private fun swapToDefaultAccount() {
|
||||
// default to the most recently used account
|
||||
val newAccount = accountManager.currentAccount
|
||||
if (newAccount == null) {
|
||||
// no account available: force account creation
|
||||
startAccountCreation()
|
||||
} else {
|
||||
currentAccount = newAccount
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the account creation activity.
|
||||
*/
|
||||
fun startAccountCreation() {
|
||||
accountManager.startAccountCreation(activity)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
val current = accountManager.currentAccount
|
||||
val currentAccount = this.currentAccount
|
||||
if (current != null && currentAccount != null && !currentAccount.name.equals(current.name)) {
|
||||
this.currentAccount = current
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since ownCloud {@link Account} can be managed from the system setting menu, the existence of the {@link
|
||||
* Account} associated to the instance must be checked every time it is restarted.
|
||||
*/
|
||||
override fun onRestart() {
|
||||
super.onRestart()
|
||||
val validAccount = currentAccount != null && accountManager.exists(currentAccount)
|
||||
if (!validAccount) {
|
||||
swapToDefaultAccount()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val account = accountManager.currentAccount
|
||||
setAccount(account)
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,6 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
enableAccountHandling = false;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.first_run_activity);
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.PassCodeActivity;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
@@ -415,10 +414,10 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
@Override
|
||||
public DarkMode getDarkThemeMode() {
|
||||
try {
|
||||
return DarkMode.valueOf(preferences.getString(PREF__DARK_THEME, DarkMode.LIGHT.name()));
|
||||
return DarkMode.valueOf(preferences.getString(PREF__DARK_THEME, DarkMode.SYSTEM.name()));
|
||||
} catch (ClassCastException e) {
|
||||
preferences.edit().putString(PREF__DARK_THEME, DarkMode.LIGHT.name()).apply();
|
||||
return DarkMode.DARK;
|
||||
preferences.edit().putString(PREF__DARK_THEME, DarkMode.SYSTEM.name()).apply();
|
||||
return DarkMode.SYSTEM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,8 +585,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(user.toPlatformAccount(),
|
||||
context);
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder));
|
||||
OCFile prefFolder = folder;
|
||||
|
||||
@@ -84,6 +84,7 @@ import com.owncloud.android.utils.ReceiversHelper;
|
||||
import com.owncloud.android.utils.SecurityUtils;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -166,6 +167,9 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
@Inject
|
||||
Clock clock;
|
||||
|
||||
@Inject
|
||||
EventBus eventBus;
|
||||
|
||||
private PassCodeManager passCodeManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -274,7 +278,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
uploadsStorageManager,
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
clock
|
||||
clock,
|
||||
eventBus
|
||||
)
|
||||
);
|
||||
|
||||
@@ -768,7 +773,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
|
||||
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
|
||||
if (syncedFolder.isEnabled()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolder);
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolder, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertL
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
@@ -621,6 +622,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
scanQR = findViewById(R.id.scanQR);
|
||||
if (deviceInfo.hasCamera(this)) {
|
||||
scanQR.setOnClickListener(v -> onScan());
|
||||
ThemeUtils.tintDrawable(scanQR.getDrawable(), getResources().getColor(R.color.login_text_color));
|
||||
} else {
|
||||
scanQR.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
@@ -9,12 +9,12 @@
|
||||
* 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.
|
||||
* <p>
|
||||
*
|
||||
* 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.
|
||||
* <p>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
@@ -29,8 +29,6 @@ import android.net.Uri;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
@@ -61,15 +59,6 @@ public class ArbitraryDataProvider {
|
||||
);
|
||||
}
|
||||
|
||||
public int deleteForKeyWhereAccountNotIn(List<String> accounts, String key) {
|
||||
return contentResolver.delete(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_ARBITRARY_DATA,
|
||||
ProviderMeta.ProviderTableMeta.ARBITRARY_DATA_CLOUD_ID + " NOT IN (?) AND " +
|
||||
ProviderMeta.ProviderTableMeta.ARBITRARY_DATA_KEY + "= ?",
|
||||
new String[]{String.valueOf(accounts), key}
|
||||
);
|
||||
}
|
||||
|
||||
public void storeOrUpdateKeyValue(String accountName, String key, long newValue) {
|
||||
storeOrUpdateKeyValue(accountName, key, String.valueOf(newValue));
|
||||
}
|
||||
@@ -112,11 +101,11 @@ public class ArbitraryDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public Long getLongValue(String accountName, String key) {
|
||||
Long getLongValue(String accountName, String key) {
|
||||
String value = getValue(accountName, key);
|
||||
|
||||
if (value.isEmpty()) {
|
||||
return -1l;
|
||||
return -1L;
|
||||
} else {
|
||||
return Long.valueOf(value);
|
||||
}
|
||||
@@ -138,9 +127,9 @@ public class ArbitraryDataProvider {
|
||||
/**
|
||||
* returns integer if found else -1
|
||||
*
|
||||
* @param accountName
|
||||
* @param key
|
||||
* @return
|
||||
* @param accountName name of account
|
||||
* @param key key to get value for
|
||||
* @return Integer specified by account and key
|
||||
*/
|
||||
public Integer getIntegerValue(String accountName, String key) {
|
||||
String value = getValue(accountName, key);
|
||||
@@ -152,17 +141,6 @@ public class ArbitraryDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns integer if found else -1
|
||||
*
|
||||
* @param account
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Integer getIntegerValue(Account account, String key) {
|
||||
return getIntegerValue(account.name, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns stored value as string or empty string
|
||||
* @return string if value found or empty string
|
||||
@@ -238,34 +216,6 @@ public class ArbitraryDataProvider {
|
||||
}
|
||||
|
||||
|
||||
public class ArbitraryDataSet {
|
||||
private int id;
|
||||
private String cloudId;
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public ArbitraryDataSet(int id, String cloudId, String key, String value) {
|
||||
this.id = id;
|
||||
this.cloudId = cloudId;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCloudId() {
|
||||
return cloudId;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Data set for {@link ArbitraryDataProvider}
|
||||
*/
|
||||
@Getter
|
||||
class ArbitraryDataSet {
|
||||
private int id;
|
||||
private String cloudId;
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
ArbitraryDataSet(int id, String cloudId, String key, String value) {
|
||||
this.id = id;
|
||||
this.cloudId = cloudId;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class FilesystemDataProvider {
|
||||
|
||||
cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH, localPath);
|
||||
cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_IS_FOLDER, isFolderValue);
|
||||
cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, false);
|
||||
cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD, Boolean.FALSE);
|
||||
cv.put(ProviderMeta.ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID, syncedFolder.getId());
|
||||
|
||||
long newCrc32 = getFileChecksum(localPath);
|
||||
|
||||
@@ -39,6 +39,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
@Getter @Setter private String remotePath;
|
||||
@Getter @Setter private boolean wifiOnly;
|
||||
@Getter @Setter private boolean chargingOnly;
|
||||
@Getter @Setter private boolean existing;
|
||||
@Getter @Setter private boolean subfolderByDate;
|
||||
@Getter @Setter private String account;
|
||||
@Getter @Setter private int uploadAction;
|
||||
@@ -54,6 +55,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
* @param remotePath remote path
|
||||
* @param wifiOnly upload on wifi only flag
|
||||
* @param chargingOnly upload on charging only
|
||||
* @param existing upload existing files
|
||||
* @param subfolderByDate create sub-folders by date (month)
|
||||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
@@ -66,6 +68,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean existing,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
@@ -73,8 +76,8 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
long timestampMs,
|
||||
MediaFolderType type,
|
||||
boolean hidden) {
|
||||
this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction,
|
||||
enabled, timestampMs, type, hidden);
|
||||
this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, existing, subfolderByDate, account,
|
||||
uploadAction, enabled, timestampMs, type, hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,6 +90,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean existing,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
@@ -99,6 +103,7 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
this.remotePath = remotePath;
|
||||
this.wifiOnly = wifiOnly;
|
||||
this.chargingOnly = chargingOnly;
|
||||
this.existing = existing;
|
||||
this.subfolderByDate = subfolderByDate;
|
||||
this.account = account;
|
||||
this.uploadAction = uploadAction;
|
||||
|
||||
@@ -45,6 +45,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
* @param remotePath remote path
|
||||
* @param wifiOnly upload on wifi only flag
|
||||
* @param chargingOnly upload on charging only
|
||||
* @param existing also upload existing
|
||||
* @param subfolderByDate create sub-folders by date (month)
|
||||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
@@ -60,6 +61,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean existing,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
@@ -70,8 +72,8 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
long numberOfFiles,
|
||||
MediaFolderType type,
|
||||
boolean hidden) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
|
||||
timestampMs, type, hidden);
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, existing, subfolderByDate, account, uploadAction,
|
||||
enabled, timestampMs, type, hidden);
|
||||
this.filePaths = filePaths;
|
||||
this.folderName = folderName;
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
@@ -82,14 +84,15 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean existing,
|
||||
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);
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, existing, subfolderByDate, account, uploadAction,
|
||||
enabled, timestampMs, type, hidden);
|
||||
this.folderName = folderName;
|
||||
}
|
||||
}
|
||||
@@ -342,6 +342,8 @@ public class SyncedFolderProvider extends Observable {
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY)) == 1;
|
||||
boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY)) == 1;
|
||||
boolean existing = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_EXISTING)) == 1;
|
||||
boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE)) == 1;
|
||||
String accountName = cursor.getString(cursor.getColumnIndex(
|
||||
@@ -357,8 +359,9 @@ public class SyncedFolderProvider extends Observable {
|
||||
boolean hidden = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;
|
||||
|
||||
syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
|
||||
accountName, uploadAction, enabled, enabledTimestampMs, type, hidden);
|
||||
syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, existing,
|
||||
subfolderByDate, accountName, uploadAction, enabled, enabledTimestampMs,
|
||||
type, hidden);
|
||||
}
|
||||
return syncedFolder;
|
||||
}
|
||||
@@ -376,6 +379,7 @@ public class SyncedFolderProvider extends Observable {
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH, syncedFolder.getRemotePath());
|
||||
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_EXISTING, syncedFolder.isExisting());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
|
||||
|
||||
@@ -410,12 +410,23 @@ public final class ThumbnailsCacheManager {
|
||||
private String mImageKey;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private GetMethod getMethod;
|
||||
private boolean roundedCorners = false;
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager, Account account)
|
||||
throws IllegalArgumentException {
|
||||
this(imageView, storageManager, account, null);
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView,
|
||||
FileDataStorageManager storageManager,
|
||||
Account account,
|
||||
List<ThumbnailGenerationTask> asyncTasks,
|
||||
boolean roundedCorners)
|
||||
throws IllegalArgumentException {
|
||||
this(imageView, storageManager, account, asyncTasks);
|
||||
this.roundedCorners = roundedCorners;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
|
||||
Account account, List<ThumbnailGenerationTask> asyncTasks)
|
||||
throws IllegalArgumentException {
|
||||
@@ -433,7 +444,7 @@ public final class ThumbnailsCacheManager {
|
||||
return getMethod;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account) {
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, Account account){
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||
}
|
||||
@@ -508,7 +519,11 @@ public final class ThumbnailsCacheManager {
|
||||
tagId = String.valueOf(((TrashbinFile) mFile).getRemoteId());
|
||||
}
|
||||
if (String.valueOf(imageView.getTag()).equals(tagId)) {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
if (roundedCorners) {
|
||||
BitmapUtils.setRoundedBitmap(bitmap, imageView);
|
||||
} else {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -809,9 +824,14 @@ public final class ThumbnailsCacheManager {
|
||||
private Context mContext;
|
||||
|
||||
|
||||
public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener, Object callContext,
|
||||
Account account, Resources resources, float avatarRadius, String userId,
|
||||
String serverName, Context context) {
|
||||
public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener,
|
||||
Object callContext,
|
||||
Account account,
|
||||
Resources resources,
|
||||
float avatarRadius,
|
||||
String userId,
|
||||
String serverName,
|
||||
Context context) {
|
||||
mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
|
||||
mCallContext = callContext;
|
||||
mAccount = account;
|
||||
@@ -850,7 +870,8 @@ public final class ThumbnailsCacheManager {
|
||||
AvatarGenerationListener listener = mAvatarGenerationListener.get();
|
||||
if (listener != null) {
|
||||
AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(mCallContext);
|
||||
if (this == avatarWorkerTask && listener.shouldCallGeneratedCallback(mUserId, mCallContext)) {
|
||||
String accountName = mUserId + "@" + mServerName;
|
||||
if (this == avatarWorkerTask && listener.shouldCallGeneratedCallback(accountName, mCallContext)) {
|
||||
listener.avatarGenerated(drawable, mCallContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class UploadsStorageManager extends Observable {
|
||||
cv.put(ProviderTableMeta.UPLOADS_FILE_SIZE, ocUpload.getFileSize());
|
||||
cv.put(ProviderTableMeta.UPLOADS_STATUS, ocUpload.getUploadStatus().value);
|
||||
cv.put(ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR, ocUpload.getLocalAction());
|
||||
cv.put(ProviderTableMeta.UPLOADS_FORCE_OVERWRITE, ocUpload.isForceOverwrite() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.UPLOADS_NAME_COLLISION_POLICY, ocUpload.getNameCollisionPolicy().serialize());
|
||||
cv.put(ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER, ocUpload.isCreateRemoteFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.UPLOADS_LAST_RESULT, ocUpload.getLastResult().getValue());
|
||||
cv.put(ProviderTableMeta.UPLOADS_CREATED_BY, ocUpload.getCreatedBy());
|
||||
@@ -305,7 +305,7 @@ public class UploadsStorageManager extends Observable {
|
||||
} else {
|
||||
list[c.getPosition()] = upload;
|
||||
}
|
||||
} while (c.moveToNext());
|
||||
} while (c.moveToNext() && !c.isAfterLast());
|
||||
}
|
||||
c.close();
|
||||
} else {
|
||||
@@ -329,8 +329,8 @@ public class UploadsStorageManager extends Observable {
|
||||
UploadStatus.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_STATUS)))
|
||||
);
|
||||
upload.setLocalAction(c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR)));
|
||||
upload.setForceOverwrite(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.UPLOADS_FORCE_OVERWRITE)) == 1);
|
||||
upload.setNameCollisionPolicy(FileUploader.NameCollisionPolicy.deserialize(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.UPLOADS_NAME_COLLISION_POLICY))));
|
||||
upload.setCreateRemoteFolder(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.UPLOADS_IS_CREATE_REMOTE_FOLDER)) == 1);
|
||||
upload.setUploadEndTimestamp(c.getLong(c.getColumnIndex(ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP)));
|
||||
|
||||
@@ -77,9 +77,9 @@ public class OCUpload implements Parcelable {
|
||||
@Getter @Setter private int localAction;
|
||||
|
||||
/**
|
||||
* Overwrite destination file?
|
||||
* What to do in case of name collision.
|
||||
*/
|
||||
@Getter @Setter private boolean forceOverwrite;
|
||||
@Getter @Setter private FileUploader.NameCollisionPolicy nameCollisionPolicy;
|
||||
|
||||
/**
|
||||
* Create destination folder?
|
||||
@@ -172,7 +172,7 @@ public class OCUpload implements Parcelable {
|
||||
fileSize = -1;
|
||||
uploadId = -1;
|
||||
localAction = FileUploader.LOCAL_BEHAVIOUR_COPY;
|
||||
forceOverwrite = false;
|
||||
nameCollisionPolicy = FileUploader.NameCollisionPolicy.DEFAULT;
|
||||
createRemoteFolder = false;
|
||||
uploadStatus = UploadStatus.UPLOAD_IN_PROGRESS;
|
||||
lastResult = UploadResult.UNKNOWN;
|
||||
@@ -281,7 +281,7 @@ public class OCUpload implements Parcelable {
|
||||
remotePath = source.readString();
|
||||
accountName = source.readString();
|
||||
localAction = source.readInt();
|
||||
forceOverwrite = source.readInt() == 1;
|
||||
nameCollisionPolicy = FileUploader.NameCollisionPolicy.deserialize(source.readInt());
|
||||
createRemoteFolder = source.readInt() == 1;
|
||||
try {
|
||||
uploadStatus = UploadStatus.valueOf(source.readString());
|
||||
@@ -312,7 +312,7 @@ public class OCUpload implements Parcelable {
|
||||
dest.writeString(remotePath);
|
||||
dest.writeString(accountName);
|
||||
dest.writeInt(localAction);
|
||||
dest.writeInt(forceOverwrite ? 1 : 0);
|
||||
dest.writeInt(nameCollisionPolicy.serialize());
|
||||
dest.writeInt(createRemoteFolder ? 1 : 0);
|
||||
dest.writeString(uploadStatus.name());
|
||||
dest.writeLong(uploadEndTimestamp);
|
||||
|
||||
@@ -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 = 53;
|
||||
public static final int DB_VERSION = 54;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
@@ -208,7 +208,7 @@ public class ProviderMeta {
|
||||
public static final String UPLOADS_STATUS = "status";
|
||||
public static final String UPLOADS_LOCAL_BEHAVIOUR = "local_behaviour";
|
||||
public static final String UPLOADS_UPLOAD_TIME = "upload_time";
|
||||
public static final String UPLOADS_FORCE_OVERWRITE = "force_overwrite";
|
||||
public static final String UPLOADS_NAME_COLLISION_POLICY = "name_collision_policy";
|
||||
public static final String UPLOADS_IS_CREATE_REMOTE_FOLDER = "is_create_remote_folder";
|
||||
public static final String UPLOADS_UPLOAD_END_TIMESTAMP = "upload_end_timestamp";
|
||||
public static final String UPLOADS_LAST_RESULT = "last_result";
|
||||
@@ -223,6 +223,7 @@ public class ProviderMeta {
|
||||
public static final String SYNCED_FOLDER_REMOTE_PATH = "remote_path";
|
||||
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_EXISTING = "existing";
|
||||
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";
|
||||
|
||||
@@ -42,8 +42,9 @@ import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
@@ -88,6 +89,7 @@ public class FileDownloader extends Service
|
||||
public static final String EXTRA_FILE_PATH = "FILE_PATH";
|
||||
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
|
||||
public static final String EXTRA_LINKED_TO_PATH = "LINKED_TO";
|
||||
public static final String EXTRA_CONFLICT_UPLOAD = "CONFLICT_UPLOAD";
|
||||
public static final String ACCOUNT_NAME = "ACCOUNT_NAME";
|
||||
|
||||
private static final int FOREGROUND_SERVICE_ID = 412;
|
||||
@@ -111,7 +113,10 @@ public class FileDownloader extends Service
|
||||
|
||||
private Notification mNotification;
|
||||
|
||||
private OCUpload conflictUpload;
|
||||
|
||||
@Inject UserAccountManager accountManager;
|
||||
@Inject UploadsStorageManager uploadsStorageManager;
|
||||
|
||||
public static String getDownloadAddedMessage() {
|
||||
return FileDownloader.class.getName() + DOWNLOAD_ADDED_MESSAGE;
|
||||
@@ -196,6 +201,7 @@ public class FileDownloader extends Service
|
||||
final String behaviour = intent.getStringExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR);
|
||||
String activityName = intent.getStringExtra(SendShareDialog.ACTIVITY_NAME);
|
||||
String packageName = intent.getStringExtra(SendShareDialog.PACKAGE_NAME);
|
||||
this.conflictUpload = intent.getParcelableExtra(FileDownloader.EXTRA_CONFLICT_UPLOAD);
|
||||
AbstractList<String> requestedDownloads = new Vector<String>();
|
||||
try {
|
||||
DownloadFileOperation newDownload = new DownloadFileOperation(account, file, behaviour, activityName,
|
||||
@@ -440,7 +446,10 @@ public class FileDownloader extends Service
|
||||
if (mCurrentAccount == null ||
|
||||
!mCurrentAccount.equals(mCurrentDownload.getAccount())) {
|
||||
mCurrentAccount = mCurrentDownload.getAccount();
|
||||
mStorageManager = new FileDataStorageManagerImpl(mCurrentAccount, getBaseContext());
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
mCurrentAccount,
|
||||
getContentResolver()
|
||||
);
|
||||
} // else, reuse storage manager from previous operation
|
||||
|
||||
// always get client from client manager, to get fresh credentials in case
|
||||
@@ -504,7 +513,7 @@ public class FileDownloader extends Service
|
||||
file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
|
||||
mStorageManager.saveFile(file);
|
||||
if (MimeTypeUtil.isMedia(mCurrentDownload.getMimeType())) {
|
||||
mStorageManager.triggerMediaScan(file.getStoragePath());
|
||||
FileDataStorageManager.triggerMediaScan(file.getStoragePath());
|
||||
}
|
||||
mStorageManager.saveConflict(file, null);
|
||||
}
|
||||
@@ -632,6 +641,10 @@ public class FileDownloader extends Service
|
||||
|
||||
// Remove success notification
|
||||
if (downloadResult.isSuccess()) {
|
||||
if (this.conflictUpload != null) {
|
||||
uploadsStorageManager.removeUpload(this.conflictUpload);
|
||||
}
|
||||
|
||||
// Sleep 2 seconds, so show the notification before remove it
|
||||
NotificationUtils.cancelWithDelay(mNotificationManager,
|
||||
R.string.downloader_download_succeeded_ticker, 2000);
|
||||
|
||||
@@ -26,8 +26,6 @@ package com.owncloud.android.jobs;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -37,21 +35,22 @@ 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.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.FilesystemDataProvider;
|
||||
import com.owncloud.android.datamodel.PushConfigurationState;
|
||||
import com.owncloud.android.datamodel.SyncedFolder;
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.users.RemoteWipeSuccessRemoteOperation;
|
||||
@@ -68,7 +67,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import static android.content.Context.ACCOUNT_SERVICE;
|
||||
import static com.owncloud.android.ui.activity.ManageAccountsActivity.PENDING_FOR_REMOVAL;
|
||||
@@ -76,7 +74,7 @@ import static com.owncloud.android.ui.activity.ManageAccountsActivity.PENDING_FO
|
||||
/**
|
||||
* Removes account and all local files
|
||||
*/
|
||||
public class AccountRemovalJob extends Job implements AccountManagerCallback<Boolean> {
|
||||
public class AccountRemovalJob extends Job {
|
||||
public static final String TAG = "AccountRemovalJob";
|
||||
public static final String ACCOUNT = "account";
|
||||
public static final String REMOTE_WIPE = "remote_wipe";
|
||||
@@ -84,11 +82,16 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
private final UploadsStorageManager uploadsStorageManager;
|
||||
private final UserAccountManager userAccountManager;
|
||||
private final Clock clock;
|
||||
private final EventBus eventBus;
|
||||
|
||||
public AccountRemovalJob(UploadsStorageManager uploadStorageManager, UserAccountManager accountManager, Clock clock) {
|
||||
public AccountRemovalJob(UploadsStorageManager uploadStorageManager,
|
||||
UserAccountManager accountManager,
|
||||
Clock clock,
|
||||
EventBus eventBus) {
|
||||
this.uploadsStorageManager = uploadStorageManager;
|
||||
this.userAccountManager = accountManager;
|
||||
this.clock = clock;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -96,80 +99,96 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
protected Result onRunJob(@NonNull Params params) {
|
||||
Context context = MainApp.getAppContext();
|
||||
PersistableBundleCompat bundle = params.getExtras();
|
||||
Account account = userAccountManager.getAccountByName(bundle.getString(ACCOUNT, ""));
|
||||
String accountName = bundle.getString(ACCOUNT, "");
|
||||
if (TextUtils.isEmpty(accountName)) {
|
||||
// didn't receive account to delete
|
||||
return Result.FAILURE;
|
||||
}
|
||||
Optional<User> optionalUser = userAccountManager.getUser(accountName);
|
||||
if (!optionalUser.isPresent()) {
|
||||
// trying to delete non-existing user
|
||||
return Result.FAILURE;
|
||||
}
|
||||
AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
|
||||
if (accountManager == null) {
|
||||
return Result.FAILURE;
|
||||
}
|
||||
boolean remoteWipe = bundle.getBoolean(REMOTE_WIPE, false);
|
||||
|
||||
if (account != null && accountManager != null) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
// disable contact backup job
|
||||
ContactsPreferenceActivity.cancelContactBackupJobForAccount(context, account);
|
||||
User user = optionalUser.get();
|
||||
// disable contact backup job
|
||||
ContactsPreferenceActivity.cancelContactBackupJobForAccount(context, user);
|
||||
|
||||
removeAccount(account, accountManager);
|
||||
final boolean userRemoved = userAccountManager.removeUser(user);
|
||||
if (userRemoved) {
|
||||
eventBus.post(new AccountRemovedEvent());
|
||||
}
|
||||
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, context);
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), context.getContentResolver());
|
||||
|
||||
// remove all files
|
||||
removeFiles(account, storageManager);
|
||||
// remove all files
|
||||
removeFiles(user, storageManager);
|
||||
|
||||
// delete all database entries
|
||||
storageManager.deleteAllFiles();
|
||||
// delete all database entries
|
||||
storageManager.deleteAllFiles();
|
||||
|
||||
// remove contact backup job
|
||||
ContactsPreferenceActivity.cancelContactBackupJobForAccount(context, account);
|
||||
// remove contact backup job
|
||||
ContactsPreferenceActivity.cancelContactBackupJobForAccount(context, user);
|
||||
|
||||
// disable daily backup
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(account.name,
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP,
|
||||
"false");
|
||||
// disable daily backup
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(),
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP,
|
||||
"false");
|
||||
|
||||
// unregister push notifications
|
||||
unregisterPushNotifications(context, account, arbitraryDataProvider);
|
||||
// unregister push notifications
|
||||
unregisterPushNotifications(context, user, arbitraryDataProvider);
|
||||
|
||||
// remove pending account removal
|
||||
arbitraryDataProvider.deleteKeyForAccount(account.name, PENDING_FOR_REMOVAL);
|
||||
// remove pending account removal
|
||||
arbitraryDataProvider.deleteKeyForAccount(user.getAccountName(), PENDING_FOR_REMOVAL);
|
||||
|
||||
// remove synced folders set for account
|
||||
remoceSyncedFolders(context, account, clock);
|
||||
// remove synced folders set for account
|
||||
remoceSyncedFolders(context, user.toPlatformAccount(), clock);
|
||||
|
||||
// delete all uploads for account
|
||||
uploadsStorageManager.removeAccountUploads(account);
|
||||
// delete all uploads for account
|
||||
uploadsStorageManager.removeAccountUploads(user.toPlatformAccount());
|
||||
|
||||
// delete stored E2E keys
|
||||
arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PRIVATE_KEY);
|
||||
arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PUBLIC_KEY);
|
||||
// delete stored E2E keys
|
||||
arbitraryDataProvider.deleteKeyForAccount(user.getAccountName(), EncryptionUtils.PRIVATE_KEY);
|
||||
arbitraryDataProvider.deleteKeyForAccount(user.getAccountName(), EncryptionUtils.PUBLIC_KEY);
|
||||
|
||||
OwnCloudClient client = createClient(account);
|
||||
if (remoteWipe && client != null) {
|
||||
if (remoteWipe) {
|
||||
Optional<OwnCloudClient> optionalClient = createClient(user);
|
||||
if (optionalClient.isPresent()) {
|
||||
OwnCloudClient client = optionalClient.get();
|
||||
String authToken = client.getCredentials().getAuthToken();
|
||||
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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
private void unregisterPushNotifications(Context context, Account account, ArbitraryDataProvider arbitraryDataProvider) {
|
||||
String arbitraryDataPushString;
|
||||
|
||||
if (!TextUtils.isEmpty(arbitraryDataPushString = arbitraryDataProvider.getValue(
|
||||
account, PushUtils.KEY_PUSH)) &&
|
||||
!TextUtils.isEmpty(context.getResources().getString(R.string.push_server_url))) {
|
||||
private void unregisterPushNotifications(Context context,
|
||||
User user,
|
||||
ArbitraryDataProvider arbitraryDataProvider) {
|
||||
final String arbitraryDataPushString = arbitraryDataProvider.getValue(user.toPlatformAccount(),
|
||||
PushUtils.KEY_PUSH);
|
||||
final String pushServerUrl = context.getResources().getString(R.string.push_server_url);
|
||||
if (!TextUtils.isEmpty(arbitraryDataPushString) && !TextUtils.isEmpty(pushServerUrl)) {
|
||||
Gson gson = new Gson();
|
||||
PushConfigurationState pushArbitraryData = gson.fromJson(arbitraryDataPushString,
|
||||
PushConfigurationState.class);
|
||||
pushArbitraryData.setShouldBeDeleted(true);
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(account.name, PushUtils.KEY_PUSH,
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), PushUtils.KEY_PUSH,
|
||||
gson.toJson(pushArbitraryData));
|
||||
|
||||
PushUtils.pushRegistrationToServer(userAccountManager, pushArbitraryData.getPushToken());
|
||||
@@ -199,44 +218,23 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFiles(Account account, FileDataStorageManager storageManager) {
|
||||
File tempDir = new File(FileStorageUtils.getTemporalPath(account.name));
|
||||
File saveDir = new File(FileStorageUtils.getSavePath(account.name));
|
||||
private void removeFiles(User user, FileDataStorageManager storageManager) {
|
||||
File tempDir = new File(FileStorageUtils.getTemporalPath(user.getAccountName()));
|
||||
File saveDir = new File(FileStorageUtils.getSavePath(user.getAccountName()));
|
||||
|
||||
FileStorageUtils.deleteRecursively(tempDir, storageManager);
|
||||
FileStorageUtils.deleteRecursively(saveDir, storageManager);
|
||||
}
|
||||
|
||||
private void removeAccount(Account account, AccountManager accountManager) {
|
||||
private Optional<OwnCloudClient> createClient(User user) {
|
||||
try {
|
||||
AccountManagerFuture<Boolean> accountRemoval = accountManager.removeAccount(account, this, null);
|
||||
boolean removal = accountRemoval.getResult();
|
||||
|
||||
if (!removal) {
|
||||
Log_OC.e(this, "Account removal of " + account.name + " failed!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(this, "Account removal of " + account.name + " failed!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private OwnCloudClient createClient(Account account) {
|
||||
OwnCloudClient client = null;
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(account, MainApp.getAppContext());
|
||||
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount,
|
||||
MainApp.getAppContext());
|
||||
Context context = MainApp.getAppContext();
|
||||
OwnCloudClientManager factory = OwnCloudClientManagerFactory.getDefaultSingleton();
|
||||
OwnCloudClient client = factory.getClientFor(user.toOwnCloudAccount(), context);
|
||||
return Optional.of(client);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(this, "Could not create client", e);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(AccountManagerFuture<Boolean> future) {
|
||||
if (future.isDone()) {
|
||||
EventBus.getDefault().post(new AccountRemovedEvent());
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.owncloud.android.jobs;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
@@ -29,15 +28,17 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateFormat;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -54,6 +55,8 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import ezvcard.Ezvcard;
|
||||
import ezvcard.VCardVersion;
|
||||
|
||||
import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFERENCE_CONTACTS_LAST_BACKUP;
|
||||
|
||||
@@ -79,14 +82,20 @@ public class ContactsBackupJob extends Job {
|
||||
protected Result onRunJob(@NonNull Params params) {
|
||||
PersistableBundleCompat bundle = params.getExtras();
|
||||
|
||||
final Account account = accountManager.getAccountByName(bundle.getString(ACCOUNT, ""));
|
||||
|
||||
if (account == null) {
|
||||
final String accountName = bundle.getString(ACCOUNT, "");
|
||||
if (TextUtils.isEmpty(accountName)) {
|
||||
// no account provided
|
||||
return Result.FAILURE;
|
||||
}
|
||||
final Optional<User> optionalUser = accountManager.getUser(accountName);
|
||||
if (!optionalUser.isPresent()) {
|
||||
return Result.FAILURE;
|
||||
}
|
||||
User user = optionalUser.get();
|
||||
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());
|
||||
Long lastExecution = arbitraryDataProvider.getLongValue(account, PREFERENCE_CONTACTS_LAST_BACKUP);
|
||||
Long lastExecution = arbitraryDataProvider.getLongValue(user.toPlatformAccount(),
|
||||
PREFERENCE_CONTACTS_LAST_BACKUP);
|
||||
|
||||
boolean force = bundle.getBoolean(FORCE, false);
|
||||
if (force || (lastExecution + 24 * 60 * 60 * 1000) < Calendar.getInstance().getTimeInMillis()) {
|
||||
@@ -96,16 +105,18 @@ public class ContactsBackupJob extends Job {
|
||||
OCFile.PATH_SEPARATOR;
|
||||
Integer daysToExpire = getContext().getResources().getInteger(R.integer.contacts_backup_expire);
|
||||
|
||||
backupContact(account, backupFolder);
|
||||
backupContact(user, backupFolder);
|
||||
|
||||
// bind to Operations Service
|
||||
operationsServiceConnection = new OperationsServiceConnection(daysToExpire, backupFolder, account);
|
||||
operationsServiceConnection = new OperationsServiceConnection(daysToExpire,
|
||||
backupFolder,
|
||||
user);
|
||||
|
||||
getContext().bindService(new Intent(getContext(), OperationsService.class), operationsServiceConnection,
|
||||
OperationsService.BIND_AUTO_CREATE);
|
||||
|
||||
// store execution date
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(account.name,
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(),
|
||||
PREFERENCE_CONTACTS_LAST_BACKUP,
|
||||
Calendar.getInstance().getTimeInMillis());
|
||||
} else {
|
||||
@@ -115,7 +126,7 @@ public class ContactsBackupJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void backupContact(Account account, String backupFolder) {
|
||||
private void backupContact(User user, String backupFolder) {
|
||||
ArrayList<String> vCard = new ArrayList<>();
|
||||
|
||||
Cursor cursor = getContext().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null,
|
||||
@@ -158,25 +169,26 @@ public class ContactsBackupJob extends Job {
|
||||
}
|
||||
}
|
||||
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
requester.uploadNewFile(
|
||||
getContext(),
|
||||
account,
|
||||
file.getAbsolutePath(),
|
||||
backupFolder + filename,
|
||||
FileUploader.LOCAL_BEHAVIOUR_MOVE,
|
||||
null,
|
||||
true,
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false
|
||||
FileUploader.uploadNewFile(
|
||||
getContext(),
|
||||
user.toPlatformAccount(),
|
||||
file.getAbsolutePath(),
|
||||
backupFolder + filename,
|
||||
FileUploader.LOCAL_BEHAVIOUR_MOVE,
|
||||
null,
|
||||
true,
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.ASK_USER
|
||||
);
|
||||
}
|
||||
|
||||
private void expireFiles(Integer daysToExpire, String backupFolderString, Account account) {
|
||||
private void expireFiles(Integer daysToExpire, String backupFolderString, User account) {
|
||||
// -1 disables expiration
|
||||
if (daysToExpire > -1) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, getContext());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account.toPlatformAccount(),
|
||||
getContext().getContentResolver());
|
||||
OCFile backupFolder = storageManager.getFileByPath(backupFolderString);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DAY_OF_YEAR, -daysToExpire);
|
||||
@@ -234,7 +246,8 @@ public class ContactsBackupJob extends Job {
|
||||
|
||||
vCard = stringBuilder.toString();
|
||||
|
||||
return vCard;
|
||||
// bump to vCard 3.0 format (min version supported by server) since Android OS exports to 2.1
|
||||
return Ezvcard.write(Ezvcard.parse(vCard).all()).version(VCardVersion.V3_0).go();
|
||||
|
||||
} catch (IOException e) {
|
||||
Log_OC.d(TAG, e.getMessage());
|
||||
@@ -259,12 +272,12 @@ public class ContactsBackupJob extends Job {
|
||||
private class OperationsServiceConnection implements ServiceConnection {
|
||||
private Integer daysToExpire;
|
||||
private String backupFolder;
|
||||
private Account account;
|
||||
private User user;
|
||||
|
||||
OperationsServiceConnection(Integer daysToExpire, String backupFolder, Account account) {
|
||||
OperationsServiceConnection(Integer daysToExpire, String backupFolder, User user) {
|
||||
this.daysToExpire = daysToExpire;
|
||||
this.backupFolder = backupFolder;
|
||||
this.account = account;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -274,7 +287,7 @@ public class ContactsBackupJob extends Job {
|
||||
|
||||
if (component.equals(new ComponentName(getContext(), OperationsService.class))) {
|
||||
operationsServiceBinder = (OperationsService.OperationsServiceBinder) service;
|
||||
expireFiles(daysToExpire, backupFolder, account);
|
||||
expireFiles(daysToExpire, backupFolder, user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
package com.owncloud.android.jobs;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -33,11 +32,13 @@ import android.text.TextUtils;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.nextcloud.client.account.User;
|
||||
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;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -130,7 +131,7 @@ public class FilesSyncJob extends Job {
|
||||
userAccountManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
FilesSyncHelper.insertAllDBEntries(preferences, clock, skipCustom);
|
||||
FilesSyncHelper.insertAllDBEntries(preferences, clock, skipCustom, false);
|
||||
|
||||
// Create all the providers we'll need
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
@@ -140,12 +141,11 @@ public class FilesSyncJob extends Job {
|
||||
Locale currentLocale = context.getResources().getConfiguration().locale;
|
||||
SimpleDateFormat sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale);
|
||||
sFormatter.setTimeZone(TimeZone.getTimeZone(TimeZone.getDefault().getID()));
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
|
||||
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
|
||||
if ((syncedFolder.isEnabled()) && (!skipCustom || MediaFolderType.CUSTOM != syncedFolder.getType())) {
|
||||
syncFolder(context, resources, lightVersion, filesystemDataProvider, currentLocale, sFormatter,
|
||||
requester, syncedFolder);
|
||||
syncedFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,10 +156,15 @@ public class FilesSyncJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void syncFolder(Context context, Resources resources, boolean lightVersion,
|
||||
FilesystemDataProvider filesystemDataProvider, Locale currentLocale,
|
||||
SimpleDateFormat sFormatter, FileUploader.UploadRequester requester,
|
||||
SyncedFolder syncedFolder) {
|
||||
private void syncFolder(
|
||||
Context context,
|
||||
Resources resources,
|
||||
boolean lightVersion,
|
||||
FilesystemDataProvider filesystemDataProvider,
|
||||
Locale currentLocale,
|
||||
SimpleDateFormat sFormatter,
|
||||
SyncedFolder syncedFolder
|
||||
) {
|
||||
String remotePath;
|
||||
boolean subfolderByDate;
|
||||
Integer uploadAction;
|
||||
@@ -167,7 +172,12 @@ public class FilesSyncJob extends Job {
|
||||
boolean needsWifi;
|
||||
File file;
|
||||
ArbitraryDataProvider arbitraryDataProvider;
|
||||
Account account = userAccountManager.getAccountByName(syncedFolder.getAccount());
|
||||
String accountName = syncedFolder.getAccount();
|
||||
Optional<User> optionalUser = userAccountManager.getUser(accountName);
|
||||
if (!optionalUser.isPresent()) {
|
||||
return;
|
||||
}
|
||||
User user = optionalUser.get();
|
||||
|
||||
if (lightVersion) {
|
||||
arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
@@ -183,13 +193,11 @@ public class FilesSyncJob extends Job {
|
||||
|
||||
if (lightVersion) {
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging);
|
||||
needsWifi = account == null || arbitraryDataProvider.getBooleanValue(account.name,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
|
||||
needsWifi = arbitraryDataProvider.getBooleanValue(accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
|
||||
String uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour);
|
||||
uploadAction = getUploadAction(uploadActionString);
|
||||
|
||||
subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders);
|
||||
|
||||
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
|
||||
} else {
|
||||
needsCharging = syncedFolder.isChargingOnly();
|
||||
@@ -199,24 +207,24 @@ public class FilesSyncJob extends Job {
|
||||
remotePath = syncedFolder.getRemotePath();
|
||||
}
|
||||
|
||||
requester.uploadFileWithOverwrite(
|
||||
context,
|
||||
account,
|
||||
file.getAbsolutePath(),
|
||||
FileStorageUtils.getInstantUploadFilePath(
|
||||
FileUploader.uploadNewFile(
|
||||
context,
|
||||
user.toPlatformAccount(),
|
||||
file.getAbsolutePath(),
|
||||
FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
currentLocale,
|
||||
remotePath,
|
||||
syncedFolder.getLocalPath(),
|
||||
lastModificationTime,
|
||||
subfolderByDate),
|
||||
uploadAction,
|
||||
mimeType,
|
||||
true, // create parent folder if not existent
|
||||
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
|
||||
needsWifi,
|
||||
needsCharging,
|
||||
true
|
||||
uploadAction,
|
||||
mimeType,
|
||||
true, // create parent folder if not existent
|
||||
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
|
||||
needsWifi,
|
||||
needsCharging,
|
||||
FileUploader.NameCollisionPolicy.ASK_USER
|
||||
);
|
||||
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(path,
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
*/
|
||||
package com.owncloud.android.jobs;
|
||||
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
@@ -38,6 +36,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
import com.google.gson.Gson;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
@@ -47,6 +46,7 @@ import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.MediaFolder;
|
||||
import com.owncloud.android.datamodel.MediaFoldersModel;
|
||||
import com.owncloud.android.datamodel.MediaProvider;
|
||||
import com.owncloud.android.datamodel.SyncedFolder;
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.activity.ManageAccountsActivity;
|
||||
@@ -138,32 +138,41 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
videoMediaFolderPaths.removeAll(mediaFoldersModel.getVideoMediaFolders());
|
||||
|
||||
if (!imageMediaFolderPaths.isEmpty() || !videoMediaFolderPaths.isEmpty()) {
|
||||
Account[] accounts = userAccountManager.getAccounts();
|
||||
List<Account> accountList = new ArrayList<>();
|
||||
for (Account account : accounts) {
|
||||
if (!arbitraryDataProvider.getBooleanValue(account, ManageAccountsActivity.PENDING_FOR_REMOVAL)) {
|
||||
accountList.add(account);
|
||||
List<User> allUsers = userAccountManager.getAllUsers();
|
||||
List<User> activeUsers = new ArrayList<>();
|
||||
for (User account : allUsers) {
|
||||
if (!arbitraryDataProvider.getBooleanValue(account.toPlatformAccount(),
|
||||
ManageAccountsActivity.PENDING_FOR_REMOVAL)) {
|
||||
activeUsers.add(account);
|
||||
}
|
||||
}
|
||||
|
||||
for (Account account : accountList) {
|
||||
for (User user : activeUsers) {
|
||||
for (String imageMediaFolder : imageMediaFolderPaths) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder, account) == null) {
|
||||
sendNotification(String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_photos)),
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1
|
||||
),
|
||||
account, imageMediaFolder, 1);
|
||||
final SyncedFolder folder = syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder,
|
||||
user.toPlatformAccount());
|
||||
if (folder == null) {
|
||||
String contentTitle = String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_photos));
|
||||
sendNotification(contentTitle,
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1),
|
||||
user,
|
||||
imageMediaFolder,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
for (String videoMediaFolder : videoMediaFolderPaths) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder, account) == null) {
|
||||
sendNotification(String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos)),
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1
|
||||
),
|
||||
account, videoMediaFolder, 2);
|
||||
final SyncedFolder folder = syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder,
|
||||
user.toPlatformAccount());
|
||||
if (folder == null) {
|
||||
String contentTitle = String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos));
|
||||
sendNotification(contentTitle,
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1),
|
||||
user,
|
||||
videoMediaFolder,
|
||||
2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,14 +188,14 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void sendNotification(String contentTitle, String subtitle, Account account, String path, int type) {
|
||||
private void sendNotification(String contentTitle, String subtitle, User user, String path, int type) {
|
||||
int notificationId = randomId.nextInt();
|
||||
|
||||
Context context = getContext();
|
||||
Intent intent = new Intent(getContext(), SyncedFoldersActivity.class);
|
||||
intent.putExtra(NOTIFICATION_ID, notificationId);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(NotificationJob.KEY_NOTIFICATION_ACCOUNT, account.name);
|
||||
intent.putExtra(NotificationJob.KEY_NOTIFICATION_ACCOUNT, user.getAccountName());
|
||||
intent.putExtra(KEY_MEDIA_FOLDER_PATH, path);
|
||||
intent.putExtra(KEY_MEDIA_FOLDER_TYPE, type);
|
||||
intent.putExtra(SyncedFoldersActivity.EXTRA_SHOW_SIDEBAR, true);
|
||||
@@ -197,7 +206,7 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.notification_icon))
|
||||
.setColor(ThemeUtils.primaryColor(getContext()))
|
||||
.setSubText(account.name)
|
||||
.setSubText(user.getAccountName())
|
||||
.setContentTitle(contentTitle)
|
||||
.setContentText(subtitle)
|
||||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
||||
|
||||
@@ -35,6 +35,8 @@ import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
@@ -50,6 +52,7 @@ public class NCJobCreator implements JobCreator {
|
||||
private final ConnectivityService connectivityService;
|
||||
private final PowerManagementService powerManagementService;
|
||||
private final Clock clock;
|
||||
private final EventBus eventBus;
|
||||
|
||||
public NCJobCreator(
|
||||
Context context,
|
||||
@@ -58,7 +61,8 @@ public class NCJobCreator implements JobCreator {
|
||||
UploadsStorageManager uploadsStorageManager,
|
||||
ConnectivityService connectivityServices,
|
||||
PowerManagementService powerManagementService,
|
||||
Clock clock
|
||||
Clock clock,
|
||||
EventBus eventBus
|
||||
) {
|
||||
this.context = context;
|
||||
this.accountManager = accountManager;
|
||||
@@ -67,6 +71,7 @@ public class NCJobCreator implements JobCreator {
|
||||
this.connectivityService = connectivityServices;
|
||||
this.powerManagementService = powerManagementService;
|
||||
this.clock = clock;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +82,7 @@ public class NCJobCreator implements JobCreator {
|
||||
case ContactsImportJob.TAG:
|
||||
return new ContactsImportJob();
|
||||
case AccountRemovalJob.TAG:
|
||||
return new AccountRemovalJob(uploadsStorageManager, accountManager, clock);
|
||||
return new AccountRemovalJob(uploadsStorageManager, accountManager, clock, eventBus);
|
||||
case FilesSyncJob.TAG:
|
||||
return new FilesSyncJob(accountManager,
|
||||
preferences,
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.owncloud.android.jobs;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
@@ -42,11 +41,12 @@ import android.util.Log;
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.google.gson.Gson;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.DecryptedPushMessage;
|
||||
import com.owncloud.android.datamodel.SignatureVerification;
|
||||
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;
|
||||
@@ -140,7 +140,9 @@ public class NotificationJob extends Job {
|
||||
} else if (decryptedPushMessage.deleteAll) {
|
||||
notificationManager.cancelAll();
|
||||
} else {
|
||||
fetchCompleteNotification(signatureVerification.getAccount(), decryptedPushMessage);
|
||||
final User user = accountManager.getUser(signatureVerification.getAccount().name)
|
||||
.orElseThrow(RuntimeException::new);
|
||||
fetchCompleteNotification(user, decryptedPushMessage);
|
||||
}
|
||||
}
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e1) {
|
||||
@@ -154,7 +156,7 @@ public class NotificationJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void sendNotification(Notification notification, Account account) {
|
||||
private void sendNotification(Notification notification, User user) {
|
||||
SecureRandom randomId = new SecureRandom();
|
||||
RichObject file = notification.subjectRichParameters.get("file");
|
||||
|
||||
@@ -166,7 +168,7 @@ public class NotificationJob extends Job {
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.putExtra(FileDisplayActivity.KEY_FILE_ID, file.id);
|
||||
}
|
||||
intent.putExtra(KEY_NOTIFICATION_ACCOUNT, account.name);
|
||||
intent.putExtra(KEY_NOTIFICATION_ACCOUNT, user.getAccountName());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
|
||||
@@ -176,9 +178,9 @@ public class NotificationJob extends Job {
|
||||
new NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_PUSH)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.notification_icon))
|
||||
.setColor(ThemeUtils.primaryColor(account, false, context))
|
||||
.setColor(ThemeUtils.primaryColor(user.toPlatformAccount(), false, context))
|
||||
.setShowWhen(true)
|
||||
.setSubText(account.name)
|
||||
.setSubText(user.getAccountName())
|
||||
.setContentTitle(notification.getSubject())
|
||||
.setContentText(notification.getMessage())
|
||||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
||||
@@ -191,7 +193,7 @@ public class NotificationJob extends Job {
|
||||
Intent disableDetection = new Intent(context, NotificationJob.NotificationReceiver.class);
|
||||
disableDetection.putExtra(NUMERIC_NOTIFICATION_ID, notification.getNotificationId());
|
||||
disableDetection.putExtra(PUSH_NOTIFICATION_ID, pushNotificationId);
|
||||
disableDetection.putExtra(KEY_NOTIFICATION_ACCOUNT, account.name);
|
||||
disableDetection.putExtra(KEY_NOTIFICATION_ACCOUNT, user.getAccountName());
|
||||
|
||||
PendingIntent disableIntent = PendingIntent.getBroadcast(context, pushNotificationId, disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
@@ -204,7 +206,7 @@ public class NotificationJob extends Job {
|
||||
Intent actionIntent = new Intent(context, NotificationJob.NotificationReceiver.class);
|
||||
actionIntent.putExtra(NUMERIC_NOTIFICATION_ID, notification.getNotificationId());
|
||||
actionIntent.putExtra(PUSH_NOTIFICATION_ID, pushNotificationId);
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACCOUNT, account.name);
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACCOUNT, user.getAccountName());
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACTION_LINK, action.link);
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACTION_TYPE, action.type);
|
||||
|
||||
@@ -228,9 +230,9 @@ public class NotificationJob extends Job {
|
||||
new NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_PUSH)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.notification_icon))
|
||||
.setColor(ThemeUtils.primaryColor(account, false, context))
|
||||
.setColor(ThemeUtils.primaryColor(user.toPlatformAccount(), false, context))
|
||||
.setShowWhen(true)
|
||||
.setSubText(account.name)
|
||||
.setSubText(user.getAccountName())
|
||||
.setContentTitle(context.getString(R.string.new_notification))
|
||||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
||||
.setAutoCancel(true)
|
||||
@@ -241,18 +243,18 @@ public class NotificationJob extends Job {
|
||||
notificationManager.notify(notification.getNotificationId(), notificationBuilder.build());
|
||||
}
|
||||
|
||||
private void fetchCompleteNotification(Account account, DecryptedPushMessage decryptedPushMessage) {
|
||||
Account currentAccount = accountManager.getAccountByName(account.name);
|
||||
private void fetchCompleteNotification(User account, DecryptedPushMessage decryptedPushMessage) {
|
||||
Optional<User> optionalUser = accountManager.getUser(account.getAccountName());
|
||||
|
||||
if (currentAccount == null) {
|
||||
if (!optionalUser.isPresent()) {
|
||||
Log_OC.e(this, "Account may not be null");
|
||||
return;
|
||||
}
|
||||
User user = optionalUser.get();
|
||||
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, context);
|
||||
OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(ocAccount, context);
|
||||
.getClientFor(user.toOwnCloudAccount(), context);
|
||||
|
||||
RemoteOperationResult result = new GetNotificationRemoteOperation(decryptedPushMessage.nid)
|
||||
.execute(client);
|
||||
@@ -295,16 +297,14 @@ public class NotificationJob extends Job {
|
||||
}
|
||||
|
||||
try {
|
||||
Account currentAccount = accountManager.getAccountByName(accountName);
|
||||
|
||||
if (currentAccount == null) {
|
||||
Optional<User> optionalUser = accountManager.getUser(accountName);
|
||||
if (!optionalUser.isPresent()) {
|
||||
Log_OC.e(this, "Account may not be null");
|
||||
return;
|
||||
}
|
||||
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, context);
|
||||
User user = optionalUser.get();
|
||||
OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(ocAccount, context);
|
||||
.getClientFor(user.toOwnCloudAccount(), context);
|
||||
|
||||
String actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE);
|
||||
String actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK);
|
||||
@@ -325,8 +325,7 @@ public class NotificationJob extends Job {
|
||||
} else if (notificationManager != null) {
|
||||
notificationManager.notify(numericNotificationId, oldNotification);
|
||||
}
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException |
|
||||
IOException | OperationCanceledException | AuthenticatorException e) {
|
||||
} catch (IOException | OperationCanceledException | AuthenticatorException e) {
|
||||
Log_OC.e(TAG, "Error initializing client", e);
|
||||
}
|
||||
}).start();
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.owncloud.android.jobs;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
@@ -29,12 +28,12 @@ import android.os.PowerManager;
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.JobManager;
|
||||
import com.evernote.android.job.JobRequest;
|
||||
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.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManagerImpl;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -43,6 +42,7 @@ import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -90,10 +90,11 @@ public class OfflineSyncJob extends Job {
|
||||
}
|
||||
}
|
||||
|
||||
Account[] accounts = userAccountManager.getAccounts();
|
||||
List<User> users = userAccountManager.getAllUsers();
|
||||
|
||||
for (Account account : accounts) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManagerImpl(account, getContext());
|
||||
for (User user : users) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
getContext().getContentResolver());
|
||||
|
||||
OCFile ocRoot = storageManager.getFileByPath(ROOT_PATH);
|
||||
|
||||
@@ -101,7 +102,7 @@ public class OfflineSyncJob extends Job {
|
||||
break;
|
||||
}
|
||||
|
||||
recursive(new File(ocRoot.getStoragePath()), storageManager, account);
|
||||
recursive(new File(ocRoot.getStoragePath()), storageManager, user);
|
||||
}
|
||||
|
||||
if (wakeLock != null) {
|
||||
@@ -112,8 +113,8 @@ public class OfflineSyncJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void recursive(File folder, FileDataStorageManager storageManager, Account account) {
|
||||
String downloadFolder = FileStorageUtils.getSavePath(account.name);
|
||||
private void recursive(File folder, FileDataStorageManager storageManager, User user) {
|
||||
String downloadFolder = FileStorageUtils.getSavePath(user.getAccountName());
|
||||
String folderName = folder.getAbsolutePath().replaceFirst(downloadFolder, "") + PATH_SEPARATOR;
|
||||
Log_OC.d(TAG, folderName + ": enter");
|
||||
|
||||
@@ -128,7 +129,7 @@ public class OfflineSyncJob extends Job {
|
||||
// check for etag change, if false, skip
|
||||
CheckEtagRemoteOperation checkEtagOperation = new CheckEtagRemoteOperation(ocFolder.getRemotePath(),
|
||||
ocFolder.getEtagOnServer());
|
||||
RemoteOperationResult result = checkEtagOperation.execute(account, getContext());
|
||||
RemoteOperationResult result = checkEtagOperation.execute(user.toPlatformAccount(), getContext());
|
||||
|
||||
// eTag changed, sync file
|
||||
switch (result.getCode()) {
|
||||
@@ -156,7 +157,7 @@ public class OfflineSyncJob extends Job {
|
||||
for (File file : files) {
|
||||
OCFile ocFile = storageManager.getFileByLocalPath(file.getPath());
|
||||
SynchronizeFileOperation synchronizeFileOperation = new SynchronizeFileOperation(ocFile.getRemotePath(),
|
||||
account, true, getContext());
|
||||
user.toPlatformAccount(), true, getContext());
|
||||
|
||||
synchronizeFileOperation.execute(storageManager, getContext());
|
||||
}
|
||||
@@ -167,7 +168,7 @@ public class OfflineSyncJob extends Job {
|
||||
|
||||
if (subfolders != null) {
|
||||
for (File subfolder : subfolders) {
|
||||
recursive(subfolder, storageManager, account);
|
||||
recursive(subfolder, storageManager, user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
||||
@@ -35,8 +34,6 @@ import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
|
||||
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
|
||||
|
||||
@@ -52,7 +49,6 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
protected String mRemotePath;
|
||||
private boolean mCreateFullPath;
|
||||
private RemoteFile createdRemoteFolder;
|
||||
@Inject Logger logger;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -67,11 +63,11 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
|
||||
|
||||
@Override
|
||||
public RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = createCreateFolderRemoteOperation(mRemotePath, mCreateFullPath).execute(client);
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = new CreateFolderRemoteOperation(mRemotePath, mCreateFullPath).execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
RemoteOperationResult remoteFolderOperationResult = createReadFolderRemoteOperation(mRemotePath)
|
||||
RemoteOperationResult remoteFolderOperationResult = new ReadFolderRemoteOperation(mRemotePath)
|
||||
.execute(client);
|
||||
|
||||
createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0);
|
||||
@@ -83,14 +79,6 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
return result;
|
||||
}
|
||||
|
||||
CreateFolderRemoteOperation createCreateFolderRemoteOperation(String remotePath, boolean createFullPath) {
|
||||
return new CreateFolderRemoteOperation(remotePath, createFullPath);
|
||||
}
|
||||
|
||||
ReadFolderRemoteOperation createReadFolderRemoteOperation(String remotePath) {
|
||||
return new ReadFolderRemoteOperation(remotePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
|
||||
if (operation instanceof CreateFolderRemoteOperation) {
|
||||
@@ -136,7 +124,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
newDir.setPermissions(createdRemoteFolder.getPermissions());
|
||||
getStorageManager().saveFile(newDir);
|
||||
|
||||
logger.d(TAG, "Create directory " + mRemotePath + " in Database");
|
||||
Log_OC.d(TAG, "Create directory " + mRemotePath + " in Database");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||