Compare commits
282
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da490b9c88 | ||
|
|
31b8bebb3b | ||
|
|
780fc7d4d7 | ||
|
|
21dad106e4 | ||
|
|
4ec4fcddbb | ||
|
|
d885b9f580 | ||
|
|
2bdcc1615c | ||
|
|
f42b1f5444 | ||
|
|
585cbbd8b7 | ||
|
|
0a2a53ad2e | ||
|
|
0a7b2de274 | ||
|
|
fb8a93b9c2 | ||
|
|
88a6c4c94d | ||
|
|
257ac81f73 | ||
|
|
a2357181ab | ||
|
|
6eb4ac7c47 | ||
|
|
8b61e74057 | ||
|
|
e5cd5ffcd6 | ||
|
|
066f4c25aa | ||
|
|
45f114671a | ||
|
|
d913950b50 | ||
|
|
5f6dc23a5a | ||
|
|
1145c3813e | ||
|
|
fd3ff4cbcb | ||
|
|
988e797025 | ||
|
|
8062340f63 | ||
|
|
4b328cbe3e | ||
|
|
1290bbe52e | ||
|
|
da104fc48a | ||
|
|
702c4f71fe | ||
|
|
f7597c1472 | ||
|
|
c27f4cea39 | ||
|
|
75442575f0 | ||
|
|
4576d45ce3 | ||
|
|
aabc97de82 | ||
|
|
c608f0081c | ||
|
|
88fe5069eb | ||
|
|
9b94cc2b58 | ||
|
|
65b82c2ee5 | ||
|
|
25d9c46f82 | ||
|
|
f9bd91b4b3 | ||
|
|
d95351b040 | ||
|
|
3ed9ce2e2b | ||
|
|
b01f71972f | ||
|
|
01e532929d | ||
|
|
d8722b52de | ||
|
|
ed52ad56aa | ||
|
|
b3e0d7721e | ||
|
|
4a46d01c4b | ||
|
|
21baad4fdc | ||
|
|
04d59133ca | ||
|
|
645f194c88 | ||
|
|
acd5d48d96 | ||
|
|
866d163a73 | ||
|
|
d006ac257e | ||
|
|
1f861dfb58 | ||
|
|
eb74b5230f | ||
|
|
1584de9769 | ||
|
|
664727b2a6 | ||
|
|
ead35eb3a1 | ||
|
|
17914038ca | ||
|
|
86c5179c8e | ||
|
|
adbc1f27aa | ||
|
|
e0ec1c1637 | ||
|
|
9dcb915266 | ||
|
|
92510cb168 | ||
|
|
a894814611 | ||
|
|
dda56defb4 | ||
|
|
cb00677172 | ||
|
|
fd48163e22 | ||
|
|
5e687f2c17 | ||
|
|
fb69c1bd51 | ||
|
|
683faab116 | ||
|
|
c3eec47779 | ||
|
|
7cf3ba93c6 | ||
|
|
ba58d37aff | ||
|
|
cd86ff16c2 | ||
|
|
2f9c5e9761 | ||
|
|
3cf0e6e5e4 | ||
|
|
92d872ceec | ||
|
|
83903ea1db | ||
|
|
e0bd44cf83 | ||
|
|
2dbf724b33 | ||
|
|
2d68e2e1c5 | ||
|
|
0b86d6a1d9 | ||
|
|
d270752390 | ||
|
|
34db134829 | ||
|
|
eac9c9df67 | ||
|
|
dc0181bac9 | ||
|
|
c612e2f547 | ||
|
|
82e226f867 | ||
|
|
85e13f2910 | ||
|
|
30f96aa984 | ||
|
|
041a6787b8 | ||
|
|
dd574f99a0 | ||
|
|
2c57e37097 | ||
|
|
5257fb236c | ||
|
|
aa431815aa | ||
|
|
1f4e857681 | ||
|
|
d17c853493 | ||
|
|
74bfe473c4 | ||
|
|
3e872df68c | ||
|
|
4e0b40517c | ||
|
|
7c62ad6b06 | ||
|
|
bedc2b48ee | ||
|
|
ca6918f9fc | ||
|
|
23e44243da | ||
|
|
540c649efe | ||
|
|
f34ba2cdca | ||
|
|
48038d564e | ||
|
|
83e0ebc463 | ||
|
|
21c0de3cdd | ||
|
|
e92daa2fc4 | ||
|
|
99d9a6923e | ||
|
|
10960bf3a2 | ||
|
|
9f24b254f9 | ||
|
|
b7876c4252 | ||
|
|
11687c65cb | ||
|
|
80fb800ef1 | ||
|
|
b91136c362 | ||
|
|
a7eb7148fa | ||
|
|
4f26261bf8 | ||
|
|
0691786fb8 | ||
|
|
6249a06a8d | ||
|
|
c8eba1d5ad | ||
|
|
609b99666f | ||
|
|
44220d73fe | ||
|
|
6e5d7a89c1 | ||
|
|
16c220e7af | ||
|
|
b9ff6cecfc | ||
|
|
ddb015bda8 | ||
|
|
0977c9d2e1 | ||
|
|
26c5c5e015 | ||
|
|
21ef006544 | ||
|
|
0223085a8d | ||
|
|
8879179cff | ||
|
|
94502f66b5 | ||
|
|
21109375c3 | ||
|
|
f1a0ac5c26 | ||
|
|
a00677cd63 | ||
|
|
dbe12e6d20 | ||
|
|
77b6b178a9 | ||
|
|
b561f68834 | ||
|
|
b59d96ace0 | ||
|
|
b6d682683c | ||
|
|
9ae550731e | ||
|
|
bfdaba8bde | ||
|
|
c82c08059a | ||
|
|
65da616f81 | ||
|
|
5273e1e7fc | ||
|
|
bd503a86c7 | ||
|
|
20c9ce361a | ||
|
|
3943e1c753 | ||
|
|
75de7b88d4 | ||
|
|
693f408276 | ||
|
|
ed8b9cbb72 | ||
|
|
f38900d989 | ||
|
|
e43ef8e062 | ||
|
|
f245b72ded | ||
|
|
d30b574ff6 | ||
|
|
fb615ef279 | ||
|
|
df6d847f29 | ||
|
|
4343c3d67f | ||
|
|
86027dd091 | ||
|
|
4690042b06 | ||
|
|
ff646aa3d0 | ||
|
|
403fc87562 | ||
|
|
142c79bc03 | ||
|
|
890789f0a7 | ||
|
|
180bdee721 | ||
|
|
039adc0a18 | ||
|
|
b59938d960 | ||
|
|
2e13212752 | ||
|
|
c2ea4de802 | ||
|
|
7f4db3fdd0 | ||
|
|
9e15f5ea39 | ||
|
|
d208681fed | ||
|
|
25aaf4b907 | ||
|
|
6b01382e7f | ||
|
|
7a8aee3e22 | ||
|
|
a3ae32129d | ||
|
|
b0563b9310 | ||
|
|
207f8947cf | ||
|
|
1ec09848b6 | ||
|
|
5131514917 | ||
|
|
38a83bb361 | ||
|
|
62fc6fa53d | ||
|
|
71264e19b8 | ||
|
|
bd3ce60985 | ||
|
|
327817c047 | ||
|
|
a39022fbbe | ||
|
|
d3d0df46f1 | ||
|
|
e3280b0bb7 | ||
|
|
575cd014d2 | ||
|
|
946e5c2c1e | ||
|
|
78ed97ca07 | ||
|
|
f77b5bd4b8 | ||
|
|
fe353a7561 | ||
|
|
c4e20a652d | ||
|
|
af63eed654 | ||
|
|
a9fcc7b03a | ||
|
|
2a43da6bdf | ||
|
|
f8d7ddd9de | ||
|
|
bee8770ce0 | ||
|
|
cc710b09cb | ||
|
|
c1aa005db9 | ||
|
|
12fe91a6dd | ||
|
|
3de5e8fa52 | ||
|
|
ae2dcbea33 | ||
|
|
48e1384219 | ||
|
|
2021da0a8b | ||
|
|
48b43581cc | ||
|
|
9a9e0e6c42 | ||
|
|
853d7cd113 | ||
|
|
4ce4027250 | ||
|
|
b5d1de3601 | ||
|
|
1615130093 | ||
|
|
a518885612 | ||
|
|
f5a1a9a9cc | ||
|
|
284bbf34e6 | ||
|
|
57db615a33 | ||
|
|
cc2593cbdb | ||
|
|
44020dcc76 | ||
|
|
1e3f86cfe1 | ||
|
|
375fb97c06 | ||
|
|
cf839eac08 | ||
|
|
9a88ee24d3 | ||
|
|
110ce5e951 | ||
|
|
5554585348 | ||
|
|
1bdccebce8 | ||
|
|
e14dc52fa7 | ||
|
|
6bb9a70603 | ||
|
|
6eb0744986 | ||
|
|
8f8b67f57f | ||
|
|
e32ec7a192 | ||
|
|
dc4cbb71e2 | ||
|
|
689a0a216b | ||
|
|
b7e9d3f954 | ||
|
|
8d0ff8fecc | ||
|
|
c6218a0e5f | ||
|
|
c7049788f7 | ||
|
|
30a5ec6ee1 | ||
|
|
562338cad1 | ||
|
|
913d8276e1 | ||
|
|
790e3fa2f8 | ||
|
|
3d60c83ba2 | ||
|
|
55a32df928 | ||
|
|
27b8ed4327 | ||
|
|
bf0779a3ed | ||
|
|
25f58cd259 | ||
|
|
f5aa60bae9 | ||
|
|
8aaf29a7c3 | ||
|
|
9eb6fe838e | ||
|
|
f6680a3375 | ||
|
|
a2963d9fc3 | ||
|
|
2d0f4e83a6 | ||
|
|
01642564ed | ||
|
|
ff9795d421 | ||
|
|
196e33998a | ||
|
|
4a808ab15c | ||
|
|
916580cb19 | ||
|
|
21fb11d79b | ||
|
|
e54db7c7c5 | ||
|
|
691ee27cc5 | ||
|
|
dc0ca5cc84 | ||
|
|
c43633ebb9 | ||
|
|
01cfd0ad33 | ||
|
|
eff6a5bed9 | ||
|
|
f53f246f6e | ||
|
|
5a4df84fc4 | ||
|
|
f459cd2c98 | ||
|
|
55d5f2f41a | ||
|
|
66144bb8b6 | ||
|
|
d1f1e6cff7 | ||
|
|
9f7fa6b6b6 | ||
|
|
b0734f5768 | ||
|
|
34cef89ce8 | ||
|
|
c4b5d8f2e9 | ||
|
|
1930e5dc74 | ||
|
|
cab2b12594 | ||
|
|
df15340fc2 | ||
|
|
44099c0792 |
No files matched your search
+371
-9
@@ -3,7 +3,7 @@ name: generic
|
||||
|
||||
steps:
|
||||
- name: generic
|
||||
image: nextcloudci/android:android-49
|
||||
image: nextcloudci/android10:android-56 # use always latest android version
|
||||
environment:
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
@@ -48,11 +48,11 @@ trigger:
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: gplay
|
||||
name: android10
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: nextcloudci/android:android-49
|
||||
- name: test
|
||||
image: nextcloudci/android10:android-56 # use always latest android version
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
@@ -66,13 +66,13 @@ steps:
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
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 &
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 10 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 10 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
- curl -o codecov.sh https://codecov.io/bash
|
||||
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5
|
||||
@@ -108,13 +108,375 @@ trigger:
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: android9
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: nextcloudci/android9:android-56
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 9 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 9 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: android8
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: nextcloudci/android8:android-56
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 8 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 8 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: android7
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: nextcloudci/android7:android-56
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 7 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 7 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: android6
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: nextcloudci/android6:android-56
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 6 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 6 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: android5
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: nextcloudci/android5:android-56
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 5 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 5 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: android4
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: nextcloudci/android4:android-56
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
ORG_GRADLE_PROJECT_coverage: ''
|
||||
commands:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- /opt/android-sdk-linux/emulator/emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio &
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit" 4 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT" 4 $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-3
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: analysis
|
||||
|
||||
steps:
|
||||
- name: analysis
|
||||
image: nextcloudci/android:android-49
|
||||
image: nextcloudci/android10:android-56 # use always latest android version
|
||||
environment:
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
@@ -163,7 +525,7 @@ name: qa
|
||||
|
||||
steps:
|
||||
- name: qa
|
||||
image: nextcloudci/android:android-49
|
||||
image: nextcloudci/android10:android-56 # use always latest android version
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
|
||||
+11
@@ -36,3 +36,14 @@ build
|
||||
fastlane/Fastfile
|
||||
*.hprof
|
||||
|
||||
# fastlane specific
|
||||
**/fastlane/report.xml
|
||||
|
||||
# deliver temporary files
|
||||
**/fastlane/Preview.html
|
||||
|
||||
# snapshot generated screenshots
|
||||
**/fastlane/screenshots
|
||||
|
||||
# scan temporary files
|
||||
**/fastlane/test_output
|
||||
Generated
+15
-1
@@ -27,6 +27,11 @@
|
||||
<emptyLine />
|
||||
</value>
|
||||
</option>
|
||||
<option name="RIGHT_MARGIN" value="120" />
|
||||
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
|
||||
</AndroidXmlCodeStyleSettings>
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
@@ -86,6 +91,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -96,6 +102,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -107,6 +114,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -117,6 +125,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -127,6 +136,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -137,6 +147,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -147,6 +158,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -158,6 +170,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -169,6 +182,7 @@
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
@@ -179,4 +193,4 @@
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
</component>
|
||||
@@ -1,3 +1,29 @@
|
||||
3.9.2 (December, 05, 2019)
|
||||
|
||||
- HOTFIX: fix login loop
|
||||
- Fix crash on opening png images
|
||||
- Translation updates
|
||||
|
||||
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)
|
||||
|
||||
- preview Markdown with syntax highlighting @AndyScherzinger
|
||||
- improved DavX5 integration @bitfireAT
|
||||
- AutoUpload: allow files to upload into subfolder
|
||||
- new media player service @ezaquarii
|
||||
- Remote wipe integration
|
||||
- Print from within Collabora
|
||||
- enhanced SingleSignOn
|
||||
- outdated server warning set to NC14
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/38
|
||||
|
||||
## 3.8.1 (October, 11, 2019)
|
||||
|
||||
- upload images into subfolder, if source folder also has subfolder
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
1. Backport pull request
|
||||
1. Pull requests that also need changes on library
|
||||
1. Adding new files
|
||||
1. File naming
|
||||
1. Menu files
|
||||
1. Translations
|
||||
1. Releases
|
||||
1. Types
|
||||
@@ -236,6 +238,24 @@ Source code of app:
|
||||
-->
|
||||
```
|
||||
|
||||
## File naming
|
||||
|
||||
The file naming patterns are inspired and based on [Ribot's Android Project And Code Guidelines](https://github.com/ribot/android-guidelines/blob/c1d8c9c904eb31bf01fe24aadb963b74281fe79a/project_and_code_guidelines.md).
|
||||
|
||||
### Menu files
|
||||
|
||||
Similar to layout files, menu files should match the name of the component. For example, if we are defining a menu file that is going to be used in the `UserProfileActivity`, then the name of the file should be `activity_user_profile.xml`. Same pattern applies for menus used in adapter view items, dialogs, etc.
|
||||
|
||||
| Component | Class Name | Menu Name |
|
||||
| ---------------- | ---------------------- | ----------------------------- |
|
||||
| Activity | `UserProfileActivity` | `activity_user_profile.xml` |
|
||||
| Fragment | `SignUpFragment` | `fragment_sign_up.xml` |
|
||||
| Dialog | `ChangePasswordDialog` | `dialog_change_password.xml` |
|
||||
| AdapterView item | --- | `item_person.xml` |
|
||||
| Partial layout | --- | `partial_stats_bar.xml` |
|
||||
|
||||
A good practice is to not include the word `menu` as part of the name because these files are already located in the `menu` directory. In case a component uses several menus in different places (via popup menus) then the resource name would be extended. For example, if the user profile activity has two popup menus for configuring the users settings and one for the handling group assignments then the file names for the menus would be: `activity_user_profile_user_settings.xml` and `activity_user_profile_group_assignments.xml`.
|
||||
|
||||
## Translations
|
||||
We manage translations via [Transifex](https://www.transifex.com/nextcloud/nextcloud/android/). So just request joining the translation team for Android on the site and start translating. All translations will then be automatically pushed to this repository, there is no need for any pull request for translations.
|
||||
|
||||
|
||||
+27
-18
@@ -7,7 +7,7 @@
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
ext.kotlin_version = '1.3.61'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
@@ -20,13 +20,14 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.1'
|
||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.4') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.1.1"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.2.2"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ configurations {
|
||||
ext {
|
||||
jacocoVersion = "0.8.2"
|
||||
daggerVersion = "2.25.2"
|
||||
markwonVersion = "4.1.2"
|
||||
markwonVersion = "4.2.0"
|
||||
prismVersion = "2.0.0"
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
|
||||
@@ -105,18 +106,24 @@ android {
|
||||
abortOnError false
|
||||
htmlReport true
|
||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities'
|
||||
disable 'MissingTranslation',
|
||||
'GradleDependency',
|
||||
'VectorPath',
|
||||
'IconMissingDensityFolder',
|
||||
'IconDensities',
|
||||
'GoogleAppIndexingWarning',
|
||||
'MissingDefaultResource'
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
javaMaxHeapSize "4g"
|
||||
}
|
||||
|
||||
compileSdkVersion 28
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -162,8 +169,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20191029
|
||||
versionName "20191029"
|
||||
versionCode 20191211
|
||||
versionName "20191211"
|
||||
}
|
||||
|
||||
qa {
|
||||
@@ -267,18 +274,21 @@ dependencies {
|
||||
gplayImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
|
||||
versionDevImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
|
||||
qaImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
|
||||
compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2
|
||||
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.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.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-beta01'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.1.0'
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
|
||||
implementation "androidx.work:work-runtime:2.2.0"
|
||||
implementation "androidx.work:work-runtime-ktx:2.2.0"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
implementation 'com.google.code.findbugs:annotations:2.0.1'
|
||||
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.0'
|
||||
@@ -292,7 +302,7 @@ dependencies {
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
|
||||
implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.2' // 'com.github.blikoon:QRCodeScanner:0.1.2'
|
||||
implementation 'com.google.android:flexbox:1.1.1'
|
||||
implementation 'com.google.android:flexbox:2.0.0'
|
||||
implementation 'org.parceler:parceler-api:1.1.12'
|
||||
kapt 'org.parceler:parceler:1.1.12'
|
||||
implementation('com.github.bumptech.glide:glide:3.8.0') {
|
||||
@@ -301,11 +311,10 @@ dependencies {
|
||||
implementation 'com.caverock:androidsvg:1.4'
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'org.jetbrains:annotations:17.0.0'
|
||||
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:2.5.1'
|
||||
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.0'
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
|
||||
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
|
||||
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
@@ -317,7 +326,7 @@ dependencies {
|
||||
compileOnly "org.projectlombok:lombok:1.18.10"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.10"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.35.0"
|
||||
ktlint "com.pinterest:ktlint:0.36.0"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.2.1'
|
||||
|
||||
// dependencies for markdown rendering
|
||||
@@ -333,7 +342,7 @@ dependencies {
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:3.1.0'
|
||||
testImplementation 'org.mockito:mockito-core:3.2.0'
|
||||
testImplementation 'androidx.test:core:1.2.0'
|
||||
testImplementation 'org.powermock:powermock-core:2.0.4'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.4'
|
||||
|
||||
+252
-3
@@ -1,6 +1,18 @@
|
||||
# This is the minimum version number required.
|
||||
fastlane_version "2.58.0"
|
||||
|
||||
## config
|
||||
# add following to your shell rc:
|
||||
# export FASTLANE_NEXTCLOUD_STORE_FILE=""
|
||||
# export FASTLANE_NEXTCLOUD_STORE_PASSWORD=""
|
||||
# export FASTLANE_NEXTCLOUD_KEY_ALIAS=""
|
||||
# export FASTLANE_NEXTCLOUD_KEY_PASSWORD=""
|
||||
# export FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN=""
|
||||
|
||||
skip_docs
|
||||
|
||||
## public lanes
|
||||
|
||||
lane :screenshotsPhone do
|
||||
build_for_screengrab()
|
||||
|
||||
@@ -15,12 +27,86 @@ lane :screenshotsTablet do
|
||||
build_for_screengrab()
|
||||
|
||||
screengrab(
|
||||
device_type: "sevenInch",
|
||||
app_apk_path: APK_LOCATION,
|
||||
tests_apk_path: TEST_APK_LOCATION
|
||||
device_type: "sevenInch",
|
||||
app_apk_path: APK_LOCATION,
|
||||
tests_apk_path: TEST_APK_LOCATION
|
||||
)
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for RC, then test it"
|
||||
lane :releasePhase1_RC do
|
||||
disableLogger()
|
||||
makeReleases()
|
||||
enableLogger()
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for FINAL, then test it"
|
||||
lane :releasePhase1_Final do
|
||||
makeReleases()
|
||||
end
|
||||
|
||||
desc "Release phase 2 for RC: checks, tag, upload gplay to playstore with values from build.gradle"
|
||||
lane :releasePhase2_RC do |options|
|
||||
info = androidVersion
|
||||
checkChangelog(info)
|
||||
checkLibrary_RC()
|
||||
checkIfScreenshotsExist()
|
||||
checkIfAPKexists()
|
||||
tag(info)
|
||||
uploadToPlaystore_RC(info)
|
||||
createGithubRelease(info)
|
||||
fdroidMergeRequest(info)
|
||||
createChangelogPullRequestRC(info)
|
||||
end
|
||||
|
||||
desc "Release phase 2 for FINAL: checks, tag, upload gplay to playstore with values from build.gradle"
|
||||
lane :releasePhase2_Final do |options|
|
||||
info = androidVersion
|
||||
checkChangelog(info)
|
||||
checkLibrary_Final()
|
||||
checkIfScreenshotsExist()
|
||||
checkIfAPKexists()
|
||||
tag(info)
|
||||
uploadToPlaystore_Final(info)
|
||||
createGithubRelease_Final(info)
|
||||
fdroidMergeRequest_Final(info)
|
||||
createChangelogPullRequest_Final(info)
|
||||
end
|
||||
|
||||
desc "Makes gplay and generic releases in ../releases/"
|
||||
lane :makeReleases do
|
||||
sh("mkdir -p ../release")
|
||||
sh("rm -rf ../release/*")
|
||||
sh("rm -rf ../build")
|
||||
|
||||
SignedRelease(flavor:"Generic")
|
||||
sh("mv ../build/outputs/apk/generic/release/*.apk ../release/")
|
||||
sh("rename 'generic-release' 'nextcloud' ../release/generic-release*")
|
||||
|
||||
SignedRelease(flavor:"Gplay")
|
||||
sh("cp ../build/outputs/apk/gplay/release/*.apk ../release/")
|
||||
end
|
||||
|
||||
desc "Create GPlay release"
|
||||
lane :createGplayRelease do |options|
|
||||
SignedRelease(flavor:"Gplay")
|
||||
sh("mv ../build/outputs/apk/gplay/release/*.apk ../release/")
|
||||
end
|
||||
|
||||
desc "Create Generic release"
|
||||
lane :createGenericRelease do |options|
|
||||
SignedRelease(flavor:"Generic")
|
||||
sh("mv ../build/outputs/apk/generic/release/*.apk ../release/")
|
||||
end
|
||||
|
||||
desc "Create Dev release"
|
||||
lane :createDevRelease do |options|
|
||||
SignedRelease(flavor:"VersionDev")
|
||||
sh("mv ../build/outputs/apk/versionDev/release/*.apk ../release/")
|
||||
end
|
||||
|
||||
## private lanes
|
||||
|
||||
desc "Build debug and test APK for screenshots"
|
||||
private_lane :build_for_screengrab do
|
||||
build_android_app(
|
||||
@@ -37,3 +123,166 @@ private_lane :build_for_screengrab do
|
||||
)
|
||||
TEST_APK_LOCATION = lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].select{ |i| i[/androidTest/] }[0]
|
||||
end
|
||||
|
||||
private_lane :createChangelogPullRequest_RC do |options|
|
||||
sh("createChangelogPullRequestRC " + options["tag"] + " \"" + options["versionName"] + "\" " + options["versionCode"] + " \"" + options["branch"] + "\" ")
|
||||
end
|
||||
|
||||
private_lane :createChangelogPullRequest_Final do |options|
|
||||
sh("createChangelogPullRequestFinal " + options["tag"] + " \"" + options["versionName"] + "\" " + options["versionCode"] + " \"" + options["branch"] + "\" ")
|
||||
end
|
||||
|
||||
private_lane :checkIfAPKexists do |options|
|
||||
sh("if [ $(/bin/ls -1 ../release | wc -l) -ne 2 ]; then echo 'APKs do not exist ../release/; aborting!' ; exit 1 ;
|
||||
fi")
|
||||
end
|
||||
|
||||
desc "compute version"
|
||||
private_lane :androidVersion do |options|
|
||||
File.open("../build.gradle","r") do |f|
|
||||
text = f.read
|
||||
|
||||
# everything between Document and Authors
|
||||
major = text.match(/def versionMajor = ([0-9]*)$/)
|
||||
minor = text.match(/def versionMinor = ([0-9]*)$/)
|
||||
patch = text.match(/def versionPatch = ([0-9]*)$/)
|
||||
build = text.match(/def versionBuild = ([0-9]*).*$/)
|
||||
|
||||
majorInt = major[1].to_i
|
||||
minorInt = minor[1].to_i
|
||||
patchInt = patch[1].to_i
|
||||
buildInt = build[1].to_i
|
||||
|
||||
versionCode = majorInt * 10000000 + minorInt * 10000 + patchInt * 100 + buildInt
|
||||
|
||||
if buildInt > 89
|
||||
name = major[1] + "." + minor[1] + "." + patch[1]
|
||||
tag = "stable-" + major[1] + "." + minor[1] + "." + patch[1]
|
||||
branch = "stable-" + major[1] + "." + minor[1]
|
||||
elsif buildInt > 50
|
||||
name = major[1] + "." + minor[1] + "." + patch[1] + " RC" + (buildInt - 50).to_s
|
||||
tag = "rc-" + major[1] + "." + minor[1] + "." + patch[1] + "-" + format('%02d', (buildInt - 50))
|
||||
branch = "stable-" + major[1] + "." + minor[1]
|
||||
else
|
||||
name = major[1] + "." + minor[1] + "." + patch[1] + " Alpha " + format('%02d', (buildInt + 1))
|
||||
tag = "/"
|
||||
branch = "stable-" + major[1] + "." + minor[1]
|
||||
end
|
||||
|
||||
print "VersionCode: " + versionCode.to_s + "\n"
|
||||
print "Name: " + name + "\n"
|
||||
print "Tag: " + tag + "\n"
|
||||
print "Branch: " + branch + "\n"
|
||||
print "\ndisable IPv6 to upload to Gplay!!!\n"
|
||||
|
||||
answer = prompt(text: "is this okay?", boolean: true)
|
||||
|
||||
if !answer
|
||||
exit
|
||||
end
|
||||
|
||||
{ "versionCode" => versionCode.to_s, "versionName" => name, "tag" => tag, "branch" => branch }
|
||||
end
|
||||
end
|
||||
|
||||
desc "check if library is set correctly"
|
||||
private_lane :checkLibrary_RC do
|
||||
sh(" if [ $(egrep 'androidLibraryVersion.*master.*' ../build.gradle -c) -eq 1 ] ; then echo 'Library is set to master tag; aborting!' ; exit 1 ; fi")
|
||||
end
|
||||
|
||||
desc "check if library is set correctly: must NOT contain master nor rc"
|
||||
private_lane :checkLibrary_Final do
|
||||
sh(" if [ $(grep 'androidLibraryVersion' ../build.gradle | egrep 'master|rc' -c) -eq 1 ] ; then echo 'Library is still set to rc tag; aborting!' ; exit 1 ; fi")
|
||||
end
|
||||
|
||||
desc "check if screenshots exists and exit"
|
||||
private_lane :checkIfScreenshotsExist do
|
||||
sh(" if [ -e metadata/android/*/images ] ; then echo 'Screenshots in fastlane folder exist; aborting!' ; exit 1 ; fi")
|
||||
end
|
||||
|
||||
private_lane :tag do |options|
|
||||
add_git_tag(
|
||||
tag: options["tag"],
|
||||
sign: true
|
||||
)
|
||||
push_git_tags(
|
||||
tag: options["tag"])
|
||||
end
|
||||
|
||||
private_lane :disableLogger do
|
||||
sh("sed -i s'#<bool name=\"logger_enabled\">false</bool>#<bool name=\"logger_enabled\">true</bool>#' ../src/main/res/values/setup.xml")
|
||||
end
|
||||
|
||||
private_lane :enableLogger do
|
||||
sh("sed -i s'#<bool name=\"logger_enabled\">true</bool>#<bool name=\"logger_enabled\">false</bool>#' ../src/main/res/values/setup.xml")
|
||||
end
|
||||
|
||||
desc "Upload to play store"
|
||||
private_lane :uploadToPlaystore_RC do |options|
|
||||
upload_to_play_store(
|
||||
skip_upload_images: true,
|
||||
track: 'beta',
|
||||
apk: "release/gplay-release-" + options["versionCode"] + ".apk"
|
||||
)
|
||||
end
|
||||
|
||||
desc "Upload to play store"
|
||||
private_lane :uploadToPlaystore_Final do |options|
|
||||
upload_to_play_store(
|
||||
skip_upload_images: true,
|
||||
apk: "release/gplay-release-" + options["versionCode"] + ".apk"
|
||||
)
|
||||
end
|
||||
|
||||
private_lane :SignedRelease do |options|
|
||||
gradle(
|
||||
task: 'assemble',
|
||||
flavor: options[:flavor],
|
||||
build_type: 'Release',
|
||||
print_command: false,
|
||||
properties: {
|
||||
"android.injected.signing.store.file" => ENV["FASTLANE_NEXTCLOUD_STORE_FILE"],
|
||||
"android.injected.signing.store.password" => ENV["FASTLANE_NEXTCLOUD_STORE_PASSWORD"],
|
||||
"android.injected.signing.key.alias" => ENV["FASTLANE_NEXTCLOUD_KEY_ALIAS"],
|
||||
"android.injected.signing.key.password" => ENV["FASTLANE_NEXTCLOUD_KEY_PASSWORD"],
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
private_lane :createGithubRelease_RC do |options|
|
||||
set_github_release(
|
||||
repository_name: "nextcloud/android",
|
||||
api_token: ENV["FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN"],
|
||||
name: options["versionName"],
|
||||
tag_name: options["tag"],
|
||||
is_prerelease: true,
|
||||
description: (File.read("metadata/android/en-US/changelogs/" + options["versionCode"] + ".txt") rescue "No changelog provided"),
|
||||
upload_assets: [ "release/gplay-release-" + options["versionCode"] + ".apk", "release/nextcloud-" +
|
||||
options["versionCode"] + ".apk" ]
|
||||
)
|
||||
end
|
||||
|
||||
private_lane :createGithubRelease_Final do |options|
|
||||
set_github_release(
|
||||
repository_name: "nextcloud/android",
|
||||
api_token: ENV["FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN"],
|
||||
name: options["versionName"],
|
||||
tag_name: options["tag"],
|
||||
description: (File.read("metadata/android/en-US/changelogs/" + options["versionCode"] + ".txt") rescue "No changelog provided"),
|
||||
upload_assets: [ "release/gplay-release-" + options["versionCode"] + ".apk", "release/nextcloud-" +
|
||||
options["versionCode"] + ".apk" ]
|
||||
)
|
||||
end
|
||||
|
||||
private_lane :fdroidMergeRequest_RC do |options|
|
||||
sh("fdroidMergeRequestRC " + options["tag"] + " \"" + options["versionName"] + "\" " + options["versionCode"])
|
||||
end
|
||||
|
||||
private_lane :fdroidMergeRequest_Final do |options|
|
||||
sh("fdroidMergeRequestFinal " + options["tag"] + " \"" + options["versionName"] + "\" " + options["versionCode"])
|
||||
end
|
||||
|
||||
private_lane :checkChangelog do |options|
|
||||
sh(" if [ ! -e metadata/android/en-US/changelogs/" + options["versionCode"] + ".txt ] ; then echo 'Changelog fastlane/metadata/android/en-US/changelogs/" + options["versionCode"] + ".txt does not exist' ; exit 1 ; fi")
|
||||
sh(" if [ $(wc -m metadata/android/en-US/changelogs/" + options["versionCode"] + ".txt | cut -d' ' -f1) -ge 500 ] ; then echo 'Changlog more than 500 chars' ; exit 1 ; fi")
|
||||
end
|
||||
@@ -1 +1 @@
|
||||
423
|
||||
409
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 59 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 73 warnings</span>
|
||||
+10
-8
@@ -4,16 +4,18 @@
|
||||
#2: LOG_PASSWORD
|
||||
#3: DRONE_BUILD_NUMBER
|
||||
#4: TYPE (IT or Unit)
|
||||
#5: DRONE_PULL_REQUEST
|
||||
#6: GIT_USERNAME
|
||||
#7: GIT_TOKEN
|
||||
#5: androidVersion
|
||||
#6: DRONE_PULL_REQUEST
|
||||
#7: GIT_USERNAME
|
||||
#8: GIT_TOKEN
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
||||
ID=$3
|
||||
USER=$1
|
||||
PASS=$2
|
||||
TYPE=$4
|
||||
|
||||
ANDROID_VERSION=$5
|
||||
FOLDER=$ID-$ANDROID_VERSION
|
||||
set -e
|
||||
|
||||
if [ $TYPE = "IT" ]; then
|
||||
@@ -22,11 +24,11 @@ else
|
||||
cd build/reports/tests/testGplayDebugUnitTest
|
||||
fi
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$ID/$(echo {} | sed s#\./##) \;
|
||||
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$ID/$(echo {} | sed s#\./##) --upload-file {} \;
|
||||
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 {} \;
|
||||
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$ID"
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$FOLDER"
|
||||
|
||||
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/$ID \" }"
|
||||
curl -u $7:$8 -X POST https://api.github.com/repos/nextcloud/android/issues/$6/comments -d "{ \"body\" : \"$TYPE test failed on Android $ANDROID_VERSION: https://www.kaminsky.me/nc-dev/android-integrationTests/$FOLDER \" }"
|
||||
|
||||
exit 1
|
||||
+7
-2
@@ -17,7 +17,8 @@
|
||||
<Match>
|
||||
<Or>
|
||||
<Class name="~.*\.Dagger.*" />
|
||||
<Class name="~com.nextcloud.client.di\..*_.*" />
|
||||
<Class name="~com\.nextcloud\.client\.di\..*_.*" />
|
||||
<Class name="~dagger\.android\..*" />
|
||||
</Or>
|
||||
</Match>
|
||||
<!-- Dagger generated code uses internal APIs -->
|
||||
@@ -30,7 +31,7 @@
|
||||
<Match>
|
||||
<Or>
|
||||
<Class name="~.*BindingImpl"/>
|
||||
<Class name="~.*\.DataBinderMapperImpl"/>
|
||||
<Class name="~.*\.DataBinderMapperImpl"/>
|
||||
</Or>
|
||||
</Match>
|
||||
|
||||
@@ -39,6 +40,10 @@
|
||||
<Or>
|
||||
<Package name="~io\.noties\..*" />
|
||||
<Package name="~third_parties\.ezvcard_android\..*" />
|
||||
<Package name="~com\.afollestad\.sectionedrecyclerview\..*" />
|
||||
<Package name="~butterknife\..*" />
|
||||
<Package name="~de\.cotech\..*" />
|
||||
<Package name="~pl\.droidsonroids\..*" />
|
||||
</Or>
|
||||
</Match>
|
||||
<Match>
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
Svobodně licencovaná Nexcloud Android aplikace, dávající vám mobilní svobodu.
|
||||
|
||||
Software, který můžete nasadit na vlastní server a ten organizuje ukládání a synchronizaci souborů. Díky doplňkům jde o kompletní groupwarové řešení.
|
||||
Funkce:
|
||||
* Snadno použitelné moderní rozhraní, přizpůsobené vzhledu, používaném na vašem serveru
|
||||
* Nahrávejte soubory na svůj Nextcloud server
|
||||
* Sdílejte je s ostatními
|
||||
* Udržujte své oblíbené soubory a složky synchronizované
|
||||
* Hledejte napříč všemi složkami na svém serveru
|
||||
* Automaticky nahrávejte své fotky a videa, pořízená zařízením
|
||||
* Udržujte si přehled pomocí oznámení
|
||||
* Podporuje vícero účtů
|
||||
* Zabezpečený přístup k vašim datům pomocí otisku prstu nebo PIN kódu
|
||||
* Napojení na DAVx5 (dříve známé pod názvem DAVdroid) pro snadné nastavení synchronizace kalendáře a kontaktů
|
||||
* Soubory nahrané do nexcloudu lze snadno sdílet s ostatními.
|
||||
* Přístup odkudkoli přes webové a mobilní rozhraní.
|
||||
* Synchronizace s počítačem umožňující offline práci.
|
||||
* Vaše data jsou na vašem serveru a máte nad nimi plnou kontrolu.
|
||||
* Jde o svobodný software, který snadno můžete sami hostovat a volně si ho přizplsobit. V případě potřeby je ale k dispozici komerční podpora.
|
||||
* Vyhledávání napříč soubory.
|
||||
* Synchronizace kontaktů a zpráv.
|
||||
* Sdílení kalendářů do mobilu (DAVx5/DAVdroid)
|
||||
* Neomezený počet uživatelů, autoupload fotek přímo z mobilu, oznámení,
|
||||
* Klienti pro WIndows, MacOS, iOS, Android, web.
|
||||
* Mnoho dalších doplňků s dalšími funkcemi.
|
||||
|
||||
Veškeré nalezené problémy hlaste na https://github.com/nextcloud/android/issues a diskutujte o aplikaci na https://help.nextcloud.com/c/clients/android
|
||||
Díky Nextcloudu budete mít kompletní privátní řešení pro všechy vaše soubory, fotky, kalendáře a kontakty.
|
||||
|
||||
Noví v Nextcloud? Nextcloud je soukromý server pro synchronizaci souborů a jejich sdílení, dále pro komunikaci. Jedná se o svobodný software a můžete ho hostovat svými silami nebo za to zaplatit nějaké společnosti. Tím máte pod kontrolou své fotky, kalendář a kontakty, dokumenty a vše ostatní.
|
||||
|
||||
Podívejte se na Nextcloud na https://nextcloud.com
|
||||
Připomínky zasílejte na https://github.com/nextcloud/android/issues, diskutovat lze na https://help.nextcloud.com/c/clients a vše ostatní najdete na https://nextcloud.com
|
||||
@@ -1 +1 @@
|
||||
Produktivní platforma hostovaná u vás, kde vaše data jsou opravdu vaše
|
||||
Platforma pro produktivitu hostovaná u vás, kde vaše data jsou opravdu vaše
|
||||
@@ -0,0 +1,19 @@
|
||||
Μια αυτόνομη πλατφόρμα που έχετε τον πλήρη έλεγχο.
|
||||
|
||||
Features:
|
||||
* Εύκολο, μοντέρνο, συμβατό με το θέμα του διακομιστή σας
|
||||
* Μεταφόρτωση αρχείων στον Nextclound διακομιστή σας
|
||||
* Κοινή χρήση
|
||||
* Κρατήστε τα αγαπημένα σας αρχεία και φακέλους συγχρονισμένα
|
||||
* Αναζήτηση σε όλ΄ους τους φακέλους στον διακομιστή σας
|
||||
* Αυτόματη μεταφόρτωση φωτογραφιών και βίντεο από την συσκευή σας
|
||||
* Ενημέρωση με ειδοποιήσεις
|
||||
* Υποστήριξη πολλαπλών λογαριασμών
|
||||
* Ασφαλή σύνδεση στα δεδομένα σας με χρήση δακτυλικού αποτυπώματος ή κωδικού PIN
|
||||
* Συνεργασία με DADVx5 (γνωστό ως DAVdroid) για εύκολη εγκατάσταση και συγχρονισμό ημερολογίου &
|
||||
|
||||
Παρακαλώ αναφέρετε τα σφάλματα στο https://github.com/nextcloud/android/issues και συζητήστε για την εφαρμογή στο https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Καινούργιος στο Nextclound? To Nextclound είναι ένας διακομιστής &συγχρονισμού αρχείων κοινόχρηστων και επικοινωνίας. Ένα ελεύθερο λογισμικό, οπου μπορείτε να το υποστηρίξετε μόνοι σας ή επι πληρωμής. Με αυτό τον τρόπο έχετε τον έλεγχο των φωτογραφιών σας, του ημερολογίου σας και των δεδομένων των επαφών σας, των αρχείων σας και οτιδήποτε άλλο.
|
||||
|
||||
Ενημερωθείτε για το Nextclound στο https://nextcloud.com
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -0,0 +1 @@
|
||||
Kontrolpean mantentzen zaituen norberak ostatutako produktibitate plataforma
|
||||
@@ -1 +1 @@
|
||||
Nextcloud Android 앱으로 내 Nextcloud에 있는 모든 파일을 사용하십시오.
|
||||
컨트롤 가능한 자체 호스팅 생산성 플랫폼
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2019 Chris Narkiewicz
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.accounts.Account
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
import com.owncloud.android.lib.common.OwnCloudBasicCredentials
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* This object represents anonymous user, ie. user that did not log in the Nextcloud server.
|
||||
* It serves as a semantically correct "empty value", allowing simplification of logic
|
||||
* in various components requiring user data, such as DB queries.
|
||||
*/
|
||||
internal class AnonymousUser(private val accountType: String) : User {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromContext(context: Context): AnonymousUser {
|
||||
val type = context.getString(R.string.account_type)
|
||||
return AnonymousUser(type)
|
||||
}
|
||||
}
|
||||
|
||||
override val accountName: String = "anonymous"
|
||||
override val server = Server(URI.create(""), MainApp.MINIMUM_SUPPORTED_SERVER_VERSION)
|
||||
override val isAnonymous = true
|
||||
|
||||
override fun toPlatformAccount(): Account {
|
||||
return Account(accountName, accountType)
|
||||
}
|
||||
|
||||
override fun toOwnCloudAccount(): OwnCloudAccount {
|
||||
return OwnCloudAccount(Uri.EMPTY, OwnCloudBasicCredentials("", ""))
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,31 @@ package com.nextcloud.client.account;
|
||||
|
||||
import android.accounts.Account;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface provides access to currently selected user Account.
|
||||
* This interface provides access to currently selected user.
|
||||
*
|
||||
* @see UserAccountManager
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface CurrentAccountProvider {
|
||||
/**
|
||||
* Get currently active account.
|
||||
* Get currently active account.
|
||||
*
|
||||
* @return Currently selected {@link Account} or first valid {@link Account} registered in OS or null, if not available at all.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
Account getCurrentAccount();
|
||||
|
||||
/**
|
||||
* Get currently active user profile. If there is no actice user, anonymous user is returned.
|
||||
*
|
||||
* @return User profile. Profile is never null.
|
||||
*/
|
||||
@NonNull
|
||||
default User getUser() {
|
||||
return new AnonymousUser("dummy");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2019 Chris Narkiewicz
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.accounts.Account
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
|
||||
/**
|
||||
* This class represents normal user logged into the Nextcloud server.
|
||||
*/
|
||||
internal class RegisteredUser(
|
||||
private val account: Account,
|
||||
private val ownCloudAccount: OwnCloudAccount,
|
||||
override val server: Server
|
||||
) : User {
|
||||
override val isAnonymous = false
|
||||
|
||||
override val accountName: String get() {
|
||||
return account.name
|
||||
}
|
||||
|
||||
override fun toPlatformAccount(): Account {
|
||||
return account
|
||||
}
|
||||
|
||||
override fun toOwnCloudAccount(): OwnCloudAccount {
|
||||
return ownCloudAccount
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2019 Chris Narkiewicz
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* This object provides all information necessary to interact
|
||||
* with backend server.
|
||||
*/
|
||||
data class Server(val uri: URI, val version: OwnCloudVersion)
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2019 Chris Narkiewicz
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.account
|
||||
|
||||
import android.accounts.Account
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
|
||||
interface User {
|
||||
val accountName: String
|
||||
val server: Server
|
||||
val isAnonymous: Boolean
|
||||
|
||||
/**
|
||||
* This is temporary helper method created to facilitate incremental refactoring.
|
||||
* Code using legacy platform Account can be partially converted to instantiate User
|
||||
* object and use account instance when required.
|
||||
*
|
||||
* This method calls will allow tracing code awaiting further refactoring.
|
||||
*
|
||||
* @return Account instance that is associated with this User object.
|
||||
*/
|
||||
@Deprecated("Temporary workaround")
|
||||
fun toPlatformAccount(): Account
|
||||
|
||||
/**
|
||||
* This is temporary helper method created to facilitate incremental refactoring.
|
||||
* Code using legacy ownCloud account can be partially converted to instantiate User
|
||||
* object and use account instance when required.
|
||||
*
|
||||
* This method calls will allow tracing code awaiting further refactoring.
|
||||
*
|
||||
* @return OwnCloudAccount instance that is associated with this User object.
|
||||
*/
|
||||
@Deprecated("Temporary workaround")
|
||||
fun toOwnCloudAccount(): OwnCloudAccount
|
||||
}
|
||||
@@ -21,10 +21,13 @@ package com.nextcloud.client.account;
|
||||
|
||||
import android.accounts.Account;
|
||||
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -51,6 +54,22 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
@NonNull
|
||||
Account[] getAccounts();
|
||||
|
||||
/**
|
||||
* Get configured nextcloud user accounts
|
||||
* @return List of users or empty list, if users are not registered.
|
||||
*/
|
||||
@NonNull
|
||||
List<User> getAllUsers();
|
||||
|
||||
/**
|
||||
* Get user with a specific account name.
|
||||
*
|
||||
* @param accountName Account name of the requested user
|
||||
* @return User or empty optional if user does not exist.
|
||||
*/
|
||||
@NonNull
|
||||
Optional<User> getUser(CharSequence accountName);
|
||||
|
||||
/**
|
||||
* Check if Nextcloud account is registered in {@link android.accounts.AccountManager}
|
||||
*
|
||||
@@ -78,10 +97,24 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
* @return Version of the OC server corresponding to account, according to the data saved
|
||||
* in the system AccountManager
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
OwnCloudVersion getServerVersion(Account account);
|
||||
|
||||
@Deprecated
|
||||
boolean isSearchSupported(@Nullable Account account);
|
||||
|
||||
/**
|
||||
* Check if user's account supports media streaming. This is a property of server where user has his account.
|
||||
*
|
||||
* @deprecated Please use {@link OwnCloudVersion#isMediaStreamingSupported()} directly,
|
||||
* obtainable from {@link User#getServer()} and {@link Server#getVersion()}
|
||||
*
|
||||
* @param account Account used to perform {@link android.accounts.AccountManager} lookup.
|
||||
*
|
||||
* @return true is server supports media streaming, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isMediaStreamingSupported(@Nullable Account account);
|
||||
|
||||
void resetOwnCloudAccount();
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -35,11 +36,16 @@ import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -80,6 +86,20 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
return accountManager.getAccountsByType(getAccountType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public List<User> getAllUsers() {
|
||||
Account[] accounts = getAccounts();
|
||||
List<User> users = new ArrayList<>(accounts.length);
|
||||
for (Account account : accounts) {
|
||||
User user = createUserFromAccount(account);
|
||||
if (user != null) {
|
||||
users.add(user);
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(Account account) {
|
||||
Account[] nextcloudAccounts = getAccounts();
|
||||
@@ -103,6 +123,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Account getCurrentAccount() {
|
||||
Account[] ocAccounts = getAccounts();
|
||||
@@ -139,6 +160,76 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
return defaultAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary solution to convert platform account to user instance.
|
||||
* It takes null and returns null on error to ease error handling
|
||||
* in legacy code.
|
||||
*
|
||||
* @param account Account instance
|
||||
* @return User instance or null, if conversion failed
|
||||
*/
|
||||
@Nullable
|
||||
private User createUserFromAccount(@Nullable Account account) {
|
||||
if (account == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
OwnCloudAccount ownCloudAccount = null;
|
||||
try {
|
||||
ownCloudAccount = new OwnCloudAccount(account, context);
|
||||
} catch (AccountUtils.AccountNotFoundException ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Server version
|
||||
*/
|
||||
String serverVersionStr = accountManager.getUserData(account, AccountUtils.Constants.KEY_OC_VERSION);
|
||||
OwnCloudVersion serverVersion;
|
||||
if (serverVersionStr != null) {
|
||||
serverVersion = new OwnCloudVersion(serverVersionStr);
|
||||
} else {
|
||||
serverVersion = MainApp.MINIMUM_SUPPORTED_SERVER_VERSION;
|
||||
}
|
||||
|
||||
/*
|
||||
* Server address
|
||||
*/
|
||||
String serverAddressStr = accountManager.getUserData(account, AccountUtils.Constants.KEY_OC_BASE_URL);
|
||||
if (serverAddressStr == null || serverAddressStr.isEmpty()) {
|
||||
return AnonymousUser.fromContext(context);
|
||||
}
|
||||
URI serverUri = URI.create(serverAddressStr); // TODO: validate
|
||||
|
||||
return new RegisteredUser(
|
||||
account,
|
||||
ownCloudAccount,
|
||||
new Server(serverUri, serverVersion)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user. If user cannot be retrieved due to data error, anonymous user is returned instead.
|
||||
*
|
||||
*
|
||||
* @return User instance
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public User getUser() {
|
||||
Account account = getCurrentAccount();
|
||||
User user = createUserFromAccount(account);
|
||||
return user != null ? user : AnonymousUser.fromContext(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Optional<User> getUser(CharSequence accountName) {
|
||||
Account account = getAccountByName(accountName.toString());
|
||||
User user = createUserFromAccount(account);
|
||||
return Optional.of(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public OwnCloudAccount getCurrentOwnCloudAccount() {
|
||||
@@ -197,6 +288,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
@NonNull
|
||||
public OwnCloudVersion getServerVersion(Account account) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.nextcloud.client.logger.FileLogHandler;
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.nextcloud.client.logger.LoggerImpl;
|
||||
import com.nextcloud.client.logger.LogsRepository;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
|
||||
@@ -106,8 +107,8 @@ class AppModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
FilesRepository filesRepository(UserAccountManager accountManager) {
|
||||
return new RemoteFilesRepository(new FilesServiceApiImpl(accountManager));
|
||||
FilesRepository filesRepository(UserAccountManager accountManager, ClientFactory clientFactory) {
|
||||
return new RemoteFilesRepository(new FilesServiceApiImpl(accountManager, clientFactory));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.owncloud.android.files.services.FileDownloader;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.jobs.NotificationJob;
|
||||
import com.owncloud.android.providers.DiskLruImageCacheFileProvider;
|
||||
import com.owncloud.android.providers.FileContentProvider;
|
||||
import com.owncloud.android.providers.UsersAndGroupsSearchProvider;
|
||||
import com.owncloud.android.services.AccountManagerService;
|
||||
import com.owncloud.android.services.OperationsService;
|
||||
@@ -148,6 +149,7 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector abstract BootupBroadcastReceiver bootupBroadcastReceiver();
|
||||
@ContributesAndroidInjector abstract NotificationJob.NotificationReceiver notificationJobBroadcastReceiver();
|
||||
|
||||
@ContributesAndroidInjector abstract FileContentProvider fileContentProvider();
|
||||
@ContributesAndroidInjector abstract UsersAndGroupsSearchProvider usersAndGroupsSearchProvider();
|
||||
@ContributesAndroidInjector abstract DiskLruImageCacheFileProvider diskLruImageCacheFileProvider();
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class ShowErrorActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.activity_error_show, menu)
|
||||
menuInflater.inflate(R.menu.activity_show_error, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class EtmPreferencesFragment : EtmBaseFragment() {
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
inflater.inflate(R.menu.etm_preferences, menu)
|
||||
inflater.inflate(R.menu.fragment_etm_preferences, menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.work.ListenableWorker
|
||||
import androidx.work.WorkerFactory
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
@@ -40,6 +41,7 @@ import javax.inject.Provider
|
||||
class BackgroundJobFactory @Inject constructor(
|
||||
private val preferences: AppPreferences,
|
||||
private val contentResolver: ContentResolver,
|
||||
private val clock: Clock,
|
||||
private val powerManagerService: PowerManagementService,
|
||||
private val backgroundJobManager: Provider<BackgroundJobManager>,
|
||||
private val deviceInfo: DeviceInfo
|
||||
@@ -58,13 +60,14 @@ class BackgroundJobFactory @Inject constructor(
|
||||
}
|
||||
|
||||
return when (workerClass) {
|
||||
ContentObserverWork::class -> createContentObserverJob(context, workerParameters)
|
||||
ContentObserverWork::class -> createContentObserverJob(context, workerParameters, clock)
|
||||
else -> null // falls back to default factory
|
||||
}
|
||||
}
|
||||
|
||||
private fun createContentObserverJob(context: Context, workerParameters: WorkerParameters): ListenableWorker? {
|
||||
val folderResolver = SyncedFolderProvider(contentResolver, preferences)
|
||||
private fun createContentObserverJob(context: Context, workerParameters: WorkerParameters, clock: Clock):
|
||||
ListenableWorker? {
|
||||
val folderResolver = SyncedFolderProvider(contentResolver, preferences, clock)
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
if (deviceInfo.apiLevel >= Build.VERSION_CODES.N) {
|
||||
return ContentObserverWork(
|
||||
|
||||
@@ -84,7 +84,7 @@ class LogsActivity : ToolbarActivity() {
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.logs_menu, menu)
|
||||
menuInflater.inflate(R.menu.activity_logs, menu)
|
||||
(menu.findItem(R.id.action_search).actionView as SearchView).apply {
|
||||
setOnQueryTextListener(searchBoxListener)
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
|
||||
@@ -35,10 +37,33 @@ import java.io.IOException;
|
||||
|
||||
public interface ClientFactory {
|
||||
|
||||
/**
|
||||
* This exception wraps all possible errors thrown by trigger-happy
|
||||
* OwnCloudClient constructor, making try-catch blocks manageable.
|
||||
*
|
||||
* This is a temporary refactoring measure, until a better
|
||||
* error handling method can be procured.
|
||||
*/
|
||||
@Deprecated
|
||||
class CreationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
CreationException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
}
|
||||
|
||||
OwnCloudClient create(User user) throws CreationException;
|
||||
|
||||
NextcloudClient createNextcloudClient(User user) throws CreationException;
|
||||
|
||||
@Deprecated
|
||||
OwnCloudClient create(Account account)
|
||||
throws OperationCanceledException, AuthenticatorException, IOException,
|
||||
AccountUtils.AccountNotFoundException;
|
||||
|
||||
@Deprecated
|
||||
OwnCloudClient create(Account account, Activity currentActivity)
|
||||
throws OperationCanceledException, AuthenticatorException, IOException,
|
||||
AccountUtils.AccountNotFoundException;
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
@@ -41,6 +43,30 @@ class ClientFactoryImpl implements ClientFactory {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OwnCloudClient create(User user) throws CreationException {
|
||||
try {
|
||||
return OwnCloudClientFactory.createOwnCloudClient(user.toPlatformAccount(), context);
|
||||
} catch (OperationCanceledException|
|
||||
AuthenticatorException|
|
||||
IOException|
|
||||
AccountUtils.AccountNotFoundException e) {
|
||||
throw new CreationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NextcloudClient createNextcloudClient(User user) throws CreationException {
|
||||
try {
|
||||
return OwnCloudClientFactory.createNextcloudClient(user.toPlatformAccount(), context);
|
||||
} catch (OperationCanceledException |
|
||||
AuthenticatorException |
|
||||
IOException |
|
||||
AccountUtils.AccountNotFoundException e) {
|
||||
throw new CreationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OwnCloudClient create(Account account)
|
||||
throws OperationCanceledException, AuthenticatorException, IOException,
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
|
||||
package com.nextcloud.client.network;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
import com.evernote.android.job.JobRequest;
|
||||
import com.nextcloud.client.account.Server;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
@@ -44,10 +43,11 @@ class ConnectivityServiceImpl implements ConnectivityService {
|
||||
|
||||
private final static String TAG = ConnectivityServiceImpl.class.getName();
|
||||
|
||||
private ConnectivityManager connectivityManager;
|
||||
private UserAccountManager accountManager;
|
||||
private ClientFactory clientFactory;
|
||||
private GetRequestBuilder requestBuilder;
|
||||
private final ConnectivityManager connectivityManager;
|
||||
private final UserAccountManager accountManager;
|
||||
private final ClientFactory clientFactory;
|
||||
private final GetRequestBuilder requestBuilder;
|
||||
private final Logger logger;
|
||||
|
||||
static class GetRequestBuilder implements Function1<String, GetMethod> {
|
||||
@Override
|
||||
@@ -59,55 +59,55 @@ class ConnectivityServiceImpl implements ConnectivityService {
|
||||
ConnectivityServiceImpl(ConnectivityManager connectivityManager,
|
||||
UserAccountManager accountManager,
|
||||
ClientFactory clientFactory,
|
||||
GetRequestBuilder requestBuilder) {
|
||||
GetRequestBuilder requestBuilder,
|
||||
Logger logger) {
|
||||
this.connectivityManager = connectivityManager;
|
||||
this.accountManager = accountManager;
|
||||
this.clientFactory = clientFactory;
|
||||
this.requestBuilder = requestBuilder;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInternetWalled() {
|
||||
if (isOnlineWithWifi()) {
|
||||
try {
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
OwnCloudAccount ocAccount = accountManager.getCurrentOwnCloudAccount();
|
||||
if (account != null && ocAccount != null) {
|
||||
OwnCloudVersion serverVersion = accountManager.getServerVersion(account);
|
||||
Server server = accountManager.getUser().getServer();
|
||||
String baseServerAddress = server.getUri().toString();
|
||||
if (baseServerAddress.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
String url;
|
||||
if (server.getVersion().compareTo(OwnCloudVersion.nextcloud_13) > 0) {
|
||||
url = baseServerAddress + "/index.php/204";
|
||||
} else {
|
||||
url = baseServerAddress + "/status.php";
|
||||
}
|
||||
|
||||
String url;
|
||||
if (serverVersion.compareTo(OwnCloudVersion.nextcloud_13) > 0) {
|
||||
url = ocAccount.getBaseUri() + "/index.php/204";
|
||||
} else {
|
||||
url = ocAccount.getBaseUri() + "/status.php";
|
||||
}
|
||||
GetMethod get = requestBuilder.invoke(url);
|
||||
HttpClient client = clientFactory.createPlainClient();
|
||||
|
||||
GetMethod get = requestBuilder.invoke(url);
|
||||
HttpClient client = clientFactory.createPlainClient();
|
||||
int status = client.executeMethod(get);
|
||||
|
||||
int status = client.executeMethod(get);
|
||||
|
||||
if (serverVersion.compareTo(OwnCloudVersion.nextcloud_13) > 0) {
|
||||
return !(status == HttpStatus.SC_NO_CONTENT &&
|
||||
(get.getResponseContentLength() == -1 || get.getResponseContentLength() == 0));
|
||||
} else {
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
try {
|
||||
// try parsing json to verify response
|
||||
// check if json contains maintenance and it should be false
|
||||
|
||||
String json = get.getResponseBodyAsString();
|
||||
return new JSONObject(json).getBoolean("maintenance");
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (server.getVersion().compareTo(OwnCloudVersion.nextcloud_13) > 0) {
|
||||
return !(status == HttpStatus.SC_NO_CONTENT &&
|
||||
(get.getResponseContentLength() == -1 || get.getResponseContentLength() == 0));
|
||||
} else {
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
try {
|
||||
// try parsing json to verify response
|
||||
// check if json contains maintenance and it should be false
|
||||
String json = get.getResponseBodyAsString();
|
||||
return new JSONObject(json).getBoolean("maintenance");
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error checking internet connection", e);
|
||||
logger.e(TAG, "Error checking internet connection", e);
|
||||
}
|
||||
} else {
|
||||
return getActiveNetworkType() == JobRequest.NetworkType.ANY;
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@@ -36,11 +37,13 @@ public class NetworkModule {
|
||||
@Provides
|
||||
ConnectivityService connectivityService(ConnectivityManager connectivityManager,
|
||||
UserAccountManager accountManager,
|
||||
ClientFactory clientFactory) {
|
||||
ClientFactory clientFactory,
|
||||
Logger logger) {
|
||||
return new ConnectivityServiceImpl(connectivityManager,
|
||||
accountManager,
|
||||
clientFactory,
|
||||
new ConnectivityServiceImpl.GetRequestBuilder());
|
||||
new ConnectivityServiceImpl.GetRequestBuilder(),
|
||||
logger);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -81,7 +80,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
||||
|
||||
Button loginButton = findViewById(R.id.login);
|
||||
loginButton.setBackgroundColor(Color.WHITE);
|
||||
loginButton.setBackgroundColor(getResources().getColor(R.color.login_btn_tint));
|
||||
loginButton.setTextColor(getResources().getColor(R.color.primary));
|
||||
|
||||
loginButton.setOnClickListener(v -> {
|
||||
@@ -95,7 +94,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
});
|
||||
|
||||
Button providerButton = findViewById(R.id.signup);
|
||||
providerButton.setBackgroundColor(getResources().getColor(R.color.primary_dark));
|
||||
providerButton.setBackgroundColor(getResources().getColor(R.color.primary));
|
||||
providerButton.setTextColor(getResources().getColor(R.color.login_text_color));
|
||||
providerButton.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE);
|
||||
providerButton.setOnClickListener(v -> {
|
||||
@@ -218,17 +217,19 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
return;
|
||||
}
|
||||
|
||||
setAccount(account);
|
||||
userAccountManager.setCurrentOwnCloudAccount(account.name);
|
||||
onAccountSet();
|
||||
|
||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||
i.setAction(FileDisplayActivity.RESTART);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static FeatureItem[] getFirstRun() {
|
||||
return new FeatureItem[]{
|
||||
new FeatureItem(R.drawable.logo, R.string.first_run_1_text, R.string.empty, true, false),
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
package com.nextcloud.client.onboarding;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@@ -99,11 +98,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
|
||||
updateNextButtonIfNeeded();
|
||||
});
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
mForwardFinishButton.setBackground(null);
|
||||
} else {
|
||||
mForwardFinishButton.setBackgroundDrawable(null);
|
||||
}
|
||||
mForwardFinishButton.setBackground(null);
|
||||
|
||||
mSkipButton = findViewById(R.id.skip);
|
||||
mSkipButton.setTextColor(fontColor);
|
||||
|
||||
@@ -23,8 +23,42 @@ package com.nextcloud.client.preferences;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface provides single point of entry for access to all application
|
||||
* preferences and allows clients to subscribe for specific configuration
|
||||
* changes.
|
||||
*/
|
||||
public interface AppPreferences {
|
||||
|
||||
/**
|
||||
* Preferences listener. Callbacks should be invoked on main thread.
|
||||
*
|
||||
* Miantainers should extend this interface with callbacks for specific
|
||||
* events.
|
||||
*/
|
||||
interface Listener {
|
||||
default void onDarkThemeModeChanged(DarkMode mode) {
|
||||
/* default empty implementation */
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers preferences listener. It no-ops if listener
|
||||
* is already registered.
|
||||
*
|
||||
* @param listener application preferences listener
|
||||
*/
|
||||
void addListener(@Nullable Listener listener);
|
||||
|
||||
/**
|
||||
* Unregister listener. It no-ops if listener is not registered.
|
||||
*
|
||||
* @param listener application preferences listener
|
||||
*/
|
||||
void removeListener(@Nullable Listener listener);
|
||||
|
||||
void setKeysReInitEnabled();
|
||||
boolean isKeysReInitEnabled();
|
||||
|
||||
@@ -239,6 +273,20 @@ public interface AppPreferences {
|
||||
*/
|
||||
int getUploaderBehaviour();
|
||||
|
||||
/**
|
||||
* Changes dark theme mode
|
||||
*
|
||||
* This is reactive property. Listeners will be invoked if registered.
|
||||
*
|
||||
* @param mode dark mode setting: on, off, system
|
||||
*/
|
||||
void setDarkThemeMode(DarkMode mode);
|
||||
|
||||
/**
|
||||
* @return dark mode setting: on, off, system
|
||||
*/
|
||||
DarkMode getDarkThemeMode();
|
||||
|
||||
/**
|
||||
* Saves the uploader behavior which the user has set last.
|
||||
*
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
|
||||
package com.nextcloud.client.preferences;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -35,19 +35,30 @@ import com.owncloud.android.ui.activity.PassCodeActivity;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import static com.owncloud.android.ui.fragment.OCFileListFragment.FOLDER_LAYOUT_LIST;
|
||||
|
||||
/**
|
||||
* Helper to simplify reading of Preferences all around the app
|
||||
* Implementation of application-wide preferences using {@link SharedPreferences}.
|
||||
*
|
||||
* Users should not use this class directly. Please use {@link AppPreferences} interafce
|
||||
* instead.
|
||||
*/
|
||||
public final class AppPreferencesImpl implements AppPreferences {
|
||||
|
||||
/**
|
||||
* Constant to access value of last path selected by the user to upload a file shared from other app.
|
||||
* Value handled by the app without direct access in the UI.
|
||||
*/
|
||||
public static final String AUTO_PREF__LAST_SEEN_VERSION_CODE = "lastSeenVersionCode";
|
||||
public static final String STORAGE_PATH = "storage_path";
|
||||
public static final String PREF__DARK_THEME = "dark_theme_mode";
|
||||
public static final float DEFAULT_GRID_COLUMN = 4.0f;
|
||||
|
||||
private static final String AUTO_PREF__LAST_UPLOAD_PATH = "last_upload_path";
|
||||
private static final String AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH = "upload_from_local_last_path";
|
||||
private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_MAP_URL = "prefs_upload_file_extension_map_url";
|
||||
@@ -68,6 +79,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
private static final String PREF__AUTO_UPLOAD_INIT = "autoUploadInit";
|
||||
private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
|
||||
private static final String PREF__FOLDER_LAYOUT = "folder_layout";
|
||||
|
||||
private static final String PREF__LOCK_TIMESTAMP = "lock_timestamp";
|
||||
private static final String PREF__SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
|
||||
private static final String PREF__LOCK = SettingsActivity.PREFERENCE_LOCK;
|
||||
@@ -79,7 +91,54 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
private final Context context;
|
||||
private final SharedPreferences preferences;
|
||||
private final CurrentAccountProvider currentAccountProvider;
|
||||
private final ListenerRegistry listeners;
|
||||
|
||||
/**
|
||||
* Adapter delegating raw {@link SharedPreferences.OnSharedPreferenceChangeListener} calls
|
||||
* with key-value pairs to respective {@link com.nextcloud.client.preferences.AppPreferences.Listener} method.
|
||||
*/
|
||||
static class ListenerRegistry implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private final AppPreferences preferences;
|
||||
private final Set<Listener> listeners;
|
||||
|
||||
ListenerRegistry(AppPreferences preferences) {
|
||||
this.preferences = preferences;
|
||||
this.listeners = new CopyOnWriteArraySet<>();
|
||||
}
|
||||
|
||||
void add(@Nullable final Listener listener) {
|
||||
if (listener != null) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
void remove(@Nullable final Listener listener) {
|
||||
if (listener != null) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (PREF__DARK_THEME.equals(key)) {
|
||||
DarkMode mode = preferences.getDarkThemeMode();
|
||||
for(Listener l : listeners) {
|
||||
l.onDarkThemeModeChanged(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a temporary workaround to access app preferences in places that cannot use
|
||||
* dependency injection yet. Use injected component via {@link AppPreferences} interface.
|
||||
*
|
||||
* WARNING: this creates new instance! it does not return app-wide singleton
|
||||
*
|
||||
* @param context Context used to create shared preferences
|
||||
* @return New instance of app preferences component
|
||||
*/
|
||||
@Deprecated
|
||||
public static AppPreferences fromContext(Context context) {
|
||||
final CurrentAccountProvider currentAccountProvider = UserAccountManagerImpl.fromContext(context);
|
||||
final SharedPreferences prefs = android.preference.PreferenceManager.getDefaultSharedPreferences(context);
|
||||
@@ -90,6 +149,18 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
this.context = appContext;
|
||||
this.preferences = preferences;
|
||||
this.currentAccountProvider = currentAccountProvider;
|
||||
this.listeners = new ListenerRegistry(this);
|
||||
this.preferences.registerOnSharedPreferenceChangeListener(listeners);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(@Nullable AppPreferences.Listener listener) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(@Nullable AppPreferences.Listener listener) {
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -211,7 +282,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
@Override
|
||||
public String getFolderLayout(OCFile folder) {
|
||||
return getFolderPreference(context,
|
||||
currentAccountProvider.getCurrentAccount(),
|
||||
currentAccountProvider.getUser(),
|
||||
PREF__FOLDER_LAYOUT,
|
||||
folder,
|
||||
FOLDER_LAYOUT_LIST);
|
||||
@@ -220,7 +291,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
@Override
|
||||
public void setFolderLayout(OCFile folder, String layout_name) {
|
||||
setFolderPreference(context,
|
||||
currentAccountProvider.getCurrentAccount(),
|
||||
currentAccountProvider.getUser(),
|
||||
PREF__FOLDER_LAYOUT,
|
||||
folder,
|
||||
layout_name);
|
||||
@@ -229,7 +300,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
@Override
|
||||
public FileSortOrder getSortOrderByFolder(OCFile folder) {
|
||||
return FileSortOrder.sortOrders.get(getFolderPreference(context,
|
||||
currentAccountProvider.getCurrentAccount(),
|
||||
currentAccountProvider.getUser(),
|
||||
PREF__FOLDER_SORT_ORDER,
|
||||
folder,
|
||||
FileSortOrder.sort_a_to_z.name));
|
||||
@@ -238,7 +309,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
@Override
|
||||
public void setSortOrder(OCFile folder, FileSortOrder sortOrder) {
|
||||
setFolderPreference(context,
|
||||
currentAccountProvider.getCurrentAccount(),
|
||||
currentAccountProvider.getUser(),
|
||||
PREF__FOLDER_SORT_ORDER,
|
||||
folder,
|
||||
sortOrder.name);
|
||||
@@ -251,28 +322,23 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
|
||||
@Override
|
||||
public FileSortOrder getSortOrderByType(FileSortOrder.Type type, FileSortOrder defaultOrder) {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
if (account == null) {
|
||||
User user = currentAccountProvider.getUser();
|
||||
if (user.isAnonymous()) {
|
||||
return defaultOrder;
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type);
|
||||
String value = dataProvider.getValue(user.getAccountName(), PREF__FOLDER_SORT_ORDER + "_" + type);
|
||||
|
||||
return value.isEmpty() ? defaultOrder : FileSortOrder.sortOrders.get(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortOrder(FileSortOrder.Type type, FileSortOrder sortOrder) {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
|
||||
if (account == null) {
|
||||
throw new IllegalArgumentException("Account may not be null!");
|
||||
}
|
||||
|
||||
User user = currentAccountProvider.getUser();
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
dataProvider.storeOrUpdateKeyValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
|
||||
dataProvider.storeOrUpdateKeyValue(user.getAccountName(), PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,6 +406,21 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDarkThemeMode(DarkMode mode) {
|
||||
preferences.edit().putString(PREF__DARK_THEME, mode.name()).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DarkMode getDarkThemeMode() {
|
||||
try {
|
||||
return DarkMode.valueOf(preferences.getString(PREF__DARK_THEME, DarkMode.LIGHT.name()));
|
||||
} catch (ClassCastException e) {
|
||||
preferences.edit().putString(PREF__DARK_THEME, DarkMode.LIGHT.name()).apply();
|
||||
return DarkMode.DARK;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUploaderBehaviour(int uploaderBehaviour) {
|
||||
preferences.edit().putInt(AUTO_PREF__UPLOADER_BEHAVIOR, uploaderBehaviour).apply();
|
||||
@@ -495,22 +576,22 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
* @return Preference value
|
||||
*/
|
||||
private static String getFolderPreference(final Context context,
|
||||
final Account account,
|
||||
final User user,
|
||||
final String preferenceName,
|
||||
final OCFile folder,
|
||||
final String defaultValue) {
|
||||
if (account == null) {
|
||||
if (user.isAnonymous()) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, folder));
|
||||
String value = dataProvider.getValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder));
|
||||
OCFile prefFolder = folder;
|
||||
while (prefFolder != null && value.isEmpty()) {
|
||||
prefFolder = storageManager.getFileById(prefFolder.getParentId());
|
||||
value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, prefFolder));
|
||||
value = dataProvider.getValue(user.getAccountName(), getKeyFromFolder(preferenceName, prefFolder));
|
||||
}
|
||||
return value.isEmpty() ? defaultValue : value;
|
||||
}
|
||||
@@ -524,16 +605,12 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
* @param value Preference value to set.
|
||||
*/
|
||||
private static void setFolderPreference(final Context context,
|
||||
final Account account,
|
||||
final User user,
|
||||
final String preferenceName,
|
||||
final OCFile folder,
|
||||
final String value) {
|
||||
if (account == null) {
|
||||
throw new IllegalArgumentException("Account may not be null!");
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
dataProvider.storeOrUpdateKeyValue(account.name, getKeyFromFolder(preferenceName, folder), value);
|
||||
dataProvider.storeOrUpdateKeyValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder), value);
|
||||
}
|
||||
|
||||
private static String getKeyFromFolder(String preferenceName, OCFile folder) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2019 Tobias Kaminsky
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.preferences;
|
||||
|
||||
public enum DarkMode {
|
||||
DARK, LIGHT, SYSTEM
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.nextcloud.java.util;
|
||||
|
||||
import com.nextcloud.java.util.function.Predicate;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.core.util.ObjectsCompat;
|
||||
import androidx.core.util.Supplier;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
* This class is backported from Java 8 to be used on older Android API levels.
|
||||
* It uses available interfaces from Kotlin and androidx. It is semantically
|
||||
* identical with Java 8 API, allowing smooth migration when those APIs become
|
||||
* available.
|
||||
*
|
||||
* A container object which may or may not contain a non-null value.
|
||||
* If a value is present, {@code isPresent()} will return {@code true} and
|
||||
* {@code get()} will return the value.
|
||||
*
|
||||
* <p>Additional methods that depend on the presence or absence of a contained
|
||||
* value are provided, such as {@link #orElse(java.lang.Object) orElse()}
|
||||
* (return a default value if value not present) and
|
||||
* {@link #ifPresent(Consumer) ifPresent()} (execute a block
|
||||
* of code if the value is present).
|
||||
*/
|
||||
public final class Optional<T> {
|
||||
/**
|
||||
* Common instance for {@code empty()}.
|
||||
*/
|
||||
private static final Optional<?> EMPTY = new Optional<>();
|
||||
|
||||
/**
|
||||
* If non-null, the value; if null, indicates no value is present
|
||||
*/
|
||||
private final T value;
|
||||
|
||||
/**
|
||||
* Constructs an empty instance.
|
||||
*
|
||||
* @implNote Generally only one empty instance, {@link Optional#EMPTY},
|
||||
* should exist per VM.
|
||||
*/
|
||||
private Optional() {
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty {@code Optional} instance. No value is present for this
|
||||
* Optional.
|
||||
*
|
||||
* @apiNote Though it may be tempting to do so, avoid testing if an object
|
||||
* is empty by comparing with {@code ==} against instances returned by
|
||||
* {@code Option.empty()}. There is no guarantee that it is a singleton.
|
||||
* Instead, use {@link #isPresent()}.
|
||||
*
|
||||
* @param <T> Type of the non-existent value
|
||||
* @return an empty {@code Optional}
|
||||
*/
|
||||
public static<T> Optional<T> empty() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Optional<T> t = (Optional<T>) EMPTY;
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance with the value present.
|
||||
*
|
||||
* @param value the non-null value to be present
|
||||
* @throws NullPointerException if value is null
|
||||
*/
|
||||
private Optional(T value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@code Optional} with the specified present non-null value.
|
||||
*
|
||||
* @param <T> the class of the value
|
||||
* @param value the value to be present, which must be non-null
|
||||
* @return an {@code Optional} with the value present
|
||||
* @throws NullPointerException if value is null
|
||||
*/
|
||||
public static <T> Optional<T> of(T value) {
|
||||
return new Optional<>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@code Optional} describing the specified value, if non-null,
|
||||
* otherwise returns an empty {@code Optional}.
|
||||
*
|
||||
* @param <T> the class of the value
|
||||
* @param value the possibly-null value to describe
|
||||
* @return an {@code Optional} with a present value if the specified value
|
||||
* is non-null, otherwise an empty {@code Optional}
|
||||
*/
|
||||
public static <T> Optional<T> ofNullable(T value) {
|
||||
return value == null ? empty() : of(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a value is present in this {@code Optional}, returns the value,
|
||||
* otherwise throws {@code NoSuchElementException}.
|
||||
*
|
||||
* @return the non-null value held by this {@code Optional}
|
||||
* @throws NoSuchElementException if there is no value present
|
||||
*
|
||||
* @see Optional#isPresent()
|
||||
*/
|
||||
public T get() {
|
||||
if (value == null) {
|
||||
throw new NoSuchElementException("No value present");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if there is a value present, otherwise {@code false}.
|
||||
*
|
||||
* @return {@code true} if there is a value present, otherwise {@code false}
|
||||
*/
|
||||
public boolean isPresent() {
|
||||
return value != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a value is present, invoke the specified consumer with the value,
|
||||
* otherwise do nothing.
|
||||
*
|
||||
* @param consumer block to be executed if a value is present
|
||||
* @throws NullPointerException if value is present and {@code consumer} is
|
||||
* null
|
||||
*/
|
||||
public void ifPresent(Consumer<? super T> consumer) {
|
||||
if (value != null) {
|
||||
consumer.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a value is present, and the value matches the given predicate,
|
||||
* return an {@code Optional} describing the value, otherwise return an
|
||||
* empty {@code Optional}.
|
||||
*
|
||||
* @param predicate a predicate to apply to the value, if present
|
||||
* @return an {@code Optional} describing the value of this {@code Optional}
|
||||
* if a value is present and the value matches the given predicate,
|
||||
* otherwise an empty {@code Optional}
|
||||
* @throws NullPointerException if the predicate is null
|
||||
*/
|
||||
public Optional<T> filter(Predicate<? super T> predicate) {
|
||||
if (predicate == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!isPresent()) {
|
||||
return this;
|
||||
} else {
|
||||
return predicate.test(value) ? this : empty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a value is present, apply the provided mapping function to it,
|
||||
* and if the result is non-null, return an {@code Optional} describing the
|
||||
* result. Otherwise return an empty {@code Optional}.
|
||||
*
|
||||
* @apiNote This method supports post-processing on optional values, without
|
||||
* the need to explicitly check for a return status. For example, the
|
||||
* following code traverses a stream of file names, selects one that has
|
||||
* not yet been processed, and then opens that file, returning an
|
||||
* {@code Optional<FileInputStream>}:
|
||||
*
|
||||
* <pre>{@code
|
||||
* Optional<FileInputStream> fis =
|
||||
* names.stream().filter(name -> !isProcessedYet(name))
|
||||
* .findFirst()
|
||||
* .map(name -> new FileInputStream(name));
|
||||
* }</pre>
|
||||
*
|
||||
* Here, {@code findFirst} returns an {@code Optional<String>}, and then
|
||||
* {@code map} returns an {@code Optional<FileInputStream>} for the desired
|
||||
* file if one exists.
|
||||
*
|
||||
* @param <U> The type of the result of the mapping function
|
||||
* @param mapper a mapping function to apply to the value, if present
|
||||
* @return an {@code Optional} describing the result of applying a mapping
|
||||
* function to the value of this {@code Optional}, if a value is present,
|
||||
* otherwise an empty {@code Optional}
|
||||
* @throws NullPointerException if the mapping function is null
|
||||
*/
|
||||
public<U> Optional<U> map(Function1<? super T, ? extends U> mapper) {
|
||||
if (mapper == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!isPresent()) {
|
||||
return empty();
|
||||
} else {
|
||||
return Optional.ofNullable(mapper.invoke(value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a value is present, apply the provided {@code Optional}-bearing
|
||||
* mapping function to it, return that result, otherwise return an empty
|
||||
* {@code Optional}. This method is similar to {@link #map(Function1)},
|
||||
* but the provided mapper is one whose result is already an {@code Optional},
|
||||
* and if invoked, {@code flatMap} does not wrap it with an additional
|
||||
* {@code Optional}.
|
||||
*
|
||||
* @param <U> The type parameter to the {@code Optional} returned by
|
||||
* @param mapper a mapping function to apply to the value, if present
|
||||
* the mapping function
|
||||
* @return the result of applying an {@code Optional}-bearing mapping
|
||||
* function to the value of this {@code Optional}, if a value is present,
|
||||
* otherwise an empty {@code Optional}
|
||||
* @throws NullPointerException if the mapping function is null or returns
|
||||
* a null result
|
||||
*/
|
||||
public<U> Optional<U> flatMap(Function1<? super T, Optional<U>> mapper) {
|
||||
if(mapper == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!isPresent()) {
|
||||
return empty();
|
||||
} else {
|
||||
Optional<U> u = mapper.invoke(value);
|
||||
if (u == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return u;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value if present, otherwise return {@code other}.
|
||||
*
|
||||
* @param other the value to be returned if there is no value present, may
|
||||
* be null
|
||||
* @return the value, if present, otherwise {@code other}
|
||||
*/
|
||||
public T orElse(T other) {
|
||||
return value != null ? value : other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value if present, otherwise invoke {@code other} and return
|
||||
* the result of that invocation.
|
||||
*
|
||||
* @param other a {@code Supplier} whose result is returned if no value
|
||||
* is present
|
||||
* @return the value if present otherwise the result of {@code other.get()}
|
||||
* @throws NullPointerException if value is not present and {@code other} is
|
||||
* null
|
||||
*/
|
||||
public T orElseGet(Supplier<? extends T> other) {
|
||||
return value != null ? value : other.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the contained value, if present, otherwise throw an exception
|
||||
* to be created by the provided supplier.
|
||||
*
|
||||
* @apiNote A method reference to the exception constructor with an empty
|
||||
* argument list can be used as the supplier. For example,
|
||||
* {@code IllegalStateException::new}
|
||||
*
|
||||
* @param <X> Type of the exception to be thrown
|
||||
* @param exceptionSupplier The supplier which will return the exception to
|
||||
* be thrown
|
||||
* @return the present value
|
||||
* @throws X if there is no value present
|
||||
* @throws NullPointerException if no value is present and
|
||||
* {@code exceptionSupplier} is null
|
||||
*/
|
||||
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
||||
if (value != null) {
|
||||
return value;
|
||||
} else {
|
||||
throw exceptionSupplier.get();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether some other object is "equal to" this Optional. The
|
||||
* other object is considered equal if:
|
||||
* <ul>
|
||||
* <li>it is also an {@code Optional} and;
|
||||
* <li>both instances have no value present or;
|
||||
* <li>the present values are "equal to" each other via {@code equals()}.
|
||||
* </ul>
|
||||
*
|
||||
* @param obj an object to be tested for equality
|
||||
* @return {code true} if the other object is "equal to" this object
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Optional)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<?> other = (Optional<?>) obj;
|
||||
return ObjectsCompat.equals(value, other.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value of the present value, if any, or 0 (zero) if
|
||||
* no value is present.
|
||||
*
|
||||
* @return hash code value of the present value or 0 if no value is present
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectsCompat.hashCode(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a non-empty string representation of this Optional suitable for
|
||||
* debugging. The exact presentation format is unspecified and may vary
|
||||
* between implementations and versions.
|
||||
*
|
||||
* @implSpec If a value is present the result must include its string
|
||||
* representation in the result. Empty and present Optionals must be
|
||||
* unambiguously differentiable.
|
||||
*
|
||||
* @return the string representation of this instance
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return value != null
|
||||
? String.format("Optional[%s]", value)
|
||||
: "Optional.empty";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.nextcloud.java.util.function;
|
||||
|
||||
/**
|
||||
* This class is backported from Java 8 to be used on older Android API levels.
|
||||
*
|
||||
* Represents a predicate (boolean-valued function) of one argument.
|
||||
*
|
||||
* <p>This is a <a href="package-summary.html">functional interface</a>
|
||||
* whose functional method is {@link #test(Object)}.
|
||||
*
|
||||
* @param <T> the type of the input to the predicate
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Predicate<T> {
|
||||
|
||||
/**
|
||||
* Evaluates this predicate on the given argument.
|
||||
*
|
||||
* @param t the input argument
|
||||
* @return {@code true} if the input argument matches the predicate,
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
boolean test(T t);
|
||||
|
||||
/**
|
||||
* Returns a composed predicate that represents a short-circuiting logical
|
||||
* AND of this predicate and another. When evaluating the composed
|
||||
* predicate, if this predicate is {@code false}, then the {@code other}
|
||||
* predicate is not evaluated.
|
||||
*
|
||||
* <p>Any exceptions thrown during evaluation of either predicate are relayed
|
||||
* to the caller; if evaluation of this predicate throws an exception, the
|
||||
* {@code other} predicate will not be evaluated.
|
||||
*
|
||||
* @param other a predicate that will be logically-ANDed with this
|
||||
* predicate
|
||||
* @return a composed predicate that represents the short-circuiting logical
|
||||
* AND of this predicate and the {@code other} predicate
|
||||
* @throws NullPointerException if other is null
|
||||
*/
|
||||
default Predicate<T> and(Predicate<? super T> other) {
|
||||
if (other == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return (t) -> test(t) && other.test(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that represents the logical negation of this
|
||||
* predicate.
|
||||
*
|
||||
* @return a predicate that represents the logical negation of this
|
||||
* predicate
|
||||
*/
|
||||
default Predicate<T> negate() {
|
||||
return (t) -> !test(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed predicate that represents a short-circuiting logical
|
||||
* OR of this predicate and another. When evaluating the composed
|
||||
* predicate, if this predicate is {@code true}, then the {@code other}
|
||||
* predicate is not evaluated.
|
||||
*
|
||||
* <p>Any exceptions thrown during evaluation of either predicate are relayed
|
||||
* to the caller; if evaluation of this predicate throws an exception, the
|
||||
* {@code other} predicate will not be evaluated.
|
||||
*
|
||||
* @param other a predicate that will be logically-ORed with this
|
||||
* predicate
|
||||
* @return a composed predicate that represents the short-circuiting logical
|
||||
* OR of this predicate and the {@code other} predicate
|
||||
* @throws NullPointerException if other is null
|
||||
*/
|
||||
default Predicate<T> or(Predicate<? super T> other) {
|
||||
if (other == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return (t) -> test(t) || other.test(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that tests if two arguments are equal according
|
||||
* to {@link androidx.core.util.ObjectsCompat#equals(Object, Object)}.
|
||||
*
|
||||
* @param <T> the type of arguments to the predicate
|
||||
* @param targetRef the object reference with which to compare for equality,
|
||||
* which may be {@code null}
|
||||
* @return a predicate that tests if two arguments are equal according
|
||||
* to {@link androidx.core.util.ObjectsCompat#equals(Object, Object)}
|
||||
*/
|
||||
static <T> Predicate<T> isEqual(Object targetRef) {
|
||||
return (null == targetRef)
|
||||
? object -> object == null
|
||||
: object -> targetRef.equals(object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2019 Chris Narkiewicz
|
||||
* Copyright (C) 2019 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a compatibility package providing some backported Java 8 classes
|
||||
* not available in some older Android runtimes.
|
||||
*/
|
||||
package com.nextcloud.java.util;
|
||||
@@ -45,6 +45,7 @@ import com.evernote.android.job.JobManager;
|
||||
import com.evernote.android.job.JobRequest;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.appinfo.AppInfo;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.di.ActivityInjector;
|
||||
import com.nextcloud.client.di.DaggerAppComponent;
|
||||
@@ -56,6 +57,7 @@ import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.onboarding.OnboardingService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.owncloud.android.authentication.PassCodeManager;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.MediaFolder;
|
||||
@@ -100,6 +102,7 @@ import javax.net.ssl.SSLEngine;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
import dagger.android.AndroidInjector;
|
||||
@@ -160,6 +163,9 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
@Inject
|
||||
BackgroundJobManager backgroundJobManager;
|
||||
|
||||
@Inject
|
||||
Clock clock;
|
||||
|
||||
private PassCodeManager passCodeManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -242,6 +248,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
@SuppressFBWarnings("ST")
|
||||
@Override
|
||||
public void onCreate() {
|
||||
setAppTheme(preferences.getDarkThemeMode());
|
||||
super.onCreate();
|
||||
|
||||
insertConscrypt();
|
||||
@@ -266,7 +273,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
preferences,
|
||||
uploadsStorageManager,
|
||||
connectivityService,
|
||||
powerManagementService
|
||||
powerManagementService,
|
||||
clock
|
||||
)
|
||||
);
|
||||
|
||||
@@ -302,7 +310,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
accountManager,
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
backgroundJobManager);
|
||||
backgroundJobManager,
|
||||
clock);
|
||||
initContactsBackup(accountManager);
|
||||
notificationChannels();
|
||||
|
||||
@@ -460,23 +469,24 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
final UserAccountManager accountManager,
|
||||
final ConnectivityService connectivityService,
|
||||
final PowerManagementService powerManagementService,
|
||||
final BackgroundJobManager jobManager
|
||||
final BackgroundJobManager jobManager,
|
||||
final Clock clock
|
||||
) {
|
||||
updateToAutoUpload();
|
||||
cleanOldEntries();
|
||||
updateAutoUploadEntries();
|
||||
cleanOldEntries(clock);
|
||||
updateAutoUploadEntries(clock);
|
||||
|
||||
if (getAppContext() != null) {
|
||||
if (PermissionUtil.checkSelfPermission(getAppContext(),
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
splitOutAutoUploadEntries();
|
||||
splitOutAutoUploadEntries(clock);
|
||||
} else {
|
||||
AppPreferences preferences = AppPreferencesImpl.fromContext(getAppContext());
|
||||
preferences.setAutoUploadSplitEntriesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
initiateExistingAutoUploadEntries();
|
||||
initiateExistingAutoUploadEntries(clock);
|
||||
|
||||
FilesSyncHelper.scheduleFilesSyncIfNeeded(mContext, jobManager);
|
||||
FilesSyncHelper.restartJobsIfNeeded(
|
||||
@@ -571,6 +581,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
// dummy change
|
||||
|
||||
|
||||
public static Context getAppContext() {
|
||||
return MainApp.mContext;
|
||||
@@ -683,18 +695,18 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAutoUploadEntries() {
|
||||
private static void updateAutoUploadEntries(Clock clock) {
|
||||
// updates entries to reflect their true paths
|
||||
Context context = getAppContext();
|
||||
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
|
||||
if (!preferences.isAutoUploadPathsUpdateEnabled()) {
|
||||
SyncedFolderProvider syncedFolderProvider =
|
||||
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences);
|
||||
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences, clock);
|
||||
syncedFolderProvider.updateAutoUploadPaths(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
private static void splitOutAutoUploadEntries() {
|
||||
private static void splitOutAutoUploadEntries(Clock clock) {
|
||||
Context context = getAppContext();
|
||||
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
|
||||
if (!preferences.isAutoUploadSplitEntriesEnabled()) {
|
||||
@@ -703,7 +715,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
Log_OC.i(TAG, "Migrate synced_folders records for image/video split");
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences);
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences, clock);
|
||||
|
||||
final List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true);
|
||||
final List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true);
|
||||
@@ -749,12 +761,12 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initiateExistingAutoUploadEntries() {
|
||||
private static void initiateExistingAutoUploadEntries(Clock clock) {
|
||||
new Thread(() -> {
|
||||
AppPreferences preferences = AppPreferencesImpl.fromContext(getAppContext());
|
||||
if (!preferences.isAutoUploadInitialized()) {
|
||||
SyncedFolderProvider syncedFolderProvider =
|
||||
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences);
|
||||
new SyncedFolderProvider(MainApp.getAppContext().getContentResolver(), preferences, clock);
|
||||
|
||||
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
|
||||
if (syncedFolder.isEnabled()) {
|
||||
@@ -768,7 +780,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}).start();
|
||||
}
|
||||
|
||||
private static void cleanOldEntries() {
|
||||
private static void cleanOldEntries(Clock clock) {
|
||||
// previous versions of application created broken entries in the SyncedFolderProvider
|
||||
// database, and this cleans all that and leaves 1 (newest) entry per synced folder
|
||||
|
||||
@@ -777,7 +789,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
|
||||
if (!preferences.isLegacyClean()) {
|
||||
SyncedFolderProvider syncedFolderProvider =
|
||||
new SyncedFolderProvider(context.getContentResolver(), preferences);
|
||||
new SyncedFolderProvider(context.getContentResolver(), preferences, clock);
|
||||
|
||||
List<SyncedFolder> syncedFolderList = syncedFolderProvider.getSyncedFolders();
|
||||
Map<Pair<String, String>, Long> syncedFolders = new HashMap<>();
|
||||
@@ -811,4 +823,18 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
return dispatchingAndroidInjector;
|
||||
}
|
||||
|
||||
|
||||
public static void setAppTheme(DarkMode mode) {
|
||||
switch (mode) {
|
||||
case LIGHT:
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
break;
|
||||
case DARK:
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
break;
|
||||
case SYSTEM:
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.blikoon.qrcodescanner.QrCodeActivity;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.device.DeviceInfo;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
@@ -402,12 +403,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
setClient(progressBar);
|
||||
|
||||
// show snackbar after 60s to switch back to old login method
|
||||
if (showLegacyLogin) {
|
||||
if (showLegacyLogin && getResources().getBoolean(R.bool.show_old_login)) {
|
||||
final String finalBaseURL = baseURL;
|
||||
new Handler().postDelayed(() -> DisplayUtils.createSnackbar(mLoginWebView,
|
||||
R.string.fallback_weblogin_text,
|
||||
Snackbar.LENGTH_INDEFINITE)
|
||||
.setActionTextColor(getResources().getColor(R.color.white))
|
||||
.setActionTextColor(getResources().getColor(R.color.themed_fg))
|
||||
.setBackgroundTint(getResources().getColor(R.color.themed_bg))
|
||||
.setTextColor(getResources().getColor(R.color.themed_fg))
|
||||
.setAction(R.string.fallback_weblogin_back, v -> {
|
||||
mLoginWebView.setVisibility(View.INVISIBLE);
|
||||
webViewLoginMethod = false;
|
||||
@@ -1733,8 +1736,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
/// add the new account as default in preferences, if there is none already
|
||||
Account defaultAccount = accountManager.getCurrentAccount();
|
||||
if (defaultAccount == null) {
|
||||
User defaultAccount = accountManager.getUser();
|
||||
if (defaultAccount.isAnonymous()) {
|
||||
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
|
||||
editor.putString("select_oc_account", accountName);
|
||||
editor.apply();
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -102,7 +103,7 @@ public final class PassCodeManager {
|
||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
||||
} else {
|
||||
if (!askedForPin && preferences.getLockTimestamp() != 0) {
|
||||
preferences.setLockTimestamp(System.currentTimeMillis());
|
||||
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ public final class PassCodeManager {
|
||||
}
|
||||
|
||||
private boolean passCodeShouldBeRequested(Long timestamp) {
|
||||
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT &&
|
||||
return (SystemClock.elapsedRealtime() - timestamp) > PASS_CODE_TIMEOUT &&
|
||||
visibleActivitiesCounter <= 0 && isPassCodeEnabled();
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ public final class PassCodeManager {
|
||||
}
|
||||
|
||||
private boolean deviceCredentialsShouldBeRequested(Long timestamp, Activity activity) {
|
||||
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT && visibleActivitiesCounter <= 0 &&
|
||||
return (SystemClock.elapsedRealtime() - timestamp) > PASS_CODE_TIMEOUT && visibleActivitiesCounter <= 0 &&
|
||||
deviceCredentialsAreEnabled(activity);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -1259,8 +1257,8 @@ public class FileDataStorageManager {
|
||||
|
||||
private void resetShareFlagsInAllFiles() {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
@@ -1279,8 +1277,8 @@ public class FileDataStorageManager {
|
||||
|
||||
private void resetShareFlagsInFolder(OCFile folder) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PARENT + "=?";
|
||||
String[] whereArgs = new String[]{account.name, String.valueOf(folder.getFileId())};
|
||||
@@ -1299,8 +1297,8 @@ public class FileDataStorageManager {
|
||||
|
||||
private void resetShareFlagInAFile(String filePath) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{account.name, filePath};
|
||||
@@ -1970,7 +1968,7 @@ public class FileDataStorageManager {
|
||||
return capability;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
private ContentValues createContentValues(String accountName, OCCapability capability) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, accountName);
|
||||
|
||||
@@ -37,7 +37,9 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -51,11 +53,11 @@ public final class MediaProvider {
|
||||
private static final Uri IMAGES_MEDIA_URI = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
private static final String[] FILE_PROJECTION = new String[]{MediaStore.MediaColumns.DATA};
|
||||
private static final String IMAGES_FILE_SELECTION = MediaStore.Images.Media.BUCKET_ID + "=";
|
||||
private static final String[] IMAGES_FOLDER_PROJECTION = {"Distinct " + MediaStore.Images.Media.BUCKET_ID,
|
||||
private static final String[] IMAGES_FOLDER_PROJECTION = {MediaStore.Images.Media.BUCKET_ID,
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
|
||||
private static final String IMAGES_FOLDER_SORT_ORDER = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " ASC";
|
||||
|
||||
private static final String[] VIDEOS_FOLDER_PROJECTION = {"Distinct " + MediaStore.Video.Media.BUCKET_ID,
|
||||
private static final String[] VIDEOS_FOLDER_PROJECTION = {MediaStore.Video.Media.BUCKET_ID,
|
||||
MediaStore.Video.Media.BUCKET_DISPLAY_NAME};
|
||||
|
||||
private MediaProvider() {
|
||||
@@ -86,28 +88,35 @@ public final class MediaProvider {
|
||||
String dataPath = MainApp.getStoragePath() + File.separator + MainApp.getDataFolder();
|
||||
|
||||
if (cursorFolders != null) {
|
||||
String folderName;
|
||||
String fileSortOrder = MediaStore.Images.Media.DATE_TAKEN + " DESC LIMIT " + itemLimit;
|
||||
Cursor cursorImages;
|
||||
|
||||
while (cursorFolders.moveToNext()) {
|
||||
String folderId = cursorFolders.getString(cursorFolders.getColumnIndex(MediaStore.Images.Media
|
||||
.BUCKET_ID));
|
||||
Map<String, String> uniqueFolders = new HashMap<>();
|
||||
|
||||
// since sdk 29 we have to manually distinct on bucket id
|
||||
while (cursorFolders.moveToNext()) {
|
||||
uniqueFolders.put(cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Images.Media.BUCKET_ID)),
|
||||
cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME))
|
||||
);
|
||||
}
|
||||
cursorFolders.close();
|
||||
|
||||
for (Map.Entry<String, String> folder : uniqueFolders.entrySet()) {
|
||||
MediaFolder mediaFolder = new MediaFolder();
|
||||
folderName = cursorFolders.getString(cursorFolders.getColumnIndex(
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
|
||||
|
||||
mediaFolder.type = MediaFolderType.IMAGE;
|
||||
mediaFolder.folderName = folderName;
|
||||
mediaFolder.folderName = folder.getValue();
|
||||
mediaFolder.filePaths = new ArrayList<>();
|
||||
|
||||
// query images
|
||||
cursorImages = contentResolver.query(
|
||||
IMAGES_MEDIA_URI,
|
||||
FILE_PROJECTION,
|
||||
IMAGES_FILE_SELECTION + folderId,
|
||||
null,
|
||||
fileSortOrder
|
||||
IMAGES_MEDIA_URI,
|
||||
FILE_PROJECTION,
|
||||
IMAGES_FILE_SELECTION + folder.getKey(),
|
||||
null,
|
||||
fileSortOrder
|
||||
);
|
||||
Log.d(TAG, "Reading images for " + mediaFolder.folderName);
|
||||
|
||||
@@ -116,7 +125,7 @@ public final class MediaProvider {
|
||||
|
||||
while (cursorImages.moveToNext()) {
|
||||
filePath = cursorImages.getString(cursorImages.getColumnIndexOrThrow(
|
||||
MediaStore.MediaColumns.DATA));
|
||||
MediaStore.MediaColumns.DATA));
|
||||
|
||||
// check if valid path and file exists
|
||||
if (isValidAndExistingFilePath(filePath)) {
|
||||
@@ -131,11 +140,11 @@ public final class MediaProvider {
|
||||
|
||||
// count images
|
||||
Cursor count = contentResolver.query(
|
||||
IMAGES_MEDIA_URI,
|
||||
FILE_PROJECTION,
|
||||
IMAGES_FILE_SELECTION + folderId,
|
||||
null,
|
||||
null);
|
||||
IMAGES_MEDIA_URI,
|
||||
FILE_PROJECTION,
|
||||
IMAGES_FILE_SELECTION + folder.getKey(),
|
||||
null,
|
||||
null);
|
||||
|
||||
if (count != null) {
|
||||
mediaFolder.numberOfFiles = count.getCount();
|
||||
@@ -146,7 +155,6 @@ public final class MediaProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
cursorFolders.close();
|
||||
}
|
||||
|
||||
return mediaFolders;
|
||||
@@ -203,31 +211,38 @@ public final class MediaProvider {
|
||||
String fileSortOrder = MediaStore.Video.Media.DATE_TAKEN + " DESC LIMIT " + itemLimit;
|
||||
Cursor cursorVideos;
|
||||
|
||||
while (cursorFolders.moveToNext()) {
|
||||
String folderId = cursorFolders.getString(cursorFolders.getColumnIndex(MediaStore.Video.Media
|
||||
.BUCKET_ID));
|
||||
Map<String, String> uniqueFolders = new HashMap<>();
|
||||
|
||||
// since sdk 29 we have to manually distinct on bucket id
|
||||
while (cursorFolders.moveToNext()) {
|
||||
uniqueFolders.put(cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Video.Media.BUCKET_ID)),
|
||||
cursorFolders.getString(
|
||||
cursorFolders.getColumnIndex(MediaStore.Video.Media.BUCKET_DISPLAY_NAME))
|
||||
);
|
||||
}
|
||||
cursorFolders.close();
|
||||
|
||||
for (Map.Entry<String, String> folder : uniqueFolders.entrySet()) {
|
||||
MediaFolder mediaFolder = new MediaFolder();
|
||||
folderName = cursorFolders.getString(cursorFolders.getColumnIndex(
|
||||
MediaStore.Video.Media.BUCKET_DISPLAY_NAME));
|
||||
mediaFolder.type = MediaFolderType.VIDEO;
|
||||
mediaFolder.folderName = folderName;
|
||||
mediaFolder.folderName = folder.getValue();
|
||||
mediaFolder.filePaths = new ArrayList<>();
|
||||
|
||||
// query videos
|
||||
cursorVideos = contentResolver.query(
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
FILE_PROJECTION,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folderId,
|
||||
null,
|
||||
fileSortOrder);
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
FILE_PROJECTION,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folder.getKey(),
|
||||
null,
|
||||
fileSortOrder);
|
||||
Log.d(TAG, "Reading videos for " + mediaFolder.folderName);
|
||||
|
||||
if (cursorVideos != null) {
|
||||
String filePath;
|
||||
while (cursorVideos.moveToNext()) {
|
||||
filePath = cursorVideos.getString(cursorVideos.getColumnIndexOrThrow(
|
||||
MediaStore.MediaColumns.DATA));
|
||||
MediaStore.MediaColumns.DATA));
|
||||
|
||||
if (filePath != null) {
|
||||
mediaFolder.filePaths.add(filePath);
|
||||
@@ -241,11 +256,11 @@ public final class MediaProvider {
|
||||
|
||||
// count images
|
||||
Cursor count = contentResolver.query(
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
FILE_PROJECTION,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folderId,
|
||||
null,
|
||||
null);
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
FILE_PROJECTION,
|
||||
MediaStore.Video.Media.BUCKET_ID + "=" + folder.getKey(),
|
||||
null,
|
||||
null);
|
||||
|
||||
if (count != null) {
|
||||
mediaFolder.numberOfFiles = count.getCount();
|
||||
|
||||
@@ -155,6 +155,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
favorite = source.readInt() == 1;
|
||||
encrypted = source.readInt() == 1;
|
||||
encryptedFileName = source.readString();
|
||||
ownerId = source.readString();
|
||||
ownerDisplayName = source.readString();
|
||||
mountType = (WebdavEntry.MountType) source.readSerializable();
|
||||
}
|
||||
|
||||
@@ -185,6 +187,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
dest.writeInt(favorite ? 1 : 0);
|
||||
dest.writeInt(encrypted ? 1 : 0);
|
||||
dest.writeString(encryptedFileName);
|
||||
dest.writeString(ownerId);
|
||||
dest.writeString(ownerDisplayName);
|
||||
dest.writeSerializable(mountType);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,30 +23,29 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Synced folder entity containing all information per synced folder.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class SyncedFolder implements Serializable, Cloneable {
|
||||
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
|
||||
public static final long EMPTY_ENABLED_TIMESTAMP_MS = -1;
|
||||
private static final long serialVersionUID = -793476118299906429L;
|
||||
|
||||
private long id = UNPERSISTED_ID;
|
||||
private String localPath;
|
||||
private String remotePath;
|
||||
private Boolean wifiOnly;
|
||||
private Boolean chargingOnly;
|
||||
private Boolean subfolderByDate;
|
||||
private String account;
|
||||
private Integer uploadAction;
|
||||
private boolean enabled;
|
||||
private MediaFolderType type;
|
||||
@Getter @Setter private long id;
|
||||
@Getter @Setter private String localPath;
|
||||
@Getter @Setter private String remotePath;
|
||||
@Getter @Setter private boolean wifiOnly;
|
||||
@Getter @Setter private boolean chargingOnly;
|
||||
@Getter @Setter private boolean subfolderByDate;
|
||||
@Getter @Setter private String account;
|
||||
@Getter @Setter private int uploadAction;
|
||||
@Getter private boolean enabled;
|
||||
@Getter private long enabledTimestampMs;
|
||||
@Getter @Setter private MediaFolderType type;
|
||||
@Getter @Setter private boolean hidden;
|
||||
|
||||
/**
|
||||
* constructor for new, to be persisted entity.
|
||||
@@ -59,11 +58,43 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
* @param enabled flag if synced folder config is active
|
||||
* @param timestampMs the current timestamp in milliseconds
|
||||
* @param type the type of the folder
|
||||
* @param hidden hide item flag
|
||||
*/
|
||||
public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
MediaFolderType type) {
|
||||
public SyncedFolder(String localPath,
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
boolean enabled,
|
||||
long timestampMs,
|
||||
MediaFolderType type,
|
||||
boolean hidden) {
|
||||
this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction,
|
||||
enabled, timestampMs, type, hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor for wrapping existing folders.
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
protected SyncedFolder(long id,
|
||||
String localPath,
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
boolean enabled,
|
||||
long timestampMs,
|
||||
MediaFolderType type,
|
||||
boolean hidden) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.remotePath = remotePath;
|
||||
this.wifiOnly = wifiOnly;
|
||||
@@ -71,8 +102,17 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
this.subfolderByDate = subfolderByDate;
|
||||
this.account = account;
|
||||
this.uploadAction = uploadAction;
|
||||
this.enabled = enabled;
|
||||
this.setEnabled(enabled, timestampMs);
|
||||
this.type = type;
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timestampMs the current timestamp in milliseconds
|
||||
*/
|
||||
public void setEnabled(boolean enabled, long timestampMs) {
|
||||
this.enabled = enabled;
|
||||
this.enabledTimestampMs = enabled ? timestampMs : EMPTY_ENABLED_TIMESTAMP_MS;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
|
||||
@@ -53,21 +53,43 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
* @param folderName the UI info for the folder's name
|
||||
* @param numberOfFiles the UI info for number of files within the folder
|
||||
* @param type the type of the folder
|
||||
* @param hidden hide item flag
|
||||
*/
|
||||
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
List<String> filePaths, String folderName, long numberOfFiles, MediaFolderType type)
|
||||
{
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
|
||||
public SyncedFolderDisplayItem(long id,
|
||||
String localPath,
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
boolean enabled,
|
||||
long timestampMs,
|
||||
List<String> filePaths,
|
||||
String folderName,
|
||||
long numberOfFiles,
|
||||
MediaFolderType type,
|
||||
boolean hidden) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
|
||||
timestampMs, type, hidden);
|
||||
this.filePaths = filePaths;
|
||||
this.folderName = folderName;
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
}
|
||||
|
||||
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
String folderName, MediaFolderType type) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
|
||||
public SyncedFolderDisplayItem(long id,
|
||||
String localPath,
|
||||
String remotePath,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean subfolderByDate,
|
||||
String account,
|
||||
int uploadAction,
|
||||
boolean enabled,
|
||||
long timestampMs,
|
||||
String folderName, MediaFolderType type, boolean hidden) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
|
||||
timestampMs, type, hidden);
|
||||
this.folderName = folderName;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
@@ -47,20 +48,22 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
|
||||
public class SyncedFolderProvider extends Observable {
|
||||
static private final String TAG = SyncedFolderProvider.class.getSimpleName();
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
private AppPreferences preferences;
|
||||
private final ContentResolver mContentResolver;
|
||||
private final AppPreferences preferences;
|
||||
private final Clock clock;
|
||||
|
||||
/**
|
||||
* constructor.
|
||||
*
|
||||
* @param contentResolver the ContentResolver to work with.
|
||||
*/
|
||||
public SyncedFolderProvider(ContentResolver contentResolver, AppPreferences preferences) {
|
||||
public SyncedFolderProvider(ContentResolver contentResolver, AppPreferences preferences, Clock clock) {
|
||||
if (contentResolver == null) {
|
||||
throw new IllegalArgumentException("Cannot create an instance with a NULL contentResolver");
|
||||
}
|
||||
mContentResolver = contentResolver;
|
||||
this.preferences = preferences;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +165,7 @@ public class SyncedFolderProvider extends Observable {
|
||||
// read sync folder object and update
|
||||
SyncedFolder syncedFolder = createSyncedFolderFromCursor(cursor);
|
||||
|
||||
syncedFolder.setEnabled(enabled);
|
||||
syncedFolder.setEnabled(enabled, clock.getCurrentTime());
|
||||
|
||||
// update sync folder object in db
|
||||
result = updateSyncFolder(syncedFolder);
|
||||
@@ -335,23 +338,27 @@ public class SyncedFolderProvider extends Observable {
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH));
|
||||
String remotePath = cursor.getString(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH));
|
||||
Boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY)) == 1;
|
||||
Boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY)) == 1;
|
||||
Boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE)) == 1;
|
||||
String accountName = cursor.getString(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT));
|
||||
Integer uploadAction = cursor.getInt(cursor.getColumnIndex(
|
||||
int uploadAction = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
|
||||
Boolean enabled = cursor.getInt(cursor.getColumnIndex(
|
||||
boolean enabled = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
|
||||
long enabledTimestampMs = cursor.getLong(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS));
|
||||
MediaFolderType type = MediaFolderType.getById(cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
|
||||
boolean hidden = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;
|
||||
|
||||
syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
|
||||
accountName, uploadAction, enabled, type);
|
||||
accountName, uploadAction, enabled, enabledTimestampMs, type, hidden);
|
||||
}
|
||||
return syncedFolder;
|
||||
}
|
||||
@@ -367,13 +374,15 @@ public class SyncedFolderProvider extends Observable {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH, syncedFolder.getLocalPath());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH, syncedFolder.getRemotePath());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.getWifiOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.getChargingOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.isWifiOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.isChargingOnly());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE, syncedFolder.getType().getId());
|
||||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.isHidden());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -76,6 +75,7 @@ import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
@@ -868,7 +868,7 @@ public final class ThumbnailsCacheManager {
|
||||
return Math.round(r.getDimension(R.dimen.file_avatar_size));
|
||||
}
|
||||
|
||||
private @NotNull
|
||||
private @NonNull
|
||||
Drawable doAvatarInBackground() {
|
||||
Bitmap avatar;
|
||||
|
||||
@@ -1173,7 +1173,8 @@ public final class ThumbnailsCacheManager {
|
||||
Bitmap resultBitmap = Bitmap.createBitmap(pxW, pxH, Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(resultBitmap);
|
||||
|
||||
c.drawColor(MainApp.getAppContext().getResources().getColor(R.color.background_color));
|
||||
// TODO check based on https://github.com/nextcloud/android/pull/3459#discussion_r339935975
|
||||
c.drawColor(MainApp.getAppContext().getResources().getColor(R.color.background_color_png));
|
||||
c.drawBitmap(bitmap, 0, 0, null);
|
||||
|
||||
return resultBitmap;
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
import com.owncloud.android.db.UploadResult;
|
||||
@@ -345,24 +346,19 @@ public class UploadsStorageManager extends Observable {
|
||||
}
|
||||
|
||||
public OCUpload[] getCurrentAndPendingUploadsForCurrentAccount() {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
User user = currentAccountProvider.getUser();
|
||||
|
||||
if (account != null) {
|
||||
return getUploads(
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.LOCK_FAILED.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
" AND " + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
account.name);
|
||||
} else {
|
||||
return new OCUpload[0];
|
||||
}
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.LOCK_FAILED.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
" AND " + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
user.getAccountName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,14 +380,10 @@ public class UploadsStorageManager extends Observable {
|
||||
}
|
||||
|
||||
public OCUpload[] getFinishedUploadsForCurrentAccount() {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
User user = currentAccountProvider.getUser();
|
||||
|
||||
if (account != null) {
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", account.name);
|
||||
} else {
|
||||
return new OCUpload[0];
|
||||
}
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", user.getAccountName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,23 +395,19 @@ public class UploadsStorageManager extends Observable {
|
||||
}
|
||||
|
||||
public OCUpload[] getFailedButNotDelayedUploadsForCurrentAccount() {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
User user = currentAccountProvider.getUser();
|
||||
|
||||
if (account != null) {
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.LOCK_FAILED.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
account.name);
|
||||
} else {
|
||||
return new OCUpload[0];
|
||||
}
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.LOCK_FAILED.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
user.getAccountName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,50 +434,41 @@ public class UploadsStorageManager extends Observable {
|
||||
}
|
||||
|
||||
public long clearFailedButNotDelayedUploads() {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
|
||||
long result = 0;
|
||||
if (account != null) {
|
||||
result = getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.LOCK_FAILED.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
new String[]{account.name}
|
||||
);
|
||||
}
|
||||
|
||||
User user = currentAccountProvider.getUser();
|
||||
final long deleted = getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.LOCK_FAILED.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
new String[]{user.getAccountName()}
|
||||
);
|
||||
Log_OC.d(TAG, "delete all failed uploads but those delayed for Wifi");
|
||||
if (result > 0) {
|
||||
if (deleted > 0) {
|
||||
notifyObserversNow();
|
||||
}
|
||||
return result;
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public long clearSuccessfulUploads() {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
|
||||
long result = 0;
|
||||
if (account != null) {
|
||||
result = getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{account.name}
|
||||
);
|
||||
}
|
||||
User user = currentAccountProvider.getUser();
|
||||
final long deleted = getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{user.getAccountName()}
|
||||
);
|
||||
|
||||
Log_OC.d(TAG, "delete all successful uploads");
|
||||
if (result > 0) {
|
||||
if (deleted > 0) {
|
||||
notifyObserversNow();
|
||||
}
|
||||
return result;
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
|
||||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 49;
|
||||
public static final int DB_VERSION = 51;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
@@ -220,10 +220,12 @@ public class ProviderMeta {
|
||||
public static final String SYNCED_FOLDER_WIFI_ONLY = "wifi_only";
|
||||
public static final String SYNCED_FOLDER_CHARGING_ONLY = "charging_only";
|
||||
public static final String SYNCED_FOLDER_ENABLED = "enabled";
|
||||
public static final String SYNCED_FOLDER_ENABLED_TIMESTAMP_MS = "enabled_timestamp_ms";
|
||||
public static final String SYNCED_FOLDER_TYPE = "type";
|
||||
public static final String SYNCED_FOLDER_SUBFOLDER_BY_DATE = "subfolder_by_date";
|
||||
public static final String SYNCED_FOLDER_ACCOUNT = "account";
|
||||
public static final String SYNCED_FOLDER_UPLOAD_ACTION = "upload_option";
|
||||
public static final String SYNCED_FOLDER_HIDDEN = "hidden";
|
||||
|
||||
// Columns of external links table
|
||||
public static final String EXTERNAL_LINKS_ICON_URL = "icon_url";
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
@@ -53,6 +54,7 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
|
||||
@Inject ConnectivityService connectivityService;
|
||||
@Inject PowerManagementService powerManagementService;
|
||||
@Inject BackgroundJobManager backgroundJobManager;
|
||||
@Inject Clock clock;
|
||||
|
||||
/**
|
||||
* Receives broadcast intent reporting that the system was just boot up.
|
||||
@@ -69,7 +71,8 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
|
||||
accountManager,
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
backgroundJobManager);
|
||||
backgroundJobManager,
|
||||
clock);
|
||||
MainApp.initContactsBackup(accountManager);
|
||||
} else {
|
||||
Log_OC.d(TAG, "Getting wrong intent: " + intent.getAction());
|
||||
|
||||
@@ -76,8 +76,6 @@ import com.owncloud.android.ui.notifications.NotificationUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.AbstractList;
|
||||
import java.util.HashMap;
|
||||
@@ -396,10 +394,10 @@ public class FileUploader extends Service
|
||||
public void retryFailedUploads(
|
||||
@NonNull final Context context,
|
||||
@Nullable final Account account,
|
||||
@NotNull final UploadsStorageManager uploadsStorageManager,
|
||||
@NotNull final ConnectivityService connectivityService,
|
||||
@NotNull final UserAccountManager accountManager,
|
||||
@NotNull final PowerManagementService powerManagementService,
|
||||
@NonNull final UploadsStorageManager uploadsStorageManager,
|
||||
@NonNull final ConnectivityService connectivityService,
|
||||
@NonNull final UserAccountManager accountManager,
|
||||
@NonNull final PowerManagementService powerManagementService,
|
||||
@Nullable final UploadResult uploadResult
|
||||
) {
|
||||
OCUpload[] failedUploads = uploadsStorageManager.getFailedUploads();
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.google.gson.Gson;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
@@ -57,18 +58,16 @@ import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
|
||||
import com.owncloud.android.ui.events.AccountRemovedEvent;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.PushUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
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;
|
||||
@@ -81,17 +80,19 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
public static final String ACCOUNT = "account";
|
||||
public static final String REMOTE_WIPE = "remote_wipe";
|
||||
|
||||
private UploadsStorageManager uploadsStorageManager;
|
||||
private UserAccountManager userAccountManager;
|
||||
private final UploadsStorageManager uploadsStorageManager;
|
||||
private final UserAccountManager userAccountManager;
|
||||
private final Clock clock;
|
||||
|
||||
public AccountRemovalJob(UploadsStorageManager uploadStorageManager, UserAccountManager accountManager) {
|
||||
public AccountRemovalJob(UploadsStorageManager uploadStorageManager, UserAccountManager accountManager, Clock clock) {
|
||||
this.uploadsStorageManager = uploadStorageManager;
|
||||
this.userAccountManager = accountManager;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Result onRunJob(@NotNull Params params) {
|
||||
protected Result onRunJob(@NonNull Params params) {
|
||||
Context context = MainApp.getAppContext();
|
||||
PersistableBundleCompat bundle = params.getExtras();
|
||||
Account account = userAccountManager.getAccountByName(bundle.getString(ACCOUNT, ""));
|
||||
@@ -129,7 +130,7 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
arbitraryDataProvider.deleteKeyForAccount(account.name, PENDING_FOR_REMOVAL);
|
||||
|
||||
// remove synced folders set for account
|
||||
remoceSyncedFolders(context, account, arbitraryDataProvider);
|
||||
remoceSyncedFolders(context, account, clock);
|
||||
|
||||
// delete all uploads for account
|
||||
uploadsStorageManager.removeAccountUploads(account);
|
||||
@@ -174,17 +175,16 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
}
|
||||
}
|
||||
|
||||
private void remoceSyncedFolders(Context context, Account account, ArbitraryDataProvider arbitraryDataProvider) {
|
||||
private void remoceSyncedFolders(Context context, Account account, Clock clock) {
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(context.getContentResolver(),
|
||||
AppPreferencesImpl.fromContext(context));
|
||||
AppPreferencesImpl.fromContext(context),
|
||||
clock);
|
||||
List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
|
||||
|
||||
List<Long> syncedFolderIds = new ArrayList<>();
|
||||
|
||||
for (SyncedFolder syncedFolder : syncedFolders) {
|
||||
if (syncedFolder.getAccount().equals(account.name)) {
|
||||
arbitraryDataProvider.deleteKeyForAccount(FilesSyncHelper.GLOBAL,
|
||||
FilesSyncHelper.SYNCEDFOLDERINITIATED + syncedFolder.getId());
|
||||
syncedFolderIds.add(syncedFolder.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.text.TextUtils;
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
@@ -76,22 +77,25 @@ public class FilesSyncJob extends Job {
|
||||
public static final String OVERRIDE_POWER_SAVING = "overridePowerSaving";
|
||||
private static final String WAKELOCK_TAG_SEPARATION = ":";
|
||||
|
||||
private UserAccountManager userAccountManager;
|
||||
private AppPreferences preferences;
|
||||
private UploadsStorageManager uploadsStorageManager;
|
||||
private ConnectivityService connectivityService;
|
||||
private PowerManagementService powerManagementService;
|
||||
private final UserAccountManager userAccountManager;
|
||||
private final AppPreferences preferences;
|
||||
private final UploadsStorageManager uploadsStorageManager;
|
||||
private final ConnectivityService connectivityService;
|
||||
private final PowerManagementService powerManagementService;
|
||||
private final Clock clock;
|
||||
|
||||
FilesSyncJob(final UserAccountManager userAccountManager,
|
||||
final AppPreferences preferences,
|
||||
final UploadsStorageManager uploadsStorageManager,
|
||||
final ConnectivityService connectivityService,
|
||||
final PowerManagementService powerManagementService) {
|
||||
final PowerManagementService powerManagementService,
|
||||
final Clock clock) {
|
||||
this.userAccountManager = userAccountManager;
|
||||
this.preferences = preferences;
|
||||
this.uploadsStorageManager = uploadsStorageManager;
|
||||
this.connectivityService = connectivityService;
|
||||
this.powerManagementService = powerManagementService;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -126,13 +130,12 @@ public class FilesSyncJob extends Job {
|
||||
userAccountManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
FilesSyncHelper.insertAllDBEntries(preferences, skipCustom);
|
||||
FilesSyncHelper.insertAllDBEntries(preferences, clock, skipCustom);
|
||||
|
||||
// Create all the providers we'll need
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
final FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver,
|
||||
preferences);
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences, clock);
|
||||
|
||||
Locale currentLocale = context.getResources().getConfiguration().locale;
|
||||
SimpleDateFormat sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale);
|
||||
@@ -189,10 +192,10 @@ public class FilesSyncJob extends Job {
|
||||
|
||||
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
|
||||
} else {
|
||||
needsCharging = syncedFolder.getChargingOnly();
|
||||
needsWifi = syncedFolder.getWifiOnly();
|
||||
needsCharging = syncedFolder.isChargingOnly();
|
||||
needsWifi = syncedFolder.isWifiOnly();
|
||||
uploadAction = syncedFolder.getUploadAction();
|
||||
subfolderByDate = syncedFolder.getSubfolderByDate();
|
||||
subfolderByDate = syncedFolder.isSubfolderByDate();
|
||||
remotePath = syncedFolder.getRemotePath();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.text.TextUtils;
|
||||
import com.evernote.android.job.Job;
|
||||
import com.google.gson.Gson;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.R;
|
||||
@@ -74,11 +75,13 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
|
||||
private static final String DISABLE_DETECTION_CLICK = "DISABLE_DETECTION_CLICK";
|
||||
|
||||
private UserAccountManager userAccountManager;
|
||||
private Random randomId = new Random();
|
||||
private final UserAccountManager userAccountManager;
|
||||
private final Clock clock;
|
||||
private final Random randomId = new Random();
|
||||
|
||||
MediaFoldersDetectionJob(UserAccountManager accountManager) {
|
||||
MediaFoldersDetectionJob(UserAccountManager accountManager, Clock clock) {
|
||||
this.userAccountManager = accountManager;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -88,7 +91,8 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(contentResolver);
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver,
|
||||
AppPreferencesImpl.fromContext(context));
|
||||
AppPreferencesImpl.fromContext(context),
|
||||
clock);
|
||||
Gson gson = new Gson();
|
||||
String arbitraryDataString;
|
||||
MediaFoldersModel mediaFoldersModel;
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.content.Context;
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.JobCreator;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
@@ -48,6 +49,7 @@ public class NCJobCreator implements JobCreator {
|
||||
private final UploadsStorageManager uploadsStorageManager;
|
||||
private final ConnectivityService connectivityService;
|
||||
private final PowerManagementService powerManagementService;
|
||||
private final Clock clock;
|
||||
|
||||
public NCJobCreator(
|
||||
Context context,
|
||||
@@ -55,7 +57,8 @@ public class NCJobCreator implements JobCreator {
|
||||
AppPreferences preferences,
|
||||
UploadsStorageManager uploadsStorageManager,
|
||||
ConnectivityService connectivityServices,
|
||||
PowerManagementService powerManagementService
|
||||
PowerManagementService powerManagementService,
|
||||
Clock clock
|
||||
) {
|
||||
this.context = context;
|
||||
this.accountManager = accountManager;
|
||||
@@ -63,6 +66,7 @@ public class NCJobCreator implements JobCreator {
|
||||
this.uploadsStorageManager = uploadsStorageManager;
|
||||
this.connectivityService = connectivityServices;
|
||||
this.powerManagementService = powerManagementService;
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,19 +77,20 @@ public class NCJobCreator implements JobCreator {
|
||||
case ContactsImportJob.TAG:
|
||||
return new ContactsImportJob();
|
||||
case AccountRemovalJob.TAG:
|
||||
return new AccountRemovalJob(uploadsStorageManager, accountManager);
|
||||
return new AccountRemovalJob(uploadsStorageManager, accountManager, clock);
|
||||
case FilesSyncJob.TAG:
|
||||
return new FilesSyncJob(accountManager,
|
||||
preferences,
|
||||
uploadsStorageManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
powerManagementService,
|
||||
clock);
|
||||
case OfflineSyncJob.TAG:
|
||||
return new OfflineSyncJob(accountManager, connectivityService, powerManagementService);
|
||||
case NotificationJob.TAG:
|
||||
return new NotificationJob(context, accountManager);
|
||||
case MediaFoldersDetectionJob.TAG:
|
||||
return new MediaFoldersDetectionJob(accountManager);
|
||||
return new MediaFoldersDetectionJob(accountManager, clock);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,6 @@ public class NotificationJob extends Job {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, context);
|
||||
OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(ocAccount, context);
|
||||
client.setOwnCloudVersion(accountManager.getServerVersion(currentAccount));
|
||||
|
||||
RemoteOperationResult result = new GetNotificationRemoteOperation(decryptedPushMessage.nid)
|
||||
.execute(client);
|
||||
@@ -306,7 +305,6 @@ public class NotificationJob extends Job {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, context);
|
||||
OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(ocAccount, context);
|
||||
client.setOwnCloudVersion(accountManager.getServerVersion(currentAccount));
|
||||
|
||||
String actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE);
|
||||
String actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK);
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
|
||||
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -119,7 +120,7 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
|
||||
Log_OC.d(TAG, "Authentication method found: " + authenticationMethodToString(authMethod));
|
||||
|
||||
if (authMethod != AuthenticationMethod.UNKNOWN) {
|
||||
result = new RemoteOperationResult(true, result.getHttpCode(), result.getHttpPhrase(), null);
|
||||
result = new RemoteOperationResult(true, result.getHttpCode(), result.getHttpPhrase(), new Header[0]);
|
||||
}
|
||||
ArrayList<Object> data = new ArrayList<>();
|
||||
data.add(authMethod);
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.OpenableColumns;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -61,8 +62,8 @@ public class DiskLruImageCacheFileProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private OCFile getFile(Uri uri) {
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account,
|
||||
User user = accountManager.getUser();
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
MainApp.getAppContext().getContentResolver());
|
||||
|
||||
return fileDataStorageManager.getFileByPath(uri.getPath());
|
||||
|
||||
@@ -42,9 +42,11 @@ import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.SyncedFolder;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
@@ -58,7 +60,10 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import dagger.android.AndroidInjection;
|
||||
|
||||
/**
|
||||
* The ContentProvider for the ownCloud App.
|
||||
@@ -91,6 +96,7 @@ public class FileContentProvider extends ContentProvider {
|
||||
public static final int ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION = 20;
|
||||
public static final int MINIMUM_PATH_SEGMENTS_SIZE = 1;
|
||||
|
||||
@Inject protected Clock clock;
|
||||
private DataBaseHelper mDbHelper;
|
||||
private Context mContext;
|
||||
private UriMatcher mUriMatcher;
|
||||
@@ -414,6 +420,7 @@ public class FileContentProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
AndroidInjection.inject(this);
|
||||
mDbHelper = new DataBaseHelper(getContext());
|
||||
mContext = getContext();
|
||||
|
||||
@@ -822,10 +829,12 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY + " INTEGER, " // wifi_only
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY + " INTEGER, " // charging only
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, " // enabled
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " INTEGER, " // enable date
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " TEXT, " // account
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER, " // upload action
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER );" // type
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER, " // type
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_HIDDEN + " INTEGER );" // hidden
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2013,6 +2022,48 @@ public class FileContentProvider extends ContentProvider {
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 50 && newVersion >= 50) {
|
||||
Log_OC.i(SQL, "Entering in the #50 add persistent enable date to synced_folders table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " INTEGER ");
|
||||
|
||||
db.execSQL("UPDATE " + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME + " SET " +
|
||||
ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS + " = CASE " +
|
||||
" WHEN enabled = 0 THEN " + SyncedFolder.EMPTY_ENABLED_TIMESTAMP_MS + " " +
|
||||
" ELSE " + clock.getCurrentTime() +
|
||||
" END ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 51 && newVersion >= 51) {
|
||||
Log_OC.i(SQL, "Entering in the #51 add show/hide to folderSync table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_HIDDEN + " INTEGER ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.os.Looper;
|
||||
import android.provider.BaseColumns;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -180,18 +181,14 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
// need to trust on the AccountUtils to get the current account since the query in the client side is not
|
||||
// directly started by our code, but from SearchView implementation
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
|
||||
if (account == null) {
|
||||
throw new IllegalArgumentException("Account may not be null!");
|
||||
}
|
||||
User user = accountManager.getUser();
|
||||
|
||||
String userQuery = lastPathSegment.toLowerCase(Locale.ROOT);
|
||||
|
||||
// request to the OC server about users and groups matching userQuery
|
||||
GetShareesRemoteOperation searchRequest = new GetShareesRemoteOperation(userQuery, REQUESTED_PAGE,
|
||||
RESULTS_PER_PAGE);
|
||||
RemoteOperationResult result = searchRequest.execute(account, getContext());
|
||||
RemoteOperationResult result = searchRequest.execute(user.toPlatformAccount(), getContext());
|
||||
List<JSONObject> names = new ArrayList<>();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
@@ -217,8 +214,10 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
Uri remoteBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_REMOTE).build();
|
||||
Uri emailBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_EMAIL).build();
|
||||
|
||||
FileDataStorageManager manager = new FileDataStorageManager(account, getContext().getContentResolver());
|
||||
boolean federatedShareAllowed = manager.getCapability(account.name).getFilesSharingFederationOutgoing()
|
||||
FileDataStorageManager manager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
getContext().getContentResolver());
|
||||
boolean federatedShareAllowed = manager.getCapability(user.getAccountName())
|
||||
.getFilesSharingFederationOutgoing()
|
||||
.isTrue();
|
||||
|
||||
try {
|
||||
|
||||
@@ -37,7 +37,6 @@ import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
@@ -51,7 +50,6 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.RestoreFileVersionRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.FileVersion;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation;
|
||||
import com.owncloud.android.operations.CheckCurrentCredentialsOperation;
|
||||
import com.owncloud.android.operations.CopyFileOperation;
|
||||
@@ -76,8 +74,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.AndroidInjection;
|
||||
|
||||
public class OperationsService extends Service {
|
||||
@@ -137,8 +133,6 @@ public class OperationsService extends Service {
|
||||
private ConcurrentMap<Integer, Pair<RemoteOperation, RemoteOperationResult>>
|
||||
mUndispatchedFinishedOperations = new ConcurrentHashMap<>();
|
||||
|
||||
@Inject UserAccountManager accountManager;
|
||||
|
||||
private static class Target {
|
||||
public Uri mServerUrl;
|
||||
public Account mAccount;
|
||||
@@ -164,7 +158,7 @@ public class OperationsService extends Service {
|
||||
HandlerThread thread = new HandlerThread("Operations thread",
|
||||
Process.THREAD_PRIORITY_BACKGROUND);
|
||||
thread.start();
|
||||
mOperationsHandler = new ServiceHandler(thread.getLooper(), this, accountManager);
|
||||
mOperationsHandler = new ServiceHandler(thread.getLooper(), this);
|
||||
mOperationsBinder = new OperationsServiceBinder(mOperationsHandler);
|
||||
|
||||
// Separated worker thread for download of folders (WIP)
|
||||
@@ -400,16 +394,14 @@ public class OperationsService extends Service {
|
||||
private Target mLastTarget;
|
||||
private OwnCloudClient mOwnCloudClient;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private UserAccountManager accountManager;
|
||||
|
||||
|
||||
public ServiceHandler(Looper looper, OperationsService service, UserAccountManager accountManager) {
|
||||
public ServiceHandler(Looper looper, OperationsService service) {
|
||||
super(looper);
|
||||
if (service == null) {
|
||||
throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
|
||||
}
|
||||
mService = service;
|
||||
this.accountManager = accountManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -443,9 +435,6 @@ public class OperationsService extends Service {
|
||||
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, mService);
|
||||
|
||||
OwnCloudVersion version = accountManager.getServerVersion(mLastTarget.mAccount);
|
||||
mOwnCloudClient.setOwnCloudVersion(version);
|
||||
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
mLastTarget.mAccount,
|
||||
mService.getContentResolver()
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.view.View;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
||||
public class RadioButtonPreference extends CheckBoxPreference implements View.OnLongClickListener {
|
||||
|
||||
public RadioButtonPreference(Context context) {
|
||||
super(context, null, android.R.attr.checkBoxPreferenceStyle);
|
||||
setWidgetLayoutResource(R.layout.preference_widget_radiobutton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -23,16 +23,15 @@ package com.owncloud.android.ui;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
|
||||
|
||||
@@ -57,12 +56,11 @@ public class ThemeableSwitchPreference extends SwitchPreference {
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
|
||||
if (view instanceof ViewGroup && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
if (view instanceof ViewGroup) {
|
||||
findSwitch((ViewGroup) view);
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
private void findSwitch(ViewGroup viewGroup) {
|
||||
ColorStateList thumbColorStateList = null;
|
||||
ColorStateList trackColorStateList = null;
|
||||
@@ -76,12 +74,14 @@ public class ThemeableSwitchPreference extends SwitchPreference {
|
||||
if(thumbColorStateList == null && trackColorStateList == null) {
|
||||
int color = ThemeUtils.primaryAccentColor(getContext());
|
||||
int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color));
|
||||
int trackColorUnchecked = getContext().getResources().getColor(R.color.switch_track_color_unchecked);
|
||||
thumbColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{color, Color.WHITE});
|
||||
trackColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{trackColor, Color.parseColor("#4D000000")});
|
||||
new int[][]{new int[]{android.R.attr.state_checked},
|
||||
new int[]{}},
|
||||
new int[]{trackColor, trackColorUnchecked});
|
||||
}
|
||||
|
||||
// setting the thumb color
|
||||
|
||||
@@ -29,10 +29,10 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.activities.model.RichObject;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
@@ -169,7 +169,8 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
||||
adapter = new ActivityListAdapter(this, getUserAccountManager(), this, storageManager, getCapabilities(), false);
|
||||
adapter = new ActivityListAdapter(this, getUserAccountManager(), this, storageManager,
|
||||
getCapabilities(), false);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
@@ -237,7 +238,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showActivities(List<Object> activities, OwnCloudClient client, int lastGiven) {
|
||||
public void showActivities(List<Object> activities, NextcloudClient client, int lastGiven) {
|
||||
boolean clear = false;
|
||||
if (this.lastGiven == UNDEFINED) {
|
||||
clear = true;
|
||||
@@ -247,12 +248,8 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
||||
|
||||
// Hide the recyclerView if list is empty
|
||||
if (adapter.isEmpty()) {
|
||||
showEmptyContent(noResultsHeadline, noResultsMessage);
|
||||
recyclerView.setVisibility(View.INVISIBLE);
|
||||
|
||||
emptyContentMessage.setText(noResultsMessage);
|
||||
emptyContentHeadline.setText(noResultsHeadline);
|
||||
emptyContentMessage.setVisibility(View.VISIBLE);
|
||||
emptyContentHeadline.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
emptyContentMessage.setVisibility(View.INVISIBLE);
|
||||
emptyContentHeadline.setVisibility(View.INVISIBLE);
|
||||
@@ -307,6 +304,9 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
||||
|
||||
emptyContentProgressBar.setVisibility(View.GONE);
|
||||
emptyContentIcon.setVisibility(View.VISIBLE);
|
||||
emptyContentHeadline.setVisibility(View.VISIBLE);
|
||||
emptyContentMessage.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.ui.activity.BaseActivity;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
public interface ActivitiesContract {
|
||||
|
||||
interface View {
|
||||
void showActivities(List<Object> activities, OwnCloudClient client, int lastGiven);
|
||||
void showActivities(List<Object> activities, NextcloudClient client, int lastGiven);
|
||||
void showActivitiesLoadError(String error);
|
||||
void showActivityDetailUI(OCFile ocFile);
|
||||
void showActivityDetailUIIsNull();
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package com.owncloud.android.ui.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
|
||||
import com.owncloud.android.ui.activities.data.files.FilesRepository;
|
||||
import com.owncloud.android.ui.activity.BaseActivity;
|
||||
@@ -51,7 +51,7 @@ public class ActivitiesPresenter implements ActivitiesContract.ActionListener {
|
||||
activitiesView.setProgressIndicatorState(true);
|
||||
activitiesRepository.getActivities(lastGiven, new ActivitiesRepository.LoadActivitiesCallback() {
|
||||
@Override
|
||||
public void onActivitiesLoaded(List<Object> activities, OwnCloudClient client, int lastGiven) {
|
||||
public void onActivitiesLoaded(List<Object> activities, NextcloudClient client, int lastGiven) {
|
||||
|
||||
if (!activityStopped) {
|
||||
activitiesView.setProgressIndicatorState(false);
|
||||
|
||||
@@ -99,7 +99,6 @@ public class StickyHeaderItemDecoration extends RecyclerView.ItemDecoration {
|
||||
int headerPosition = adapter.getHeaderPositionForItem(itemPosition);
|
||||
int layoutId = adapter.getHeaderLayout(itemPosition);
|
||||
View header = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
|
||||
header.setBackgroundColor(Color.WHITE);
|
||||
adapter.bindHeaderData(header, headerPosition);
|
||||
return header;
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.activities;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,7 +29,7 @@ import androidx.annotation.NonNull;
|
||||
*/
|
||||
public interface ActivitiesRepository {
|
||||
interface LoadActivitiesCallback {
|
||||
void onActivitiesLoaded(List<Object> activities, OwnCloudClient client, int lastGiven);
|
||||
void onActivitiesLoaded(List<Object> activities, NextcloudClient client, int lastGiven);
|
||||
void onActivitiesLoadedError(String error);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.activities;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.lib.resources.activities.model.Activity;
|
||||
|
||||
import java.util.List;
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
public interface ActivitiesServiceApi {
|
||||
|
||||
interface ActivitiesServiceCallback<T> {
|
||||
void onLoaded(T activities, OwnCloudClient client, int lastGiven);
|
||||
void onLoaded(T activities, NextcloudClient client, int lastGiven);
|
||||
void onError (String error);
|
||||
}
|
||||
|
||||
|
||||
+9
-12
@@ -29,10 +29,10 @@ import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -58,8 +58,9 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
|
||||
@Override
|
||||
public void getAllActivities(int lastGiven, ActivitiesServiceCallback<List<Object>> callback) {
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
GetActivityListTask getActivityListTask = new GetActivityListTask(account, accountManager, lastGiven, callback);
|
||||
GetActivityListTask getActivityListTask = new GetActivityListTask(accountManager.getUser().toPlatformAccount(),
|
||||
lastGiven,
|
||||
callback);
|
||||
getActivityListTask.execute();
|
||||
}
|
||||
|
||||
@@ -68,17 +69,14 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
private final ActivitiesServiceCallback<List<Object>> callback;
|
||||
private List<Object> activities;
|
||||
private Account account;
|
||||
private UserAccountManager accountManager;
|
||||
private int lastGiven;
|
||||
private String errorMessage;
|
||||
private OwnCloudClient ownCloudClient;
|
||||
private NextcloudClient client;
|
||||
|
||||
private GetActivityListTask(Account account,
|
||||
UserAccountManager accountManager,
|
||||
int lastGiven,
|
||||
ActivitiesServiceCallback<List<Object>> callback) {
|
||||
this.account = account;
|
||||
this.accountManager = accountManager;
|
||||
this.lastGiven = lastGiven;
|
||||
this.callback = callback;
|
||||
activities = new ArrayList<>();
|
||||
@@ -91,9 +89,8 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
OwnCloudAccount ocAccount;
|
||||
try {
|
||||
ocAccount = new OwnCloudAccount(account, context);
|
||||
ownCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, MainApp.getAppContext());
|
||||
ownCloudClient.setOwnCloudVersion(accountManager.getServerVersion(account));
|
||||
client = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getNextcloudClientFor(ocAccount, MainApp.getAppContext());
|
||||
|
||||
GetActivitiesRemoteOperation getRemoteActivitiesOperation;
|
||||
if (lastGiven > 0) {
|
||||
@@ -102,7 +99,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
getRemoteActivitiesOperation = new GetActivitiesRemoteOperation();
|
||||
}
|
||||
|
||||
final RemoteOperationResult result = getRemoteActivitiesOperation.execute(ownCloudClient);
|
||||
final RemoteOperationResult result = getRemoteActivitiesOperation.execute(client);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
final ArrayList<Object> data = result.getData();
|
||||
@@ -141,7 +138,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
protected void onPostExecute(Boolean success) {
|
||||
super.onPostExecute(success);
|
||||
if (success) {
|
||||
callback.onLoaded(activities, ownCloudClient, lastGiven);
|
||||
callback.onLoaded(activities, client, lastGiven);
|
||||
} else {
|
||||
callback.onError(errorMessage);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.activities;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RemoteActivitiesRepository implements ActivitiesRepository {
|
||||
activitiesServiceApi.getAllActivities(lastGiven,
|
||||
new ActivitiesServiceApi.ActivitiesServiceCallback<List<Object>>() {
|
||||
@Override
|
||||
public void onLoaded(List<Object> activities, OwnCloudClient client, int lastGiven) {
|
||||
public void onLoaded(List<Object> activities, NextcloudClient client, int lastGiven) {
|
||||
callback.onActivitiesLoaded(activities, client, lastGiven);
|
||||
}
|
||||
|
||||
|
||||
+19
-32
@@ -22,19 +22,16 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.files;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -44,8 +41,6 @@ import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.ui.activity.BaseActivity;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Implementation of the Files service API that communicates with the NextCloud remote server.
|
||||
*/
|
||||
@@ -54,15 +49,18 @@ public class FilesServiceApiImpl implements FilesServiceApi {
|
||||
private static final String TAG = FilesServiceApiImpl.class.getSimpleName();
|
||||
|
||||
private UserAccountManager accountManager;
|
||||
private ClientFactory clientFactory;
|
||||
|
||||
public FilesServiceApiImpl(UserAccountManager accountManager) {
|
||||
public FilesServiceApiImpl(UserAccountManager accountManager, ClientFactory clientFactory) {
|
||||
this.accountManager = accountManager;
|
||||
this.clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readRemoteFile(String fileUrl, BaseActivity activity, FilesServiceCallback<OCFile> callback) {
|
||||
ReadRemoteFileTask readRemoteFileTask = new ReadRemoteFileTask(
|
||||
accountManager,
|
||||
clientFactory,
|
||||
fileUrl,
|
||||
activity,
|
||||
callback
|
||||
@@ -77,30 +75,28 @@ public class FilesServiceApiImpl implements FilesServiceApi {
|
||||
// TODO: Figure out a better way to do this than passing a BaseActivity reference.
|
||||
private final BaseActivity baseActivity;
|
||||
private final String fileUrl;
|
||||
private final Account account;
|
||||
private final User user;
|
||||
private final UserAccountManager accountManager;
|
||||
private final ClientFactory clientFactory;
|
||||
|
||||
private ReadRemoteFileTask(UserAccountManager accountManager,
|
||||
ClientFactory clientFactory,
|
||||
String fileUrl,
|
||||
BaseActivity baseActivity,
|
||||
FilesServiceCallback<OCFile> callback) {
|
||||
this.callback = callback;
|
||||
this.baseActivity = baseActivity;
|
||||
this.fileUrl = fileUrl;
|
||||
this.account = accountManager.getCurrentAccount();
|
||||
this.user = accountManager.getUser();
|
||||
this.accountManager = accountManager;
|
||||
this.clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
final Context context = MainApp.getAppContext();
|
||||
OwnCloudAccount ocAccount;
|
||||
OwnCloudClient ownCloudClient;
|
||||
try {
|
||||
ocAccount = new OwnCloudAccount(account, context);
|
||||
ownCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, MainApp.getAppContext());
|
||||
ownCloudClient.setOwnCloudVersion(accountManager.getServerVersion(account));
|
||||
OwnCloudClient ownCloudClient = clientFactory.create(user);
|
||||
// always update file as it could be an old state saved in database
|
||||
RemoteOperationResult resultRemoteFileOp = new ReadFileRemoteOperation(fileUrl).execute(ownCloudClient);
|
||||
|
||||
@@ -111,28 +107,19 @@ public class FilesServiceApiImpl implements FilesServiceApi {
|
||||
if (remoteOcFile.isFolder()) {
|
||||
// perform folder synchronization
|
||||
RemoteOperation synchFolderOp = new RefreshFolderOperation(remoteOcFile,
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
true,
|
||||
baseActivity.getStorageManager(),
|
||||
baseActivity.getAccount(),
|
||||
context);
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
true,
|
||||
baseActivity.getStorageManager(),
|
||||
baseActivity.getAccount(),
|
||||
context);
|
||||
synchFolderOp.execute(ownCloudClient);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
||||
} catch (ClientFactory.CreationException e) {
|
||||
Log_OC.e(TAG, "Account not found", e);
|
||||
errorMessage = baseActivity.getString(R.string.account_not_found);
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "IO error", e);
|
||||
errorMessage = baseActivity.getString(R.string.io_error);
|
||||
} catch (OperationCanceledException e) {
|
||||
Log_OC.e(TAG, "Operation has been canceled", e);
|
||||
errorMessage = baseActivity.getString(R.string.operation_canceled);
|
||||
} catch (AuthenticatorException e) {
|
||||
Log_OC.e(TAG, "Authentication Exception", e);
|
||||
errorMessage = baseActivity.getString(R.string.authentication_exception);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -8,9 +8,14 @@ import android.accounts.OperationCanceledException;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PersistableBundle;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
@@ -19,43 +24,93 @@ import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* Base activity with common behaviour for activities dealing with ownCloud {@link Account}s .
|
||||
*/
|
||||
public abstract class BaseActivity extends AppCompatActivity implements Injectable {
|
||||
|
||||
private static final String TAG = BaseActivity.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* ownCloud {@link Account} where the main {@link OCFile} handled by the activity is located.
|
||||
*/
|
||||
private Account mCurrentAccount;
|
||||
private Account currentAccount;
|
||||
|
||||
/**
|
||||
* Capabilities of the server where {@link #mCurrentAccount} lives.
|
||||
* Capabilities of the server where {@link #currentAccount} lives.
|
||||
*/
|
||||
private OCCapability mCapabilities;
|
||||
private OCCapability capabilities;
|
||||
|
||||
/**
|
||||
* Access point to the cached database for the current ownCloud {@link Account}.
|
||||
*/
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private FileDataStorageManager storageManager;
|
||||
|
||||
/**
|
||||
* Tracks whether the activity should be recreate()'d after a theme change
|
||||
*/
|
||||
private boolean themeChangePending;
|
||||
private boolean paused;
|
||||
|
||||
@Inject UserAccountManager accountManager;
|
||||
@Inject AppPreferences preferences;
|
||||
|
||||
private AppPreferences.Listener onPreferencesChanged = new AppPreferences.Listener() {
|
||||
@Override
|
||||
public void onDarkThemeModeChanged(DarkMode mode) {
|
||||
onThemeSettingsModeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public UserAccountManager getUserAccountManager() {
|
||||
return accountManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
preferences.addListener(onPreferencesChanged);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
preferences.removeListener(onPreferencesChanged);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
paused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
paused = false;
|
||||
|
||||
if (themeChangePending) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
setAccount(account, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
Log_OC.v(TAG, "onNewIntent() start");
|
||||
Account current = accountManager.getCurrentAccount();
|
||||
if (current != null && mCurrentAccount != null && !mCurrentAccount.name.equals(current.name)) {
|
||||
mCurrentAccount = current;
|
||||
if (current != null && currentAccount != null && !currentAccount.name.equals(current.name)) {
|
||||
currentAccount = current;
|
||||
}
|
||||
Log_OC.v(TAG, "onNewIntent() stop");
|
||||
}
|
||||
@@ -68,13 +123,21 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
protected void onRestart() {
|
||||
Log_OC.v(TAG, "onRestart() start");
|
||||
super.onRestart();
|
||||
boolean validAccount = mCurrentAccount != null && accountManager.exists(mCurrentAccount);
|
||||
boolean validAccount = currentAccount != null && accountManager.exists(currentAccount);
|
||||
if (!validAccount) {
|
||||
swapToDefaultAccount();
|
||||
}
|
||||
Log_OC.v(TAG, "onRestart() end");
|
||||
}
|
||||
|
||||
private void onThemeSettingsModeChanged() {
|
||||
if (paused) {
|
||||
themeChangePending = true;
|
||||
} else {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets and validates the ownCloud {@link Account} associated to the Activity.
|
||||
*
|
||||
@@ -87,10 +150,19 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
protected void setAccount(Account account, boolean savedAccount) {
|
||||
boolean validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name);
|
||||
if (validAccount) {
|
||||
mCurrentAccount = account;
|
||||
currentAccount = account;
|
||||
} else {
|
||||
swapToDefaultAccount();
|
||||
}
|
||||
|
||||
if(currentAccount != null) {
|
||||
storageManager = new FileDataStorageManager(currentAccount, getContentResolver());
|
||||
capabilities = storageManager.getCapability(currentAccount.name);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUser(User user) {
|
||||
setAccount(user.toPlatformAccount(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +178,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
/// no account available: force account creation
|
||||
createAccount(true);
|
||||
} else {
|
||||
mCurrentAccount = newAccount;
|
||||
currentAccount = newAccount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,26 +199,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
new Handler());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the ownCloud {@link Account} associated to the Activity was just updated.
|
||||
*
|
||||
* Child classes must grant that state depending on the {@link Account} is updated.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void onAccountSet() {
|
||||
if (getAccount() != null) {
|
||||
mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
|
||||
mCapabilities = mStorageManager.getCapability(mCurrentAccount.name);
|
||||
} else {
|
||||
Log_OC.e(TAG, "onAccountChanged was called with NULL account associated!");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void setAccount(Account account) {
|
||||
mCurrentAccount = account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the capabilities of the server where the current OC account lives.
|
||||
*
|
||||
@@ -154,7 +206,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
* set yet.
|
||||
*/
|
||||
public OCCapability getCapabilities() {
|
||||
return mCapabilities;
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,20 +217,19 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
||||
* is located.
|
||||
*/
|
||||
public Account getAccount() {
|
||||
return mCurrentAccount;
|
||||
return currentAccount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if(mCurrentAccount != null) {
|
||||
onAccountSet();
|
||||
public Optional<User> getUser() {
|
||||
if (currentAccount != null) {
|
||||
return accountManager.getUser(currentAccount.name);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public FileDataStorageManager getStorageManager() {
|
||||
return mStorageManager;
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
@@ -93,7 +92,7 @@ public class CommunityActivity extends FileActivity {
|
||||
getString(R.string.contributing_link)))));
|
||||
|
||||
MaterialButton reportButton = findViewById(R.id.community_testing_report);
|
||||
reportButton.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
|
||||
reportButton.setBackgroundColor(ThemeUtils.primaryColor(this,true));
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Html;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -56,10 +57,12 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.PassCodeManager;
|
||||
@@ -69,7 +72,6 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.ExternalLink;
|
||||
import com.owncloud.android.lib.common.ExternalLinkType;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.Quota;
|
||||
import com.owncloud.android.lib.common.UserInfo;
|
||||
import com.owncloud.android.lib.common.accounts.ExternalLinksOperation;
|
||||
@@ -109,7 +111,9 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
@@ -215,6 +219,9 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
@Inject
|
||||
AppPreferences preferences;
|
||||
|
||||
@Inject
|
||||
ClientFactory clientFactory;
|
||||
|
||||
/**
|
||||
* Initializes the drawer, its content and highlights the menu item with the given id.
|
||||
* This method needs to be called after the content view has been set.
|
||||
@@ -355,21 +362,19 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false);
|
||||
}
|
||||
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
User account = accountManager.getUser();
|
||||
filterDrawerMenu(navigationView.getMenu(), account);
|
||||
}
|
||||
|
||||
private void filterDrawerMenu(Menu menu, Account account) {
|
||||
OCCapability capability = null;
|
||||
if (account != null) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());
|
||||
capability = storageManager.getCapability(account.name);
|
||||
}
|
||||
private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
|
||||
getContentResolver());
|
||||
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
||||
|
||||
boolean hasSearchSupport = accountManager.getServerVersion(account).isSearchSupported();
|
||||
boolean hasSearchSupport = user.getServer().getVersion().isSearchSupported();
|
||||
|
||||
DrawerMenuUtil.filterSearchMenuItems(menu, account, getResources(), hasSearchSupport);
|
||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, account, capability, accountManager);
|
||||
DrawerMenuUtil.filterSearchMenuItems(menu, user.toPlatformAccount(), getResources(), hasSearchSupport);
|
||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, user.toPlatformAccount(), capability, accountManager);
|
||||
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
|
||||
|
||||
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
|
||||
@@ -683,7 +688,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
if (mNavigationView != null && mDrawerLayout != null) {
|
||||
if (persistingAccounts.size() > 0) {
|
||||
repopulateAccountList(persistingAccounts);
|
||||
setAccountInDrawer(accountManager.getCurrentAccount());
|
||||
setAccountInDrawer(accountManager.getUser());
|
||||
populateDrawerOwnCloudAccounts();
|
||||
|
||||
// activate second/end account avatar
|
||||
@@ -789,30 +794,25 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
* sets the given account name in the drawer in case the drawer is available. The account name is shortened
|
||||
* beginning from the @-sign in the username.
|
||||
*
|
||||
* @param account the account to be set in the drawer
|
||||
* @param user the account to be set in the drawer
|
||||
*/
|
||||
protected void setAccountInDrawer(Account account) {
|
||||
if (mDrawerLayout != null && account != null) {
|
||||
protected void setAccountInDrawer(User user) {
|
||||
if (mDrawerLayout != null && user != null) {
|
||||
TextView username = (TextView) findNavigationViewChildById(R.id.drawer_username);
|
||||
TextView usernameFull = (TextView) findNavigationViewChildById(R.id.drawer_username_full);
|
||||
|
||||
usernameFull.setText(DisplayUtils.convertIdn(account.name.substring(account.name.lastIndexOf('@') + 1),
|
||||
String name = user.getAccountName();
|
||||
usernameFull.setText(DisplayUtils.convertIdn(name.substring(name.lastIndexOf('@') + 1),
|
||||
false));
|
||||
usernameFull.setTextColor(ThemeUtils.fontColor(this));
|
||||
|
||||
try {
|
||||
OwnCloudAccount oca = new OwnCloudAccount(account, this);
|
||||
username.setText(oca.getDisplayName());
|
||||
username.setTextColor(ThemeUtils.fontColor(this));
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
||||
Log_OC.w(TAG, "Couldn't read display name of account fallback to account name");
|
||||
username.setText(UserAccountManager.getUsername(account));
|
||||
}
|
||||
username.setText(user.toOwnCloudAccount().getDisplayName());
|
||||
username.setTextColor(ThemeUtils.fontColor(this));
|
||||
|
||||
View currentAccountView = findNavigationViewChildById(R.id.drawer_current_account);
|
||||
currentAccountView.setTag(account.name);
|
||||
currentAccountView.setTag(name);
|
||||
|
||||
DisplayUtils.setAvatar(account, this, mCurrentAccountAvatarRadiusDimension, getResources(),
|
||||
DisplayUtils.setAvatar(user.toPlatformAccount(), this, mCurrentAccountAvatarRadiusDimension, getResources(),
|
||||
currentAccountView, this);
|
||||
|
||||
// check and show quota info if available
|
||||
@@ -956,6 +956,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
};
|
||||
|
||||
DisplayUtils.downloadIcon(getUserAccountManager(),
|
||||
clientFactory,
|
||||
this,
|
||||
firstQuota.iconUrl,
|
||||
target,
|
||||
@@ -989,7 +990,17 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
MenuItem menuItem = mNavigationView.getMenu().getItem(i);
|
||||
if (menuItem.getIcon() != null) {
|
||||
menuItem.getIcon().clearColorFilter();
|
||||
menuItem.setTitle(Html.fromHtml("<font color='#000000'>" + menuItem.getTitle() + "</font>"));
|
||||
if (menuItem.getGroupId() != R.id.drawer_menu_accounts
|
||||
|| menuItem.getItemId() == R.id.drawer_menu_account_add
|
||||
|| menuItem.getItemId() == R.id.drawer_menu_account_manage) {
|
||||
ThemeUtils.tintDrawable(
|
||||
menuItem.getIcon(), ContextCompat.getColor(this, R.color.drawer_menu_icon));
|
||||
}
|
||||
menuItem.setTitle(Html.fromHtml(
|
||||
"<font color='"
|
||||
+ ThemeUtils.colorToHexString(ContextCompat.getColor(this, R.color.text_color))
|
||||
+ "'>" + menuItem.getTitle()
|
||||
+ "</font>"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,14 +1023,14 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
// set user space information
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
final Account currentAccount = accountManager.getCurrentAccount();
|
||||
final User user = accountManager.getUser();
|
||||
|
||||
if (currentAccount == null) {
|
||||
if (user.isAnonymous()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Context context = MainApp.getAppContext();
|
||||
RemoteOperationResult result = new GetUserInfoRemoteOperation().execute(currentAccount, context);
|
||||
RemoteOperationResult result = new GetUserInfoRemoteOperation().execute(user.toPlatformAccount(), context);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
final UserInfo userInfo = (UserInfo) result.getData().get(0);
|
||||
@@ -1068,7 +1079,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
float density = getResources().getDisplayMetrics().density;
|
||||
final int size = Math.round(24 * density);
|
||||
int greyColor = getResources().getColor(R.color.standard_grey);
|
||||
int greyColor = ContextCompat.getColor(this, R.color.drawer_menu_icon);
|
||||
|
||||
for (final ExternalLink link : externalLinksProvider.getExternalLink(ExternalLinkType.LINK)) {
|
||||
int id = mNavigationView.getMenu().add(R.id.drawer_menu_external_links,
|
||||
@@ -1089,6 +1100,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
};
|
||||
|
||||
DisplayUtils.downloadIcon(getUserAccountManager(),
|
||||
clientFactory,
|
||||
this,
|
||||
link.iconUrl,
|
||||
target,
|
||||
@@ -1263,6 +1275,12 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) {
|
||||
|
||||
getDelegate().setLocalNightMode(DarkMode.DARK == preferences.getDarkThemeMode() ?
|
||||
AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
|
||||
getDelegate().applyDayNight();
|
||||
}
|
||||
setDrawerMenuItemChecked(mCheckedMenuItem);
|
||||
}
|
||||
|
||||
@@ -1278,7 +1296,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
// current account has changed
|
||||
if (data.getBooleanExtra(ManageAccountsActivity.KEY_CURRENT_ACCOUNT_CHANGED, false)) {
|
||||
setAccount(accountManager.getCurrentAccount());
|
||||
setAccount(accountManager.getCurrentAccount(), false);
|
||||
updateAccountList();
|
||||
restart();
|
||||
} else {
|
||||
@@ -1360,12 +1378,11 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
}
|
||||
}
|
||||
|
||||
Account currentAccount = accountManager.getCurrentAccount();
|
||||
|
||||
mAvatars[0] = currentAccount;
|
||||
User user = accountManager.getUser();
|
||||
mAvatars[0] = user.toPlatformAccount();
|
||||
int j = 0;
|
||||
for (int i = 1; i <= 2 && i < persistingAccounts.size() && j < persistingAccounts.size(); j++) {
|
||||
if (!currentAccount.equals(persistingAccounts.get(j))) {
|
||||
if (!user.equals(persistingAccounts.get(j))) {
|
||||
mAvatars[i] = persistingAccounts.get(j);
|
||||
i++;
|
||||
}
|
||||
@@ -1421,7 +1438,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
@Override
|
||||
protected void onStop() {
|
||||
if (preferences.getLockTimestamp() != 0) {
|
||||
preferences.setLockTimestamp(System.currentTimeMillis());
|
||||
preferences.setLockTimestamp(SystemClock.elapsedRealtime());
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onStop();
|
||||
@@ -1447,11 +1464,10 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
getCapabilities.execute(getStorageManager(), getBaseContext());
|
||||
}
|
||||
|
||||
Account account = accountManager.getCurrentAccount();
|
||||
|
||||
if (account != null && getStorageManager() != null &&
|
||||
getStorageManager().getCapability(account.name) != null &&
|
||||
getStorageManager().getCapability(account.name).getExternalLinks().isTrue()) {
|
||||
User user = accountManager.getUser();
|
||||
String name = user.getAccountName();
|
||||
if (getStorageManager() != null && getStorageManager().getCapability(name) != null &&
|
||||
getStorageManager().getCapability(name).getExternalLinks().isTrue()) {
|
||||
|
||||
int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
|
||||
FileActivity.APP_OPENED_COUNT);
|
||||
@@ -1466,7 +1482,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
Log_OC.d("ExternalLinks", "update via api");
|
||||
RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
|
||||
RemoteOperationResult result = getExternalLinksOperation.execute(account, this);
|
||||
RemoteOperationResult result = getExternalLinksOperation.execute(user.toPlatformAccount(), this);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
externalLinksProvider.deleteAllExternalLinks();
|
||||
|
||||
@@ -28,7 +28,6 @@ package com.owncloud.android.ui.activity;
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
@@ -42,7 +41,6 @@ import android.content.SyncRequest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcelable;
|
||||
@@ -54,11 +52,13 @@ import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.appinfo.AppInfo;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.media.PlayerServiceConnection;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -321,7 +321,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
}
|
||||
} else {
|
||||
createMinFragments(savedInstanceState);
|
||||
refreshList(true);
|
||||
syncAndUpdateFolder(true);
|
||||
}
|
||||
|
||||
setIndeterminate(mSyncInProgress);
|
||||
@@ -394,7 +394,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// permission was granted
|
||||
EventBus.getDefault().post(new TokenPushEvent());
|
||||
refreshList(true);
|
||||
syncAndUpdateFolder(true);
|
||||
// toggle on is save since this is the only scenario this code gets accessed
|
||||
} else {
|
||||
// permission denied --> do nothing
|
||||
@@ -502,9 +502,13 @@ public class FileDisplayActivity extends FileActivity
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
|
||||
if (ACTION_DETAILS.equalsIgnoreCase(intent.getAction())) {
|
||||
OCFile file = intent.getParcelableExtra(EXTRA_FILE);
|
||||
setFile(file);
|
||||
setIntent(intent);
|
||||
setFile(intent.getParcelableExtra(EXTRA_FILE));
|
||||
showDetails(file);
|
||||
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
handleOpenFileViaIntent(intent);
|
||||
} else if (RESTART.equals(intent.getAction())) {
|
||||
@@ -685,7 +689,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
updateActionBarTitleAndHomeButton(null);
|
||||
}
|
||||
|
||||
public void refreshListOfFilesFragment(boolean fromSearch) {
|
||||
public void updateListOfFilesFragment(boolean fromSearch) {
|
||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||
if (fileListFragment != null) {
|
||||
fileListFragment.listDirectory(MainApp.isOnlyOnDevice(), fromSearch);
|
||||
@@ -765,7 +769,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main_menu, menu);
|
||||
inflater.inflate(R.menu.activity_file_display, menu);
|
||||
menu.findItem(R.id.action_create_dir).setVisible(false);
|
||||
|
||||
menu.findItem(R.id.action_select_all).setVisible(false);
|
||||
@@ -937,7 +941,6 @@ public class FileDisplayActivity extends FileActivity
|
||||
/**
|
||||
* Called, when the user selected something for uploading
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
@@ -1075,10 +1078,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
ArrayList<Parcelable> streamsToUpload = new ArrayList<>();
|
||||
|
||||
//getClipData is only supported on api level 16+, Jelly Bean
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
|
||||
contentIntent.getClipData() != null &&
|
||||
contentIntent.getClipData().getItemCount() > 0) {
|
||||
if (contentIntent.getClipData() != null && contentIntent.getClipData().getItemCount() > 0) {
|
||||
|
||||
for (int i = 0; i < contentIntent.getClipData().getItemCount(); i++) {
|
||||
streamsToUpload.add(contentIntent.getClipData().getItemAt(i).getUri());
|
||||
@@ -1162,13 +1162,6 @@ public class FileDisplayActivity extends FileActivity
|
||||
} else {
|
||||
// all closed
|
||||
|
||||
//if PreviewImageActivity called this activity and mDualPane==false then calls PreviewImageActivity again
|
||||
if (ACTION_DETAILS.equalsIgnoreCase(getIntent().getAction()) && !mDualPane) {
|
||||
getIntent().setAction(null);
|
||||
getIntent().putExtra(EXTRA_FILE, (OCFile) null);
|
||||
startImagePreview(getFile(), false);
|
||||
}
|
||||
|
||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||
if (mDualPane || getSecondFragment() == null) {
|
||||
OCFile currentDir = getCurrentDir();
|
||||
@@ -1210,6 +1203,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
protected void onResume() {
|
||||
Log_OC.v(TAG, "onResume() start");
|
||||
super.onResume();
|
||||
syncAndUpdateFolder(false);
|
||||
|
||||
OCFile startFile = null;
|
||||
if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
|
||||
@@ -1222,7 +1216,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
searchView.setQuery(searchQuery, false);
|
||||
} else if (getListOfFilesFragment() != null && !getListOfFilesFragment().isSearchFragment()
|
||||
&& startFile == null) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
} else {
|
||||
getListOfFilesFragment().listDirectory(startFile, false, false);
|
||||
updateActionBarTitleAndHomeButton(startFile);
|
||||
@@ -1470,7 +1464,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
String linkedToRemotePath =
|
||||
intent.getStringExtra(FileUploader.EXTRA_LINKED_TO_PATH);
|
||||
if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1554,7 +1548,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
if (sameAccount && isDescendant) {
|
||||
String linkedToRemotePath = intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH);
|
||||
if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
}
|
||||
refreshSecondFragment(
|
||||
intent.getAction(),
|
||||
@@ -1825,7 +1819,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
}
|
||||
OCFile parentFile = getStorageManager().getFileById(removedFile.getParentId());
|
||||
if (parentFile != null && parentFile.equals(getCurrentDir())) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
}
|
||||
supportInvalidateOptionsMenu();
|
||||
} else {
|
||||
@@ -1881,7 +1875,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
private void onMoveFileOperationFinish(MoveFileOperation operation,
|
||||
RemoteOperationResult result) {
|
||||
if (result.isSuccess()) {
|
||||
refreshListOfFilesFragment(false);
|
||||
syncAndUpdateFolder(true);
|
||||
} else {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(
|
||||
@@ -1919,7 +1913,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
|
||||
fileDetailFragment.getFileDetailSharingFragment().onUpdateShareInformation(result, getFile());
|
||||
}
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
} else {
|
||||
// Detect Failure (403) --> maybe needs password
|
||||
String password = operation.getPassword();
|
||||
@@ -1972,7 +1966,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
if (result.isSuccess()) {
|
||||
updateFileFromDB();
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
} else if (fileDetailFragment != null && fileDetailFragment.getView() != null) {
|
||||
String errorResponse;
|
||||
|
||||
@@ -2022,7 +2016,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
*/
|
||||
private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperationResult result) {
|
||||
if (result.isSuccess()) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
} else {
|
||||
try {
|
||||
DisplayUtils.showSnackMessage(
|
||||
@@ -2076,7 +2070,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
}
|
||||
|
||||
if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -2136,7 +2130,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
*/
|
||||
@Override
|
||||
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
|
||||
refreshListOfFilesFragment(false);
|
||||
updateListOfFilesFragment(false);
|
||||
FileFragment details = getSecondFragment();
|
||||
if (details instanceof FileDetailFragment &&
|
||||
file.equals(details.getFile())) {
|
||||
@@ -2447,15 +2441,15 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
@Override
|
||||
public void onRefresh(boolean ignoreETag) {
|
||||
refreshList(ignoreETag);
|
||||
syncAndUpdateFolder(ignoreETag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
refreshList(true);
|
||||
syncAndUpdateFolder(true);
|
||||
}
|
||||
|
||||
private void refreshList(boolean ignoreETag) {
|
||||
private void syncAndUpdateFolder(boolean ignoreETag) {
|
||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||
if (listOfFiles != null && !listOfFiles.isSearchFragment()) {
|
||||
OCFile folder = listOfFiles.getCurrentFile();
|
||||
@@ -2545,8 +2539,8 @@ public class FileDisplayActivity extends FileActivity
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Account account = getAccount();
|
||||
if (account != null) {
|
||||
Optional<User> optionalUser = getUser();
|
||||
if (optionalUser.isPresent()) {
|
||||
/// Check whether the 'main' OCFile handled by the Activity is contained in the
|
||||
// current Account
|
||||
OCFile file = getFile();
|
||||
@@ -2572,10 +2566,12 @@ public class FileDisplayActivity extends FileActivity
|
||||
}
|
||||
setFile(file);
|
||||
|
||||
setAccountInDrawer(account);
|
||||
User user = optionalUser.get();
|
||||
setAccountInDrawer(user);
|
||||
setupDrawer();
|
||||
|
||||
final boolean accountChanged = !account.equals(mLastDisplayedAccount);
|
||||
final String lastDisplayedAccountName = mLastDisplayedAccount != null ? mLastDisplayedAccount.name : null;
|
||||
final boolean accountChanged = !user.getAccountName().equals(lastDisplayedAccountName);
|
||||
if (accountChanged) {
|
||||
Log_OC.d(TAG, "Initializing Fragments in onAccountChanged..");
|
||||
initFragmentsWithFile();
|
||||
@@ -2587,7 +2583,11 @@ public class FileDisplayActivity extends FileActivity
|
||||
updateActionBarTitleAndHomeButton(file.isFolder() ? null : file);
|
||||
}
|
||||
}
|
||||
mLastDisplayedAccount = account;
|
||||
if (optionalUser.isPresent()) {
|
||||
mLastDisplayedAccount = optionalUser.get().toPlatformAccount();
|
||||
} else {
|
||||
mLastDisplayedAccount = null;
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new TokenPushEvent());
|
||||
checkForNewDevVersionNecessary(findViewById(R.id.root_layout), getApplicationContext());
|
||||
@@ -2621,7 +2621,8 @@ public class FileDisplayActivity extends FileActivity
|
||||
return;
|
||||
}
|
||||
|
||||
setAccount(newAccount);
|
||||
setAccount(newAccount, false);
|
||||
updateAccountList();
|
||||
}
|
||||
|
||||
String fileId = String.valueOf(intent.getStringExtra(KEY_FILE_ID));
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -37,10 +38,10 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
@@ -90,8 +91,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
private boolean mSearchOnlyFolders;
|
||||
private boolean mDoNotEnterEncryptedFolder;
|
||||
|
||||
protected Button mCancelBtn;
|
||||
protected Button mChooseBtn;
|
||||
protected MaterialButton mCancelBtn;
|
||||
protected MaterialButton mChooseBtn;
|
||||
private String caption;
|
||||
@Inject AppPreferences preferences;
|
||||
|
||||
@@ -292,11 +293,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main_menu, menu);
|
||||
menu.findItem(R.id.action_switch_view).setVisible(false);
|
||||
menu.findItem(R.id.action_sync_account).setVisible(false);
|
||||
menu.findItem(R.id.action_select_all).setVisible(false);
|
||||
// menu.findItem(R.id.action_sort).setVisible(false);
|
||||
inflater.inflate(R.menu.activity_folder_picker, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -405,7 +402,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
|
||||
|
||||
if (mChooseBtn != null) {
|
||||
mChooseBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
|
||||
mChooseBtn.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
|
||||
mChooseBtn.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
|
||||
mChooseBtn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.view.MenuItem;
|
||||
|
||||
import com.evernote.android.job.JobRequest;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -126,15 +127,12 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
|
||||
Account[] accountList = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
|
||||
originalAccounts = DisplayUtils.toAccountNameSet(Arrays.asList(accountList));
|
||||
|
||||
Account currentAccount = getUserAccountManager().getCurrentAccount();
|
||||
Account currentAccount = getAccount();
|
||||
|
||||
if (currentAccount != null) {
|
||||
originalCurrentAccount = currentAccount.name;
|
||||
}
|
||||
|
||||
setAccount(currentAccount);
|
||||
onAccountSet();
|
||||
|
||||
arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
|
||||
multipleAccountsSupported = getResources().getBoolean(R.bool.multiaccount_support);
|
||||
@@ -201,11 +199,11 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
|
||||
* @return true if account list has changed, false if not
|
||||
*/
|
||||
private boolean hasCurrentAccountChanged() {
|
||||
Account account = getUserAccountManager().getCurrentAccount();
|
||||
if (account == null) {
|
||||
User account = getUserAccountManager().getUser();
|
||||
if (account.isAnonymous()) {
|
||||
return true;
|
||||
} else {
|
||||
return !account.name.equals(originalCurrentAccount);
|
||||
return !account.getAccountName().equals(originalCurrentAccount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +321,8 @@ public class ManageAccountsActivity extends FileActivity implements AccountListA
|
||||
}
|
||||
}
|
||||
|
||||
if (getUserAccountManager().getCurrentAccount() == null) {
|
||||
User user = getUserAccountManager().getUser();
|
||||
if (user.isAnonymous()) {
|
||||
String accountName = "";
|
||||
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
|
||||
if (accounts.length != 0) {
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
@@ -39,13 +36,14 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.jobs.NotificationJob;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -58,9 +56,10 @@ import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.PushUtils;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
@@ -109,7 +108,9 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
private NotificationListAdapter adapter;
|
||||
private Snackbar snackbar;
|
||||
private OwnCloudClient client;
|
||||
private Account currentAccount;
|
||||
private Optional<User> optionalUser;
|
||||
|
||||
@Inject ClientFactory clientFactory;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -119,16 +120,18 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
setContentView(R.layout.notifications_layout);
|
||||
unbinder = ButterKnife.bind(this);
|
||||
|
||||
currentAccount = getAccount();
|
||||
optionalUser = getUser();
|
||||
|
||||
// use account from intent (opened via android notification can have a different account than current one)
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
String account = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
|
||||
|
||||
if (account != null && (currentAccount == null || !account.equalsIgnoreCase(currentAccount.name))) {
|
||||
accountManager.setCurrentOwnCloudAccount(account);
|
||||
setAccount(getUserAccountManager().getCurrentAccount());
|
||||
currentAccount = getAccount();
|
||||
String accountName = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
|
||||
if(accountName != null && optionalUser.isPresent()) {
|
||||
User user = optionalUser.get();
|
||||
if (user.getAccountName().equalsIgnoreCase(accountName)) {
|
||||
accountManager.setCurrentOwnCloudAccount(accountName);
|
||||
setUser(getUserAccountManager().getUser());
|
||||
optionalUser = getUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +145,7 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
setupDrawer(R.id.nav_notifications);
|
||||
ThemeUtils.setColoredTitle(getSupportActionBar(), getString(R.string.drawer_item_notifications), this);
|
||||
|
||||
if (currentAccount == null) {
|
||||
if (!optionalUser.isPresent()) {
|
||||
// show error
|
||||
runOnUiThread(() -> setEmptyContent(noResultsHeadline, getString(R.string.account_not_found)));
|
||||
return;
|
||||
@@ -156,7 +159,6 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
swipeEmptyListRefreshLayout.setOnRefreshListener(() -> {
|
||||
setLoadingMessage();
|
||||
fetchAndSetData();
|
||||
|
||||
});
|
||||
|
||||
setupPushWarning();
|
||||
@@ -175,16 +177,16 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_not_implemented,
|
||||
Snackbar.LENGTH_INDEFINITE);
|
||||
} else {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
|
||||
boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(currentAccount.name,
|
||||
final ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
final String accountName = optionalUser.isPresent() ? optionalUser.get().getAccountName() : "";
|
||||
final boolean usesOldLogin = arbitraryDataProvider.getBooleanValue(accountName,
|
||||
UserAccountManager.ACCOUNT_USES_STANDARD_PASSWORD);
|
||||
|
||||
if (usesOldLogin) {
|
||||
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_old_login,
|
||||
Snackbar.LENGTH_INDEFINITE);
|
||||
} else {
|
||||
String pushValue = arbitraryDataProvider.getValue(currentAccount.name, PushUtils.KEY_PUSH);
|
||||
String pushValue = arbitraryDataProvider.getValue(accountName, PushUtils.KEY_PUSH);
|
||||
|
||||
if (pushValue == null || pushValue.isEmpty()) {
|
||||
snackbar = Snackbar.make(emptyContentContainer, R.string.push_notifications_temp_error,
|
||||
@@ -250,13 +252,11 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
|
||||
private void fetchAndSetData() {
|
||||
Thread t = new Thread(() -> {
|
||||
if (client == null) {
|
||||
if (client == null && optionalUser.isPresent()) {
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, this);
|
||||
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this);
|
||||
client.setOwnCloudVersion(accountManager.getServerVersion(currentAccount));
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException |
|
||||
IOException | OperationCanceledException | AuthenticatorException e) {
|
||||
User user = optionalUser.get();
|
||||
client = clientFactory.create(user);
|
||||
} catch (ClientFactory.CreationException e) {
|
||||
Log_OC.e(TAG, "Error initializing client", e);
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ public class NotificationsActivity extends FileActivity implements Notifications
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.notifications_actions_menu, menu);
|
||||
getMenuInflater().inflate(R.menu.activity_notifications, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
@@ -97,7 +97,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
||||
int elementColor = ThemeUtils.elementColor(this);
|
||||
|
||||
mBCancel = findViewById(R.id.cancel);
|
||||
mBCancel.getBackground().setColorFilter(elementColor, PorterDuff.Mode.SRC_ATOP);
|
||||
mBCancel.setBackgroundColor(ThemeUtils.primaryColor(this));
|
||||
|
||||
mPassCodeHdr = findViewById(R.id.header);
|
||||
mPassCodeHdrExplanation = findViewById(R.id.explanation);
|
||||
@@ -240,7 +240,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
||||
if (ACTION_CHECK.equals(getIntent().getAction())) {
|
||||
if (checkPassCode()) {
|
||||
/// pass code accepted in request, user is allowed to access the app
|
||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
|
||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
|
||||
hideSoftKeyboard();
|
||||
finish();
|
||||
|
||||
@@ -250,7 +250,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
||||
|
||||
} else if (ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
|
||||
if (checkPassCode()) {
|
||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
|
||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra(KEY_CHECK_RESULT, true);
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
@@ -63,6 +64,7 @@ import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -206,8 +208,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
Log_OC.i(TAG, "No ownCloud account is available");
|
||||
DialogNoAccount dialog = new DialogNoAccount();
|
||||
dialog.show(getSupportFragmentManager(), null);
|
||||
} else if (!savedAccount) {
|
||||
setAccount(accounts[0]);
|
||||
}
|
||||
|
||||
if (!somethingToUpload()) {
|
||||
@@ -400,6 +400,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
final EditText userInput = view.findViewById(R.id.user_input);
|
||||
setFilename(userInput, selectPos);
|
||||
userInput.setHighlightColor(ThemeUtils.primaryColor(getContext()));
|
||||
userInput.requestFocus();
|
||||
|
||||
final Spinner spinner = view.findViewById(R.id.file_type);
|
||||
@@ -677,7 +678,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
// there is no need for checking for is there more then one
|
||||
// account at this point
|
||||
// since account setup can set only one account at time
|
||||
setAccount(accounts[0]);
|
||||
setAccount(accounts[0], false);
|
||||
populateDirectoryList();
|
||||
}
|
||||
}
|
||||
@@ -748,10 +749,10 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
mListView.setAdapter(sa);
|
||||
}
|
||||
Button btnChooseFolder = findViewById(R.id.uploader_choose_folder);
|
||||
btnChooseFolder.setOnClickListener(this);
|
||||
btnChooseFolder.getBackground().setColorFilter(ThemeUtils.primaryColor(getAccount(), true, this),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
MaterialButton btnChooseFolder = findViewById(R.id.uploader_choose_folder);
|
||||
btnChooseFolder.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
|
||||
btnChooseFolder.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
|
||||
btnChooseFolder.setOnClickListener(this);
|
||||
btnChooseFolder.setTextColor(ThemeUtils.fontColor(this));
|
||||
|
||||
if (mFile.canWrite()) {
|
||||
@@ -1015,7 +1016,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.receive_file_menu, menu);
|
||||
inflater.inflate(R.menu.activity_receive_external_files, menu);
|
||||
|
||||
if (!isHaveMultipleAccount()) {
|
||||
MenuItem switchAccountMenu = menu.findItem(R.id.action_switch_account);
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
@@ -53,7 +54,7 @@ public class RequestCredentialsActivity extends Activity {
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(System.currentTimeMillis());
|
||||
AppPreferencesImpl.fromContext(this).setLockTimestamp(SystemClock.elapsedRealtime());
|
||||
finishWithResult(KEY_CHECK_RESULT_TRUE);
|
||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
||||
finishWithResult(KEY_CHECK_RESULT_CANCEL);
|
||||
|
||||
@@ -49,6 +49,7 @@ import android.widget.Toast;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
@@ -155,7 +156,8 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
|
||||
break;
|
||||
}
|
||||
|
||||
Glide.with(this).using(new CustomGlideStreamLoader(currentAccountProvider)).load(template.getThumbnailLink())
|
||||
Glide.with(this).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
|
||||
.load(template.getThumbnailLink())
|
||||
.placeholder(placeholder)
|
||||
.error(placeholder)
|
||||
.into(thumbnail);
|
||||
@@ -250,7 +252,7 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
|
||||
}
|
||||
|
||||
if ("image/png".equalsIgnoreCase(file.getMimeType())) {
|
||||
thumbnailView.setBackgroundColor(getResources().getColor(R.color.background_color));
|
||||
thumbnailView.setBackgroundColor(getResources().getColor(R.color.bg_default));
|
||||
}
|
||||
} else {
|
||||
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
|
||||
@@ -314,9 +316,9 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
|
||||
OCFile file = data.getParcelableExtra(FolderPickerActivity.EXTRA_FILES);
|
||||
|
||||
new Thread(() -> {
|
||||
Account account = currentAccountProvider.getCurrentAccount();
|
||||
User user = currentAccountProvider.getUser();
|
||||
RichDocumentsCreateAssetOperation operation = new RichDocumentsCreateAssetOperation(file.getRemotePath());
|
||||
RemoteOperationResult result = operation.execute(account, this);
|
||||
RemoteOperationResult result = operation.execute(user.toPlatformAccount(), this);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
String asset = (String) result.getSingleData();
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -39,7 +38,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
@@ -53,12 +51,15 @@ import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.etm.EtmActivity;
|
||||
import com.nextcloud.client.logger.ui.LogsActivity;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.owncloud.android.BuildConfig;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
@@ -70,8 +71,6 @@ import com.owncloud.android.datastorage.DataStorageProvider;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
import com.owncloud.android.lib.common.ExternalLink;
|
||||
import com.owncloud.android.lib.common.ExternalLinkType;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask;
|
||||
import com.owncloud.android.utils.DeviceCredentialUtils;
|
||||
@@ -81,6 +80,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -96,7 +96,7 @@ import androidx.core.content.res.ResourcesCompat;
|
||||
*
|
||||
* It proxies the necessary calls via {@link androidx.appcompat.app.AppCompatDelegate} to be used with AppCompat.
|
||||
*/
|
||||
public class SettingsActivity extends PreferenceActivity
|
||||
public class SettingsActivity extends ThemedPreferenceActivity
|
||||
implements StorageMigration.StorageMigrationProgressListener, LoadingVersionNumberTask.VersionDevInterface,
|
||||
Injectable {
|
||||
|
||||
@@ -108,6 +108,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
public static final String LOCK_PASSCODE = "passcode";
|
||||
public static final String LOCK_DEVICE_CREDENTIALS = "device_credentials";
|
||||
|
||||
|
||||
public final static String PREFERENCE_USE_FINGERPRINT = "use_fingerprint";
|
||||
public static final String PREFERENCE_SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
|
||||
|
||||
@@ -131,10 +132,11 @@ public class SettingsActivity extends PreferenceActivity
|
||||
private String storagePath;
|
||||
private String pendingLock;
|
||||
|
||||
private Account account;
|
||||
private User user;
|
||||
@Inject ArbitraryDataProvider arbitraryDataProvider;
|
||||
@Inject AppPreferences preferences;
|
||||
@Inject UserAccountManager accountManager;
|
||||
@Inject ClientFactory clientFactory;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
@@ -157,7 +159,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
String appVersion = getAppVersion();
|
||||
PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("preference_screen");
|
||||
|
||||
account = accountManager.getCurrentAccount();
|
||||
user = accountManager.getUser();
|
||||
|
||||
// retrieve user's base uri
|
||||
setupBaseUri();
|
||||
@@ -409,7 +411,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
}
|
||||
|
||||
private void setupE2EMnemonicPreference(PreferenceCategory preferenceCategoryMore) {
|
||||
String mnemonic = arbitraryDataProvider.getValue(account.name, EncryptionUtils.MNEMONIC);
|
||||
String mnemonic = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.MNEMONIC);
|
||||
|
||||
Preference pMnemonic = findPreference("mnemonic");
|
||||
if (pMnemonic != null) {
|
||||
@@ -604,11 +606,11 @@ public class SettingsActivity extends PreferenceActivity
|
||||
|
||||
final SwitchPreference pUploadOnWifiCheckbox = (SwitchPreference) findPreference("synced_folder_on_wifi");
|
||||
pUploadOnWifiCheckbox.setChecked(
|
||||
arbitraryDataProvider.getBooleanValue(account, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
|
||||
arbitraryDataProvider.getBooleanValue(user.toPlatformAccount(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
|
||||
|
||||
pUploadOnWifiCheckbox.setOnPreferenceClickListener(preference -> {
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(account.name, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
|
||||
String.valueOf(pUploadOnWifiCheckbox.isChecked()));
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
|
||||
String.valueOf(pUploadOnWifiCheckbox.isChecked()));
|
||||
|
||||
return true;
|
||||
});
|
||||
@@ -692,6 +694,34 @@ public class SettingsActivity extends PreferenceActivity
|
||||
}
|
||||
|
||||
loadStoragePath();
|
||||
|
||||
ListPreference themePref = (ListPreference) findPreference("darkTheme");
|
||||
|
||||
List<String> themeEntries = new ArrayList<>(3);
|
||||
themeEntries.add(getString(R.string.prefs_value_theme_light));
|
||||
themeEntries.add(getString(R.string.prefs_value_theme_dark));
|
||||
themeEntries.add(getString(R.string.prefs_value_theme_system));
|
||||
|
||||
List<String> themeValues = new ArrayList<>(3);
|
||||
themeValues.add(DarkMode.LIGHT.name());
|
||||
themeValues.add(DarkMode.DARK.name());
|
||||
themeValues.add(DarkMode.SYSTEM.name());
|
||||
|
||||
themePref.setEntries(themeEntries.toArray(new String[0]));
|
||||
themePref.setEntryValues(themeValues.toArray(new String[0]));
|
||||
|
||||
if (TextUtils.isEmpty(themePref.getEntry())) {
|
||||
themePref.setValue(DarkMode.LIGHT.name());
|
||||
themePref.setSummary(TextUtils.isEmpty(themePref.getEntry()) ? DarkMode.LIGHT.name() : themePref.getEntry());
|
||||
}
|
||||
|
||||
themePref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
DarkMode mode = DarkMode.valueOf((String) newValue);
|
||||
preferences.setDarkThemeMode(mode);
|
||||
MainApp.setAppTheme(mode);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private String getAppVersion() {
|
||||
@@ -727,7 +757,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.getDecorView().setBackgroundDrawable(new ColorDrawable(ResourcesCompat
|
||||
.getColor(getResources(), R.color.background_color, null)));
|
||||
.getColor(getResources(), R.color.bg_default, null)));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window.setStatusBarColor(ThemeUtils.primaryColor(this));
|
||||
@@ -755,7 +785,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
davDroidLoginIntent.setData(Uri.parse(serverBaseUri.toString() + AuthenticatorActivity.WEB_LOGIN));
|
||||
davDroidLoginIntent.putExtra("davPath", DAV_PATH);
|
||||
}
|
||||
davDroidLoginIntent.putExtra("username", UserAccountManager.getUsername(account));
|
||||
davDroidLoginIntent.putExtra("username", UserAccountManager.getUsername(user.toPlatformAccount()));
|
||||
|
||||
startActivityForResult(davDroidLoginIntent, ACTION_REQUEST_CODE_DAVDROID_SETUP);
|
||||
} else {
|
||||
@@ -780,9 +810,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
// retrieve and set user's base URI
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(account, MainApp.getAppContext());
|
||||
serverBaseUri = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount,
|
||||
getApplicationContext()).getBaseUri();
|
||||
serverBaseUri = clientFactory.create(user).getBaseUri();
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error retrieving user's base URI", e);
|
||||
}
|
||||
@@ -848,7 +876,7 @@ public class SettingsActivity extends PreferenceActivity
|
||||
RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE) {
|
||||
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
String mnemonic = arbitraryDataProvider.getValue(account.name, EncryptionUtils.MNEMONIC);
|
||||
String mnemonic = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.MNEMONIC);
|
||||
|
||||
int accentColor = ThemeUtils.primaryAccentColor(this);
|
||||
|
||||
@@ -1008,5 +1036,4 @@ public class SettingsActivity extends PreferenceActivity
|
||||
public void returnVersion(Integer latestVersion) {
|
||||
FileActivity.showDevSnackbar(this, latestVersion, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
@@ -144,7 +143,8 @@ public class SsoGrantPermissionActivity extends BaseActivity {
|
||||
int start = text.indexOf(textBlock);
|
||||
int end = start + textBlock.length();
|
||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, end, 0);
|
||||
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.text_color)), start, end,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
return ssb;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
@@ -38,12 +37,18 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.BuildConfig;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
@@ -86,6 +91,9 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS;
|
||||
import static com.owncloud.android.datamodel.SyncedFolderDisplayItem.UNPERSISTED_ID;
|
||||
@@ -101,18 +109,37 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
private static final String SYNCED_FOLDER_PREFERENCES_DIALOG_TAG = "SYNCED_FOLDER_PREFERENCES_DIALOG";
|
||||
private static final String TAG = SyncedFoldersActivity.class.getSimpleName();
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private SyncedFolderAdapter mAdapter;
|
||||
private LinearLayout mProgress;
|
||||
private TextView mEmpty;
|
||||
private SyncedFolderProvider mSyncedFolderProvider;
|
||||
private SyncedFolderPreferencesDialogFragment mSyncedFolderPreferencesDialogFragment;
|
||||
@BindView(R.id.empty_list_view)
|
||||
public LinearLayout emptyContentContainer;
|
||||
|
||||
@BindView(R.id.empty_list_icon)
|
||||
public ImageView emptyContentIcon;
|
||||
|
||||
@BindView(R.id.empty_list_progress)
|
||||
public ProgressBar emptyContentProgressBar;
|
||||
|
||||
@BindView(R.id.empty_list_view_headline)
|
||||
public TextView emptyContentHeadline;
|
||||
|
||||
@BindView(R.id.empty_list_view_text)
|
||||
public TextView emptyContentMessage;
|
||||
|
||||
@BindView(R.id.empty_list_view_action)
|
||||
public MaterialButton emptyContentActionButton;
|
||||
|
||||
@BindView(android.R.id.list)
|
||||
public RecyclerView mRecyclerView;
|
||||
|
||||
private SyncedFolderAdapter adapter;
|
||||
private SyncedFolderProvider syncedFolderProvider;
|
||||
private SyncedFolderPreferencesDialogFragment syncedFolderPreferencesDialogFragment;
|
||||
private boolean showSidebar = true;
|
||||
|
||||
private String path;
|
||||
private int type;
|
||||
@Inject AppPreferences preferences;
|
||||
@Inject PowerManagementService powerManagementService;
|
||||
@Inject Clock clock;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -123,16 +150,17 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
}
|
||||
|
||||
setContentView(R.layout.synced_folders_layout);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
String account;
|
||||
Account currentAccount;
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
account = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
|
||||
currentAccount = getAccount();
|
||||
|
||||
if (account != null && currentAccount != null && !account.equalsIgnoreCase(currentAccount.name)) {
|
||||
accountManager.setCurrentOwnCloudAccount(account);
|
||||
setAccount(getUserAccountManager().getCurrentAccount());
|
||||
final String accountName = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT);
|
||||
Optional<User> optionalUser = getUser();
|
||||
if (optionalUser.isPresent() && accountName != null) {
|
||||
User user = optionalUser.get();
|
||||
if (!accountName.equalsIgnoreCase(user.getAccountName())) {
|
||||
accountManager.setCurrentOwnCloudAccount(accountName);
|
||||
setUser(getUserAccountManager().getUser());
|
||||
}
|
||||
}
|
||||
|
||||
path = getIntent().getStringExtra(MediaFoldersDetectionJob.KEY_MEDIA_FOLDER_PATH);
|
||||
@@ -175,7 +203,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.synced_folders_menu, menu);
|
||||
inflater.inflate(R.menu.activity_synced_folders, menu);
|
||||
|
||||
if (powerManagementService.isPowerSavingExclusionAvailable()) {
|
||||
MenuItem item = menu.findItem(R.id.action_disable_power_save_check);
|
||||
@@ -216,50 +244,56 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
* sets up the UI elements and loads all media/synced folders.
|
||||
*/
|
||||
private void setupContent() {
|
||||
mRecyclerView = findViewById(android.R.id.list);
|
||||
|
||||
mProgress = findViewById(android.R.id.progress);
|
||||
mEmpty = findViewById(android.R.id.empty);
|
||||
|
||||
final int gridWidth = getResources().getInteger(R.integer.media_grid_width);
|
||||
boolean lightVersion = getResources().getBoolean(R.bool.syncedFolder_light);
|
||||
mAdapter = new SyncedFolderAdapter(this, gridWidth, this, lightVersion);
|
||||
mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences);
|
||||
adapter = new SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion);
|
||||
syncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences, clock);
|
||||
emptyContentIcon.setImageResource(R.drawable.nav_synced_folders);
|
||||
emptyContentActionButton.setBackgroundColor(ThemeUtils.primaryColor(this));
|
||||
emptyContentActionButton.setTextColor(ThemeUtils.fontColor(this));
|
||||
|
||||
final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
|
||||
mAdapter.setLayoutManager(lm);
|
||||
adapter.setLayoutManager(lm);
|
||||
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
|
||||
mRecyclerView.addItemDecoration(new MediaGridItemDecoration(spacing));
|
||||
mRecyclerView.setLayoutManager(lm);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
load(gridWidth * 2, false);
|
||||
}
|
||||
|
||||
@OnClick(R.id.empty_list_view_action)
|
||||
public void showHiddenItems() {
|
||||
if (adapter.getSectionCount() == 0 && adapter.getUnfilteredSectionCount() > adapter.getSectionCount()) {
|
||||
adapter.toggleHiddenItemsVisibility();
|
||||
emptyContentContainer.setVisibility(View.GONE);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loads all media/synced folders, adds them to the recycler view adapter and shows the list.
|
||||
*
|
||||
* @param perFolderMediaItemLimit the amount of media items to be loaded/shown per media folder
|
||||
*/
|
||||
private void load(final int perFolderMediaItemLimit, boolean force) {
|
||||
if (mAdapter.getItemCount() > 0 && !force) {
|
||||
if (adapter.getItemCount() > 0 && !force) {
|
||||
return;
|
||||
}
|
||||
setListShown(false);
|
||||
showLoadingContent();
|
||||
final List<MediaFolder> mediaFolders = MediaProvider.getImageFolders(getContentResolver(),
|
||||
perFolderMediaItemLimit, this, false);
|
||||
mediaFolders.addAll(MediaProvider.getVideoFolders(getContentResolver(), perFolderMediaItemLimit,
|
||||
this, false));
|
||||
|
||||
List<SyncedFolder> syncedFolderArrayList = mSyncedFolderProvider.getSyncedFolders();
|
||||
List<SyncedFolder> syncedFolderArrayList = syncedFolderProvider.getSyncedFolders();
|
||||
List<SyncedFolder> currentAccountSyncedFoldersList = new ArrayList<>();
|
||||
Account currentAccount = getUserAccountManager().getCurrentAccount();
|
||||
User user = getUserAccountManager().getUser();
|
||||
for (SyncedFolder syncedFolder : syncedFolderArrayList) {
|
||||
if (currentAccount != null && syncedFolder.getAccount().equals(currentAccount.name)) {
|
||||
|
||||
if (syncedFolder.getAccount().equals(user.getAccountName())) {
|
||||
// delete non-existing & disabled synced folders
|
||||
if (!new File(syncedFolder.getLocalPath()).exists() && !syncedFolder.isEnabled()) {
|
||||
mSyncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
|
||||
syncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
|
||||
} else {
|
||||
currentAccountSyncedFoldersList.add(syncedFolder);
|
||||
}
|
||||
@@ -269,14 +303,14 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
List<SyncedFolderDisplayItem> syncFolderItems = sortSyncedFolderItems(
|
||||
mergeFolderData(currentAccountSyncedFoldersList, mediaFolders));
|
||||
|
||||
mAdapter.setSyncFolderItems(syncFolderItems);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
setListShown(true);
|
||||
adapter.setSyncFolderItems(syncFolderItems);
|
||||
adapter.notifyDataSetChanged();
|
||||
showList();
|
||||
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
int section = mAdapter.getSectionByLocalPathAndType(path, type);
|
||||
int section = adapter.getSectionByLocalPathAndType(path, type);
|
||||
if (section >= 0) {
|
||||
onSyncFolderSettingsClick(section, mAdapter.get(section));
|
||||
onSyncFolderSettingsClick(section, adapter.get(section));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -380,16 +414,18 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
syncedFolder.getId(),
|
||||
syncedFolder.getLocalPath(),
|
||||
syncedFolder.getRemotePath(),
|
||||
syncedFolder.getWifiOnly(),
|
||||
syncedFolder.getChargingOnly(),
|
||||
syncedFolder.getSubfolderByDate(),
|
||||
syncedFolder.isWifiOnly(),
|
||||
syncedFolder.isChargingOnly(),
|
||||
syncedFolder.isSubfolderByDate(),
|
||||
syncedFolder.getAccount(),
|
||||
syncedFolder.getUploadAction(),
|
||||
syncedFolder.isEnabled(),
|
||||
clock.getCurrentTime(),
|
||||
filePaths,
|
||||
localFolder.getName(),
|
||||
files.length,
|
||||
syncedFolder.getType());
|
||||
syncedFolder.getType(),
|
||||
syncedFolder.isHidden());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,16 +441,18 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
syncedFolder.getId(),
|
||||
syncedFolder.getLocalPath(),
|
||||
syncedFolder.getRemotePath(),
|
||||
syncedFolder.getWifiOnly(),
|
||||
syncedFolder.getChargingOnly(),
|
||||
syncedFolder.getSubfolderByDate(),
|
||||
syncedFolder.isWifiOnly(),
|
||||
syncedFolder.isChargingOnly(),
|
||||
syncedFolder.isSubfolderByDate(),
|
||||
syncedFolder.getAccount(),
|
||||
syncedFolder.getUploadAction(),
|
||||
syncedFolder.isEnabled(),
|
||||
clock.getCurrentTime(),
|
||||
mediaFolder.filePaths,
|
||||
mediaFolder.folderName,
|
||||
mediaFolder.numberOfFiles,
|
||||
mediaFolder.type);
|
||||
mediaFolder.type,
|
||||
syncedFolder.isHidden());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,13 +470,15 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
getAccount().name,
|
||||
getAccount().name,
|
||||
FileUploader.LOCAL_BEHAVIOUR_FORGET,
|
||||
false,
|
||||
clock.getCurrentTime(),
|
||||
mediaFolder.filePaths,
|
||||
mediaFolder.folderName,
|
||||
mediaFolder.numberOfFiles,
|
||||
mediaFolder.type);
|
||||
mediaFolder.type,
|
||||
false);
|
||||
}
|
||||
|
||||
private File[] getFileList(File localFolder) {
|
||||
@@ -484,15 +524,35 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
}
|
||||
|
||||
/**
|
||||
* show/hide recycler view list or the empty message / progress info.
|
||||
*
|
||||
* @param shown flag if list should be shown
|
||||
* show recycler view list or the empty message info (in case list is empty).
|
||||
*/
|
||||
private void setListShown(boolean shown) {
|
||||
private void showList() {
|
||||
if (mRecyclerView != null) {
|
||||
mRecyclerView.setVisibility(shown ? View.VISIBLE : View.GONE);
|
||||
mProgress.setVisibility(shown ? View.GONE : View.VISIBLE);
|
||||
mEmpty.setVisibility(shown && mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
emptyContentProgressBar.setVisibility(View.GONE);
|
||||
|
||||
checkAndShowEmptyListContent();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndShowEmptyListContent() {
|
||||
if (adapter.getSectionCount() == 0 && adapter.getUnfilteredSectionCount() > adapter.getSectionCount()) {
|
||||
emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
int hiddenFoldersCount = adapter.getHiddenFolderCount();
|
||||
|
||||
showEmptyContent(getString(R.string.drawer_synced_folders),
|
||||
getResources().getQuantityString(R.plurals.synced_folders_show_hidden_folders,
|
||||
hiddenFoldersCount,
|
||||
hiddenFoldersCount),
|
||||
getResources().getQuantityString(R.plurals.synced_folders_show_hidden_folders,
|
||||
hiddenFoldersCount,
|
||||
hiddenFoldersCount));
|
||||
} else if (adapter.getSectionCount() == 0 && adapter.getUnfilteredSectionCount() == 0) {
|
||||
emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
showEmptyContent(getString(R.string.drawer_synced_folders),
|
||||
getString(R.string.synced_folders_no_results));
|
||||
} else {
|
||||
emptyContentContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,8 +578,8 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
Log.d(TAG, "Show custom folder dialog");
|
||||
SyncedFolderDisplayItem emptyCustomFolder = new SyncedFolderDisplayItem(
|
||||
SyncedFolder.UNPERSISTED_ID, null, null, true, false,
|
||||
false, getAccount().name,
|
||||
FileUploader.LOCAL_BEHAVIOUR_FORGET, false, null, MediaFolderType.CUSTOM);
|
||||
false, getAccount().name, FileUploader.LOCAL_BEHAVIOUR_FORGET, false,
|
||||
clock.getCurrentTime(), null, MediaFolderType.CUSTOM, false);
|
||||
onSyncFolderSettingsClick(0, emptyCustomFolder);
|
||||
}
|
||||
|
||||
@@ -548,14 +608,11 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
|
||||
@Override
|
||||
public void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
|
||||
getContentResolver());
|
||||
|
||||
if (syncedFolderDisplayItem.getId() > UNPERSISTED_ID) {
|
||||
mSyncedFolderProvider.updateSyncedFolderEnabled(syncedFolderDisplayItem.getId(),
|
||||
syncedFolderDisplayItem.isEnabled());
|
||||
syncedFolderProvider.updateSyncedFolderEnabled(syncedFolderDisplayItem.getId(),
|
||||
syncedFolderDisplayItem.isEnabled());
|
||||
} else {
|
||||
long storedId = mSyncedFolderProvider.storeSyncedFolder(syncedFolderDisplayItem);
|
||||
long storedId = syncedFolderProvider.storeSyncedFolder(syncedFolderDisplayItem);
|
||||
if (storedId != -1) {
|
||||
syncedFolderDisplayItem.setId(storedId);
|
||||
}
|
||||
@@ -565,9 +622,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolderDisplayItem);
|
||||
|
||||
showBatteryOptimizationInfo();
|
||||
} else {
|
||||
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + syncedFolderDisplayItem.getId();
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,22 +631,72 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.addToBackStack(null);
|
||||
|
||||
mSyncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
|
||||
syncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
|
||||
syncedFolderDisplayItem, section);
|
||||
mSyncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
|
||||
syncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVisibilityToggleClick(int section, SyncedFolderDisplayItem syncedFolder) {
|
||||
syncedFolder.setHidden(!syncedFolder.isHidden());
|
||||
|
||||
saveOrUpdateSyncedFolder(syncedFolder);
|
||||
adapter.setSyncFolderItem(section, syncedFolder);
|
||||
|
||||
checkAndShowEmptyListContent();
|
||||
}
|
||||
|
||||
private void showEmptyContent(String headline, String message) {
|
||||
showEmptyContent(headline, message, false);
|
||||
emptyContentActionButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showEmptyContent(String headline, String message, String action) {
|
||||
showEmptyContent(headline, message, false);
|
||||
emptyContentActionButton.setText(action);
|
||||
emptyContentActionButton.setVisibility(View.VISIBLE);
|
||||
emptyContentMessage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showLoadingContent() {
|
||||
showEmptyContent(
|
||||
getString(R.string.drawer_synced_folders),
|
||||
getString(R.string.synced_folders_loading_folders),
|
||||
true
|
||||
);
|
||||
emptyContentActionButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showEmptyContent(String headline, String message, boolean loading) {
|
||||
if (emptyContentContainer != null) {
|
||||
emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
|
||||
emptyContentHeadline.setText(headline);
|
||||
emptyContentMessage.setText(message);
|
||||
emptyContentMessage.setVisibility(View.VISIBLE);
|
||||
|
||||
if (loading) {
|
||||
emptyContentProgressBar.setVisibility(View.VISIBLE);
|
||||
emptyContentIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
emptyContentProgressBar.setVisibility(View.GONE);
|
||||
emptyContentIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER
|
||||
&& resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) {
|
||||
&& resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null) {
|
||||
OCFile chosenFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
|
||||
mSyncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
|
||||
syncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
|
||||
}
|
||||
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_LOCAL_FOLDER
|
||||
&& resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) {
|
||||
&& resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null) {
|
||||
String localPath = data.getStringExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES);
|
||||
mSyncedFolderPreferencesDialogFragment.setLocalFolderSummary(localPath);
|
||||
syncedFolderPreferencesDialogFragment.setLocalFolderSummary(localPath);
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
@@ -600,76 +704,80 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
|
||||
@Override
|
||||
public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
|
||||
getContentResolver());
|
||||
|
||||
// custom folders newly created aren't in the list already,
|
||||
// so triggering a refresh
|
||||
if (MediaFolderType.CUSTOM == syncedFolder.getType() && syncedFolder.getId() == UNPERSISTED_ID) {
|
||||
SyncedFolderDisplayItem newCustomFolder = new SyncedFolderDisplayItem(
|
||||
SyncedFolder.UNPERSISTED_ID, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(),
|
||||
syncedFolder.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(),
|
||||
syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.getEnabled(),
|
||||
new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType());
|
||||
long storedId = mSyncedFolderProvider.storeSyncedFolder(newCustomFolder);
|
||||
if (storedId != -1) {
|
||||
newCustomFolder.setId(storedId);
|
||||
if (newCustomFolder.isEnabled()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(newCustomFolder);
|
||||
} else {
|
||||
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + newCustomFolder.getId();
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
|
||||
}
|
||||
}
|
||||
mAdapter.addSyncFolderItem(newCustomFolder);
|
||||
syncedFolder.isWifiOnly(), syncedFolder.isChargingOnly(), syncedFolder.isSubfolderByDate(),
|
||||
syncedFolder.getAccount(), syncedFolder.getUploadAction(), syncedFolder.isEnabled(),
|
||||
clock.getCurrentTime(), new File(syncedFolder.getLocalPath()).getName(), syncedFolder.getType(), syncedFolder.isHidden());
|
||||
|
||||
saveOrUpdateSyncedFolder(newCustomFolder);
|
||||
adapter.addSyncFolderItem(newCustomFolder);
|
||||
} else {
|
||||
SyncedFolderDisplayItem item = mAdapter.get(syncedFolder.getSection());
|
||||
item = updateSyncedFolderItem(item, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(), syncedFolder
|
||||
.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(), syncedFolder
|
||||
.getUploadAction(), syncedFolder.getEnabled());
|
||||
SyncedFolderDisplayItem item = adapter.get(syncedFolder.getSection());
|
||||
updateSyncedFolderItem(item, syncedFolder.getId(), syncedFolder.getLocalPath(),
|
||||
syncedFolder.getRemotePath(), syncedFolder
|
||||
.isWifiOnly(), syncedFolder.isChargingOnly(), syncedFolder.isSubfolderByDate(), syncedFolder
|
||||
.getUploadAction(), syncedFolder.isEnabled());
|
||||
|
||||
if (syncedFolder.getId() == UNPERSISTED_ID) {
|
||||
// newly set up folder sync config
|
||||
long storedId = mSyncedFolderProvider.storeSyncedFolder(item);
|
||||
if (storedId != -1) {
|
||||
item.setId(storedId);
|
||||
if (item.isEnabled()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
|
||||
} else {
|
||||
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// existing synced folder setup to be updated
|
||||
mSyncedFolderProvider.updateSyncFolder(item);
|
||||
if (item.isEnabled()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
|
||||
} else {
|
||||
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
|
||||
}
|
||||
}
|
||||
saveOrUpdateSyncedFolder(item);
|
||||
|
||||
mAdapter.setSyncFolderItem(syncedFolder.getSection(), item);
|
||||
// TODO test if notifiyItemChanged is suffiecient (should improve performance)
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
mSyncedFolderPreferencesDialogFragment = null;
|
||||
syncedFolderPreferencesDialogFragment = null;
|
||||
|
||||
if (syncedFolder.getEnabled()) {
|
||||
if (syncedFolder.isEnabled()) {
|
||||
showBatteryOptimizationInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveOrUpdateSyncedFolder(SyncedFolderDisplayItem item) {
|
||||
if (item.getId() == UNPERSISTED_ID) {
|
||||
// newly set up folder sync config
|
||||
storeSyncedFolder(item);
|
||||
} else {
|
||||
// existing synced folder setup to be updated
|
||||
syncedFolderProvider.updateSyncFolder(item);
|
||||
if (item.isEnabled()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
|
||||
} else {
|
||||
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
|
||||
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
|
||||
getContentResolver());
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void storeSyncedFolder(SyncedFolderDisplayItem item) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(MainApp.getAppContext().
|
||||
getContentResolver());
|
||||
long storedId = syncedFolderProvider.storeSyncedFolder(item);
|
||||
if (storedId != -1) {
|
||||
item.setId(storedId);
|
||||
if (item.isEnabled()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(item);
|
||||
} else {
|
||||
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelSyncedFolderPreference() {
|
||||
mSyncedFolderPreferencesDialogFragment = null;
|
||||
syncedFolderPreferencesDialogFragment = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
|
||||
mSyncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
|
||||
mAdapter.removeItem(syncedFolder.getSection());
|
||||
syncedFolderProvider.deleteSyncedFolder(syncedFolder.getId());
|
||||
adapter.removeItem(syncedFolder.getSection());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,24 +791,24 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
* @param subfolderByDate created sub folders
|
||||
* @param uploadAction upload action
|
||||
* @param enabled is sync enabled
|
||||
* @return the updated item
|
||||
*/
|
||||
private SyncedFolderDisplayItem updateSyncedFolderItem(SyncedFolderDisplayItem item,
|
||||
private void updateSyncedFolderItem(SyncedFolderDisplayItem item,
|
||||
long id,
|
||||
String localPath,
|
||||
String remotePath,
|
||||
Boolean wifiOnly,
|
||||
Boolean chargingOnly,
|
||||
Boolean subfolderByDate,
|
||||
boolean wifiOnly,
|
||||
boolean chargingOnly,
|
||||
boolean subfolderByDate,
|
||||
Integer uploadAction,
|
||||
Boolean enabled) {
|
||||
boolean enabled) {
|
||||
item.setId(id);
|
||||
item.setLocalPath(localPath);
|
||||
item.setRemotePath(remotePath);
|
||||
item.setWifiOnly(wifiOnly);
|
||||
item.setChargingOnly(chargingOnly);
|
||||
item.setSubfolderByDate(subfolderByDate);
|
||||
item.setUploadAction(uploadAction);
|
||||
item.setEnabled(enabled);
|
||||
return item;
|
||||
item.setEnabled(enabled, clock.getCurrentTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -727,7 +835,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setDrawerMenuItemChecked(R.id.nav_synced_folders);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Daniel Bailey
|
||||
* Copyright (C) 2019 Daniel Bailey
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ThemedPreferenceActivity extends PreferenceActivity {
|
||||
|
||||
/**
|
||||
* Tracks whether the activity should be recreate()'d after a theme change
|
||||
*/
|
||||
private boolean themeChangePending;
|
||||
private boolean paused;
|
||||
|
||||
@Inject AppPreferences preferences;
|
||||
|
||||
private AppPreferences.Listener onThemeChangedListener = new AppPreferences.Listener() {
|
||||
@Override
|
||||
public void onDarkThemeModeChanged(DarkMode mode) {
|
||||
preferences.setDarkThemeMode(mode);
|
||||
|
||||
if (paused) {
|
||||
themeChangePending = true;
|
||||
return;
|
||||
}
|
||||
recreate();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
preferences.addListener(onThemeChangedListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
preferences.removeListener(onThemeChangedListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
paused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
paused = false;
|
||||
|
||||
if (themeChangePending) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
@@ -92,7 +91,7 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
private boolean mSelectAll;
|
||||
private boolean mLocalFolderPickerMode;
|
||||
private LocalFileListFragment mFileListFragment;
|
||||
protected Button mUploadBtn;
|
||||
protected MaterialButton mUploadBtn;
|
||||
private Spinner mBehaviourSpinner;
|
||||
private Account mAccountOnCreation;
|
||||
private DialogFragment mCurrentDialog;
|
||||
@@ -178,7 +177,8 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
mCancelButton.setOnClickListener(this);
|
||||
|
||||
mUploadBtn = findViewById(R.id.upload_files_btn_upload);
|
||||
mUploadBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
|
||||
mUploadBtn.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
|
||||
mUploadBtn.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
|
||||
mUploadBtn.setOnClickListener(this);
|
||||
|
||||
int localBehaviour = preferences.getUploaderBehaviour();
|
||||
@@ -254,7 +254,7 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
mOptionsMenu = menu;
|
||||
getMenuInflater().inflate(R.menu.upload_files_picker, menu);
|
||||
getMenuInflater().inflate(R.menu.activity_upload_files, menu);
|
||||
|
||||
if(!mLocalFolderPickerMode) {
|
||||
MenuItem selectAll = menu.findItem(R.id.action_select_all);
|
||||
|
||||
@@ -43,9 +43,11 @@ import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.JobManager;
|
||||
import com.evernote.android.job.JobRequest;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
@@ -230,9 +232,9 @@ public class UploadListActivity extends FileActivity {
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
ThemeUtils.setColoredTitle(getSupportActionBar(), R.string.uploads_view_title, this);
|
||||
final Account account = getAccount();
|
||||
if (account != null) {
|
||||
setAccountInDrawer(account);
|
||||
final Optional<User> optionalUser = getUser();
|
||||
if (optionalUser.isPresent()) {
|
||||
setAccountInDrawer(optionalUser.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +271,7 @@ public class UploadListActivity extends FileActivity {
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.upload_list_menu, menu);
|
||||
inflater.inflate(R.menu.activity_upload_list, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.AlertDialog;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@@ -135,9 +135,6 @@ public class UserInfoActivity extends FileActivity implements Injectable {
|
||||
setContentView(R.layout.user_info_layout);
|
||||
unbinder = ButterKnife.bind(this);
|
||||
|
||||
setAccount(getUserAccountManager().getCurrentAccount());
|
||||
onAccountSet();
|
||||
|
||||
boolean useBackgroundImage = URLUtil.isValidUrl(
|
||||
getStorageManager().getCapability(account.name).getServerBackground());
|
||||
|
||||
@@ -159,7 +156,7 @@ public class UserInfoActivity extends FileActivity implements Injectable {
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.user_info_menu, menu);
|
||||
inflater.inflate(R.menu.activity_user_info, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.resources.activities.model.Activity;
|
||||
import com.owncloud.android.lib.resources.files.model.FileVersion;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
@@ -69,7 +69,7 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
|
||||
this.versionListInterface = versionListInterface;
|
||||
}
|
||||
|
||||
public void setActivityAndVersionItems(List<Object> items, OwnCloudClient newClient, boolean clear) {
|
||||
public void setActivityAndVersionItems(List<Object> items, NextcloudClient newClient, boolean clear) {
|
||||
if (client == null) {
|
||||
client = newClient;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ package com.owncloud.android.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.PictureDrawable;
|
||||
import android.net.Uri;
|
||||
import android.text.Spannable;
|
||||
@@ -52,11 +51,12 @@ import com.bumptech.glide.load.model.StreamEncoder;
|
||||
import com.bumptech.glide.load.resource.file.FileToStreamDecoder;
|
||||
import com.caverock.androidsvg.SVG;
|
||||
import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.activities.model.Activity;
|
||||
import com.owncloud.android.lib.resources.activities.model.RichElement;
|
||||
@@ -91,10 +91,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
private final ActivityListInterface activityListInterface;
|
||||
private final int px;
|
||||
private static final String TAG = ActivityListAdapter.class.getSimpleName();
|
||||
protected OwnCloudClient client;
|
||||
protected NextcloudClient client;
|
||||
|
||||
protected Context context;
|
||||
private CurrentAccountProvider currentAccountProvider;
|
||||
private ClientFactory clientFactory;
|
||||
private FileDataStorageManager storageManager;
|
||||
private OCCapability capability;
|
||||
protected List<Object> values;
|
||||
@@ -118,7 +119,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
this.isDetailView = isDetailView;
|
||||
}
|
||||
|
||||
public void setActivityItems(List<Object> activityItems, OwnCloudClient client, boolean clear) {
|
||||
public void setActivityItems(List<Object> activityItems, NextcloudClient client, boolean clear) {
|
||||
this.client = client;
|
||||
String sTime = "";
|
||||
|
||||
@@ -247,8 +248,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
if (MimeTypeUtil.isImageOrVideo(previewObject.getMimeType())) {
|
||||
int placeholder = R.drawable.file;
|
||||
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider)).load(previewObject.getSource()).
|
||||
placeholder(placeholder).error(placeholder).into(imageView);
|
||||
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
|
||||
.load(previewObject.getSource())
|
||||
.placeholder(placeholder)
|
||||
.error(placeholder)
|
||||
.into(imageView);
|
||||
} else {
|
||||
if (MimeTypeUtil.isFolder(previewObject.getMimeType())) {
|
||||
imageView.setImageDrawable(
|
||||
@@ -298,8 +302,10 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
String uri = client.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px +
|
||||
Uri.encode(file.getRemotePath(), "/");
|
||||
|
||||
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider)).load(uri).placeholder(placeholder)
|
||||
.error(placeholder).into(fileIcon); // using custom fetcher
|
||||
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
|
||||
.load(uri).placeholder(placeholder)
|
||||
.error(placeholder)
|
||||
.into(fileIcon); // using custom fetcher
|
||||
|
||||
} else {
|
||||
if (isDetailView) {
|
||||
@@ -369,7 +375,12 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
}
|
||||
}, idx1, idx2, 0);
|
||||
ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), idx1, idx2, 0);
|
||||
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), idx1, idx2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.setSpan(
|
||||
new ForegroundColorSpan(context.getResources().getColor(R.color.text_color)),
|
||||
idx1,
|
||||
idx2,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
idx1 = text.indexOf('{', idx2);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.owncloud.android.ui.adapter;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -156,7 +155,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
gridViewHolder.checkbox.setImageDrawable(ThemeUtils.tintDrawable(R.drawable.ic_checkbox_marked,
|
||||
ThemeUtils.primaryColor(mContext)));
|
||||
} else {
|
||||
gridViewHolder.itemLayout.setBackgroundColor(Color.WHITE);
|
||||
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
|
||||
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ package com.owncloud.android.ui.adapter;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.PictureDrawable;
|
||||
import android.net.Uri;
|
||||
@@ -77,7 +75,7 @@ import butterknife.ButterKnife;
|
||||
public class NotificationListAdapter extends RecyclerView.Adapter<NotificationListAdapter.NotificationViewHolder> {
|
||||
private static final String FILE = "file";
|
||||
private StyleSpan styleSpanBold = new StyleSpan(Typeface.BOLD);
|
||||
private ForegroundColorSpan foregroundColorSpanBlack = new ForegroundColorSpan(Color.BLACK);
|
||||
private ForegroundColorSpan foregroundColorSpanBlack;
|
||||
|
||||
private List<Notification> notificationsList;
|
||||
private OwnCloudClient client;
|
||||
@@ -87,6 +85,8 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
||||
this.notificationsList = new ArrayList<>();
|
||||
this.client = client;
|
||||
this.notificationsActivity = notificationsActivity;
|
||||
foregroundColorSpanBlack = new ForegroundColorSpan(
|
||||
notificationsActivity.getResources().getColor(R.color.text_color));
|
||||
}
|
||||
|
||||
public void setNotificationItems(List<Notification> notificationItems) {
|
||||
@@ -166,15 +166,14 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
||||
int primaryColor = ThemeUtils.primaryColor(notificationsActivity);
|
||||
|
||||
if (action.primary) {
|
||||
button.getBackground().setColorFilter(primaryColor, PorterDuff.Mode.SRC_ATOP);
|
||||
button.setBackgroundColor(primaryColor);
|
||||
button.setTextColor(ThemeUtils.fontColor(notificationsActivity));
|
||||
button.setTypeface(button.getTypeface(), Typeface.BOLD);
|
||||
} else {
|
||||
button.setStrokeColor(ColorStateList.valueOf(resources.getColor(R.color.grey_200)));
|
||||
button.setStrokeWidth(3);
|
||||
|
||||
button.getBackground().setColorFilter(resources.getColor(R.color.transparent),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
button.setBackgroundColor(resources.getColor(R.color.transparent));
|
||||
button.setTextColor(primaryColor);
|
||||
button.setTypeface(button.getTypeface(), Typeface.BOLD);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
@@ -48,6 +47,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.R;
|
||||
@@ -118,7 +118,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
private Set<OCFile> checkedFiles;
|
||||
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private Account account;
|
||||
private User user;
|
||||
private OCFileListFragmentInterface ocFileListFragmentInterface;
|
||||
|
||||
private FilesFilter mFilesFilter;
|
||||
@@ -136,7 +136,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
public OCFileListAdapter(
|
||||
Context context,
|
||||
Account account,
|
||||
User user,
|
||||
AppPreferences preferences,
|
||||
UserAccountManager accountManager,
|
||||
ComponentsGetter transferServiceGetter,
|
||||
@@ -148,16 +148,16 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
mContext = context;
|
||||
this.preferences = preferences;
|
||||
this.accountManager = accountManager;
|
||||
this.account = account;
|
||||
this.user = user;
|
||||
mHideItemOptions = argHideItemOptions;
|
||||
this.gridView = gridView;
|
||||
checkedFiles = new HashSet<>();
|
||||
|
||||
this.transferServiceGetter = transferServiceGetter;
|
||||
|
||||
if (account != null) {
|
||||
if (this.user != null) {
|
||||
AccountManager platformAccountManager = AccountManager.get(mContext);
|
||||
userId = platformAccountManager.getUserData(account,
|
||||
userId = platformAccountManager.getUserData(this.user.toPlatformAccount(),
|
||||
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
||||
} else {
|
||||
userId = "";
|
||||
@@ -330,7 +330,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
gridViewHolder.checkbox.setImageDrawable(ThemeUtils.tintDrawable(R.drawable.ic_checkbox_marked,
|
||||
ThemeUtils.primaryColor(mContext)));
|
||||
} else {
|
||||
gridViewHolder.itemLayout.setBackgroundColor(Color.WHITE);
|
||||
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
|
||||
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
showFederatedShareAvatar(sharee.getUserId(), avatarRadius, resources, avatar);
|
||||
} else {
|
||||
avatar.setTag(sharee);
|
||||
DisplayUtils.setAvatar(account,
|
||||
DisplayUtils.setAvatar(user.toPlatformAccount(),
|
||||
sharee.getUserId(),
|
||||
sharee.getDisplayName(),
|
||||
this,
|
||||
@@ -461,17 +461,17 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
OperationsService.OperationsServiceBinder operationsServiceBinder = transferServiceGetter.getOperationsServiceBinder();
|
||||
FileDownloader.FileDownloaderBinder fileDownloaderBinder = transferServiceGetter.getFileDownloaderBinder();
|
||||
FileUploader.FileUploaderBinder fileUploaderBinder = transferServiceGetter.getFileUploaderBinder();
|
||||
if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(account, file)) {
|
||||
if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(user.toPlatformAccount(), file)) {
|
||||
//synchronizing
|
||||
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
||||
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(account, file)) {
|
||||
} else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(user.toPlatformAccount(), file)) {
|
||||
// downloading
|
||||
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
||||
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(account, file)) {
|
||||
} else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(user.toPlatformAccount(), file)) {
|
||||
//uploading
|
||||
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
||||
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
||||
@@ -576,13 +576,17 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
|
||||
try {
|
||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView, mStorageManager,
|
||||
account, asyncTasks);
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
|
||||
mStorageManager,
|
||||
user.toPlatformAccount(),
|
||||
asyncTasks);
|
||||
|
||||
if (thumbnail == null) {
|
||||
thumbnail = BitmapUtils.drawableToBitmap(
|
||||
MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
|
||||
account, mContext));
|
||||
MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
||||
file.getFileName(),
|
||||
user.toPlatformAccount(),
|
||||
mContext));
|
||||
}
|
||||
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
||||
new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(),
|
||||
@@ -598,12 +602,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
|
||||
if ("image/png".equalsIgnoreCase(file.getMimeType())) {
|
||||
thumbnailView.setBackgroundColor(mContext.getResources().getColor(R.color.background_color));
|
||||
thumbnailView.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
|
||||
}
|
||||
} else {
|
||||
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
||||
file.getFileName(),
|
||||
account,
|
||||
user.toPlatformAccount(),
|
||||
mContext));
|
||||
}
|
||||
}
|
||||
@@ -686,7 +690,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
sharedIconView.setImageResource(R.drawable.ic_unshared);
|
||||
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_share));
|
||||
}
|
||||
if (accountManager.accountOwnsFile(file, account)) {
|
||||
if (accountManager.accountOwnsFile(file, user.toPlatformAccount())) {
|
||||
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
|
||||
} else {
|
||||
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.showShareDetailView(file));
|
||||
@@ -704,7 +708,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
* @param limitToMimeType show only files of this mimeType
|
||||
*/
|
||||
public void swapDirectory(
|
||||
Account account,
|
||||
User account,
|
||||
OCFile directory,
|
||||
FileDataStorageManager updatedStorageManager,
|
||||
boolean onlyOnDevice, String limitToMimeType
|
||||
@@ -713,8 +717,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
|
||||
mStorageManager = updatedStorageManager;
|
||||
showShareAvatar = mStorageManager.getCapability(account.name).getVersion().isShareesOnDavSupported();
|
||||
this.account = account;
|
||||
showShareAvatar = mStorageManager.getCapability(account.getAccountName()).getVersion().isShareesOnDavSupported();
|
||||
this.user = account;
|
||||
}
|
||||
if (mStorageManager != null) {
|
||||
mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
|
||||
@@ -745,11 +749,11 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
FileDataStorageManager storageManager, OCFile folder, boolean clear) {
|
||||
if (storageManager != null && mStorageManager == null) {
|
||||
mStorageManager = storageManager;
|
||||
showShareAvatar = mStorageManager.getCapability(account.name).getVersion().isShareesOnDavSupported();
|
||||
showShareAvatar = mStorageManager.getCapability(user.getAccountName()).getVersion().isShareesOnDavSupported();
|
||||
}
|
||||
|
||||
if (mStorageManager == null) {
|
||||
mStorageManager = new FileDataStorageManager(account, mContext.getContentResolver());
|
||||
mStorageManager = new FileDataStorageManager(user.toPlatformAccount(), mContext.getContentResolver());
|
||||
}
|
||||
|
||||
if (clear) {
|
||||
@@ -809,12 +813,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
shares.add(ocShare);
|
||||
|
||||
// get ocFile from Server to have an up-to-date copy
|
||||
RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(account,
|
||||
RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(user.toPlatformAccount(),
|
||||
mContext);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(file, account);
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(file, user.toPlatformAccount());
|
||||
file = mStorageManager.saveFileWithParent(file, mContext);
|
||||
|
||||
ShareType newShareType = ocShare.getShareType();
|
||||
@@ -869,7 +873,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
for (Object remoteFile : objects) {
|
||||
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) remoteFile);
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, account);
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, user.toPlatformAccount());
|
||||
|
||||
try {
|
||||
if (ExtendedListFragment.SearchType.PHOTO_SEARCH == searchType) {
|
||||
@@ -886,9 +890,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
true,
|
||||
false,
|
||||
mStorageManager,
|
||||
account,
|
||||
user.toPlatformAccount(),
|
||||
mContext);
|
||||
refreshFolderOperation.execute(account, mContext);
|
||||
refreshFolderOperation.execute(user.toPlatformAccount(), mContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 345 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user