Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f7597cc68 | ||
|
|
d31a83c426 | ||
|
|
0acae91fdf | ||
|
|
f6e8636cfa | ||
|
|
ba62819180 | ||
|
|
cee5b45b84 | ||
|
|
05748959e9 | ||
|
|
969c0d3916 | ||
|
|
726e4ca7b4 | ||
|
|
444dcd000e | ||
|
|
551628d4fe | ||
|
|
9f7f28c7c1 | ||
|
|
5fa9f7420d | ||
|
|
db5b0752f8 | ||
|
|
7cbfc58036 | ||
|
|
3d7e8b770a | ||
|
|
f1a70ccb32 | ||
|
|
d721941032 | ||
|
|
f07e14fd30 | ||
|
|
7af28a1c36 | ||
|
|
e5f56152b0 | ||
|
|
4a4ad20e66 | ||
|
|
74e68d6b8e | ||
|
|
a887a4c32b | ||
|
|
50b19e5d77 | ||
|
|
bcb1262064 | ||
|
|
214689bc0d | ||
|
|
ed4917db14 | ||
|
|
815e30166e | ||
|
|
40d40c32b1 | ||
|
|
51365fa7c3 | ||
|
|
3848346f4a | ||
|
|
3c7fe3a405 | ||
|
|
8c9841f033 | ||
|
|
ff4a0a7030 | ||
|
|
197552a488 | ||
|
|
beb45efc0b | ||
|
|
b630abe052 | ||
|
|
07a2106d45 | ||
|
|
10f6ec94fa | ||
|
|
738291b2fa | ||
|
|
14fd15e9ae | ||
|
|
4073cd235c | ||
|
|
cc517ffcfd | ||
|
|
98d1b5e2b9 | ||
|
|
3102c23d2c | ||
|
|
32a0d1c309 | ||
|
|
212b3a6ef9 | ||
|
|
fd7b722ac4 | ||
|
|
0207e70323 | ||
|
|
fb5ae37a38 | ||
|
|
ced60bf59b | ||
|
|
3c609a329f | ||
|
|
9a0d1085ed | ||
|
|
a5142483a4 | ||
|
|
1edaffeafe | ||
|
|
b2ff37505e | ||
|
|
ebbedb46a0 | ||
|
|
dfe2e5dbd4 | ||
|
|
c1f5817f3f | ||
|
|
9f23230bf1 | ||
|
|
fbfdf1104a | ||
|
|
bf587f1a65 | ||
|
|
cbfa9ff6cb | ||
|
|
6db7c79962 | ||
|
|
dbae9443eb | ||
|
|
e13a3ca7cb | ||
|
|
79f4270bb9 | ||
|
|
5f73a5ec75 | ||
|
|
0ad81bdd29 | ||
|
|
8af257d54f | ||
|
|
a7088c8c87 | ||
|
|
5b76892ab1 | ||
|
|
7005cdef2e | ||
|
|
643454c1d7 | ||
|
|
20d2ef989d | ||
|
|
dfc94f4505 | ||
|
|
8f0e4eab60 | ||
|
|
93d0875883 | ||
|
|
947e4a1b10 | ||
|
|
c55e9b8fd2 | ||
|
|
2b5c39095d | ||
|
|
348ae4435a | ||
|
|
a22b0724ae | ||
|
|
c42c24be80 | ||
|
|
7e03aa39b5 | ||
|
|
097434916e | ||
|
|
728de81736 | ||
|
|
21f2ce7425 | ||
|
|
8ba7eb619e | ||
|
|
5609b5041e | ||
|
|
d36c2d35a5 | ||
|
|
741cc24d11 | ||
|
|
5288548e70 | ||
|
|
e0d5676151 | ||
|
|
7ed4e2b24e | ||
|
|
58ba15ac95 | ||
|
|
fe1cd33c26 | ||
|
|
c3f838d445 | ||
|
|
2f60b75fc5 | ||
|
|
f6e7c44596 | ||
|
|
1017e3ac3b | ||
|
|
2913918232 | ||
|
|
ca7350fa8a | ||
|
|
2c5fb2b2f9 | ||
|
|
d70502f747 | ||
|
|
38c28332e2 | ||
|
|
bd5c9dfa1e | ||
|
|
db4a7ee8f5 | ||
|
|
066fef03c2 | ||
|
|
741fb410f1 | ||
|
|
961e6c179a | ||
|
|
22657040bd | ||
|
|
a9dc3f5787 | ||
|
|
e5ec91b5a7 | ||
|
|
1ecd64f128 | ||
|
|
6dfb4c7ef6 | ||
|
|
56a1fc868d | ||
|
|
7140340c59 | ||
|
|
360f9dab90 | ||
|
|
83d4aaf1ab | ||
|
|
01d9d2e437 | ||
|
|
98d930b8ab | ||
|
|
0fa902d2d2 | ||
|
|
1f5352f2ec | ||
|
|
72fce1dd1e | ||
|
|
9e633b91b5 | ||
|
|
37fdd97c29 | ||
|
|
cb0ae700db | ||
|
|
9f3e1857db | ||
|
|
f0a608acde | ||
|
|
4a791dda86 | ||
|
|
3e05624064 | ||
|
|
33dfc9651a | ||
|
|
14172fd1f0 | ||
|
|
b18ff7404e | ||
|
|
ed8819ec86 | ||
|
|
a424706368 | ||
|
|
7ced94d42e | ||
|
|
86ebd24f2d | ||
|
|
99d6c1c5fd | ||
|
|
0aed8aaa86 | ||
|
|
c5abe938bd | ||
|
|
4e52f7f970 | ||
|
|
a43933082d | ||
|
|
374bb21c33 | ||
|
|
558f1775de | ||
|
|
934e1f406a | ||
|
|
7732ff065b | ||
|
|
9e6fa5c769 | ||
|
|
59fddce138 | ||
|
|
e503106960 | ||
|
|
96aecac8ed | ||
|
|
ab3dff9e1b | ||
|
|
2bbaf7b21d | ||
|
|
9370cbab09 | ||
|
|
a04f52915a | ||
|
|
0de60103b1 | ||
|
|
388301082d | ||
|
|
4bdd27ffe0 | ||
|
|
fb1bb6905c | ||
|
|
3a28b84e9d | ||
|
|
94d7506cb5 | ||
|
|
ab0ea3e8d9 | ||
|
|
eb08f75257 | ||
|
|
e40893a136 | ||
|
|
5f185326ab | ||
|
|
a9f689044d | ||
|
|
7360bbabfe | ||
|
|
0f9ec55d7a | ||
|
|
7802fabf0e | ||
|
|
f6f401aa0d | ||
|
|
123593fc4e | ||
|
|
a9b8bf7f3a | ||
|
|
0630142792 | ||
|
|
94dfdd88a6 | ||
|
|
33d5826337 | ||
|
|
7306bc096d | ||
|
|
a475af6ac6 | ||
|
|
c048fe2121 | ||
|
|
ace90ef2ad | ||
|
|
1b1a58ed8c | ||
|
|
6e7cdededb | ||
|
|
cc06c8b613 | ||
|
|
347abae8aa | ||
|
|
b65fd5bd46 | ||
|
|
6d3c96c8f3 | ||
|
|
6a6913b17e | ||
|
|
28279bc3c1 | ||
|
|
663537f304 | ||
|
|
39bb258648 | ||
|
|
a33cc9d278 | ||
|
|
73c22d4e8f | ||
|
|
7b88e39572 | ||
|
|
6f31f92a3f | ||
|
|
f499fb3ee8 | ||
|
|
d053177cf7 | ||
|
|
8e5f893812 | ||
|
|
7f1ba75b7d | ||
|
|
b6b57fa06e | ||
|
|
adac921f5c | ||
|
|
78b879d10f | ||
|
|
7c5948b61a | ||
|
|
0b15433cda | ||
|
|
228a44fc87 | ||
|
|
fbb3a339bc | ||
|
|
5d9d094f42 | ||
|
|
094416e8e3 | ||
|
|
fd7cf51a4b | ||
|
|
3e3d80d08c | ||
|
|
fa9804d742 | ||
|
|
49a93485c4 | ||
|
|
a2487ff457 | ||
|
|
7d000f964e | ||
|
|
b633ebd86b | ||
|
|
77ab8116cc | ||
|
|
e95caf3572 | ||
|
|
75ce22d2db | ||
|
|
9801bbef76 | ||
|
|
45ef15cd66 | ||
|
|
36eaee63b6 | ||
|
|
6bd0fd9eb6 | ||
|
|
5adef2978a | ||
|
|
9016b98cb1 | ||
|
|
389b0efe14 | ||
|
|
b0ac12f933 | ||
|
|
d968dc20b3 | ||
|
|
e9734ffb00 | ||
|
|
89eaa947e1 | ||
|
|
134286eff1 | ||
|
|
fe20249af3 | ||
|
|
af14a5ae95 | ||
|
|
9ed8713503 | ||
|
|
bb83592db3 | ||
|
|
2d3aef36f6 | ||
|
|
74e7b13968 | ||
|
|
df6256edd4 | ||
|
|
5843499d7a | ||
|
|
46c410cad6 | ||
|
|
016fa1373a | ||
|
|
2c1c49076c | ||
|
|
d9f2d996bf | ||
|
|
13f071a721 | ||
|
|
3963a0dec1 | ||
|
|
b417d6eae9 | ||
|
|
561c5f4b94 | ||
|
|
40c2de359f | ||
|
|
2c2a07de46 | ||
|
|
7f00d2b018 | ||
|
|
2b0f55982e | ||
|
|
f53b16a48c | ||
|
|
bfc054f38a | ||
|
|
08ed7a971e | ||
|
|
1bc187ec48 | ||
|
|
93e0fef71b | ||
|
|
cbe99d978e | ||
|
|
0734102c4c | ||
|
|
4e1ef91f8c | ||
|
|
25adbd4f47 | ||
|
|
c3f015b695 | ||
|
|
f0c09bdd7b | ||
|
|
abaecc3bcc | ||
|
|
b12671234a | ||
|
|
5e6beb78ff | ||
|
|
834ad8018a | ||
|
|
84d740c231 | ||
|
|
bbdeec4d9e | ||
|
|
5858f68878 | ||
|
|
c1396fd3b8 | ||
|
|
46f0880b83 | ||
|
|
8b9147ac4a | ||
|
|
4653f10957 | ||
|
|
894b4b0977 | ||
|
|
1a473b6f6e | ||
|
|
fde2de08e0 | ||
|
|
f53e509085 | ||
|
|
d37e0e8254 | ||
|
|
c0e80d5ebd | ||
|
|
f22a7c70b3 | ||
|
|
8a5d4bec67 | ||
|
|
766b7c755a | ||
|
|
6c889e62cb | ||
|
|
7f3ca4fa9f | ||
|
|
e53d40a4e3 | ||
|
|
bf7e13efbf | ||
|
|
7a9e67e788 | ||
|
|
fbfefd5235 | ||
|
|
535624264c | ||
|
|
a7bf4aa581 | ||
|
|
67e2fee514 | ||
|
|
7d2d48f1c6 | ||
|
|
7f47effb34 | ||
|
|
7651a9df83 | ||
|
|
d66a60e6af | ||
|
|
697d660d42 | ||
|
|
c45ae25414 | ||
|
|
14d6e473a3 | ||
|
|
46051694fe | ||
|
|
44793c2ba7 | ||
|
|
9caa4ab460 | ||
|
|
42f5469afc | ||
|
|
0b19e2129d | ||
|
|
796db9d195 | ||
|
|
bc2a0725ac | ||
|
|
78f1289cd5 | ||
|
|
1227572edd | ||
|
|
f8428a0d1f | ||
|
|
5f30815410 | ||
|
|
e568054e94 | ||
|
|
0c051fd72b | ||
|
|
3f1dfed3a8 | ||
|
|
0c7bec049f | ||
|
|
f36ac479a8 | ||
|
|
510c6c26e8 | ||
|
|
909c9606ce | ||
|
|
4923a8efa7 | ||
|
|
3e741eee31 | ||
|
|
99e3843427 | ||
|
|
3996901d7c | ||
|
|
c09264bc0f | ||
|
|
4f7fd16470 | ||
|
|
d19e9e0556 | ||
|
|
56d7169ca2 | ||
|
|
3a77d8071d | ||
|
|
a65b208355 | ||
|
|
0f0173ccf3 | ||
|
|
8c2c38d916 | ||
|
|
4f0bf90433 | ||
|
|
bd01843be7 | ||
|
|
d5fe7679da | ||
|
|
be11180ca9 | ||
|
|
9938f2e421 | ||
|
|
3facd6c200 | ||
|
|
97c53b38ce | ||
|
|
d7febee4fa | ||
|
|
68d6fe5557 | ||
|
|
f782e3d9fd | ||
|
|
1cc383df2a | ||
|
|
84cef3bafc | ||
|
|
de4fc2cd2b | ||
|
|
9b3f00c12d | ||
|
|
26bbfa3538 | ||
|
|
3f62afabf6 | ||
|
|
d178cde220 | ||
|
|
2b26a5176a | ||
|
|
60295480b5 | ||
|
|
020e5a2c3b | ||
|
|
2d82f80e9c | ||
|
|
706ae93a32 | ||
|
|
57ce989a5a | ||
|
|
23fea78a96 | ||
|
|
1dd355ddec | ||
|
|
e1d6842552 | ||
|
|
644b91dce0 | ||
|
|
92ddf10d07 | ||
|
|
a906a14b15 | ||
|
|
66c25fa255 | ||
|
|
6fbe0b5952 | ||
|
|
ad21ad34cd | ||
|
|
f18b9363ad | ||
|
|
ac971ae36d | ||
|
|
a5d0fe9362 | ||
|
|
4ce26101b0 | ||
|
|
55f6aebabf | ||
|
|
c9d3605ec2 | ||
|
|
489b5e0514 | ||
|
|
158d061127 | ||
|
|
a8409b3aa8 | ||
|
|
d93f893b6b | ||
|
|
613c242205 | ||
|
|
edc6198f29 | ||
|
|
0c3c286c0a | ||
|
|
7aab6137be |
No files matched your search
@@ -25,10 +25,10 @@ steps:
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport && scripts/deleteOutdatedComments.sh "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
@@ -104,10 +104,10 @@ steps:
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport && scripts/deleteOutdatedComments.sh "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $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
|
||||
@@ -187,7 +187,7 @@ steps:
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
@@ -262,7 +262,7 @@ steps:
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
@@ -388,7 +388,7 @@ steps:
|
||||
- sed -i "/qa/,/\}/ s/versionCode .*/versionCode $DRONE_BUILD_NUMBER/" build.gradle
|
||||
- sed -i "/qa/,/\}/ s/versionName .*/versionName \"$DRONE_BUILD_NUMBER\"/" build.gradle
|
||||
- ./gradlew assembleQaDebug
|
||||
- /opt/android-sdk-linux/build-tools/*/apksigner sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
- $(find /opt/android-sdk-linux/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
- scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
|
||||
trigger:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# You can add one username per supported platform and one custom link
|
||||
custom: https://www.bountysource.com/teams/nextcloud/issues?tracker_ids=38838206
|
||||
custom: https://nextcloud.com/include/
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install NDK
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install NDK
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Build generic
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
|
||||
// Gradle build file
|
||||
//
|
||||
// This project was started in Eclipse and later moved to Android Studio. In the transition, both IDEs were supported.
|
||||
// Due to this, the files layout is not the usual in new projects created with Android Studio / gradle. This file
|
||||
// merges declarations usually split in two separates build.gradle file, one for global settings of the project in
|
||||
// its root folder, another one for the app module in subfolder of root.
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.72'
|
||||
@@ -20,13 +21,11 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.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 'com.android.tools.build:gradle:4.0.0'
|
||||
classpath('com.hiya:jacoco-android:0.2')
|
||||
classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.4.4'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.9.1"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.10.0"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:4.3.0'
|
||||
}
|
||||
@@ -39,7 +38,7 @@ apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'pmd'
|
||||
apply plugin: 'jacoco-android'
|
||||
apply plugin: 'com.hiya.jacoco-android'
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
apply plugin: 'shot'
|
||||
@@ -51,7 +50,7 @@ configurations {
|
||||
exclude group: 'com.google.firebase', module: 'firebase-core'
|
||||
exclude group: 'com.google.firebase', module: 'firebase-analytics'
|
||||
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitely
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
|
||||
|
||||
// check for updates every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
@@ -60,15 +59,15 @@ configurations {
|
||||
|
||||
ext {
|
||||
jacocoVersion = "0.8.2"
|
||||
daggerVersion = "2.27"
|
||||
daggerVersion = "2.28.1"
|
||||
markwonVersion = "4.4.0"
|
||||
prismVersion = "2.0.0"
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
androidLibraryVersion ="f37013d222bc868514fa74a94fa9efd8fd2db8bc"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
// allows for -Dpre-dex=false to be set
|
||||
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
|
||||
// allows for -D pre-dex=false to be set
|
||||
preDexEnabled = "true" == System.getProperty("pre-dex", "true")
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -99,9 +98,7 @@ for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()
|
||||
}
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '3.1.12'
|
||||
}
|
||||
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
@@ -126,7 +123,7 @@ android {
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 17
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 29
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
@@ -174,8 +171,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20200129
|
||||
versionName "20200129"
|
||||
versionCode 20200701
|
||||
versionName "20200701"
|
||||
}
|
||||
|
||||
qa {
|
||||
@@ -196,7 +193,7 @@ android {
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
dexOptions {
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -D pre-dex=false.
|
||||
preDexLibraries = preDexEnabled && !travisBuild
|
||||
}
|
||||
|
||||
@@ -238,41 +235,33 @@ android {
|
||||
android.applicationVariants.all { variant ->
|
||||
String variantName = variant.name
|
||||
String capVariantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1)
|
||||
tasks.register("spotbugs${capVariantName}", SpotBugsTask) {
|
||||
tasks.register("spotbugs${capVariantName}Report", SpotBugsTask) {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = "max"
|
||||
reportLevel = "medium"
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
|
||||
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
|
||||
pluginClasspath = project.configurations.spotbugsPlugins
|
||||
source = fileTree('src/main/java')
|
||||
classpath = files()
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = true
|
||||
html {
|
||||
enabled = true
|
||||
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled true
|
||||
}
|
||||
|
||||
viewBinding {
|
||||
enabled true
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,6 +295,7 @@ dependencies {
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
|
||||
implementation "androidx.work:work-runtime:2.3.4"
|
||||
implementation "androidx.work:work-runtime-ktx:2.3.4"
|
||||
implementation "androidx.fragment:fragment:1.2.5"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.7'
|
||||
@@ -341,7 +331,7 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.36.0"
|
||||
ktlint "com.pinterest:ktlint:0.37.2"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.4.0'
|
||||
|
||||
// Shimmer animation
|
||||
@@ -368,8 +358,6 @@ dependencies {
|
||||
testImplementation 'org.json:json:20200518'
|
||||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||
kaptAndroidTest "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kaptTest "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
@@ -402,7 +390,11 @@ dependencies {
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
androidTestImplementation "org.mockito:mockito-android:3.3.3"
|
||||
androidTestImplementation 'net.bytebuddy:byte-buddy:1.10.11'
|
||||
androidTestImplementation 'net.bytebuddy:byte-buddy:1.10.13'
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '3.1.12'
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
@@ -425,17 +417,15 @@ android.applicationVariants.all { variant ->
|
||||
tasks.register("combinedTestReport", JacocoReport) {
|
||||
|
||||
reports {
|
||||
xml.enabled = true
|
||||
html.enabled = true
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
csv.enabled false
|
||||
}
|
||||
|
||||
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
|
||||
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
|
||||
def mainSrc = "$project.projectDir/src/main/java"
|
||||
|
||||
sourceDirectories = files([mainSrc])
|
||||
classDirectories = files([debugTree])
|
||||
executionData = fileTree(dir: project.buildDir, includes: [
|
||||
additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
classDirectories.setFrom files(subprojects.sourceSets.main.output)
|
||||
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Wed Aug 21 07:03:37 CEST 2019
|
||||
#Fri May 29 07:39:21 CEST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
@@ -55,4 +55,11 @@
|
||||
<issue id="NewApi" severity="error">
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<issue id="ObsoleteLintCustomCheck" severity="warning">
|
||||
<ignore path="**/fragment-1.2.5/**/lint.jar" />
|
||||
<ignore path="**/work-runtime-2.3.4/**/lint.jar" />
|
||||
<ignore path="**/jetified-butterknife-runtime-10.2.1/**/lint.jar" />
|
||||
<ignore path="**/jetified-dagger-lint-aar-2.28.1/**/lint.jar" />
|
||||
</issue>
|
||||
</lint>
|
||||
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@@ -1 +1 @@
|
||||
373
|
||||
335
|
||||
@@ -56,7 +56,7 @@ if result != 0
|
||||
exit 1
|
||||
end
|
||||
|
||||
system './gradlew spotbugsGplayDebug'
|
||||
system './gradlew spotbugsGplayDebugReport'
|
||||
|
||||
# find FindBugs report file
|
||||
findbugs_reports = Dir.glob(FINDBUGS_REPORT_FILE)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 95 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 83 warnings</span>
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BRANCH=$1
|
||||
TYPE=$2
|
||||
PR=$3
|
||||
GITHUB_USER=$4
|
||||
GITHUB_PASSWORD=$5
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
|
||||
# delete all old comments, matching this type
|
||||
oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -74,7 +74,7 @@ sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g
|
||||
|
||||
## update/create all screenshots
|
||||
#./gradlew gplayDebugExecuteScreenshotTests -Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotOnServerTest
|
||||
#-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest
|
||||
|
||||
## update screenshots in a class
|
||||
#./gradlew gplayDebugExecuteScreenshotTests \
|
||||
@@ -94,7 +94,7 @@ until [ $resultCode -eq 0 ] || [ $retryCount -gt 2 ]
|
||||
do
|
||||
# test all screenshots
|
||||
./gradlew gplayDebugExecuteScreenshotTests \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotOnServerTest
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest
|
||||
|
||||
resultCode=$?
|
||||
((retryCount++))
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## emulator
|
||||
if [[ ! $(emulator -list-avds | grep uiComparison -c) -eq 0 ]]; then
|
||||
avdmanager delete avd -n uiComparison
|
||||
(sleep 5; echo "no") | avdmanager create avd -n uiComparison -c 100M -k "system-images;android-27;google_apis;x86" --abi "google_apis/x86"
|
||||
fi
|
||||
|
||||
if [ "$1" == "debug" ]; then
|
||||
emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 1>/dev/null &
|
||||
else
|
||||
emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 1>/dev/null &
|
||||
fi
|
||||
PID=$!
|
||||
|
||||
scripts/wait_for_emulator.sh
|
||||
|
||||
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
|
||||
## update/create all screenshots
|
||||
#./gradlew gplayDebugExecuteScreenshotTests -Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotWithoutServerTest
|
||||
|
||||
## update screenshots in a class
|
||||
#./gradlew gplayDebugExecuteScreenshotTests \
|
||||
#-Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.class=\
|
||||
#com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest
|
||||
|
||||
## update single screenshot within a class
|
||||
#./gradlew gplayDebugExecuteScreenshotTests \
|
||||
#-Precord \
|
||||
#-Pandroid.testInstrumentationRunnerArguments.class=\
|
||||
#com.nextcloud.client.FileDisplayActivityIT#showShares
|
||||
|
||||
resultCode=-1
|
||||
retryCount=0
|
||||
until [ $resultCode -eq 0 ] || [ $retryCount -gt 2 ]
|
||||
do
|
||||
# test all screenshots
|
||||
./gradlew gplayDebugRemoveScreenshots
|
||||
./gradlew gplayDebugExecuteScreenshotTests \
|
||||
-Precord \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotWithoutServerTest
|
||||
|
||||
resultCode=$?
|
||||
((retryCount++))
|
||||
done
|
||||
|
||||
sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g src/main/res/values/setup.xml
|
||||
|
||||
if [ "$1" == "debug" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# tidy up
|
||||
kill "$PID"
|
||||
@@ -1,6 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
deleteOldComments() {
|
||||
# delete all old comments, matching this type
|
||||
echo "Deleting old comments for $BRANCH_TYPE"
|
||||
oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
count=$(echo $oldComments | grep true | wc -l)
|
||||
echo "Found $count old comments"
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
echo "Deleting comment: $comment"
|
||||
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
}
|
||||
|
||||
upload() {
|
||||
deleteOldComments
|
||||
|
||||
cd $1
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
|
||||
@@ -9,7 +24,7 @@ upload() {
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
|
||||
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
||||
-d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
||||
|
||||
exit 1
|
||||
}
|
||||
@@ -17,10 +32,11 @@ upload() {
|
||||
#1: LOG_USERNAME
|
||||
#2: LOG_PASSWORD
|
||||
#3: DRONE_BUILD_NUMBER
|
||||
#4: TYPE (IT or Unit)
|
||||
#5: DRONE_PULL_REQUEST
|
||||
#6: GIT_USERNAME
|
||||
#7: GIT_TOKEN
|
||||
#4: BRANCH (stable or master)
|
||||
#5: TYPE (IT or Unit)
|
||||
#6: DRONE_PULL_REQUEST
|
||||
#7: GIT_USERNAME
|
||||
#8: GIT_TOKEN
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
||||
ID=$3
|
||||
@@ -31,7 +47,8 @@ TYPE=$5
|
||||
PR=$6
|
||||
GITHUB_USER=$7
|
||||
GITHUB_PASSWORD=$8
|
||||
REMOTE_FOLDER=$ID-$TYPE
|
||||
REMOTE_FOLDER=$ID-$TYPE-$BRANCH
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
|
||||
set -e
|
||||
|
||||
@@ -46,24 +63,28 @@ fi
|
||||
if [ -e $FOLDER ]; then
|
||||
upload $FOLDER
|
||||
else
|
||||
echo "$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
deleteOldComments
|
||||
echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD \
|
||||
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
-d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
|
||||
if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
|
||||
TYPE="IT"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/androidTests/connected/flavors/GPLAY"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
|
||||
TYPE="Unit"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/tests/testGplayDebugUnitTest"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/shot/verification ] ; then
|
||||
TYPE="Screenshot"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/shot/verification"
|
||||
fi
|
||||
fi
|
||||
@@ -32,6 +32,7 @@
|
||||
<Or>
|
||||
<Class name="~.*BindingImpl"/>
|
||||
<Class name="~.*\.DataBinderMapperImpl" />
|
||||
<Class name="~.*Binding" />
|
||||
</Or>
|
||||
</Match>
|
||||
|
||||
|
||||
@@ -31,6 +31,4 @@
|
||||
android:sharedUserId="${applicationId}.uid">
|
||||
|
||||
<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator, tools.fastlane.screengrab" />
|
||||
|
||||
<application android:name="com.owncloud.android.TestApp"></application>
|
||||
</manifest>
|
||||
@@ -23,13 +23,13 @@
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activities.ActivitiesActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithoutServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -52,18 +52,6 @@ public class ActivitiesActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithoutServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
ActivitiesActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithoutServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
ActivitiesActivity sut = activityRule.launchActivity(null);
|
||||
@@ -72,7 +60,15 @@ public class ActivitiesActivityIT extends AbstractIT {
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
shortSleep();
|
||||
sut.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sut.emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
sut.recyclerView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.events.SearchEvent;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
@@ -67,7 +66,6 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
@@ -78,7 +76,6 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void drawer() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
@@ -93,7 +90,6 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void showShares() {
|
||||
assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -48,7 +47,6 @@ public class FirstRunActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.Manifest;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.NotificationsActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -46,7 +45,6 @@ public class NotificationsActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
|
||||
@@ -22,25 +22,14 @@
|
||||
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.facebook.testing.screenshot.ScreenshotRunner;
|
||||
import com.owncloud.android.TestApp;
|
||||
|
||||
import androidx.test.runner.AndroidJUnitRunner;
|
||||
|
||||
public class ScreenshotTestRunner extends AndroidJUnitRunner {
|
||||
|
||||
@Override
|
||||
public Application newApplication(ClassLoader cl, String className, Context context)
|
||||
throws ClassNotFoundException,
|
||||
IllegalAccessException,
|
||||
InstantiationException {
|
||||
return super.newApplication(cl, TestApp.class.getName(), context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle args) {
|
||||
super.onCreate(args);
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithoutServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -48,7 +47,6 @@ public class SettingsActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithoutServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity test = activityRule.launchActivity(null);
|
||||
|
||||
@@ -26,7 +26,7 @@ import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -45,7 +45,6 @@ public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.Manifest;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.UploadListActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -46,7 +45,6 @@ public class UploadListActivityActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.facebook.testing.screenshot.Screenshot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest
|
||||
import org.junit.Assume
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -42,13 +41,14 @@ class EtmActivityTest : AbstractIT() {
|
||||
@Before
|
||||
fun before() {
|
||||
// tests only on NC 18
|
||||
Assume.assumeTrue(storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0)
|
||||
Assume.assumeTrue(
|
||||
storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun overview() {
|
||||
val sut: Activity = activityRule.launchActivity(null)
|
||||
@@ -59,7 +59,6 @@ class EtmActivityTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun preferences() {
|
||||
val sut: EtmActivity = activityRule.launchActivity(null)
|
||||
@@ -70,7 +69,6 @@ class EtmActivityTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun accounts() {
|
||||
val sut: EtmActivity = activityRule.launchActivity(null)
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files
|
||||
|
||||
import android.net.Uri
|
||||
import com.nextcloud.client.account.Server
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nhaarman.mockitokotlin2.mock
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.junit.runners.Suite
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.net.URI
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
DeepLinkHandlerTest.DeepLinkPattern::class,
|
||||
DeepLinkHandlerTest.FileDeepLink::class
|
||||
)
|
||||
class DeepLinkHandlerTest {
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
class DeepLinkPattern {
|
||||
|
||||
companion object {
|
||||
val FILE_ID = 1234
|
||||
val SERVER_BASE_URLS = listOf(
|
||||
"http://hostname.net",
|
||||
"https://hostname.net",
|
||||
"http://hostname.net/subdir1",
|
||||
"https://hostname.net/subdir1",
|
||||
"http://hostname.net/subdir1/subdir2",
|
||||
"https://hostname.net/subdir1/subdir2",
|
||||
"http://hostname.net/subdir1/subdir2/subdir3",
|
||||
"https://hostname.net/subdir1/subdir2/subdir3"
|
||||
)
|
||||
val INDEX_PHP_PATH = listOf(
|
||||
"",
|
||||
"/index.php"
|
||||
)
|
||||
|
||||
@Parameterized.Parameters
|
||||
@JvmStatic
|
||||
fun urls(): Array<Array<Any>> {
|
||||
val testInput = mutableListOf<Array<Any>>()
|
||||
SERVER_BASE_URLS.forEach { baseUrl ->
|
||||
INDEX_PHP_PATH.forEach { indexPath ->
|
||||
val url = "$baseUrl$indexPath/f/$FILE_ID"
|
||||
testInput.add(arrayOf(baseUrl, indexPath, "$FILE_ID", url))
|
||||
}
|
||||
}
|
||||
return testInput.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
lateinit var baseUrl: String
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
lateinit var indexPath: String
|
||||
|
||||
@Parameterized.Parameter(2)
|
||||
lateinit var fileId: String
|
||||
|
||||
@Parameterized.Parameter(3)
|
||||
lateinit var url: String
|
||||
|
||||
@Test
|
||||
fun matches_deep_link_patterns() {
|
||||
val match = DeepLinkHandler.DEEP_LINK_PATTERN.matchEntire(url)
|
||||
assertNotNull("Url [$url] does not match pattern", match)
|
||||
assertEquals(baseUrl, match?.groupValues?.get(DeepLinkHandler.BASE_URL_GROUP_INDEX))
|
||||
assertEquals(indexPath, match?.groupValues?.get(DeepLinkHandler.INDEX_PATH_GROUP_INDEX))
|
||||
assertEquals(fileId, match?.groupValues?.get(DeepLinkHandler.FILE_ID_GROUP_INDEX))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_trailing_path_allowed_after_file_id() {
|
||||
val invalidUrl = "$url/"
|
||||
val match = DeepLinkHandler.DEEP_LINK_PATTERN.matchEntire(invalidUrl)
|
||||
assertNull(match)
|
||||
}
|
||||
}
|
||||
|
||||
class FileDeepLink {
|
||||
|
||||
companion object {
|
||||
const val OTHER_SERVER_BASE_URL = "https://someotherserver.net"
|
||||
const val SERVER_BASE_URL = "https://server.net"
|
||||
const val FILE_ID = "1234567890"
|
||||
val DEEP_LINK = Uri.parse("$SERVER_BASE_URL/index.php/f/$FILE_ID")
|
||||
|
||||
fun createMockUser(serverBaseUrl: String): User {
|
||||
val user = mock<User>()
|
||||
val uri = URI.create(serverBaseUrl)
|
||||
val server = Server(uri = uri, version = OwnCloudVersion.nextcloud_19)
|
||||
whenever(user.server).thenReturn(server)
|
||||
return user
|
||||
}
|
||||
}
|
||||
|
||||
@Mock
|
||||
lateinit var userAccountManager: UserAccountManager
|
||||
lateinit var allUsers: List<User>
|
||||
lateinit var handler: DeepLinkHandler
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
whenever(userAccountManager.allUsers).thenAnswer { allUsers }
|
||||
allUsers = emptyList()
|
||||
handler = DeepLinkHandler(userAccountManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_user_can_open_file() {
|
||||
// GIVEN
|
||||
// no user capable of opening the file
|
||||
allUsers = listOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link is valid
|
||||
// no user can open the file
|
||||
assertNotNull(match)
|
||||
assertEquals(0, match?.users?.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun single_user_can_open_file() {
|
||||
// GIVEN
|
||||
// multiple users registered
|
||||
// one user capable of opening the link
|
||||
val matchingUser = createMockUser(SERVER_BASE_URL)
|
||||
allUsers = listOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
matchingUser,
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link can be opened by single user
|
||||
assertNotNull(match)
|
||||
assertSame(matchingUser, match?.users?.get(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiple_users_can_open_file() {
|
||||
// GIVEN
|
||||
// mutltiple users registered
|
||||
// multiple users capable of opening the link
|
||||
val matchingUsers = setOf(
|
||||
createMockUser(SERVER_BASE_URL),
|
||||
createMockUser(SERVER_BASE_URL)
|
||||
)
|
||||
val otherUsers = setOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
allUsers = listOf(matchingUsers, otherUsers).flatten()
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link can be opened by multiple matching users
|
||||
assertNotNull(match)
|
||||
assertEquals(matchingUsers, match?.users?.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun match_contains_extracted_file_id() {
|
||||
// WHEN
|
||||
// valid deep file link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// file id is returned
|
||||
assertEquals(FILE_ID, match?.fileId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_match_for_invalid_link() {
|
||||
// GIVEN
|
||||
// invalid deep link
|
||||
val invalidLink = Uri.parse("http://www.dodgylink.com/index.php")
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(invalidLink)
|
||||
|
||||
// THEN
|
||||
// no match
|
||||
assertNull(match)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.integration.deck
|
||||
package com.nextcloud.client.integrations.deck
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -243,10 +243,7 @@ class MigrationsManagerTest {
|
||||
// pending migrations
|
||||
// mandatory migrations are passing
|
||||
// one migration is optional and fails
|
||||
assertEquals("Fixture should provide 1 optional, failing migration",
|
||||
1,
|
||||
migrations.count { !it.mandatory }
|
||||
)
|
||||
assertEquals("Fixture should provide 1 optional, failing migration", 1, migrations.count { !it.mandatory })
|
||||
val optionalFailingMigration = migrations.first { !it.mandatory }
|
||||
whenever(optionalFailingMigration.run()).thenThrow(RuntimeException())
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android;
|
||||
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesServiceApi;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class ActivitiesModuleMock {
|
||||
@Provides
|
||||
ActivitiesRepository activitiesRepository(ActivitiesServiceApi api) {
|
||||
return new LocalActivitiesRepository();
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
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;
|
||||
import com.owncloud.android.lib.resources.activities.model.RichElementTypeAdapter;
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject;
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObjectAdapter;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.TAG;
|
||||
|
||||
public class LocalActivitiesRepository implements ActivitiesRepository {
|
||||
String json = "{\n" +
|
||||
" \"ocs\": {\n" +
|
||||
" \"meta\": {\n" +
|
||||
" \"status\": \"ok\",\n" +
|
||||
" \"statuscode\": 200,\n" +
|
||||
" \"message\": \"OK\"\n" +
|
||||
" },\n" +
|
||||
" \"data\": [\n" +
|
||||
" {\n" +
|
||||
" \"activity_id\": 1114442,\n" +
|
||||
" \"app\": \"files\",\n" +
|
||||
" \"type\": \"file_created\",\n" +
|
||||
" \"user\": \"test\",\n" +
|
||||
" \"subject\": \"You created IMG_0255.JPG\",\n" +
|
||||
" \"subject_rich\": [\n" +
|
||||
" \"You created {file}\",\n" +
|
||||
" {\n" +
|
||||
" \"file\": {\n" +
|
||||
" \"type\": \"file\",\n" +
|
||||
" \"id\": \"3523820\",\n" +
|
||||
" \"name\": \"IMG_0255.JPG\",\n" +
|
||||
" \"path\": \"IMG_0255.JPG\",\n" +
|
||||
" \"link\": \"https:\\/\\/cloud.server.com\\/f\\/3523820\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"message\": \"\",\n" +
|
||||
" \"message_rich\": [\n" +
|
||||
" \"\",\n" +
|
||||
" []\n" +
|
||||
" ],\n" +
|
||||
" \"object_type\": \"files\",\n" +
|
||||
" \"object_id\": 3523820,\n" +
|
||||
" \"object_name\": \"\\/IMG_0255.JPG\",\n" +
|
||||
" \"objects\": {\n" +
|
||||
" \"3523820\": \"\\/IMG_0255.JPG\"\n" +
|
||||
" },\n" +
|
||||
" \"link\": \"https:\\/\\/cloud.server.com\\/apps\\/files\\/?dir=\\/\",\n" +
|
||||
" \"icon\": \"https:\\/\\/cloud.server.com\\/apps\\/files\\/img\\/add-color.svg\",\n" +
|
||||
" \"datetime\": \"2020-03-19T12:18:25+00:00\",\n" +
|
||||
" \"previews\": [\n" +
|
||||
" {\n" +
|
||||
" \"link\": \"https:\\/\\/cloud.server.com\\/apps\\/files\\/?dir=\\/&scrollto=IMG_0255.JPG\",\n" +
|
||||
" \"source\": \"https:\\/\\/cloud.server.com\\/core\\/preview.png?file=\\/IMG_0255.JPG&c=b68e0f2668cc89eec0d17e6125ff8ae7&x=150&y=150\",\n" +
|
||||
" \"mimeType\": \"image\\/jpeg\",\n" +
|
||||
" \"isMimeTypeIcon\": false,\n" +
|
||||
" \"fileId\": 3523820,\n" +
|
||||
" \"view\": \"files\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }]}}";
|
||||
|
||||
@Override
|
||||
public void getActivities(int lastGiven, @NonNull LoadActivitiesCallback callback) {
|
||||
|
||||
ArrayList activities = parseResult(json);
|
||||
|
||||
callback.onActivitiesLoaded(activities, 1);
|
||||
}
|
||||
|
||||
protected ArrayList<Activity> parseResult(String response) {
|
||||
if (response == null || response.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
try {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
JsonObject jo = (JsonObject) jsonParser.parse(response);
|
||||
JsonArray jsonDataArray = jo.getAsJsonObject("ocs").getAsJsonArray("data");
|
||||
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(RichElement.class, new RichElementTypeAdapter())
|
||||
.registerTypeAdapter(PreviewObject.class, new PreviewObjectAdapter())
|
||||
.create();
|
||||
Type listType = new TypeToken<List<Activity>>() {
|
||||
}.getType();
|
||||
|
||||
return gson.fromJson(jsonDataArray, listType);
|
||||
|
||||
} catch (JsonSyntaxException e) {
|
||||
Log_OC.e(TAG, "Not a valid json: " + response, e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.nextcloud.client.appinfo.AppInfoModule;
|
||||
import com.nextcloud.client.device.DeviceModule;
|
||||
import com.nextcloud.client.di.AppModule;
|
||||
import com.nextcloud.client.di.ViewModelModule;
|
||||
import com.nextcloud.client.jobs.JobsModule;
|
||||
import com.nextcloud.client.network.NetworkModule;
|
||||
import com.nextcloud.client.onboarding.OnboardingModule;
|
||||
import com.nextcloud.client.preferences.PreferencesModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Component;
|
||||
import dagger.android.support.AndroidSupportInjectionModule;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
AndroidSupportInjectionModule.class,
|
||||
AppModule.class,
|
||||
PreferencesModule.class,
|
||||
AppInfoModule.class,
|
||||
NetworkModule.class,
|
||||
DeviceModule.class,
|
||||
OnboardingModule.class,
|
||||
ViewModelModule.class,
|
||||
JobsModule.class,
|
||||
ActivitiesModuleMock.class
|
||||
})
|
||||
|
||||
public interface TestAppComponent {
|
||||
|
||||
void inject(TestApp app);
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
Builder application(Application application);
|
||||
|
||||
TestAppComponent build();
|
||||
}
|
||||
}
|
||||
@@ -77,20 +77,24 @@ class FileUploaderIT : AbstractIT() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
@@ -99,19 +103,23 @@ class FileUploaderIT : AbstractIT() {
|
||||
|
||||
val ocUpload2 = OCUpload(getSavePath(account.name) + "/empty.txt", "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
@@ -137,7 +145,8 @@ class FileUploaderIT : AbstractIT() {
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT)
|
||||
FileUploader.NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
@@ -154,7 +163,8 @@ class FileUploaderIT : AbstractIT() {
|
||||
account,
|
||||
ocFile2,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE)
|
||||
FileUploader.NameCollisionPolicy.OVERWRITE
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
@@ -174,20 +184,24 @@ class FileUploaderIT : AbstractIT() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
@@ -197,22 +211,26 @@ class FileUploaderIT : AbstractIT() {
|
||||
val file2 = File(getSavePath(account.name) + "/empty.txt")
|
||||
val ocUpload2 = OCUpload(file2.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.RENAME,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.addRenameUploadListener {
|
||||
renameListenerWasTriggered = true
|
||||
}
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.RENAME,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.addRenameUploadListener {
|
||||
renameListenerWasTriggered = true
|
||||
}
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
@@ -244,7 +262,8 @@ class FileUploaderIT : AbstractIT() {
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT)
|
||||
FileUploader.NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
@@ -261,7 +280,8 @@ class FileUploaderIT : AbstractIT() {
|
||||
account,
|
||||
ocFile2,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
FileUploader.NameCollisionPolicy.RENAME)
|
||||
FileUploader.NameCollisionPolicy.RENAME
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
@@ -284,20 +304,24 @@ class FileUploaderIT : AbstractIT() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
@@ -306,19 +330,22 @@ class FileUploaderIT : AbstractIT() {
|
||||
|
||||
val ocUpload2 = OCUpload(getSavePath(account.name) + "/empty.txt", "/testFile.txt", account.name)
|
||||
|
||||
assertFalse(UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.CANCEL,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
.execute(client, storageManager).isSuccess)
|
||||
assertFalse(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
null,
|
||||
ocUpload2,
|
||||
FileUploader.NameCollisionPolicy.CANCEL,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
)
|
||||
.execute(client, storageManager).isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
@@ -344,7 +371,8 @@ class FileUploaderIT : AbstractIT() {
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT)
|
||||
FileUploader.NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
@@ -361,7 +389,8 @@ class FileUploaderIT : AbstractIT() {
|
||||
account,
|
||||
ocFile2,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
FileUploader.NameCollisionPolicy.CANCEL)
|
||||
FileUploader.NameCollisionPolicy.CANCEL
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -42,7 +41,6 @@ public class ManageAccountsActivityIT extends AbstractIT {
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
@@ -53,7 +51,6 @@ public class ManageAccountsActivityIT extends AbstractIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void userInfoDetail() {
|
||||
ManageAccountsActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
@@ -50,7 +50,6 @@ import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -90,14 +89,15 @@ class OCFileListFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun showRichWorkspace() {
|
||||
assertTrue(CreateFolderOperation("/test/", account, targetContext).execute(client, storageManager).isSuccess)
|
||||
|
||||
val ocUpload = OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
val ocUpload = OCUpload(
|
||||
FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
"/test/Readme.md",
|
||||
account.name)
|
||||
account.name
|
||||
)
|
||||
val newUpload = UploadFileOperation(
|
||||
UploadsStorageManager(UserAccountManagerImpl.fromContext(targetContext), targetContext.contentResolver),
|
||||
connectivityServiceMock,
|
||||
@@ -109,20 +109,27 @@ class OCFileListFragmentIT : AbstractIT() {
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false)
|
||||
false
|
||||
)
|
||||
|
||||
newUpload.addRenameUploadListener {}
|
||||
newUpload.setRemoteFolderToBeCreated()
|
||||
|
||||
assertTrue(newUpload.execute(client, storageManager).isSuccess)
|
||||
|
||||
assertTrue(RefreshFolderOperation(storageManager.getFileByPath("/test/"),
|
||||
System.currentTimeMillis() / SECOND_IN_MILLIS,
|
||||
false,
|
||||
true,
|
||||
storageManager,
|
||||
account,
|
||||
targetContext).execute(client).isSuccess)
|
||||
assertTrue(
|
||||
RefreshFolderOperation(
|
||||
storageManager.getFileByPath("/test/"),
|
||||
System.currentTimeMillis() / SECOND_IN_MILLIS,
|
||||
false,
|
||||
true,
|
||||
storageManager,
|
||||
account,
|
||||
targetContext
|
||||
)
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val sut = ActivityScenario.launch(FileDisplayActivity::class.java)
|
||||
shortSleep()
|
||||
@@ -169,22 +176,27 @@ class OCFileListFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun createAndShowShareToUser() {
|
||||
val path = "/shareToAdmin/"
|
||||
TestCase.assertTrue(CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
// share folder to user "admin"
|
||||
TestCase.assertTrue(CreateShareRemoteOperation(path,
|
||||
ShareType.USER,
|
||||
"admin",
|
||||
false,
|
||||
"",
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
|
||||
.execute(client).isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateShareRemoteOperation(
|
||||
path,
|
||||
ShareType.USER,
|
||||
"admin",
|
||||
false,
|
||||
"",
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER
|
||||
)
|
||||
.execute(client).isSuccess
|
||||
)
|
||||
|
||||
val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
||||
sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
||||
@@ -195,22 +207,28 @@ class OCFileListFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun createAndShowShareToGroup() {
|
||||
val path = "/shareToGroup/"
|
||||
TestCase.assertTrue(CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
// share folder to group
|
||||
assertTrue(CreateShareRemoteOperation("/shareToGroup/",
|
||||
ShareType.GROUP,
|
||||
"users",
|
||||
false,
|
||||
"",
|
||||
OCShare.DEFAULT_PERMISSION)
|
||||
.execute(client).isSuccess)
|
||||
assertTrue(
|
||||
CreateShareRemoteOperation(
|
||||
"/shareToGroup/",
|
||||
ShareType.GROUP,
|
||||
"users",
|
||||
false,
|
||||
"",
|
||||
OCShare.DEFAULT_PERMISSION
|
||||
)
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
||||
sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
||||
@@ -253,22 +271,28 @@ class OCFileListFragmentIT : AbstractIT() {
|
||||
// }
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
fun createAndShowShareViaLink() {
|
||||
val path = "/shareViaLink/"
|
||||
TestCase.assertTrue(CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateFolderOperation(path, account, targetContext)
|
||||
.execute(client, storageManager)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
// share folder via public link
|
||||
TestCase.assertTrue(CreateShareRemoteOperation("/shareViaLink/",
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
true,
|
||||
"",
|
||||
OCShare.READ_PERMISSION_FLAG)
|
||||
.execute(client).isSuccess)
|
||||
TestCase.assertTrue(
|
||||
CreateShareRemoteOperation(
|
||||
"/shareViaLink/",
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
true,
|
||||
"",
|
||||
OCShare.READ_PERMISSION_FLAG
|
||||
)
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val sut: FileDisplayActivity = activityRule.launchActivity(null)
|
||||
sut.startSyncFolderOperation(storageManager.getFileByPath("/"), true)
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.ScreenshotWithServerTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -52,7 +51,6 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void displaySimpleTextFile() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
@@ -71,7 +69,6 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotWithServerTest
|
||||
@ScreenshotTest
|
||||
public void displayJavaSnippetFile() throws IOException {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Savarankiška produktyvumo platforma, leidžianti Jums išlaikyti kontrolę.
|
||||
|
||||
Savybės:
|
||||
* Paprasta, moderni sąsaja, tinkanti Jūsų serveriui.
|
||||
* Įkelti failai į „Nextcloud“ serverį
|
||||
* Failų bendrinimas su kitais naudotojais
|
||||
* Mėgstamų failų ir aplankų sinchronizacija.
|
||||
* Galima paieška visuose serverio aplankuose.
|
||||
* Automatinis Jūsų įrenginio darytų nuotraukų ir vaizdo įrašų įkėlimas
|
||||
* Pranešimai apie atnaujinimus
|
||||
* Kelių paskyrų palaikymas
|
||||
* Saugi prieiga prie savo duomenų naudojant pirštų atspaudus arba PIN kodą
|
||||
* Integracija su „DAVx5“ (anksčiau vadintu „DAVdroid“), kad būtų galima lengvai nustatyti kalendoriaus & kontaktų sinchronizavimą
|
||||
. Prašome praneškite apie visas kilusias problemas puslapyje https://github.com/nextcloud/android/issues arba https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Naujai prisijungėte Nextcloud? „Nextcloud“ yra privatus failų sinchronizavimo & ir ryšių serveris. Tai nemokama programinė įranga, kurią galite admnistruoti patys arba naudotis mokamais kitų įmonių pasiūlymais. Nextcloud Jūs kontroliuoti savo nuotraukas, kalendorių ar kontaktinius duomenis, dokumentus ir visa kita.
|
||||
|
||||
Išbandykite „Nextcloud“ https://nextcloud.com.
|
||||
@@ -1 +1 @@
|
||||
Nextcloud Android programėlė suteikia jums mobiliąją prieigą prie jūsų visų Next
|
||||
Savarankiška platforma, leidžianti Jums išlaikyti kontrolę
|
||||
@@ -66,12 +66,6 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name="com.evernote.android.job.gcm.PlatformGcmService"
|
||||
android:enabled="true"
|
||||
tools:node="remove">
|
||||
</service>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -121,14 +121,13 @@
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="http"
|
||||
android:host="*"
|
||||
android:pathPattern="/.*index.php/f/.*"
|
||||
/>
|
||||
<data android:scheme="https"
|
||||
android:host="*"
|
||||
android:pathPattern="/.*index.php/f/.*"
|
||||
/>
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="*" />
|
||||
<data android:pathPattern="/f/..*" />
|
||||
<data android:pathPattern="/..*/f/..*" />
|
||||
<data android:pathPattern="/..*/..*/f/..*" />
|
||||
<data android:pathPattern="/..*/..*/..*/f/..*" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable"
|
||||
android:resource="@xml/users_and_groups_searchable"/>
|
||||
@@ -251,7 +250,7 @@
|
||||
android:authorities="@string/users_and_groups_search_authority"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:label="@string/search_users_and_groups_hint" />
|
||||
android:label="@string/share_search" />
|
||||
|
||||
<provider
|
||||
android:name=".providers.DocumentsStorageProvider"
|
||||
|
||||
@@ -137,8 +137,18 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
* @param account account to compare
|
||||
* @return false if ownerId is not set or owner is a different account
|
||||
*/
|
||||
@Deprecated
|
||||
boolean accountOwnsFile(OCFile file, Account account);
|
||||
|
||||
/**
|
||||
* Checks if an account owns the file (file's ownerId is the same as account name)
|
||||
*
|
||||
* @param file File to check
|
||||
* @param user user to check against
|
||||
* @return false if ownerId is not set or owner is a different account
|
||||
*/
|
||||
boolean userOwnsFile(OCFile file, User user);
|
||||
|
||||
/**
|
||||
* Extract username from account.
|
||||
*
|
||||
|
||||
@@ -340,6 +340,11 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
return TextUtils.isEmpty(ownerId) || account.name.split("@")[0].equals(ownerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userOwnsFile(OCFile file, User user) {
|
||||
return accountOwnsFile(file, user.toPlatformAccount());
|
||||
}
|
||||
|
||||
public boolean migrateUserId() {
|
||||
Account[] ocAccounts = accountManager.getAccountsByType(MainApp.getAccountType(context));
|
||||
String userId;
|
||||
|
||||
@@ -40,9 +40,11 @@ internal class Task<T>(
|
||||
try {
|
||||
val result = taskBody.invoke()
|
||||
if (!cancelled.get()) {
|
||||
postResult.invoke(Runnable {
|
||||
onSuccess?.invoke(result)
|
||||
})
|
||||
postResult.invoke(
|
||||
Runnable {
|
||||
onSuccess?.invoke(result)
|
||||
}
|
||||
)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
if (!cancelled.get()) {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.di;
|
||||
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesServiceApi;
|
||||
import com.owncloud.android.ui.activities.data.activities.RemoteActivitiesRepository;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class ActivitiesModule {
|
||||
@Provides
|
||||
ActivitiesRepository activitiesRepository(ActivitiesServiceApi api) {
|
||||
return new RemoteActivitiesRepository(api);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import android.app.Application;
|
||||
|
||||
import com.nextcloud.client.appinfo.AppInfoModule;
|
||||
import com.nextcloud.client.device.DeviceModule;
|
||||
import com.nextcloud.client.integrations.IntegrationsModule;
|
||||
import com.nextcloud.client.jobs.JobsModule;
|
||||
import com.nextcloud.client.network.NetworkModule;
|
||||
import com.nextcloud.client.onboarding.OnboardingModule;
|
||||
@@ -46,7 +47,7 @@ import dagger.android.support.AndroidSupportInjectionModule;
|
||||
OnboardingModule.class,
|
||||
ViewModelModule.class,
|
||||
JobsModule.class,
|
||||
ActivitiesModule.class
|
||||
IntegrationsModule.class
|
||||
})
|
||||
@Singleton
|
||||
public interface AppComponent {
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.app.NotificationManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Handler;
|
||||
@@ -50,8 +51,10 @@ import com.nextcloud.client.migrations.MigrationsManagerImpl;
|
||||
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;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesServiceApi;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesServiceApiImpl;
|
||||
import com.owncloud.android.ui.activities.data.activities.RemoteActivitiesRepository;
|
||||
import com.owncloud.android.ui.activities.data.files.FilesRepository;
|
||||
import com.owncloud.android.ui.activities.data.files.FilesServiceApiImpl;
|
||||
import com.owncloud.android.ui.activities.data.files.RemoteFilesRepository;
|
||||
@@ -66,7 +69,7 @@ import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module(includes = {ComponentsModule.class, VariantComponentsModule.class})
|
||||
public class AppModule {
|
||||
class AppModule {
|
||||
|
||||
@Provides
|
||||
AccountManager accountManager(Application application) {
|
||||
@@ -78,6 +81,11 @@ public class AppModule {
|
||||
return application;
|
||||
}
|
||||
|
||||
@Provides
|
||||
PackageManager packageManager(Application application) {
|
||||
return application.getPackageManager();
|
||||
}
|
||||
|
||||
@Provides
|
||||
ContentResolver contentResolver(Context context) {
|
||||
return context.getContentResolver();
|
||||
@@ -107,6 +115,10 @@ public class AppModule {
|
||||
return new ActivitiesServiceApiImpl(accountManager);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ActivitiesRepository activitiesRepository(ActivitiesServiceApi api) {
|
||||
return new RemoteActivitiesRepository(api);
|
||||
}
|
||||
|
||||
@Provides
|
||||
FilesRepository filesRepository(UserAccountManager accountManager, ClientFactory clientFactory) {
|
||||
|
||||
@@ -49,7 +49,8 @@ class ShowErrorActivity : AppCompatActivity() {
|
||||
|
||||
val snackbar = DisplayUtils.createSnackbar(
|
||||
error_page_container,
|
||||
R.string.error_report_issue_text, Snackbar.LENGTH_INDEFINITE)
|
||||
R.string.error_report_issue_text, Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
.setAction(R.string.error_report_issue_action) { reportIssue() }
|
||||
|
||||
snackbar.show()
|
||||
|
||||
@@ -51,9 +51,12 @@ class EtmActivity : ToolbarActivity(), Injectable {
|
||||
setupToolbar()
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.etm_title))
|
||||
vm = ViewModelProvider(this, viewModelFactory).get(EtmViewModel::class.java)
|
||||
vm.currentPage.observe(this, Observer {
|
||||
onPageChanged(it)
|
||||
})
|
||||
vm.currentPage.observe(
|
||||
this,
|
||||
Observer {
|
||||
onPageChanged(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
|
||||
@@ -33,11 +33,11 @@ class EtmMenuFragment : EtmBaseFragment() {
|
||||
private lateinit var list: RecyclerView
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
adapter = EtmMenuAdapter(context!!, this::onClickedItem)
|
||||
adapter = EtmMenuAdapter(requireContext(), this::onClickedItem)
|
||||
adapter.pages = vm.pages
|
||||
val view = inflater.inflate(R.layout.fragment_etm_menu, container, false)
|
||||
list = view.findViewById(R.id.etm_menu_list)
|
||||
list.layoutManager = LinearLayoutManager(context!!)
|
||||
list.layoutManager = LinearLayoutManager(requireContext())
|
||||
list.adapter = adapter
|
||||
return view
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ class EtmBackgroundJobsFragment : EtmBaseFragment() {
|
||||
|
||||
private val dateFormat = SimpleDateFormat("YYYY-MM-dd HH:MM:ssZ", Locale.getDefault())
|
||||
var backgroundJobs: List<JobInfo> = emptyList()
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = inflater.inflate(R.layout.etm_background_job_list_item, parent, false)
|
||||
@@ -112,7 +112,7 @@ class EtmBackgroundJobsFragment : EtmBaseFragment() {
|
||||
list.layoutManager = LinearLayoutManager(context)
|
||||
list.addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
|
||||
list.adapter = adapter
|
||||
vm.backgroundJobs.observe(this, Observer { onBackgroundJobsUpdated(it) })
|
||||
vm.backgroundJobs.observe(viewLifecycleOwner, Observer { onBackgroundJobsUpdated(it) })
|
||||
return view
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files
|
||||
|
||||
import android.net.Uri
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
|
||||
/**
|
||||
* This component parses and matches deep links.
|
||||
* Result is returned to the UI for further processing.
|
||||
*
|
||||
* TODO: This is intermediate refactring step; this component should be moved into
|
||||
* [com.nextcloud.client.mixins.ActivityMixin] and handle UI callbacks as well
|
||||
*/
|
||||
class DeepLinkHandler(
|
||||
private val userAccountManager: UserAccountManager
|
||||
) {
|
||||
|
||||
/**
|
||||
* Provide parsed link arguments and context information required
|
||||
* to launch it.
|
||||
*/
|
||||
data class Match(val users: List<User>, val fileId: String)
|
||||
|
||||
companion object {
|
||||
val DEEP_LINK_PATTERN = Regex("""(.*?)(/index\.php)?/f/([0-9]+)$""")
|
||||
val BASE_URL_GROUP_INDEX = 1
|
||||
val INDEX_PATH_GROUP_INDEX = 2
|
||||
val FILE_ID_GROUP_INDEX = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse deep link and return a match result.
|
||||
* Matching result may depend on environmental factors, such
|
||||
* as app version or registered users.
|
||||
*
|
||||
* @param uri Deep link as arrived in incoming [android.content.Intent]
|
||||
* @return deep link match result with all context data required for further processing; null if link does not match
|
||||
*/
|
||||
fun parseDeepLink(uri: Uri): Match? {
|
||||
val match = DEEP_LINK_PATTERN.matchEntire(uri.toString())
|
||||
if (match != null) {
|
||||
val baseServerUrl = match.groupValues[BASE_URL_GROUP_INDEX]
|
||||
val fileId = match.groupValues[FILE_ID_GROUP_INDEX]
|
||||
return Match(users = getMatchingUsers(baseServerUrl), fileId = fileId)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMatchingUsers(serverBaseUrl: String): List<User> =
|
||||
userAccountManager.allUsers.filter { it.server.uri.toString() == serverBaseUrl }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.nextcloud.client.integrations
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import com.nextcloud.client.integrations.deck.DeckApi
|
||||
import com.nextcloud.client.integrations.deck.DeckApiImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Module
|
||||
class IntegrationsModule {
|
||||
@Provides
|
||||
fun deckApi(context: Context, packageManager: PackageManager): DeckApi {
|
||||
return DeckApiImpl(context, packageManager)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# Package com.nextcloud.client.integrations
|
||||
|
||||
This package provides utilities and interfaces to integrate
|
||||
Files application with 3rd party apps.
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.integration.deck;
|
||||
package com.nextcloud.client.integrations.deck;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.integration.deck;
|
||||
package com.nextcloud.client.integrations.deck;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
@@ -140,24 +140,29 @@ class AccountRemovalWork(
|
||||
user: User,
|
||||
arbitraryDataProvider: ArbitraryDataProvider
|
||||
) {
|
||||
val arbitraryDataPushString = arbitraryDataProvider.getValue(user.toPlatformAccount(),
|
||||
PushUtils.KEY_PUSH)
|
||||
val arbitraryDataPushString = arbitraryDataProvider.getValue(user.toPlatformAccount(), PushUtils.KEY_PUSH)
|
||||
val pushServerUrl = context.resources.getString(R.string.push_server_url)
|
||||
if (!TextUtils.isEmpty(arbitraryDataPushString) && !TextUtils.isEmpty(pushServerUrl)) {
|
||||
val gson = Gson()
|
||||
val pushArbitraryData = gson.fromJson(arbitraryDataPushString,
|
||||
PushConfigurationState::class.java)
|
||||
val pushArbitraryData = gson.fromJson(
|
||||
arbitraryDataPushString,
|
||||
PushConfigurationState::class.java
|
||||
)
|
||||
pushArbitraryData.isShouldBeDeleted = true
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(user.accountName, PushUtils.KEY_PUSH,
|
||||
gson.toJson(pushArbitraryData))
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(
|
||||
user.accountName, PushUtils.KEY_PUSH,
|
||||
gson.toJson(pushArbitraryData)
|
||||
)
|
||||
PushUtils.pushRegistrationToServer(userAccountManager, pushArbitraryData.getPushToken())
|
||||
}
|
||||
}
|
||||
|
||||
private fun remoceSyncedFolders(context: Context, account: Account, clock: Clock) {
|
||||
val syncedFolderProvider = SyncedFolderProvider(context.contentResolver,
|
||||
val syncedFolderProvider = SyncedFolderProvider(
|
||||
context.contentResolver,
|
||||
AppPreferencesImpl.fromContext(context),
|
||||
clock)
|
||||
clock
|
||||
)
|
||||
val syncedFolders = syncedFolderProvider.syncedFolders
|
||||
val syncedFolderIds: MutableList<Long> = ArrayList()
|
||||
for (syncedFolder in syncedFolders) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.integrations.deck.DeckApi
|
||||
import com.nextcloud.client.logger.Logger
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
@@ -60,7 +61,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private val uploadsStorageManager: UploadsStorageManager,
|
||||
private val connectivityService: ConnectivityService,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val eventBus: EventBus
|
||||
private val eventBus: EventBus,
|
||||
private val deckApi: DeckApi
|
||||
) : WorkerFactory() {
|
||||
|
||||
@Suppress("ComplexMethod") // it's just a trivial dispatch
|
||||
@@ -173,7 +175,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
context,
|
||||
params,
|
||||
notificationManager,
|
||||
accountManager
|
||||
accountManager,
|
||||
deckApi
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,8 @@ internal class BackgroundJobManagerImpl(
|
||||
val request = periodicRequestBuilder(
|
||||
jobClass = FilesSyncWork::class,
|
||||
jobName = JOB_PERIODIC_FILES_SYNC,
|
||||
intervalMins = DEFAULT_PERIODIC_JOB_INTERVAL_MINUTES).build()
|
||||
intervalMins = DEFAULT_PERIODIC_JOB_INTERVAL_MINUTES
|
||||
).build()
|
||||
workManager.enqueueUniquePeriodicWork(JOB_PERIODIC_FILES_SYNC, ExistingPeriodicWorkPolicy.REPLACE, request)
|
||||
}
|
||||
|
||||
@@ -297,7 +298,8 @@ internal class BackgroundJobManagerImpl(
|
||||
|
||||
val request = oneTimeRequestBuilder(
|
||||
jobClass = FilesSyncWork::class,
|
||||
jobName = JOB_IMMEDIATE_FILES_SYNC)
|
||||
jobName = JOB_IMMEDIATE_FILES_SYNC
|
||||
)
|
||||
.setInputData(arguments)
|
||||
.build()
|
||||
|
||||
|
||||
@@ -87,8 +87,10 @@ class ContactsBackupWork(
|
||||
return Result.failure()
|
||||
}
|
||||
val user = optionalUser.get()
|
||||
val lastExecution = arbitraryDataProvider.getLongValue(user.toPlatformAccount(),
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_LAST_BACKUP)
|
||||
val lastExecution = arbitraryDataProvider.getLongValue(
|
||||
user.toPlatformAccount(),
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_LAST_BACKUP
|
||||
)
|
||||
val force = inputData.getBoolean(FORCE, false)
|
||||
if (force || lastExecution + JOB_INTERVAL_MS < Calendar.getInstance().timeInMillis) {
|
||||
Log_OC.d(TAG, "start contacts backup job")
|
||||
@@ -121,8 +123,10 @@ class ContactsBackupWork(
|
||||
|
||||
private fun backupContact(user: User, backupFolder: String) {
|
||||
val vCard = ArrayList<String>()
|
||||
val cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null,
|
||||
null, null, null)
|
||||
val cursor = contentResolver.query(
|
||||
ContactsContract.Contacts.CONTENT_URI, null,
|
||||
null, null, null
|
||||
)
|
||||
if (cursor != null && cursor.count > 0) {
|
||||
cursor.moveToFirst()
|
||||
for (i in 0 until cursor.count) {
|
||||
@@ -168,8 +172,10 @@ class ContactsBackupWork(
|
||||
|
||||
private fun expireFiles(daysToExpire: Int, backupFolderString: String, user: User) { // -1 disables expiration
|
||||
if (daysToExpire > -1) {
|
||||
val storageManager = FileDataStorageManager(user.toPlatformAccount(),
|
||||
applicationContext.getContentResolver())
|
||||
val storageManager = FileDataStorageManager(
|
||||
user.toPlatformAccount(),
|
||||
applicationContext.getContentResolver()
|
||||
)
|
||||
val backupFolder: OCFile = storageManager.getFileByPath(backupFolderString)
|
||||
val cal = Calendar.getInstance()
|
||||
cal.add(Calendar.DAY_OF_YEAR, -daysToExpire)
|
||||
|
||||
@@ -86,8 +86,11 @@ class FilesSyncWork(
|
||||
var wakeLock: WakeLock? = null
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG)
|
||||
wakeLock = powerManager.newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK,
|
||||
MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG
|
||||
)
|
||||
wakeLock.acquire(WAKELOCK_ACQUIRE_TIMEOUT_MS)
|
||||
}
|
||||
val overridePowerSaving = inputData.getBoolean(OVERRIDE_POWER_SAVING, false)
|
||||
@@ -99,10 +102,12 @@ class FilesSyncWork(
|
||||
val resources = context.resources
|
||||
val lightVersion = resources.getBoolean(R.bool.syncedFolder_light)
|
||||
val skipCustom = inputData.getBoolean(SKIP_CUSTOM, false)
|
||||
FilesSyncHelper.restartJobsIfNeeded(uploadsStorageManager,
|
||||
FilesSyncHelper.restartJobsIfNeeded(
|
||||
uploadsStorageManager,
|
||||
userAccountManager,
|
||||
connectivityService,
|
||||
powerManagementService)
|
||||
powerManagementService
|
||||
)
|
||||
FilesSyncHelper.insertAllDBEntries(preferences, clock, skipCustom)
|
||||
// Create all the providers we'll needq
|
||||
val filesystemDataProvider = FilesystemDataProvider(contentResolver)
|
||||
@@ -112,8 +117,10 @@ class FilesSyncWork(
|
||||
dateFormat.timeZone = TimeZone.getTimeZone(TimeZone.getDefault().id)
|
||||
for (syncedFolder in syncedFolderProvider.syncedFolders) {
|
||||
if (syncedFolder.isEnabled && (!skipCustom || MediaFolderType.CUSTOM != syncedFolder.type)) {
|
||||
syncFolder(context, resources, lightVersion, filesystemDataProvider, currentLocale, dateFormat,
|
||||
syncedFolder)
|
||||
syncFolder(
|
||||
context, resources, lightVersion, filesystemDataProvider, currentLocale, dateFormat,
|
||||
syncedFolder
|
||||
)
|
||||
}
|
||||
}
|
||||
wakeLock?.release()
|
||||
@@ -157,8 +164,10 @@ class FilesSyncWork(
|
||||
val mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.absolutePath)
|
||||
if (lightVersion) {
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging)
|
||||
needsWifi = arbitraryDataProvider!!.getBooleanValue(accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI)
|
||||
needsWifi = arbitraryDataProvider!!.getBooleanValue(
|
||||
accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI
|
||||
)
|
||||
val uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour)
|
||||
uploadAction = getUploadAction(uploadActionString)
|
||||
subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders)
|
||||
@@ -190,8 +199,10 @@ class FilesSyncWork(
|
||||
needsCharging,
|
||||
FileUploader.NameCollisionPolicy.ASK_USER
|
||||
)
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(path,
|
||||
java.lang.Long.toString(syncedFolder.id))
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(
|
||||
path,
|
||||
java.lang.Long.toString(syncedFolder.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,38 +123,51 @@ class MediaFoldersDetectionWork constructor(
|
||||
val allUsers = userAccountManager.allUsers
|
||||
val activeUsers: MutableList<User> = ArrayList()
|
||||
for (account in allUsers) {
|
||||
if (!arbitraryDataProvider.getBooleanValue(account.toPlatformAccount(),
|
||||
ManageAccountsActivity.PENDING_FOR_REMOVAL)) {
|
||||
if (!arbitraryDataProvider.getBooleanValue(
|
||||
account.toPlatformAccount(),
|
||||
ManageAccountsActivity.PENDING_FOR_REMOVAL
|
||||
)
|
||||
) {
|
||||
activeUsers.add(account)
|
||||
}
|
||||
}
|
||||
for (user in activeUsers) {
|
||||
for (imageMediaFolder in imageMediaFolderPaths) {
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder,
|
||||
user.toPlatformAccount())
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(
|
||||
imageMediaFolder,
|
||||
user.toPlatformAccount()
|
||||
)
|
||||
if (folder == null) {
|
||||
val contentTitle = String.format(
|
||||
resources.getString(R.string.new_media_folder_detected),
|
||||
resources.getString(R.string.new_media_folder_photos)
|
||||
)
|
||||
sendNotification(contentTitle,
|
||||
sendNotification(
|
||||
contentTitle,
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1),
|
||||
user,
|
||||
imageMediaFolder,
|
||||
1)
|
||||
1
|
||||
)
|
||||
}
|
||||
}
|
||||
for (videoMediaFolder in videoMediaFolderPaths) {
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder,
|
||||
user.toPlatformAccount())
|
||||
val folder = syncedFolderProvider.findByLocalPathAndAccount(
|
||||
videoMediaFolder,
|
||||
user.toPlatformAccount()
|
||||
)
|
||||
if (folder == null) {
|
||||
val contentTitle = String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos))
|
||||
sendNotification(contentTitle,
|
||||
val contentTitle = String.format(
|
||||
context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos)
|
||||
)
|
||||
sendNotification(
|
||||
contentTitle,
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1),
|
||||
user,
|
||||
videoMediaFolder,
|
||||
2)
|
||||
2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,8 +175,10 @@ class MediaFoldersDetectionWork constructor(
|
||||
}
|
||||
} else {
|
||||
mediaFoldersModel = MediaFoldersModel(imageMediaFolderPaths, videoMediaFolderPaths)
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS,
|
||||
gson.toJson(mediaFoldersModel))
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(
|
||||
ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS,
|
||||
gson.toJson(mediaFoldersModel)
|
||||
)
|
||||
}
|
||||
return Result.success()
|
||||
}
|
||||
@@ -180,7 +195,8 @@ class MediaFoldersDetectionWork constructor(
|
||||
intent.putExtra(SyncedFoldersActivity.EXTRA_SHOW_SIDEBAR, true)
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT)
|
||||
val notificationBuilder = NotificationCompat.Builder(
|
||||
context, NotificationUtils.NOTIFICATION_CHANNEL_GENERAL)
|
||||
context, NotificationUtils.NOTIFICATION_CHANNEL_GENERAL
|
||||
)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
|
||||
.setColor(ThemeUtils.primaryColor(context))
|
||||
|
||||
@@ -42,7 +42,7 @@ import androidx.work.WorkerParameters
|
||||
import com.google.gson.Gson
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.integration.deck.DeckApiImpl
|
||||
import com.nextcloud.client.integrations.deck.DeckApi
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.DecryptedPushMessage
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
@@ -75,7 +75,8 @@ class NotificationWork constructor(
|
||||
private val context: Context,
|
||||
params: WorkerParameters,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val accountManager: UserAccountManager
|
||||
private val accountManager: UserAccountManager,
|
||||
private val deckApi: DeckApi
|
||||
) : Worker(context, params) {
|
||||
|
||||
companion object {
|
||||
@@ -99,17 +100,21 @@ class NotificationWork constructor(
|
||||
val base64DecodedSignature = Base64.decode(signature, Base64.DEFAULT)
|
||||
val privateKey = PushUtils.readKeyFromFile(false) as PrivateKey
|
||||
try {
|
||||
val signatureVerification = PushUtils.verifySignature(context,
|
||||
val signatureVerification = PushUtils.verifySignature(
|
||||
context,
|
||||
accountManager,
|
||||
base64DecodedSignature,
|
||||
base64DecodedSubject)
|
||||
base64DecodedSubject
|
||||
)
|
||||
if (signatureVerification != null && signatureVerification.isSignatureValid) {
|
||||
val cipher = Cipher.getInstance("RSA/None/PKCS1Padding")
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey)
|
||||
val decryptedSubject = cipher.doFinal(base64DecodedSubject)
|
||||
val gson = Gson()
|
||||
val decryptedPushMessage = gson.fromJson(String(decryptedSubject),
|
||||
DecryptedPushMessage::class.java)
|
||||
val decryptedPushMessage = gson.fromJson(
|
||||
String(decryptedSubject),
|
||||
DecryptedPushMessage::class.java
|
||||
)
|
||||
if (decryptedPushMessage.delete) {
|
||||
notificationManager.cancel(decryptedPushMessage.nid)
|
||||
} else if (decryptedPushMessage.deleteAll) {
|
||||
@@ -135,7 +140,6 @@ class NotificationWork constructor(
|
||||
val randomId = SecureRandom()
|
||||
val file = notification.subjectRichParameters["file"]
|
||||
|
||||
val deckApi = DeckApiImpl(context, context.packageManager)
|
||||
val deckActionOverrideIntent = deckApi.createForwardToDeckActionIntent(notification, user)
|
||||
|
||||
val pendingIntent: PendingIntent
|
||||
@@ -174,10 +178,16 @@ class NotificationWork constructor(
|
||||
disableDetection.putExtra(NUMERIC_NOTIFICATION_ID, notification.getNotificationId())
|
||||
disableDetection.putExtra(PUSH_NOTIFICATION_ID, pushNotificationId)
|
||||
disableDetection.putExtra(KEY_NOTIFICATION_ACCOUNT, user.accountName)
|
||||
val disableIntent = PendingIntent.getBroadcast(context, pushNotificationId, disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
notificationBuilder.addAction(NotificationCompat.Action(R.drawable.ic_close,
|
||||
context.getString(R.string.remove_push_notification), disableIntent))
|
||||
val disableIntent = PendingIntent.getBroadcast(
|
||||
context, pushNotificationId, disableDetection,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
)
|
||||
notificationBuilder.addAction(
|
||||
NotificationCompat.Action(
|
||||
R.drawable.ic_close,
|
||||
context.getString(R.string.remove_push_notification), disableIntent
|
||||
)
|
||||
)
|
||||
} else { // Actions
|
||||
for (action in notification.getActions()) {
|
||||
val actionIntent = Intent(context, NotificationReceiver::class.java)
|
||||
@@ -186,9 +196,11 @@ class NotificationWork constructor(
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACCOUNT, user.accountName)
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACTION_LINK, action.link)
|
||||
actionIntent.putExtra(KEY_NOTIFICATION_ACTION_TYPE, action.type)
|
||||
val actionPendingIntent = PendingIntent.getBroadcast(context, randomId.nextInt(),
|
||||
val actionPendingIntent = PendingIntent.getBroadcast(
|
||||
context, randomId.nextInt(),
|
||||
actionIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
)
|
||||
var icon: Int
|
||||
icon = if (action.primary) {
|
||||
R.drawable.ic_check_circle
|
||||
@@ -209,7 +221,8 @@ class NotificationWork constructor(
|
||||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
||||
.setAutoCancel(true)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setContentIntent(pendingIntent).build())
|
||||
.setContentIntent(pendingIntent).build()
|
||||
)
|
||||
val notificationManager = NotificationManagerCompat.from(context)
|
||||
notificationManager.notify(notification.getNotificationId(), notificationBuilder.build())
|
||||
}
|
||||
@@ -255,51 +268,54 @@ class NotificationWork constructor(
|
||||
val numericNotificationId = intent.getIntExtra(NUMERIC_NOTIFICATION_ID, 0)
|
||||
val accountName = intent.getStringExtra(KEY_NOTIFICATION_ACCOUNT)
|
||||
if (numericNotificationId != 0) {
|
||||
Thread(Runnable {
|
||||
val notificationManager = context.getSystemService(
|
||||
Activity.NOTIFICATION_SERVICE) as NotificationManager
|
||||
var oldNotification: android.app.Notification? = null
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && notificationManager != null) {
|
||||
for (statusBarNotification in notificationManager.activeNotifications) {
|
||||
if (numericNotificationId == statusBarNotification.id) {
|
||||
oldNotification = statusBarNotification.notification
|
||||
break
|
||||
}
|
||||
}
|
||||
cancel(context, numericNotificationId)
|
||||
}
|
||||
try {
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (optionalUser.isPresent) {
|
||||
val user = optionalUser.get()
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(user.toOwnCloudAccount(), context)
|
||||
val actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE)
|
||||
val actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK)
|
||||
val success: Boolean
|
||||
success = if (!TextUtils.isEmpty(actionType) && !TextUtils.isEmpty(actionLink)) {
|
||||
val resultCode = executeAction(actionType, actionLink, client)
|
||||
resultCode == HttpStatus.SC_OK || resultCode == HttpStatus.SC_ACCEPTED
|
||||
} else {
|
||||
DeleteNotificationRemoteOperation(numericNotificationId)
|
||||
.execute(client).isSuccess
|
||||
}
|
||||
if (success) {
|
||||
if (oldNotification == null) {
|
||||
cancel(context, numericNotificationId)
|
||||
Thread(
|
||||
Runnable {
|
||||
val notificationManager = context.getSystemService(
|
||||
Activity.NOTIFICATION_SERVICE
|
||||
) as NotificationManager
|
||||
var oldNotification: android.app.Notification? = null
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && notificationManager != null) {
|
||||
for (statusBarNotification in notificationManager.activeNotifications) {
|
||||
if (numericNotificationId == statusBarNotification.id) {
|
||||
oldNotification = statusBarNotification.notification
|
||||
break
|
||||
}
|
||||
} else {
|
||||
notificationManager.notify(numericNotificationId, oldNotification)
|
||||
}
|
||||
cancel(context, numericNotificationId)
|
||||
}
|
||||
try {
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (optionalUser.isPresent) {
|
||||
val user = optionalUser.get()
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(user.toOwnCloudAccount(), context)
|
||||
val actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE)
|
||||
val actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK)
|
||||
val success: Boolean
|
||||
success = if (!TextUtils.isEmpty(actionType) && !TextUtils.isEmpty(actionLink)) {
|
||||
val resultCode = executeAction(actionType, actionLink, client)
|
||||
resultCode == HttpStatus.SC_OK || resultCode == HttpStatus.SC_ACCEPTED
|
||||
} else {
|
||||
DeleteNotificationRemoteOperation(numericNotificationId)
|
||||
.execute(client).isSuccess
|
||||
}
|
||||
if (success) {
|
||||
if (oldNotification == null) {
|
||||
cancel(context, numericNotificationId)
|
||||
}
|
||||
} else {
|
||||
notificationManager.notify(numericNotificationId, oldNotification)
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: OperationCanceledException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: AuthenticatorException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: OperationCanceledException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
} catch (e: AuthenticatorException) {
|
||||
Log_OC.e(TAG, "Error initializing client", e)
|
||||
}
|
||||
}).start()
|
||||
).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,10 @@ class OfflineSyncWork constructor(
|
||||
val ocFolder = storageManager.getFileByPath(folderName)
|
||||
Log_OC.d(TAG, folderName + ": currentEtag: " + ocFolder.etag)
|
||||
// check for etag change, if false, skip
|
||||
val checkEtagOperation = CheckEtagRemoteOperation(ocFolder.encryptedFileName,
|
||||
ocFolder.etagOnServer)
|
||||
val checkEtagOperation = CheckEtagRemoteOperation(
|
||||
ocFolder.remotePath,
|
||||
ocFolder.etagOnServer
|
||||
)
|
||||
val result = checkEtagOperation.execute(user.toPlatformAccount(), context)
|
||||
when (result.code) {
|
||||
ResultCode.ETAG_UNCHANGED -> {
|
||||
@@ -116,10 +118,12 @@ class OfflineSyncWork constructor(
|
||||
if (files != null) {
|
||||
for (file in files) {
|
||||
val ocFile = storageManager.getFileByLocalPath(file.path)
|
||||
val synchronizeFileOperation = SynchronizeFileOperation(ocFile.remotePath,
|
||||
val synchronizeFileOperation = SynchronizeFileOperation(
|
||||
ocFile.remotePath,
|
||||
user,
|
||||
true,
|
||||
context)
|
||||
context
|
||||
)
|
||||
synchronizeFileOperation.execute(storageManager, context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ data class LogEntry(val timestamp: Date, val level: Level, val tag: String, val
|
||||
* 1970-01-01T00:00:00.000Z;D;tag;some message
|
||||
*/
|
||||
private val ENTRY_PARSE_REGEXP = Regex(
|
||||
pattern = """(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z);([ADEIVW]);([^;]+);(.*)"""
|
||||
pattern =
|
||||
"""(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z);([ADEIVW]);([^;]+);(.*)"""
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -114,11 +114,13 @@ class LogsViewModel @Inject constructor(
|
||||
val sizeKb = logsSize / KILOBYTE
|
||||
return when {
|
||||
isLoading.value == true -> context.getString(R.string.logs_status_loading)
|
||||
isFiltered -> context.getString(R.string.logs_status_filtered,
|
||||
isFiltered -> context.getString(
|
||||
R.string.logs_status_filtered,
|
||||
sizeKb,
|
||||
displayedEntries,
|
||||
allEntries.size,
|
||||
filterDurationMs)
|
||||
filterDurationMs
|
||||
)
|
||||
!isFiltered -> context.getString(R.string.logs_status_not_filtered, sizeKb)
|
||||
else -> ""
|
||||
}
|
||||
|
||||
@@ -104,8 +104,10 @@ class Migrations @Inject constructor(
|
||||
logger.i(TAG, "$description: no users to migrate")
|
||||
} else {
|
||||
users.forEach {
|
||||
val backupEnabled = arbitraryDataProvider.getBooleanValue(it.accountName,
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP)
|
||||
val backupEnabled = arbitraryDataProvider.getBooleanValue(
|
||||
it.accountName,
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP
|
||||
)
|
||||
if (backupEnabled) {
|
||||
jobManager.schedulePeriodicContactsBackup(it)
|
||||
}
|
||||
|
||||
@@ -138,10 +138,10 @@ public interface AppPreferences {
|
||||
/**
|
||||
* Set preferred folder display type.
|
||||
*
|
||||
* @param folder Folder
|
||||
* @param layout_name preference value
|
||||
* @param folder Folder which layout is being set or null for root folder
|
||||
* @param layoutName preference value
|
||||
*/
|
||||
void setFolderLayout(OCFile folder, String layout_name);
|
||||
void setFolderLayout(@Nullable OCFile folder, String layoutName);
|
||||
|
||||
/**
|
||||
* Saves the path where the user selected to do the last upload of a file shared from other app.
|
||||
@@ -213,16 +213,18 @@ public interface AppPreferences {
|
||||
/**
|
||||
* Get preferred folder sort order.
|
||||
*
|
||||
* @param folder Folder whoch order is being retrieved or null for root folder
|
||||
* @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
|
||||
*/
|
||||
FileSortOrder getSortOrderByFolder(OCFile folder);
|
||||
FileSortOrder getSortOrderByFolder(@Nullable OCFile folder);
|
||||
|
||||
/**
|
||||
* Set preferred folder sort order.
|
||||
*
|
||||
* @param sortOrder the sort order
|
||||
* @param folder Folder which sort order is changed; if null, root folder is assumed
|
||||
* @param sortOrder the sort order of a folder
|
||||
*/
|
||||
void setSortOrder(OCFile folder, FileSortOrder sortOrder);
|
||||
void setSortOrder(@Nullable OCFile folder, FileSortOrder sortOrder);
|
||||
|
||||
/**
|
||||
* Set preferred folder sort order.
|
||||
|
||||
@@ -289,12 +289,12 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFolderLayout(OCFile folder, String layout_name) {
|
||||
public void setFolderLayout(@Nullable OCFile folder, String layoutName) {
|
||||
setFolderPreference(context,
|
||||
currentAccountProvider.getUser(),
|
||||
PREF__FOLDER_LAYOUT,
|
||||
folder,
|
||||
layout_name);
|
||||
layoutName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,7 +307,7 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortOrder(OCFile folder, FileSortOrder sortOrder) {
|
||||
public void setSortOrder(@Nullable OCFile folder, FileSortOrder sortOrder) {
|
||||
setFolderPreference(context,
|
||||
currentAccountProvider.getUser(),
|
||||
PREF__FOLDER_SORT_ORDER,
|
||||
@@ -607,13 +607,13 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
private static void setFolderPreference(final Context context,
|
||||
final User user,
|
||||
final String preferenceName,
|
||||
final OCFile folder,
|
||||
@Nullable final OCFile folder,
|
||||
final String value) {
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
dataProvider.storeOrUpdateKeyValue(user.getAccountName(), getKeyFromFolder(preferenceName, folder), value);
|
||||
}
|
||||
|
||||
private static String getKeyFromFolder(String preferenceName, OCFile folder) {
|
||||
private static String getKeyFromFolder(String preferenceName, @Nullable OCFile folder) {
|
||||
final String folderIdString = String.valueOf(folder != null ? folder.getFileId() :
|
||||
FileDataStorageManager.ROOT_PARENT_ID);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.NoSuchElementException;
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.core.util.ObjectsCompat;
|
||||
import androidx.core.util.Supplier;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
@@ -84,6 +85,7 @@ public final class Optional<T> {
|
||||
*/
|
||||
public static<T> Optional<T> empty() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressFBWarnings("USBR_UNNECESSARY_STORE_BEFORE_RETURN")
|
||||
Optional<T> t = (Optional<T>) EMPTY;
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,8 @@ class ChooseAccountDialogFragment : DialogFragment(), AvatarGenerationListener,
|
||||
resources.getDimension(R.dimen.list_item_avatar_icon_radius),
|
||||
resources,
|
||||
user_icon,
|
||||
context)
|
||||
context
|
||||
)
|
||||
|
||||
// Defining user texts, accounts, etc.
|
||||
user_name.text = user.toOwnCloudAccount().displayName
|
||||
@@ -88,17 +89,21 @@ class ChooseAccountDialogFragment : DialogFragment(), AvatarGenerationListener,
|
||||
account.text = user.accountName
|
||||
|
||||
// Defining user right indicator
|
||||
val icon = ThemeUtils.tintDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_check_circle),
|
||||
ThemeUtils.primaryColor(requireContext(), true))
|
||||
val icon = ThemeUtils.tintDrawable(
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.ic_check_circle),
|
||||
ThemeUtils.primaryColor(requireContext(), true)
|
||||
)
|
||||
account_menu.setImageDrawable(icon)
|
||||
|
||||
// Creating adapter for accounts list
|
||||
val adapter = UserListAdapter(activity as BaseActivity,
|
||||
val adapter = UserListAdapter(
|
||||
activity as BaseActivity,
|
||||
accountManager,
|
||||
getAccountListItems(),
|
||||
this,
|
||||
false,
|
||||
false)
|
||||
false
|
||||
)
|
||||
accounts_list.adapter = adapter
|
||||
|
||||
// Creating listeners for quick-actions
|
||||
|
||||
@@ -98,7 +98,6 @@ import javax.net.ssl.SSLEngine;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.util.Pair;
|
||||
@@ -223,7 +222,10 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
super.attachBaseContext(base);
|
||||
|
||||
initGlobalContext(this);
|
||||
setupDagger();
|
||||
DaggerAppComponent.builder()
|
||||
.application(this)
|
||||
.build()
|
||||
.inject(this);
|
||||
|
||||
// we don't want to handle crashes occurring inside crash reporter activity/process;
|
||||
// let the platform deal with those
|
||||
@@ -238,14 +240,6 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setupDagger() {
|
||||
DaggerAppComponent.builder()
|
||||
.application(this)
|
||||
.build()
|
||||
.inject(this);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("ST")
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -479,12 +473,10 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
ReceiversHelper.registerPowerChangeReceiver(uploadsStorageManager,
|
||||
accountManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
}
|
||||
ReceiversHelper.registerPowerChangeReceiver(uploadsStorageManager,
|
||||
accountManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
ReceiversHelper.registerPowerSaveReceiver(uploadsStorageManager,
|
||||
|
||||
@@ -1195,9 +1195,9 @@ public class FileDataStorageManager {
|
||||
* @param path Path of the file.
|
||||
* @param type Type of the share to get
|
||||
* @param shareWith Target of the share. Ignored in type is {@link ShareType#PUBLIC_LINK}
|
||||
* @return First {@link OCShare} instance found in DB bound to the file in 'path'
|
||||
* @return All {@link OCShare} instance found in DB bound to the file in 'path'
|
||||
*/
|
||||
public OCShare getFirstShareByPathAndType(String path, ShareType type, String shareWith) {
|
||||
public List<OCShare> getSharesByPathAndType(String path, ShareType type, String shareWith) {
|
||||
Cursor cursor;
|
||||
if (shareWith == null) {
|
||||
shareWith = "";
|
||||
@@ -1246,14 +1246,18 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
OCShare share = null;
|
||||
List<OCShare> shares = new ArrayList<>();
|
||||
OCShare share;
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
share = createShareInstance(cursor);
|
||||
do {
|
||||
share = createShareInstance(cursor);
|
||||
shares.add(share);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
return share;
|
||||
return shares;
|
||||
}
|
||||
|
||||
// test with null cursor?
|
||||
@@ -1274,6 +1278,7 @@ public class FileDataStorageManager {
|
||||
share.setPasswordProtected(getInt(cursor, ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED) == 1);
|
||||
share.setNote(getString(cursor, ProviderTableMeta.OCSHARES_NOTE));
|
||||
share.setHideFileDownload(getInt(cursor, ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD) == 1);
|
||||
share.setShareLink(getString(cursor, ProviderTableMeta.OCSHARES_SHARE_LINK));
|
||||
|
||||
return share;
|
||||
}
|
||||
@@ -1603,7 +1608,7 @@ public class FileDataStorageManager {
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<ContentProviderOperation> prepareInsertShares(
|
||||
List<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
|
||||
Iterable<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
|
||||
|
||||
ContentValues contentValues;
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
@@ -1626,6 +1631,7 @@ public class FileDataStorageManager {
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_LINK, share.getShareLink());
|
||||
|
||||
// adding a new share resource
|
||||
operations.add(ContentProviderOperation
|
||||
|
||||
@@ -76,6 +76,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
@@ -888,7 +889,7 @@ public final class ThumbnailsCacheManager {
|
||||
Log_OC.e(TAG, "Out of memory");
|
||||
} catch (Throwable t) {
|
||||
// the app should never break due to a problem with avatars
|
||||
thumbnail = mResources.getDrawable(R.drawable.account_circle_white);
|
||||
thumbnail = ResourcesCompat.getDrawable(mResources, R.drawable.account_circle_white, null);
|
||||
Log_OC.e(TAG, "Generation of avatar for " + mUserId + " failed", t);
|
||||
}
|
||||
|
||||
@@ -1011,7 +1012,7 @@ public final class ThumbnailsCacheManager {
|
||||
try {
|
||||
return TextDrawable.createAvatar(mAccount, mAvatarRadius);
|
||||
} catch (Exception e1) {
|
||||
return mResources.getDrawable(R.drawable.ic_user);
|
||||
return ResourcesCompat.getDrawable(mResources, R.drawable.ic_user, null);
|
||||
}
|
||||
} else {
|
||||
return BitmapUtils.bitmapToCircularBitmapDrawable(mResources, avatar);
|
||||
@@ -1060,17 +1061,19 @@ public final class ThumbnailsCacheManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Bitmap addVideoOverlay(Bitmap thumbnail){
|
||||
Drawable playButtonDrawable = MainApp.getAppContext().getResources().getDrawable(R.drawable.view_play);
|
||||
public static Bitmap addVideoOverlay(Bitmap thumbnail) {
|
||||
Drawable playButtonDrawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(),
|
||||
R.drawable.view_play,
|
||||
null);
|
||||
Bitmap playButton = BitmapUtils.drawableToBitmap(playButtonDrawable);
|
||||
|
||||
Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton,
|
||||
(int) (thumbnail.getWidth() * 0.3),
|
||||
(int) (thumbnail.getHeight() * 0.3), true);
|
||||
(int) (thumbnail.getWidth() * 0.3),
|
||||
(int) (thumbnail.getHeight() * 0.3), true);
|
||||
|
||||
Bitmap resultBitmap = Bitmap.createBitmap(thumbnail.getWidth(),
|
||||
thumbnail.getHeight(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
thumbnail.getHeight(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
|
||||
Canvas c = new Canvas(resultBitmap);
|
||||
|
||||
|
||||
@@ -24,14 +24,13 @@ package com.owncloud.android.datastorage.providers;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
abstract class AbstractStoragePointProvider implements IStoragePointProvider {
|
||||
|
||||
boolean canBeAddedToAvailableList(List<StoragePoint> currentList, String path) {
|
||||
boolean canBeAddedToAvailableList(Iterable<StoragePoint> currentList, String path) {
|
||||
if (path == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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 = 57;
|
||||
public static final int DB_VERSION = 58;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
@@ -145,6 +145,7 @@ public class ProviderMeta {
|
||||
public static final String OCSHARES_IS_PASSWORD_PROTECTED = "is_password_protected";
|
||||
public static final String OCSHARES_NOTE = "note";
|
||||
public static final String OCSHARES_HIDE_DOWNLOAD = "hide_download";
|
||||
public static final String OCSHARES_SHARE_LINK = "share_link";
|
||||
|
||||
public static final String OCSHARES_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE
|
||||
+ " collate nocase asc";
|
||||
|
||||
@@ -226,7 +226,7 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterDetails(List<Integer> toShow, List<Integer> toHide) {
|
||||
private void filterDetails(Collection<Integer> toShow, Collection<Integer> toHide) {
|
||||
if (isSingleSelection()) {
|
||||
toShow.add(R.id.action_see_details);
|
||||
} else {
|
||||
@@ -353,7 +353,7 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterOpenWith(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
private void filterOpenWith(Collection<Integer> toShow, Collection<Integer> toHide, boolean synchronizing) {
|
||||
if (!isSingleFile() || !anyFileDown() || synchronizing) {
|
||||
toHide.add(R.id.action_open_file_with);
|
||||
} else {
|
||||
@@ -407,7 +407,7 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterRename(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
private void filterRename(Collection<Integer> toShow, Collection<Integer> toHide, boolean synchronizing) {
|
||||
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
|
||||
toHide.add(R.id.action_rename_file);
|
||||
} else {
|
||||
|
||||
@@ -71,7 +71,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.activity.ConflictsResolveActivity;
|
||||
import com.owncloud.android.ui.activity.UploadListActivity;
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
@@ -671,12 +671,15 @@ public class FileUploader extends Service
|
||||
}
|
||||
|
||||
/// includes a pending intent in the notification showing the details
|
||||
Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
|
||||
showUploadListIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
|
||||
showUploadListIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
|
||||
showUploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
|
||||
showUploadListIntent, 0));
|
||||
Intent intent = UploadListActivity.createIntent(upload.getFile(),
|
||||
upload.getAccount(),
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||
this);
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this,
|
||||
(int) System.currentTimeMillis(),
|
||||
intent,
|
||||
0)
|
||||
);
|
||||
|
||||
if (!upload.isInstantPicture() && !upload.isInstantVideo()) {
|
||||
if (mNotificationManager == null) {
|
||||
@@ -776,14 +779,24 @@ public class FileUploader extends Service
|
||||
PendingIntent.FLAG_ONE_SHOT
|
||||
));
|
||||
} else {
|
||||
//in case of failure, do not show details file view (because there is no file!)
|
||||
Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
|
||||
showUploadListIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
|
||||
showUploadListIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
|
||||
showUploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(
|
||||
this, (int) System.currentTimeMillis(), showUploadListIntent, 0
|
||||
));
|
||||
Intent intent;
|
||||
if (uploadResult.getCode().equals(ResultCode.SYNC_CONFLICT)) {
|
||||
intent = ConflictsResolveActivity.createIntent(upload.getFile(),
|
||||
upload.getAccount(),
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||
this);
|
||||
} else {
|
||||
intent = UploadListActivity.createIntent(upload.getFile(),
|
||||
upload.getAccount(),
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||
this);
|
||||
}
|
||||
|
||||
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this,
|
||||
(int) System.currentTimeMillis(),
|
||||
intent,
|
||||
0)
|
||||
);
|
||||
}
|
||||
|
||||
mNotificationBuilder.setContentText(content);
|
||||
|
||||
@@ -47,10 +47,10 @@ import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
* View containing controls for a {@link MediaPlayer}.
|
||||
*
|
||||
* Holds buttons "play / pause", "rewind", "fast forward" and a progress slider.
|
||||
*
|
||||
* View containing controls for a {@link MediaPlayer}.
|
||||
* <p>
|
||||
* Holds buttons "play / pause", "rewind", "fast forward" and a progress slider.
|
||||
* <p>
|
||||
* It synchronizes itself with the state of the {@link MediaPlayer}.
|
||||
*/
|
||||
public class MediaControlView extends FrameLayout implements OnClickListener, OnSeekBarChangeListener {
|
||||
@@ -313,7 +313,6 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
||||
int pos;
|
||||
boolean playing = playerControl.isPlaying();
|
||||
switch (v.getId()) {
|
||||
|
||||
case R.id.playBtn:
|
||||
doPauseResume();
|
||||
break;
|
||||
@@ -337,6 +336,10 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
||||
}
|
||||
setProgress();
|
||||
break;
|
||||
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,9 @@ package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.GetSharesForFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
@@ -49,45 +47,23 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
// Check if the share link already exists
|
||||
RemoteOperation operation = new GetSharesForFileRemoteOperation(path, false, false);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
|
||||
// Create public link if doesn't exist yet
|
||||
boolean publicShareExists = false;
|
||||
if (result.isSuccess()) {
|
||||
OCShare share;
|
||||
for (int i=0 ; i<result.getData().size(); i++) {
|
||||
share = (OCShare) result.getData().get(i);
|
||||
if (ShareType.PUBLIC_LINK.equals(share.getShareType())) {
|
||||
publicShareExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!publicShareExists) {
|
||||
CreateShareRemoteOperation createOp = new CreateShareRemoteOperation(
|
||||
path,
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
false,
|
||||
password,
|
||||
OCShare.DEFAULT_PERMISSION
|
||||
);
|
||||
createOp.setGetShareDetails(true);
|
||||
result = createOp.execute(client);
|
||||
}
|
||||
CreateShareRemoteOperation createOp = new CreateShareRemoteOperation(path,
|
||||
ShareType.PUBLIC_LINK,
|
||||
"",
|
||||
false,
|
||||
password,
|
||||
OCShare.DEFAULT_PERMISSION);
|
||||
createOp.setGetShareDetails(true);
|
||||
RemoteOperationResult result = createOp.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (result.getData().size() > 0) {
|
||||
Object item = result.getData().get(0);
|
||||
if (item instanceof OCShare) {
|
||||
if (item instanceof OCShare) {
|
||||
updateData((OCShare) item);
|
||||
} else {
|
||||
ArrayList<Object> data = result.getData();
|
||||
result = new RemoteOperationResult(
|
||||
RemoteOperationResult.ResultCode.SHARE_NOT_FOUND
|
||||
);
|
||||
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
result.setData(data);
|
||||
}
|
||||
} else {
|
||||
@@ -110,8 +86,8 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
getStorageManager().saveShare(share);
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
if (file!=null) {
|
||||
OCFile file = getStorageManager().getFileByEncryptedRemotePath(path);
|
||||
if (file != null) {
|
||||
file.setPublicLink(share.getShareLink());
|
||||
file.setSharedViaLink(true);
|
||||
getStorageManager().saveFile(file);
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -46,44 +44,37 @@ public class UnshareOperation extends SyncOperation {
|
||||
private static final int SINGLY_SHARED = 1;
|
||||
|
||||
private String mRemotePath;
|
||||
private ShareType mShareType;
|
||||
private String mShareWith;
|
||||
private Context mContext;
|
||||
private long shareId;
|
||||
|
||||
public UnshareOperation(String remotePath, ShareType shareType, String shareWith,
|
||||
Context context) {
|
||||
public UnshareOperation(String remotePath, long shareId) {
|
||||
mRemotePath = remotePath;
|
||||
mShareType = shareType;
|
||||
mShareWith = shareWith;
|
||||
mContext = context;
|
||||
this.shareId = shareId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = null;
|
||||
RemoteOperationResult result;
|
||||
|
||||
// Get Share for a file
|
||||
OCShare share = getStorageManager().getFirstShareByPathAndType(mRemotePath,
|
||||
mShareType, mShareWith);
|
||||
OCShare share = getStorageManager().getShareById(shareId);
|
||||
|
||||
if (share != null) {
|
||||
OCFile file = getStorageManager().getFileByPath(mRemotePath);
|
||||
RemoveShareRemoteOperation operation =
|
||||
new RemoveShareRemoteOperation((int) share.getRemoteId());
|
||||
OCFile file = getStorageManager().getFileByEncryptedRemotePath(mRemotePath);
|
||||
RemoveShareRemoteOperation operation = new RemoveShareRemoteOperation(share.getRemoteId());
|
||||
result = operation.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
Log_OC.d(TAG, "Share id = " + share.getRemoteId() + " deleted");
|
||||
|
||||
if (ShareType.PUBLIC_LINK.equals(mShareType)) {
|
||||
if (ShareType.PUBLIC_LINK.equals(share.getShareType())) {
|
||||
file.setSharedViaLink(false);
|
||||
file.setPublicLink("");
|
||||
} else if (ShareType.USER.equals(mShareType) || ShareType.GROUP.equals(mShareType)
|
||||
|| ShareType.FEDERATED.equals(mShareType)){
|
||||
} else if (ShareType.USER.equals(share.getShareType()) || ShareType.GROUP.equals(share.getShareType())
|
||||
|| ShareType.FEDERATED.equals(share.getShareType())) {
|
||||
// Check if it is the last share
|
||||
List <OCShare> sharesWith = getStorageManager().
|
||||
getSharesWithForAFile(mRemotePath,
|
||||
getStorageManager().getAccount().name);
|
||||
List<OCShare> sharesWith = getStorageManager().
|
||||
getSharesWithForAFile(mRemotePath,
|
||||
getStorageManager().getAccount().name);
|
||||
if (sharesWith.size() == SINGLY_SHARED) {
|
||||
file.setSharedWithSharee(false);
|
||||
}
|
||||
@@ -104,15 +95,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean existsFile(OwnCloudClient client, String remotePath){
|
||||
ExistenceCheckRemoteOperation existsOperation =
|
||||
new ExistenceCheckRemoteOperation(remotePath, mContext, false);
|
||||
RemoteOperationResult result = existsOperation.execute(client);
|
||||
return result.isSuccess();
|
||||
private boolean existsFile(OwnCloudClient client, String remotePath) {
|
||||
return new ExistenceCheckRemoteOperation(remotePath, false).execute(client).isSuccess();
|
||||
}
|
||||
|
||||
public ShareType getShareType() {
|
||||
return mShareType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.resources.shares.GetShareRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
@@ -44,25 +43,22 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
private Boolean publicUploadOnFile;
|
||||
private Boolean hideFileDownload;
|
||||
private long expirationDateInMillis;
|
||||
private long shareId;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||
*/
|
||||
public UpdateShareViaLinkOperation(String path) {
|
||||
public UpdateShareViaLinkOperation(String path, long shareId) {
|
||||
this.path = path;
|
||||
expirationDateInMillis = 0;
|
||||
this.shareId = shareId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
OCShare publicShare = getStorageManager().getFirstShareByPathAndType(path, ShareType.PUBLIC_LINK, "");
|
||||
|
||||
if (publicShare == null) {
|
||||
// TODO try to get remote share before failing?
|
||||
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
}
|
||||
OCShare publicShare = getStorageManager().getShareById(shareId);
|
||||
|
||||
UpdateShareRemoteOperation updateOp = new UpdateShareRemoteOperation(publicShare.getRemoteId());
|
||||
updateOp.setPassword(password);
|
||||
|
||||
@@ -233,11 +233,11 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
if (result.getCode() == RemoteOperationResult.ResultCode.SYNC_CONFLICT) {
|
||||
// ISSUE 5: if the user is not running the app (this is a service!),
|
||||
// this can be very intrusive; a notification should be preferred
|
||||
Intent i = new Intent(context, ConflictsResolveActivity.class);
|
||||
i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.putExtra(ConflictsResolveActivity.EXTRA_FILE, finalFile);
|
||||
i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
|
||||
context.startActivity(i);
|
||||
Intent intent = ConflictsResolveActivity.createIntent(finalFile,
|
||||
user.toPlatformAccount(),
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK,
|
||||
context);
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
FileStorageUtils.checkIfFileFinishedSaving(finalFile);
|
||||
if (!result.isSuccess()) {
|
||||
|
||||
@@ -747,7 +747,8 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + TEXT
|
||||
+ ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_NOTE + TEXT
|
||||
+ ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + " INTEGER );");
|
||||
+ ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_LINK + " TEXT );");
|
||||
}
|
||||
|
||||
private void createCapabilitiesTable(SQLiteDatabase db) {
|
||||
@@ -2234,6 +2235,24 @@ public class FileContentProvider extends ContentProvider {
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 58 && newVersion >= 58) {
|
||||
Log_OC.i(SQL, "Entering in the #58 add public link to share table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.OCSHARES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.OCSHARES_SHARE_LINK + " TEXT ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,8 +108,6 @@ public class OperationsService extends Service {
|
||||
public static final String EXTRA_SHARE_NOTE = "SHARE_NOTE";
|
||||
public static final String EXTRA_IN_BACKGROUND = "IN_BACKGROUND";
|
||||
|
||||
public static final String EXTRA_COOKIE = "COOKIE";
|
||||
|
||||
public static final String ACTION_CREATE_SHARE_VIA_LINK = "CREATE_SHARE_VIA_LINK";
|
||||
public static final String ACTION_CREATE_SHARE_WITH_SHAREE = "CREATE_SHARE_WITH_SHAREE";
|
||||
public static final String ACTION_UNSHARE = "UNSHARE";
|
||||
@@ -127,9 +125,6 @@ public class OperationsService extends Service {
|
||||
public static final String ACTION_CHECK_CURRENT_CREDENTIALS = "CHECK_CURRENT_CREDENTIALS";
|
||||
public static final String ACTION_RESTORE_VERSION = "RESTORE_VERSION";
|
||||
|
||||
public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() + ".OPERATION_ADDED";
|
||||
public static final String ACTION_OPERATION_FINISHED = OperationsService.class.getName() + ".OPERATION_FINISHED";
|
||||
|
||||
private ServiceHandler mOperationsHandler;
|
||||
private OperationsServiceBinder mOperationsBinder;
|
||||
|
||||
@@ -143,12 +138,10 @@ public class OperationsService extends Service {
|
||||
private static class Target {
|
||||
public Uri mServerUrl;
|
||||
public Account mAccount;
|
||||
public String mCookie;
|
||||
|
||||
public Target(Account account, Uri serverUrl, String cookie) {
|
||||
public Target(Account account, Uri serverUrl) {
|
||||
mAccount = account;
|
||||
mServerUrl = serverUrl;
|
||||
mCookie = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,12 +515,7 @@ public class OperationsService extends Service {
|
||||
} else {
|
||||
Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT);
|
||||
String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL);
|
||||
String cookie = operationIntent.getStringExtra(EXTRA_COOKIE);
|
||||
target = new Target(
|
||||
account,
|
||||
(serverUrl == null) ? null : Uri.parse(serverUrl),
|
||||
cookie
|
||||
);
|
||||
target = new Target(account, (serverUrl == null) ? null : Uri.parse(serverUrl));
|
||||
|
||||
String action = operationIntent.getAction();
|
||||
String remotePath;
|
||||
@@ -550,7 +538,8 @@ public class OperationsService extends Service {
|
||||
shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
|
||||
if (!TextUtils.isEmpty(remotePath)) {
|
||||
UpdateShareViaLinkOperation updateLinkOperation = new UpdateShareViaLinkOperation(remotePath);
|
||||
UpdateShareViaLinkOperation updateLinkOperation =
|
||||
new UpdateShareViaLinkOperation(remotePath, shareId);
|
||||
|
||||
password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
updateLinkOperation.setPassword(password);
|
||||
@@ -559,7 +548,7 @@ public class OperationsService extends Service {
|
||||
updateLinkOperation.setExpirationDateInMillis(expirationDate);
|
||||
|
||||
boolean hideFileDownload = operationIntent.getBooleanExtra(EXTRA_SHARE_HIDE_FILE_DOWNLOAD,
|
||||
false);
|
||||
false);
|
||||
updateLinkOperation.setHideFileDownload(hideFileDownload);
|
||||
|
||||
if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) {
|
||||
@@ -605,17 +594,16 @@ public class OperationsService extends Service {
|
||||
int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1);
|
||||
if (!TextUtils.isEmpty(remotePath)) {
|
||||
operation = new CreateShareWithShareeOperation(remotePath, shareeName, shareType,
|
||||
permissions);
|
||||
permissions);
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_UNSHARE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE);
|
||||
String shareWith = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
|
||||
shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
|
||||
if (!TextUtils.isEmpty(remotePath)) {
|
||||
operation = new UnshareOperation(remotePath, shareType, shareWith, this);
|
||||
if (shareId > 0) {
|
||||
operation = new UnshareOperation(remotePath, shareId);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
@@ -51,6 +52,7 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
@@ -231,12 +233,12 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showActivities(List<Object> activities, int lastGiven) {
|
||||
public void showActivities(List<Object> activities, NextcloudClient client, int lastGiven) {
|
||||
boolean clear = false;
|
||||
if (this.lastGiven == UNDEFINED) {
|
||||
clear = true;
|
||||
}
|
||||
adapter.setActivityItems(activities, clear);
|
||||
adapter.setActivityItems(activities, client, clear);
|
||||
this.lastGiven = lastGiven;
|
||||
|
||||
// Hide the recyclerView if list is empty
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.BaseActivity;
|
||||
|
||||
@@ -26,7 +27,7 @@ import java.util.List;
|
||||
public interface ActivitiesContract {
|
||||
|
||||
interface View {
|
||||
void showActivities(List<Object> activities, int lastGiven);
|
||||
void showActivities(List<Object> activities, NextcloudClient client, int lastGiven);
|
||||
void showActivitiesLoadError(String error);
|
||||
void showActivityDetailUI(OCFile ocFile);
|
||||
void showActivityDetailUIIsNull();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.owncloud.android.ui.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activities.data.activities.ActivitiesRepository;
|
||||
import com.owncloud.android.ui.activities.data.files.FilesRepository;
|
||||
@@ -50,11 +51,11 @@ public class ActivitiesPresenter implements ActivitiesContract.ActionListener {
|
||||
activitiesView.setProgressIndicatorState(true);
|
||||
activitiesRepository.getActivities(lastGiven, new ActivitiesRepository.LoadActivitiesCallback() {
|
||||
@Override
|
||||
public void onActivitiesLoaded(List<Object> activities, int lastGiven) {
|
||||
public void onActivitiesLoaded(List<Object> activities, NextcloudClient client, int lastGiven) {
|
||||
|
||||
if (!activityStopped) {
|
||||
activitiesView.setProgressIndicatorState(false);
|
||||
activitiesView.showActivities(activities, lastGiven);
|
||||
activitiesView.showActivities(activities, client, lastGiven);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -27,7 +29,7 @@ import androidx.annotation.NonNull;
|
||||
*/
|
||||
public interface ActivitiesRepository {
|
||||
interface LoadActivitiesCallback {
|
||||
void onActivitiesLoaded(List<Object> activities, int lastGiven);
|
||||
void onActivitiesLoaded(List<Object> activities, NextcloudClient client, int lastGiven);
|
||||
void onActivitiesLoadedError(String error);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.owncloud.android.lib.resources.activities.model.Activity;
|
||||
|
||||
import java.util.List;
|
||||
@@ -30,9 +31,10 @@ import java.util.List;
|
||||
public interface ActivitiesServiceApi {
|
||||
|
||||
interface ActivitiesServiceCallback<T> {
|
||||
void onLoaded(T activities, int lastGiven);
|
||||
void onLoaded(T activities, NextcloudClient client, int lastGiven);
|
||||
void onError (String error);
|
||||
}
|
||||
|
||||
void getAllActivities(int lastGiven, ActivitiesServiceApi.ActivitiesServiceCallback<List<Object>> callback);
|
||||
|
||||
}
|
||||
@@ -71,6 +71,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
private Account account;
|
||||
private int lastGiven;
|
||||
private String errorMessage;
|
||||
private NextcloudClient client;
|
||||
|
||||
private GetActivityListTask(Account account,
|
||||
int lastGiven,
|
||||
@@ -88,7 +89,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
OwnCloudAccount ocAccount;
|
||||
try {
|
||||
ocAccount = new OwnCloudAccount(account, context);
|
||||
NextcloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
client = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getNextcloudClientFor(ocAccount, MainApp.getAppContext());
|
||||
|
||||
GetActivitiesRemoteOperation getRemoteActivitiesOperation;
|
||||
@@ -137,7 +138,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
protected void onPostExecute(Boolean success) {
|
||||
super.onPostExecute(success);
|
||||
if (success) {
|
||||
callback.onLoaded(activities, lastGiven);
|
||||
callback.onLoaded(activities, client, lastGiven);
|
||||
} else {
|
||||
callback.onError(errorMessage);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activities.data.activities;
|
||||
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -36,8 +38,8 @@ public class RemoteActivitiesRepository implements ActivitiesRepository {
|
||||
activitiesServiceApi.getAllActivities(lastGiven,
|
||||
new ActivitiesServiceApi.ActivitiesServiceCallback<List<Object>>() {
|
||||
@Override
|
||||
public void onLoaded(List<Object> activities, int lastGiven) {
|
||||
callback.onActivitiesLoaded(activities, lastGiven);
|
||||
public void onLoaded(List<Object> activities, NextcloudClient client, int lastGiven) {
|
||||
callback.onActivitiesLoaded(activities, client, lastGiven);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,8 +92,7 @@ public class CommunityActivity extends FileActivity {
|
||||
getString(R.string.contributing_link)))));
|
||||
|
||||
MaterialButton reportButton = findViewById(R.id.community_testing_report);
|
||||
reportButton.setBackgroundColor(ThemeUtils.primaryColor(this,true));
|
||||
reportButton.setTextColor(ThemeUtils.fontColor(this, false));
|
||||
ThemeUtils.colorPrimaryButton(reportButton, this);
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
@@ -69,6 +71,17 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
|
||||
private int localBehaviour = FileUploader.LOCAL_BEHAVIOUR_FORGET;
|
||||
protected OnConflictDecisionMadeListener listener;
|
||||
|
||||
public static Intent createIntent(OCFile file, Account account, Integer flag, Context context) {
|
||||
Intent intent = new Intent(context, ConflictsResolveActivity.class);
|
||||
if (flag != null) {
|
||||
intent.setFlags(intent.getFlags() | flag);
|
||||
}
|
||||
intent.putExtra(ConflictsResolveActivity.EXTRA_FILE, file);
|
||||
intent.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, account);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -33,8 +34,6 @@ import com.owncloud.android.ui.fragment.FileFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.ContactListFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.ContactsBackupFragment;
|
||||
|
||||
import org.parceler.Parcels;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
@@ -46,12 +45,33 @@ import androidx.fragment.app.FragmentTransaction;
|
||||
*/
|
||||
public class ContactsPreferenceActivity extends FileActivity implements FileFragment.ContainerActivity {
|
||||
public static final String TAG = ContactsPreferenceActivity.class.getSimpleName();
|
||||
|
||||
|
||||
private static final String EXTRA_FILE = "FILE";
|
||||
private static final String EXTRA_USER = "USER";
|
||||
/**
|
||||
* Warning: default for this extra is different between this activity and {@link ContactsBackupFragment}
|
||||
*/
|
||||
public static final String EXTRA_SHOW_SIDEBAR = "SHOW_SIDEBAR";
|
||||
public static final String PREFERENCE_CONTACTS_AUTOMATIC_BACKUP = "PREFERENCE_CONTACTS_AUTOMATIC_BACKUP";
|
||||
public static final String PREFERENCE_CONTACTS_LAST_BACKUP = "PREFERENCE_CONTACTS_LAST_BACKUP";
|
||||
public static final String BACKUP_TO_LIST = "BACKUP_TO_LIST";
|
||||
public static final String EXTRA_SHOW_SIDEBAR = "SHOW_SIDEBAR";
|
||||
|
||||
public static void startActivity(Context context) {
|
||||
Intent intent = new Intent(context, ContactsPreferenceActivity.class);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void startActivityWithContactsFile(Context context, User user, OCFile file) {
|
||||
Intent intent = new Intent(context, ContactsPreferenceActivity.class);
|
||||
intent.putExtra(EXTRA_FILE, file);
|
||||
intent.putExtra(EXTRA_USER, user);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void startActivityWithoutSidebar(Context context) {
|
||||
Intent intent = new Intent(context, ContactsPreferenceActivity.class);
|
||||
intent.putExtra(EXTRA_SHOW_SIDEBAR, false);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Inject BackgroundJobManager backgroundJobManager;
|
||||
|
||||
@@ -86,14 +106,11 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
if (intent == null || intent.getParcelableExtra(ContactListFragment.FILE_NAME) == null ||
|
||||
intent.getParcelableExtra(ContactListFragment.USER) == null) {
|
||||
ContactsBackupFragment fragment = new ContactsBackupFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(EXTRA_SHOW_SIDEBAR, showSidebar);
|
||||
fragment.setArguments(bundle);
|
||||
ContactsBackupFragment fragment = ContactsBackupFragment.create(showSidebar);
|
||||
transaction.add(R.id.frame_container, fragment);
|
||||
} else {
|
||||
OCFile file = Parcels.unwrap(intent.getParcelableExtra(ContactListFragment.FILE_NAME));
|
||||
User user = Parcels.unwrap(intent.getParcelableExtra(ContactListFragment.USER));
|
||||
OCFile file = intent.getParcelableExtra(ContactListFragment.FILE_NAME);
|
||||
User user = intent.getParcelableExtra(ContactListFragment.USER);
|
||||
ContactListFragment contactListFragment = ContactListFragment.newInstance(file, user);
|
||||
transaction.add(R.id.frame_container, contactListFragment);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ 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.nextcloud.java.util.Optional;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -103,8 +102,8 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
@@ -251,7 +250,9 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
mDrawerLayout.addDrawerListener(mDrawerToggle);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
mDrawerToggle.setDrawerSlideAnimationEnabled(true);
|
||||
Drawable backArrow = getResources().getDrawable(R.drawable.ic_arrow_back);
|
||||
Drawable backArrow = ResourcesCompat.getDrawable(getResources(),
|
||||
R.drawable.ic_arrow_back,
|
||||
null);
|
||||
mDrawerToggle.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, ThemeUtils.appBarPrimaryFontColor(this)));
|
||||
mDrawerToggle.getDrawerArrowDrawable().setColor(ThemeUtils.appBarPrimaryFontColor(this));
|
||||
}
|
||||
@@ -368,7 +369,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
startActivity(SyncedFoldersActivity.class);
|
||||
break;
|
||||
case R.id.nav_contacts:
|
||||
startActivity(ContactsPreferenceActivity.class);
|
||||
ContactsPreferenceActivity.startActivity(this);
|
||||
break;
|
||||
case R.id.nav_settings:
|
||||
startActivity(SettingsActivity.class);
|
||||
@@ -439,6 +440,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
private void startPhotoSearch(MenuItem menuItem) {
|
||||
SearchEvent searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
|
||||
MainApp.showOnlyFilesOnDevice(false);
|
||||
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
@@ -701,7 +703,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
mCheckedMenuItem = menuItemId;
|
||||
MenuItem currentItem = mNavigationView.getMenu().findItem(menuItemId);
|
||||
int drawerColor = getResources().getColor(R.color.drawer_text_color);
|
||||
int activeColor = ThemeUtils.elementColor(this);
|
||||
int activeColor = ThemeUtils.primaryColor(null, true, true, this);
|
||||
|
||||
currentItem.setChecked(true);
|
||||
|
||||
@@ -895,12 +897,6 @@ 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);
|
||||
}
|
||||
|
||||
|
||||