Compare commits
462
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c2fc79824 | ||
|
|
4fac5b07a0 | ||
|
|
eeddeefc5f | ||
|
|
142990052e | ||
|
|
bf8a54d0e2 | ||
|
|
d7a4f270dc | ||
|
|
f1978da46f | ||
|
|
1f5025a6e6 | ||
|
|
be80e38e2f | ||
|
|
9a6bee5407 | ||
|
|
fb047939ef | ||
|
|
1b359d3998 | ||
|
|
4306850628 | ||
|
|
5759e9b3ba | ||
|
|
ce86481516 | ||
|
|
acf2a1edfa | ||
|
|
7e585c273c | ||
|
|
c1a75ffc1d | ||
|
|
d93d5ef151 | ||
|
|
f50453bb27 | ||
|
|
37b8ae825c | ||
|
|
a89dcd94d8 | ||
|
|
4490a02efa | ||
|
|
315769979b | ||
|
|
ce0d4ba3db | ||
|
|
abb58599f7 | ||
|
|
c5378a7d8d | ||
|
|
3634c432df | ||
|
|
64afaf2820 | ||
|
|
4176ac2917 | ||
|
|
557f8b53e9 | ||
|
|
677133ad4f | ||
|
|
7eba750e4a | ||
|
|
3e3a32e588 | ||
|
|
c0515a02f6 | ||
|
|
59c6169ccc | ||
|
|
bf134ceece | ||
|
|
6cf499828c | ||
|
|
824a91ad5d | ||
|
|
52f77239f7 | ||
|
|
803cfadb1f | ||
|
|
23b91eb2e8 | ||
|
|
2ab33bd1f4 | ||
|
|
83c5306c9b | ||
|
|
6daf772501 | ||
|
|
d45f047a38 | ||
|
|
2e9428ad69 | ||
|
|
3079073da6 | ||
|
|
4894157942 | ||
|
|
4d192025aa | ||
|
|
5838918a0a | ||
|
|
075bb74736 | ||
|
|
a37b34fc78 | ||
|
|
2d028495c7 | ||
|
|
8c679c20b7 | ||
|
|
034058ff1e | ||
|
|
7d02c0b045 | ||
|
|
88ce0bd256 | ||
|
|
c09fd78e90 | ||
|
|
41fbb08395 | ||
|
|
398503a4b3 | ||
|
|
ad60cc2415 | ||
|
|
0a2ed61fa9 | ||
|
|
4b7175a89c | ||
|
|
efadfa6759 | ||
|
|
045e3feb81 | ||
|
|
4e9f48341f | ||
|
|
f6b7f5ae80 | ||
|
|
d60465d3b0 | ||
|
|
63211df14a | ||
|
|
0eed3b00a9 | ||
|
|
8f63377171 | ||
|
|
7aa8496c68 | ||
|
|
cb1bff1ce0 | ||
|
|
396c8c4906 | ||
|
|
e8264e0231 | ||
|
|
5901f97c0d | ||
|
|
4d24261e84 | ||
|
|
b6efa6c8b6 | ||
|
|
d0ed64f977 | ||
|
|
e77216cfbe | ||
|
|
653c82351c | ||
|
|
a353e3ca6a | ||
|
|
19e9692541 | ||
|
|
3e0c4e70c5 | ||
|
|
9e115d91d0 | ||
|
|
77da74be3a | ||
|
|
cad6cd6a19 | ||
|
|
3c8475c8b0 | ||
|
|
594eba571f | ||
|
|
bf51735633 | ||
|
|
478fccf6a1 | ||
|
|
bbd1f96f76 | ||
|
|
59cf6b9ba4 | ||
|
|
3e7efd86ff | ||
|
|
e5597e14c9 | ||
|
|
e197b31c15 | ||
|
|
9c9079df54 | ||
|
|
f605fd597c | ||
|
|
bf034d2383 | ||
|
|
34c016ff27 | ||
|
|
f3844cfb73 | ||
|
|
135a36a10a | ||
|
|
0f34902fb4 | ||
|
|
43ce903559 | ||
|
|
9f9adfe9af | ||
|
|
41321b77c5 | ||
|
|
62afaefff6 | ||
|
|
0aceb0d001 | ||
|
|
30b5f87c1d | ||
|
|
84303837a6 | ||
|
|
70c364ebe8 | ||
|
|
9264eb8ecc | ||
|
|
0c07ef376b | ||
|
|
2285b4208e | ||
|
|
7be83616a1 | ||
|
|
51db0a6f57 | ||
|
|
8264ed040d | ||
|
|
f020e02dfb | ||
|
|
b997966e90 | ||
|
|
c1e014373f | ||
|
|
8cebbf8146 | ||
|
|
d3d78ab744 | ||
|
|
96af008653 | ||
|
|
1910e4cfa6 | ||
|
|
3fc27cc927 | ||
|
|
3fdc757ac1 | ||
|
|
b972c46686 | ||
|
|
09d1fe7654 | ||
|
|
e1514db205 | ||
|
|
3a2f68523d | ||
|
|
53cc99b032 | ||
|
|
6b038492b1 | ||
|
|
f4f9af41dc | ||
|
|
a7c95b46c5 | ||
|
|
2eb476639a | ||
|
|
cc5b9a10eb | ||
|
|
36df660d29 | ||
|
|
3bbc5adecd | ||
|
|
9bc802dddf | ||
|
|
6e6bbb7d8b | ||
|
|
8650de4d45 | ||
|
|
49bbf945fe | ||
|
|
b4fc0388c0 | ||
|
|
bd253f1584 | ||
|
|
1762ecbd26 | ||
|
|
6011fc42c5 | ||
|
|
76b8681061 | ||
|
|
4d485d00e7 | ||
|
|
3a7ef82632 | ||
|
|
0807696761 | ||
|
|
be320936d9 | ||
|
|
ce5acb05ab | ||
|
|
3c87e5a14f | ||
|
|
d5da8965d3 | ||
|
|
b785b0b18d | ||
|
|
7a0af443b2 | ||
|
|
90e74a6722 | ||
|
|
d177ed6755 | ||
|
|
ed103ad530 | ||
|
|
fb06caff1c | ||
|
|
e7a5cfd45a | ||
|
|
b34001d866 | ||
|
|
b5827c7ec1 | ||
|
|
f4d25af034 | ||
|
|
d6fcc4869f | ||
|
|
df5eddcd85 | ||
|
|
9d0457f16e | ||
|
|
5d40c37121 | ||
|
|
c72076ae21 | ||
|
|
828b0a7d75 | ||
|
|
b31d650b28 | ||
|
|
4ed02c40b7 | ||
|
|
64bfb52541 | ||
|
|
dbf8f9e68a | ||
|
|
8069f04766 | ||
|
|
23a1f2530e | ||
|
|
60d13157d5 | ||
|
|
8a19ee7d84 | ||
|
|
730f10e9d7 | ||
|
|
9a24eb221d | ||
|
|
3705e5a209 | ||
|
|
40268978e7 | ||
|
|
959cce44fb | ||
|
|
404bbe3f13 | ||
|
|
70978089b6 | ||
|
|
b35ddef4fb | ||
|
|
28112b6444 | ||
|
|
bc2f52840b | ||
|
|
2e6fb57cef | ||
|
|
c29fddfc7e | ||
|
|
9780b3ef08 | ||
|
|
b2301cb040 | ||
|
|
85170d2389 | ||
|
|
93bc0b4050 | ||
|
|
77211f2cf0 | ||
|
|
37d34de34f | ||
|
|
350f9e9ef4 | ||
|
|
8d676ea556 | ||
|
|
bef25b7bc0 | ||
|
|
a1167ea3d7 | ||
|
|
71784259f9 | ||
|
|
f6709fcf6d | ||
|
|
0d3211e974 | ||
|
|
d2e867d61b | ||
|
|
13b76b3fb9 | ||
|
|
1742509309 | ||
|
|
6850d73c40 | ||
|
|
0b1e102715 | ||
|
|
e46818f3fa | ||
|
|
9c5a390257 | ||
|
|
1f5bae0dbb | ||
|
|
8091470ae3 | ||
|
|
162ccfc15c | ||
|
|
0aae8653d8 | ||
|
|
3dab2b0a4c | ||
|
|
52c000a50f | ||
|
|
4f1d4f4250 | ||
|
|
69b86b5e6c | ||
|
|
c381bc9da8 | ||
|
|
8ba7257628 | ||
|
|
560ae2c311 | ||
|
|
c0c1e0085b | ||
|
|
c8a87a2e06 | ||
|
|
49d516969d | ||
|
|
b32e1705d9 | ||
|
|
bd58321cfa | ||
|
|
7ea630a88e | ||
|
|
e37e11cc3e | ||
|
|
facf8a2aae | ||
|
|
c5ff313d27 | ||
|
|
c9d77884c5 | ||
|
|
f20f74fec9 | ||
|
|
e250b61e01 | ||
|
|
6210a69297 | ||
|
|
f91a9725d7 | ||
|
|
0d5b557bf2 | ||
|
|
bcbbdfb9df | ||
|
|
dd95a6af0f | ||
|
|
d74c5da260 | ||
|
|
c4cfd0de25 | ||
|
|
0e23d84b72 | ||
|
|
7944422a2f | ||
|
|
8ac77c731e | ||
|
|
c15bc58a39 | ||
|
|
ab8bcbddc2 | ||
|
|
df5aa98cd0 | ||
|
|
90302c0de0 | ||
|
|
ad7771d8e4 | ||
|
|
ce72bef98c | ||
|
|
59a4e24ade | ||
|
|
630585b2e4 | ||
|
|
d375140e4a | ||
|
|
91590b2408 | ||
|
|
aa96a1ded7 | ||
|
|
ebce82e1e8 | ||
|
|
27ea5731bb | ||
|
|
5771aa3631 | ||
|
|
fbb350a64b | ||
|
|
7ad8a1a863 | ||
|
|
831f083153 | ||
|
|
4736124a9e | ||
|
|
3b9e6fa210 | ||
|
|
59745fb8ca | ||
|
|
52b61670a4 | ||
|
|
01eaebbe98 | ||
|
|
6d567fb68c | ||
|
|
27855ddb84 | ||
|
|
a90766c5b9 | ||
|
|
77a46d0e29 | ||
|
|
fac6bf5461 | ||
|
|
8dff447f68 | ||
|
|
8324d47d43 | ||
|
|
fce151948f | ||
|
|
a22a80374e | ||
|
|
e705342dc3 | ||
|
|
a81792e788 | ||
|
|
e1c27f65b5 | ||
|
|
b963818a98 | ||
|
|
b48fbb2e06 | ||
|
|
334ec4824c | ||
|
|
401f99762c | ||
|
|
44896ba832 | ||
|
|
cf983d621f | ||
|
|
e7ae1a5364 | ||
|
|
d0a3302212 | ||
|
|
7e2230970b | ||
|
|
dac6bac8df | ||
|
|
7fc2d9f902 | ||
|
|
5c0e4be5c9 | ||
|
|
87cda5a97f | ||
|
|
dab0ea373c | ||
|
|
078d19382c | ||
|
|
f74570f348 | ||
|
|
ea58ad6340 | ||
|
|
5e135e6ced | ||
|
|
82e713c167 | ||
|
|
c01061b9df | ||
|
|
148f9b119b | ||
|
|
46f916b1a2 | ||
|
|
b6c528763c | ||
|
|
bc2179965f | ||
|
|
2e2e509835 | ||
|
|
30fc18d772 | ||
|
|
7876f44e5b | ||
|
|
31ea2e7be4 | ||
|
|
08d36d68e3 | ||
|
|
e39c1658f1 | ||
|
|
5d1e3a2213 | ||
|
|
952fe722f6 | ||
|
|
c0fa9b9bf6 | ||
|
|
1d1e4f974b | ||
|
|
8e835271d5 | ||
|
|
6f8e5b53b3 | ||
|
|
a5d6731611 | ||
|
|
0c525db644 | ||
|
|
9bbf69a621 | ||
|
|
33af9119ce | ||
|
|
4eb62c7655 | ||
|
|
e9758fda6c | ||
|
|
7a17e13d55 | ||
|
|
f9bc65b6e1 | ||
|
|
febc475634 | ||
|
|
b9b6d9da78 | ||
|
|
3f4502e861 | ||
|
|
6d8c7af90c | ||
|
|
a4e3347abf | ||
|
|
a71f449adc | ||
|
|
96fe9e094c | ||
|
|
b105abc56f | ||
|
|
bb5790cd1a | ||
|
|
506dee2337 | ||
|
|
1cf1b0f1da | ||
|
|
15bc754ea7 | ||
|
|
01641a05f4 | ||
|
|
84a1cc37a5 | ||
|
|
a4088eb173 | ||
|
|
70f0d9c61b | ||
|
|
0c6b7fc4a1 | ||
|
|
bf9df6e0b2 | ||
|
|
f3fff52304 | ||
|
|
3cde7fc4ee | ||
|
|
9b19f3940b | ||
|
|
e5e776c288 | ||
|
|
f648fdc31c | ||
|
|
5ea50b1030 | ||
|
|
c3269e6639 | ||
|
|
bba96eef89 | ||
|
|
d9080650ac | ||
|
|
704a41b281 | ||
|
|
585f734e32 | ||
|
|
412d32e58d | ||
|
|
73ecd3505e | ||
|
|
f2759fc5dd | ||
|
|
5b07b66492 | ||
|
|
2b91e651d4 | ||
|
|
80582657f0 | ||
|
|
82de7f631a | ||
|
|
333b544001 | ||
|
|
6e98e25184 | ||
|
|
36bed52eae | ||
|
|
976abb854b | ||
|
|
d667354e09 | ||
|
|
6b468d5751 | ||
|
|
a61f6e8f93 | ||
|
|
86e564bb91 | ||
|
|
f5b9f28cc0 | ||
|
|
7dad67ad35 | ||
|
|
0eb93b4e8b | ||
|
|
f5ad4c9117 | ||
|
|
14e7cfcbef | ||
|
|
89e4cc7be0 | ||
|
|
00b2cfb785 | ||
|
|
8b8820ef91 | ||
|
|
d3ffbb6bd0 | ||
|
|
725ecb192c | ||
|
|
15fa3804af | ||
|
|
5d359ba7a0 | ||
|
|
df779d9f2a | ||
|
|
b9633f1c22 | ||
|
|
a6ec9e3049 | ||
|
|
bec84e799e | ||
|
|
4eb45af6d0 | ||
|
|
61579b1166 | ||
|
|
41aae0b753 | ||
|
|
23ff844e70 | ||
|
|
a3730c7c82 | ||
|
|
a587defb76 | ||
|
|
38407d55a9 | ||
|
|
63435257f0 | ||
|
|
17065f9193 | ||
|
|
6caecfce72 | ||
|
|
1dabdb5315 | ||
|
|
131a8fafcd | ||
|
|
b5f742f3ba | ||
|
|
726cb1a3eb | ||
|
|
59d0b99121 | ||
|
|
b061b1a557 | ||
|
|
3b1c6ae68f | ||
|
|
d5ed79ab66 | ||
|
|
df3bb79365 | ||
|
|
7308f3464b | ||
|
|
8a53f5ff56 | ||
|
|
3e5de81414 | ||
|
|
6b59ade7bd | ||
|
|
ebed24ab5d | ||
|
|
64c227afc9 | ||
|
|
bb6947d9d9 | ||
|
|
f35db9a594 | ||
|
|
fb446d433a | ||
|
|
1e443545c9 | ||
|
|
0ee0c655cf | ||
|
|
183f8f5398 | ||
|
|
91e300cb68 | ||
|
|
641895c0d5 | ||
|
|
e84522c2fa | ||
|
|
dc4077325b | ||
|
|
44c42e1c01 | ||
|
|
f2f86932f4 | ||
|
|
943d197253 | ||
|
|
3a015657cb | ||
|
|
974520a733 | ||
|
|
b1dedf3435 | ||
|
|
29347af729 | ||
|
|
9efd3ec7ad | ||
|
|
169b0e560b | ||
|
|
9c560eae63 | ||
|
|
3e2c4b1db0 | ||
|
|
cb47072fa7 | ||
|
|
59d4e7688f | ||
|
|
8291a19487 | ||
|
|
1bb7d764ca | ||
|
|
251cecb1a7 | ||
|
|
d67b6ab6e6 | ||
|
|
ddcca92012 | ||
|
|
739c1d9257 | ||
|
|
6978587ae1 | ||
|
|
da1064fc37 | ||
|
|
a41be3d3cb | ||
|
|
798093ae19 | ||
|
|
929cb20149 | ||
|
|
2676cd88e5 | ||
|
|
c40a912815 | ||
|
|
6a177d3dee | ||
|
|
79677f5281 | ||
|
|
7e17aca4ff | ||
|
|
c78e05e873 | ||
|
|
2e9d7ce028 | ||
|
|
a4eafbf757 | ||
|
|
799c3a3163 | ||
|
|
22e7f71e22 | ||
|
|
0ae679f3b5 | ||
|
|
13d602422e | ||
|
|
ed95f486fc | ||
|
|
93ef48add6 | ||
|
|
2c6bfc4c9e | ||
|
|
fd23d58cb9 | ||
|
|
d40a4a1731 | ||
|
|
01edfe6491 | ||
|
|
ae94e219ba | ||
|
|
1958c06b87 | ||
|
|
0efdf2bbac |
No files matched your search
+55
-55
@@ -1,67 +1,67 @@
|
||||
pipeline:
|
||||
compile:
|
||||
image: nextcloudci/android:android-40
|
||||
commands:
|
||||
# build app and assemble APK
|
||||
- sh -c "if [ '${FLAVOR}' != 'Analysis' ]; then ./gradlew assemble${FLAVOR}; fi"
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: [Generic, Gplay]
|
||||
compile:
|
||||
image: nextcloudci/android:android-42
|
||||
commands:
|
||||
# build app and assemble APK
|
||||
- sh -c "if [ '${FLAVOR}' != 'Analysis' ]; then ./gradlew assemble${FLAVOR}; fi"
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: [Generic, Gplay]
|
||||
|
||||
test:
|
||||
image: nextcloudci/android:android-40
|
||||
privileged: true
|
||||
commands:
|
||||
- emulator -avd android-27 -no-window -no-audio &
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit"
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT"
|
||||
- ./gradlew combinedTestReport
|
||||
- curl -o codecov.sh https://codecov.io/bash
|
||||
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5
|
||||
secrets: [ LOG_USERNAME, LOG_PASSWORD ]
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Gplay
|
||||
test:
|
||||
image: nextcloudci/android:android-42
|
||||
privileged: true
|
||||
commands:
|
||||
- emulator -avd android-27 -no-window -no-audio &
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit"
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT"
|
||||
- ./gradlew combinedTestReport
|
||||
- curl -o codecov.sh https://codecov.io/bash
|
||||
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5
|
||||
secrets: [ LOG_USERNAME, LOG_PASSWORD ]
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Gplay
|
||||
|
||||
analysis:
|
||||
image: nextcloudci/android:android-40
|
||||
commands:
|
||||
- export BRANCH=$(scripts/analysis/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
|
||||
- scripts/analysis/analysis-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST
|
||||
secrets: [ GIT_USERNAME, GIT_TOKEN, LOG_USERNAME, LOG_PASSWORD ]
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Analysis
|
||||
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
host: $EMAIL_HOST
|
||||
port: 587
|
||||
username: $EMAIL_USERNAME
|
||||
password: $EMAIL_PASSWORD
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
recipients: [ $EMAIL_RECIPIENTS ]
|
||||
secrets: [ EMAIL_USERNAME, EMAIL_PASSWORD, EMAIL_RECIPIENTS, EMAIL_HOST ]
|
||||
when:
|
||||
event: push
|
||||
status: failure
|
||||
branch: master
|
||||
analysis:
|
||||
image: nextcloudci/android:android-42
|
||||
commands:
|
||||
- export BRANCH=$(scripts/analysis/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
|
||||
- scripts/analysis/analysis-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST
|
||||
secrets: [ GIT_USERNAME, GIT_TOKEN, LOG_USERNAME, LOG_PASSWORD ]
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Analysis
|
||||
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
host: $EMAIL_HOST
|
||||
port: 587
|
||||
username: $EMAIL_USERNAME
|
||||
password: $EMAIL_PASSWORD
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
recipients: [ $EMAIL_RECIPIENTS ]
|
||||
secrets: [ EMAIL_USERNAME, EMAIL_PASSWORD, EMAIL_RECIPIENTS, EMAIL_HOST ]
|
||||
when:
|
||||
event: push
|
||||
status: failure
|
||||
branch: master
|
||||
|
||||
matrix:
|
||||
FLAVOR:
|
||||
FLAVOR:
|
||||
- Generic
|
||||
- Gplay
|
||||
- Analysis
|
||||
|
||||
services:
|
||||
server:
|
||||
image: nextcloudci/server:server-1
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Gplay
|
||||
server:
|
||||
image: nextcloudci/server:server-3
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Gplay
|
||||
|
||||
branches: master
|
||||
@@ -0,0 +1,33 @@
|
||||
# .editorconfig
|
||||
|
||||
# see http://EditorConfig.org
|
||||
|
||||
# This is the file in the root of the project.
|
||||
# For sub folders you can have other files that override only some settings.
|
||||
# For these, this settings should be false.
|
||||
root=true
|
||||
|
||||
[*]
|
||||
max_line_length=120
|
||||
# use spaces, not tabs.
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
charset=utf-8
|
||||
|
||||
# Trimming is good for consistency
|
||||
trim_trailing_whitespace=true
|
||||
# I've seen cases where a missing new_line was ignored on *nix systems.
|
||||
# Never again with this setting!
|
||||
insert_final_newline=true
|
||||
|
||||
[*.properties]
|
||||
# Exception for Java properties files should be encoded latin1 (aka iso8859-1)
|
||||
charset=latin1
|
||||
|
||||
[*.{cmd,bat}]
|
||||
# batch files on Windows should stay with CRLF
|
||||
end_of_line=crlf
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace=false
|
||||
@@ -1,3 +1,10 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
labels: bug
|
||||
|
||||
---
|
||||
|
||||
### Actual behaviour
|
||||
- Tell us what happens
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
labels: enhancement
|
||||
|
||||
---
|
||||
|
||||
### Is your feature request related to a problem? Please describe.
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
### Describe the solution you'd like
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
### Describe alternatives you've considered
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
### Additional context
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
**NOTE:** Be super sure to remove sensitive data like passwords, note that everybody can look here! You can use the Issue Template application to prefill some of the required information: https://apps.nextcloud.com/apps/issuetemplate
|
||||
+54
-11
@@ -1,10 +1,53 @@
|
||||
## 3.2.4 (Sept, 04, 2018)
|
||||
fix push notification on gplay release
|
||||
## 3.4.0 (December, 17, 2018)
|
||||
- hide download when creating share links
|
||||
- direct editing files with Collabora (Collabora Server >=4.0)
|
||||
- sort deleted files by deletion date by default
|
||||
- set/edit notes on shares
|
||||
- search inside of text files
|
||||
- actions on notifications
|
||||
- remember last path on upload
|
||||
- share file to Talk room
|
||||
- show local size in "on device" view
|
||||
- SSO: add request header for deck app
|
||||
- bug fixes
|
||||
For a detailed list, please visit: https://github.com/nextcloud/android/milestone/25
|
||||
|
||||
## 3.2.3 (Aug, 21, 2018)
|
||||
- Fix crash on Android Android 4.x
|
||||
## 3.3.2 (November, 02, 2018)
|
||||
- fix fingerprint not working on certain devices
|
||||
|
||||
## 3.2.2 (Aug, 20, 2018)
|
||||
For full list please see https://github.com/nextcloud/android/milestone/27
|
||||
|
||||
## 3.3.1 (October, 29, 2018)
|
||||
Bugfix release
|
||||
- fix crash on shared folder/file via Talk
|
||||
- fix crash on Notification activity
|
||||
- fixed setup DAVdroid via settings
|
||||
- hide edit option on shares, if not allowed
|
||||
|
||||
For full list please see https://github.com/nextcloud/android/milestone/26
|
||||
|
||||
## 3.3.0 (September, 19, 2018)
|
||||
- Support for Trashbin (Nc14+)
|
||||
- Media streaming (Nc14+)
|
||||
- New media detection for AutoUpload
|
||||
- Improved TalkBack screenreader support
|
||||
- Show outdated server warning for server <NC12
|
||||
- Add support for device credentials
|
||||
- Show offline / maintenance info
|
||||
- Improved activities
|
||||
- Improved file detail / sharing with comments
|
||||
- Improved Share link creation via bottom sheet
|
||||
- Improved Notification, supporting actions
|
||||
- Minor UI/UX improvements
|
||||
- Many bug fixes
|
||||
|
||||
## 3.2.4 (September, 04, 2018)
|
||||
- Fix push notification on gplay release
|
||||
|
||||
## 3.2.3 (August, 21, 2018)
|
||||
- Fix crash on Android 4.x
|
||||
|
||||
## 3.2.2 (August, 20, 2018)
|
||||
- New simple signup screen
|
||||
|
||||
## 3.2.1 (June, 11, 2018)
|
||||
@@ -22,27 +65,27 @@ fix push notification on gplay release
|
||||
- minor UI/UX improvements
|
||||
- many bug fixes
|
||||
|
||||
## 3.1.0 (Apr, 22, 2018)
|
||||
## 3.1.0 (April, 22, 2018)
|
||||
- enhance support for 8.x
|
||||
- speed improvements
|
||||
- minor UI/UX improvements
|
||||
- many bug fixes
|
||||
|
||||
## 3.0.3 (Mar, 05, 2018)
|
||||
## 3.0.3 (March, 05, 2018)
|
||||
- Fix creating folders in auto upload
|
||||
|
||||
## 3.0.2 (Feb, 27, 2018)
|
||||
## 3.0.2 (February, 27, 2018)
|
||||
- Fix crash on old android versions
|
||||
- Fix E2E
|
||||
- Fix crash on old server
|
||||
|
||||
## 3.0.1 (Feb, 14, 2018)
|
||||
## 3.0.1 (February, 14, 2018)
|
||||
- Bugfix E2E
|
||||
- Fix SSL via PlayStore updater
|
||||
- Fix push notification
|
||||
- New android lib, fixing wrong user agent
|
||||
|
||||
## 3.0.0 (Feb, 08, 2018)
|
||||
## 3.0.0 (February, 08, 2018)
|
||||
- End to end encryption
|
||||
- Screen adapted images instead of downloading
|
||||
- direct access to operations for single files
|
||||
@@ -58,7 +101,7 @@ fix push notification on gplay release
|
||||
- UI enhancements
|
||||
- bug fixes
|
||||
|
||||
## 2.0.0 (Oct, 17, 2017)
|
||||
## 2.0.0 (October, 17, 2017)
|
||||
- Account-wide search (Nc 12+)
|
||||
- Auto upload available on Android 4+
|
||||
- Separation between Image & Video for Auto upload
|
||||
|
||||
@@ -45,7 +45,7 @@ Easy starting points are also reviewing [pull requests](https://github.com/nextc
|
||||
#### With a computer:
|
||||
- connect the device via USB
|
||||
- open command prompt/terminal
|
||||
- enter `adb logcat | grep "$(adb shell ps | grep com.nextcloud.client | awk '{print $2}')" > logcatOutput.txt` to save the output to this file
|
||||
- enter `adb logcat | grep "$(adb shell ps | awk '/com.nextcloud.client/{print $2}')" > logcatOutput.txt` to save the output to this file
|
||||
|
||||
**Note:** You must have [adb](https://developer.android.com/studio/releases/platform-tools.html) installed first!
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ To set up the project in Android Studio follow the next steps:
|
||||
* Make sure you have called ```git submodule update``` whenever you switched branches
|
||||
* Open Android Studio and select 'Import Project (Eclipse ADT, Gradle, etc)'. Browse through your file system to the folder 'android' where the project is located. Android Studio will then create the '.iml' files it needs. If you ever close the project but the files are still there, you just select 'Open Project…'. The file chooser will show an Android face as the folder icon, which you can select to reopen the project.
|
||||
* Android Studio will try to build the project directly after importing it. To build it manually, follow the menu path 'Build'/'Make Project', or just click the 'Play' button in the toolbar to build and run it in a mobile device or an emulator. The resulting APK file will be saved in the 'build/outputs/apk/' subdirectory in the project folder.
|
||||
* Setup Android Studio editor configurtation for the project: ```Settings``` → ```Editor``` → ```Code Style``` → ```Scheme: Project``` and ```Enable EditorConfig support```
|
||||
|
||||
|
||||
### 3. Working in a terminal with Gradle:
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.3.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
@@ -75,4 +75,4 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
+48
-49
@@ -7,19 +7,16 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||
classpath 'org.codehaus.groovy:groovy-all:2.4.12'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.3') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.3')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +33,6 @@ configurations.all {
|
||||
}
|
||||
|
||||
ext {
|
||||
supportLibraryVersion = '27.1.1'
|
||||
jacocoVersion = "0.8.2"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
@@ -46,10 +42,10 @@ ext {
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
google()
|
||||
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
@@ -58,9 +54,9 @@ repositories {
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 4
|
||||
def versionMinor = 5
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-49=Alpha / 50-98=RC / 99=stable
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
|
||||
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
|
||||
@@ -72,20 +68,20 @@ android {
|
||||
abortOnError false
|
||||
htmlReport true
|
||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||
disable 'MissingTranslation'
|
||||
disable 'MissingTranslation', 'GradleDependency'
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
javaMaxHeapSize "4g"
|
||||
}
|
||||
|
||||
compileSdkVersion 27
|
||||
compileSdkVersion 28
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
targetSdkVersion 28
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
|
||||
@@ -96,12 +92,12 @@ android {
|
||||
|
||||
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
|
||||
if (versionBuild > 98) {
|
||||
if (versionBuild > 89) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
} else if (versionBuild > 49) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-49)
|
||||
} else if (versionBuild > 50) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
|
||||
} else {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha"+(versionBuild+1)
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
@@ -130,8 +126,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20180919
|
||||
versionName "20180919"
|
||||
versionCode 20190105
|
||||
versionName "20190105"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +179,7 @@ android {
|
||||
ignoreFailures = false
|
||||
effort = "max"
|
||||
reportLevel = "medium"
|
||||
classes = fileTree("$project.buildDir/intermediates/classes/gplay/debug/com/owncloud")
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/gplayDebug/compileGplayDebugJavaWithJavac/classes/")
|
||||
excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
|
||||
source = fileTree('src/main/java')
|
||||
pluginClasspath = project.configurations.findbugsPlugins
|
||||
@@ -210,65 +206,68 @@ android {
|
||||
|
||||
dependencies {
|
||||
// dependencies for app building
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
// implementation project('nextcloud-android-library')
|
||||
genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
|
||||
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
||||
implementation "com.android.support:design:${supportLibraryVersion}"
|
||||
genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
|
||||
gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
|
||||
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
||||
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
|
||||
implementation "com.android.support:exifinterface:${supportLibraryVersion}"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.2.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.0.0'
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.0' // need this version for Android <7
|
||||
implementation 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'com.github.evernote:android-job:v1.2.5'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
||||
implementation 'com.github.tobiaskaminsky:android-job:v1.2.6.1' // 'com.github.evernote:android-job:v1.2.5'
|
||||
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.4'
|
||||
implementation 'org.lukhnos:nnio:0.2'
|
||||
implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
|
||||
|
||||
implementation 'org.parceler:parceler-api:1.1.11'
|
||||
annotationProcessor 'org.parceler:parceler:1.1.11'
|
||||
implementation ('com.github.bumptech.glide:glide:3.7.0') {
|
||||
implementation 'org.parceler:parceler-api:1.1.12'
|
||||
annotationProcessor 'org.parceler:parceler:1.1.12'
|
||||
implementation('com.github.bumptech.glide:glide:3.7.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation 'com.caverock:androidsvg:1.3'
|
||||
implementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
implementation 'androidx.annotation:annotation:1.0.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.22.0'
|
||||
testImplementation 'org.mockito:mockito-core:2.23.4'
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation 'com.android.support.test:rules:1.0.2'
|
||||
androidTestImplementation 'androidx.test:rules:1.1.1'
|
||||
// Android JUnit Runner
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||
|
||||
// Espresso core
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
|
||||
// androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
implementation 'org.jetbrains:annotations:16.0.2'
|
||||
implementation 'org.jetbrains:annotations:16.0.3'
|
||||
|
||||
compileOnly "org.projectlombok:lombok:1.18.4"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.4"
|
||||
|
||||
androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
|
||||
|
||||
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
|
||||
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
|
||||
|
||||
|
||||
// jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
|
||||
// jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
// androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
@@ -309,6 +308,6 @@ task combinedTestReport(type: JacocoReport) {
|
||||
sourceDirectories = files([mainSrc])
|
||||
classDirectories = files([debugTree])
|
||||
executionData = fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M0 0h24v24H0z" fill="none" />
|
||||
<path
|
||||
d="M15.67 4H14V2h-4v2H8.33C7.6 4 7 4.6 7 5.33v15.33C7 21.4 7.6 22 8.33 22h7.33c.74 0 1.34-.6 1.34-1.33V5.33C17 4.6 16.4 4 15.67 4zM13 18h-2v-2h2v2zm0-4h-2V9h2v5z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 318 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/>
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 216 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewbox="0 0 16 16">
|
||||
<path
|
||||
d="M8 1.5C3.582 1.5 0 3.962 0 7s3.582 5.5 8 5.5c.25 0 .49-.016.734-.03L13 16v-4.703c1.83-1.008 3-2.56 3-4.297 0-3.038-3.582-5.5-8-5.5z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 262 B |
@@ -13,7 +13,7 @@
|
||||
viewBox="0 0 128 128"
|
||||
version="1.1"
|
||||
id="svg829"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||
sodipodi:docname="first_run_talk.svg">
|
||||
<defs
|
||||
id="defs823"/>
|
||||
@@ -25,8 +25,8 @@
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="297.07973"
|
||||
inkscape:cy="366.5173"
|
||||
inkscape:cx="197.26742"
|
||||
inkscape:cy="78.319822"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
@@ -35,10 +35,10 @@
|
||||
fit-margin-left="2"
|
||||
fit-margin-right="2"
|
||||
fit-margin-bottom="2"
|
||||
inkscape:window-width="1600"
|
||||
inkscape:window-height="835"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-y="34"
|
||||
inkscape:window-maximized="1"/>
|
||||
<metadata
|
||||
id="metadata826">
|
||||
@@ -58,9 +58,11 @@
|
||||
id="layer1"
|
||||
transform="translate(-15.580506,-52.12649)">
|
||||
<path
|
||||
style="fill:#ffffff;stroke-width:4.78543139"
|
||||
d="M 241.85938,2.6035156 C 109.72511,2.6053865 2.6113188,109.72517 2.6152344,241.86133 c 8.69e-5,132.13334 107.1127156,239.24815 239.2441456,239.25 26.38805,-0.0535 52.46249,-4.4707 77.19954,-12.96295 16.31567,-5.60118 32.04955,-12.97512 46.90788,-22.039 12.78608,5.081 32.46588,14.50729 51.91537,22.30803 25.27886,10.13878 50.16864,17.53156 59.02799,9.06892 8.75623,-8.36216 2.65569,-33.29226 -6.22433,-58.86696 -7.73207,-22.26856 -17.57143,-45.02584 -21.54521,-57.75999 9.61628,-16.68601 17.14139,-34.39874 22.46771,-52.73831 6.22776,-21.44334 9.44951,-43.74365 9.49323,-66.26169 C 481.09967,109.72865 373.99016,2.6150774 241.86133,2.6113281 Z m 0.0273,90.9609374 h 0.002 c 81.9303,3.48e-4 148.34762,66.419397 148.34766,148.351567 -0.004,81.92844 -66.42304,148.34179 -148.34961,148.34179 -81.92656,0 -148.342022,-66.41335 -148.347658,-148.34179 2.7e-5,-81.93241 66.417128,-148.351563 148.347658,-148.351567 z"
|
||||
transform="matrix(0.26458333,0,0,0.26458333,15.580506,52.12649)"
|
||||
id="path4753"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#ffffff;stroke-width:1.26614535"
|
||||
d="m 79.572589,52.815123 a 63.300934,63.301842 0 0 0 -63.300038,63.303717 63.300934,63.301842 0 0 0 63.300038,63.3018 63.300934,63.301842 0 0 0 32.836581,-9.26097 c 7.77991,3.09162 25.20623,12.26357 29.35376,8.30176 4.33401,-4.13896 -5.08818,-23.61904 -7.34707,-30.85775 A 63.300934,63.301842 0 0 0 142.8719,116.11826 63.300934,63.301842 0 0 0 79.572762,52.817324 Z m 0.0074,24.06677 A 39.250508,39.251409 0 0 1 118.83033,116.13329 39.250508,39.251409 0 0 1 79.579825,155.382 39.250508,39.251409 0 0 1 40.329319,116.13329 39.250508,39.251409 0 0 1 79.579825,76.881893 Z"
|
||||
id="path2"/>
|
||||
sodipodi:nodetypes="cccscscscscccsccscs"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -8,4 +8,5 @@
|
||||
<Match>
|
||||
<Class name="~.*\.R\$.*"/>
|
||||
</Match>
|
||||
<Bug pattern="PATH_TRAVERSAL_IN" />
|
||||
</FindBugsFilter>
|
||||
@@ -0,0 +1,5 @@
|
||||
# workaround since lombok and desugering have an issue
|
||||
# to be fixed with gradle Android plugin 3.3.0
|
||||
android.enableD8.desugaring=false
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
+2
-2
@@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
distributionSha256Sum=7a2c66d1a78f811d5f37d14630ad21cec5e77a2a4dc61e787e2257a6341016ce
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
distributionSha256Sum=9af7345c199f1731c187c96d3fe3d31f5405192a42046bafa71d846c3d9adacb
|
||||
@@ -1,17 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
<issue id="UnusedAttribute">
|
||||
<ignore regexp="importantForAutofill"/>
|
||||
<ignore regexp="autofillHints"/>
|
||||
</issue>
|
||||
<issue id="InvalidPackage">
|
||||
<ignore path="**/freemarker-2.3.23.jar"/>
|
||||
<ignore path="**/nnio-0.2.jar"/>
|
||||
<ignore path="**/pkix-1.54.0.0.jar"/>
|
||||
</issue>
|
||||
|
||||
|
||||
<issue id="UnusedResources">
|
||||
<ignore regexp="store_short_desc|store_full_desc|store_short_dev_desc|store_full_dev_desc" />
|
||||
<ignore
|
||||
regexp="screenshot_01_gridView|screenshot_02_listView|screenshot_03_drawer|screenshot_04_accounts|screenshot_05_autoUpload|screenshot_06_davdroid"/>
|
||||
<ignore path="**/raw/encryption_key_words.txt" />
|
||||
</issue>
|
||||
|
||||
|
||||
<issue id="MissingQuantity">
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
</issue>
|
||||
@@ -28,178 +33,15 @@
|
||||
</issue>
|
||||
|
||||
<issue id="UnusedResources">
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
<ignore path="**/values-b+es+419/strings.xml" />
|
||||
<ignore path="**/values-pt-rPT/strings.xml"/>
|
||||
<ignore path="**/values-ro/strings.xml"/>
|
||||
<ignore path="**/values-zh-rCN/strings.xml"/>
|
||||
<ignore path="**/values-bg-rBG/strings.xml"/>
|
||||
<ignore path="**/values-nb-rNO/strings.xml"/>
|
||||
<ignore path="**/values-es/strings.xml"/>
|
||||
<ignore path="**/values-fa/strings.xml"/>
|
||||
<ignore path="**/values-ko/strings.xml"/>
|
||||
<ignore path="**/values-ru/strings.xml"/>
|
||||
<ignore path="**/values-ast/strings.xml"/>
|
||||
<ignore path="**/values-es-rCO/strings.xml"/>
|
||||
<ignore path="**/values-es-rCL/strings.xml"/>
|
||||
<ignore path="**/values-es-rSV/strings.xml"/>
|
||||
<ignore path="**/values-sv/strings.xml"/>
|
||||
<ignore path="**/values-tr/strings.xml"/>
|
||||
<ignore path="**/values-es-rUY/strings.xml"/>
|
||||
<ignore path="**/values-es-rGT/strings.xml"/>
|
||||
<ignore path="**/values-fr/strings.xml"/>
|
||||
<ignore path="**/values-es-rMX/strings.xml"/>
|
||||
<ignore path="**/values-fi-rFI/strings.xml"/>
|
||||
<ignore path="**/values-ar/strings.xml"/>
|
||||
<ignore path="**/values-es-rAR/strings.xml"/>
|
||||
<ignore path="**/values-de-rDE/strings.xml"/>
|
||||
<ignore path="**/values-ca/strings.xml"/>
|
||||
<ignore path="**/values-is/strings.xml"/>
|
||||
<ignore path="**/values-es-rNI/strings.xml"/>
|
||||
<ignore path="**/values-es-rPR/strings.xml"/>
|
||||
<ignore path="**/values-es-rDO/strings.xml"/>
|
||||
<ignore path="**/values-sq/strings.xml"/>
|
||||
<ignore path="**/values-pt-rBR/strings.xml"/>
|
||||
<ignore path="**/values-ja-rJP/strings.xml"/>
|
||||
<ignore path="**/values-sr/strings.xml"/>
|
||||
<ignore path="**/values-it/strings.xml"/>
|
||||
<ignore path="**/values-hu-rHU/strings.xml"/>
|
||||
<ignore path="**/values-pl/strings.xml"/>
|
||||
<ignore path="**/values-es-rHN/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-es-rPA/strings.xml"/>
|
||||
<ignore path="**/values-nl/strings.xml"/>
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
<ignore path="**/values-eu/strings.xml"/>
|
||||
<ignore path="**/values-es-rCR/strings.xml"/>
|
||||
<ignore path="**/values-da/strings.xml"/>
|
||||
<ignore path="**/values-es-rEC/strings.xml"/>
|
||||
<ignore path="**/values-de/strings.xml"/>
|
||||
<ignore path="**/values-sl/strings.xml"/>
|
||||
<ignore path="**/values-es-rPY/strings.xml"/>
|
||||
<ignore path="**/values-es-rPE/strings.xml"/>
|
||||
<ignore path="**/values-zh-rTW/strings.xml"/>
|
||||
<ignore path="**/values-el/strings.xml"/>
|
||||
<ignore path="**/values-id/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-en-rGB/strings.xml"/>
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
|
||||
<issue id="TypographyEllipsis">
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
<ignore path="**/values-pt-rPT/strings.xml"/>
|
||||
<ignore path="**/values-ro/strings.xml"/>
|
||||
<ignore path="**/values-zh-rCN/strings.xml"/>
|
||||
<ignore path="**/values-bg-rBG/strings.xml"/>
|
||||
<ignore path="**/values-nb-rNO/strings.xml"/>
|
||||
<ignore path="**/values-es/strings.xml"/>
|
||||
<ignore path="**/values-fa/strings.xml"/>
|
||||
<ignore path="**/values-ko/strings.xml"/>
|
||||
<ignore path="**/values-ru/strings.xml"/>
|
||||
<ignore path="**/values-ast/strings.xml"/>
|
||||
<ignore path="**/values-es-rCO/strings.xml"/>
|
||||
<ignore path="**/values-es-rCL/strings.xml"/>
|
||||
<ignore path="**/values-es-rSV/strings.xml"/>
|
||||
<ignore path="**/values-sv/strings.xml"/>
|
||||
<ignore path="**/values-tr/strings.xml"/>
|
||||
<ignore path="**/values-es-rUY/strings.xml"/>
|
||||
<ignore path="**/values-es-rGT/strings.xml"/>
|
||||
<ignore path="**/values-fr/strings.xml"/>
|
||||
<ignore path="**/values-es-rMX/strings.xml"/>
|
||||
<ignore path="**/values-fi-rFI/strings.xml"/>
|
||||
<ignore path="**/values-ar/strings.xml"/>
|
||||
<ignore path="**/values-es-rAR/strings.xml"/>
|
||||
<ignore path="**/values-de-rDE/strings.xml"/>
|
||||
<ignore path="**/values-ca/strings.xml"/>
|
||||
<ignore path="**/values-is/strings.xml"/>
|
||||
<ignore path="**/values-es-rNI/strings.xml"/>
|
||||
<ignore path="**/values-es-rPR/strings.xml"/>
|
||||
<ignore path="**/values-es-rDO/strings.xml"/>
|
||||
<ignore path="**/values-sq/strings.xml"/>
|
||||
<ignore path="**/values-pt-rBR/strings.xml"/>
|
||||
<ignore path="**/values-ja-rJP/strings.xml"/>
|
||||
<ignore path="**/values-sr/strings.xml"/>
|
||||
<ignore path="**/values-it/strings.xml"/>
|
||||
<ignore path="**/values-hu-rHU/strings.xml"/>
|
||||
<ignore path="**/values-pl/strings.xml"/>
|
||||
<ignore path="**/values-es-rHN/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-es-rPA/strings.xml"/>
|
||||
<ignore path="**/values-nl/strings.xml"/>
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
<ignore path="**/values-eu/strings.xml"/>
|
||||
<ignore path="**/values-es-rCR/strings.xml"/>
|
||||
<ignore path="**/values-da/strings.xml"/>
|
||||
<ignore path="**/values-es-rEC/strings.xml"/>
|
||||
<ignore path="**/values-de/strings.xml"/>
|
||||
<ignore path="**/values-sl/strings.xml"/>
|
||||
<ignore path="**/values-es-rPY/strings.xml"/>
|
||||
<ignore path="**/values-es-rPE/strings.xml"/>
|
||||
<ignore path="**/values-zh-rTW/strings.xml"/>
|
||||
<ignore path="**/values-el/strings.xml"/>
|
||||
<ignore path="**/values-id/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-en-rGB/strings.xml"/>
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="Typos">
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
<ignore path="**/values-pt-rPT/strings.xml"/>
|
||||
<ignore path="**/values-ro/strings.xml"/>
|
||||
<ignore path="**/values-zh-rCN/strings.xml"/>
|
||||
<ignore path="**/values-bg-rBG/strings.xml"/>
|
||||
<ignore path="**/values-nb-rNO/strings.xml"/>
|
||||
<ignore path="**/values-es/strings.xml"/>
|
||||
<ignore path="**/values-fa/strings.xml"/>
|
||||
<ignore path="**/values-ko/strings.xml"/>
|
||||
<ignore path="**/values-ru/strings.xml"/>
|
||||
<ignore path="**/values-ast/strings.xml"/>
|
||||
<ignore path="**/values-es-rCO/strings.xml"/>
|
||||
<ignore path="**/values-es-rCL/strings.xml"/>
|
||||
<ignore path="**/values-es-rSV/strings.xml"/>
|
||||
<ignore path="**/values-sv/strings.xml"/>
|
||||
<ignore path="**/values-tr/strings.xml"/>
|
||||
<ignore path="**/values-es-rUY/strings.xml"/>
|
||||
<ignore path="**/values-es-rGT/strings.xml"/>
|
||||
<ignore path="**/values-fr/strings.xml"/>
|
||||
<ignore path="**/values-es-rMX/strings.xml"/>
|
||||
<ignore path="**/values-fi-rFI/strings.xml"/>
|
||||
<ignore path="**/values-ar/strings.xml"/>
|
||||
<ignore path="**/values-es-rAR/strings.xml"/>
|
||||
<ignore path="**/values-de-rDE/strings.xml"/>
|
||||
<ignore path="**/values-ca/strings.xml"/>
|
||||
<ignore path="**/values-is/strings.xml"/>
|
||||
<ignore path="**/values-es-rNI/strings.xml"/>
|
||||
<ignore path="**/values-es-rPR/strings.xml"/>
|
||||
<ignore path="**/values-es-rDO/strings.xml"/>
|
||||
<ignore path="**/values-sq/strings.xml"/>
|
||||
<ignore path="**/values-pt-rBR/strings.xml"/>
|
||||
<ignore path="**/values-ja-rJP/strings.xml"/>
|
||||
<ignore path="**/values-sr/strings.xml"/>
|
||||
<ignore path="**/values-it/strings.xml"/>
|
||||
<ignore path="**/values-hu-rHU/strings.xml"/>
|
||||
<ignore path="**/values-pl/strings.xml"/>
|
||||
<ignore path="**/values-es-rHN/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-es-rPA/strings.xml"/>
|
||||
<ignore path="**/values-nl/strings.xml"/>
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
<ignore path="**/values-eu/strings.xml"/>
|
||||
<ignore path="**/values-es-rCR/strings.xml"/>
|
||||
<ignore path="**/values-da/strings.xml"/>
|
||||
<ignore path="**/values-es-rEC/strings.xml"/>
|
||||
<ignore path="**/values-de/strings.xml"/>
|
||||
<ignore path="**/values-sl/strings.xml"/>
|
||||
<ignore path="**/values-es-rPY/strings.xml"/>
|
||||
<ignore path="**/values-es-rPE/strings.xml"/>
|
||||
<ignore path="**/values-zh-rTW/strings.xml"/>
|
||||
<ignore path="**/values-el/strings.xml"/>
|
||||
<ignore path="**/values-id/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-en-rGB/strings.xml"/>
|
||||
|
||||
<issue id="Typos">
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
</lint>
|
||||
@@ -8,74 +8,107 @@
|
||||
#6: DRONE_BUILD_NUMBER
|
||||
#7: PULL_REQUEST_NUMBER
|
||||
|
||||
stableBranch="master"
|
||||
repository="android"
|
||||
|
||||
ruby scripts/analysis/lint-up.rb $1 $2 $3
|
||||
lintValue=$?
|
||||
|
||||
./gradlew findbugs
|
||||
|
||||
# exit codes:
|
||||
# 0: count was reduced
|
||||
# 1: count was increased
|
||||
# 2: count stayed the same
|
||||
|
||||
./gradlew findbugs
|
||||
|
||||
echo "Branch: $3"
|
||||
|
||||
if [ $3 = "master" ]; then
|
||||
echo "New findbugs result for master at: https://www.kaminsky.me/nc-dev/client-findbugs/master.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/master.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s'/Summary/FindBugs (master)/' | tr "\"" "\'" | tr -d "\r\n")
|
||||
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/findbugs.html
|
||||
|
||||
if [ $3 = $stableBranch ]; then
|
||||
echo "New findbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"/Summary/FindBugs ($stableBranch)/" | tr "\"" "\'" | tr -d "\r\n")
|
||||
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/findbugs-summary-$stableBranch.html
|
||||
|
||||
if [ $lintValue -ne 1 ]; then
|
||||
echo "New lint result for master at: https://www.kaminsky.me/nc-dev/client-lint/master.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/master.html --upload-file build/reports/lint/lint.html
|
||||
echo "New lint result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file build/reports/lint/lint.html
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
if [ -e $6 ]; then
|
||||
6="master-"$(date +%F)
|
||||
6=$stableBranch"-"$(date +%F)
|
||||
fi
|
||||
echo "New lint results at https://www.kaminsky.me/nc-dev/client-lint/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/$6.html --upload-file build/reports/lint/lint.html
|
||||
|
||||
echo "New findbugs results at https://www.kaminsky.me/nc-dev/client-findbugs/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/$6.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$6.html --upload-file build/reports/lint/lint.html
|
||||
|
||||
echo "New findbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$6.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
# delete all old comments
|
||||
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
|
||||
|
||||
# check library, only if base branch is master
|
||||
baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"")
|
||||
if [ $baseBranch = "master" -a $(grep "android-library:master" build.gradle -c) -ne 3 ]; then
|
||||
checkLibraryMessage="<h1>Android-library is not set to master branch in build.gradle</h1>"
|
||||
checkLibrary=1
|
||||
else
|
||||
else
|
||||
checkLibrary=0
|
||||
fi
|
||||
|
||||
|
||||
# lint and findbugs file must exist
|
||||
if [ ! -s build/reports/lint/lint.html ] ; then
|
||||
echo "lint.html file is missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -s build/reports/findbugs/findbugs.html ] ; then
|
||||
echo "findbugs.html file is missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# add comment with results
|
||||
lintResultNew=$(grep "Lint Report.* [0-9]* warnings" build/reports/lint/lint.html | cut -f2 -d':' |cut -f1 -d'<')
|
||||
lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ")
|
||||
lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
||||
lintErrorOld=$(grep "[0-9]* error" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
|
||||
lintWarningOld=$(grep "[0-9]* warning" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
|
||||
lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/client-lint/master.html'>Master</a></td><td><a href='https://www.kaminsky.me/nc-dev/client-lint/"$6".html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
|
||||
findbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"#Summary#<a href=\"https://www.kaminsky.me/nc-dev/client-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
||||
findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/index.php/s/YaHngKMM6ERmBeg/download | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/client-findbugs/master.html">FindBugs</a>#'| tr "\"" "\'" | tr -d "\n")
|
||||
|
||||
lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ")
|
||||
if ( [ -z $lintErrorNew ] ); then
|
||||
lintErrorNew=0
|
||||
fi
|
||||
|
||||
lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
||||
if ( [ -z $lintWarningNew ] ); then
|
||||
lintWarningNew=0
|
||||
fi
|
||||
|
||||
lintResultOld=$(curl 2>/dev/null https://raw.githubusercontent.com/nextcloud/android/$stableBranch/scripts/analysis/lint-results.txt)
|
||||
lintErrorOld=$(echo $lintResultOld | grep "[0-9]* error" -o | cut -f1 -d" ")
|
||||
if ( [ -z $lintErrorOld ] ); then
|
||||
lintErrorOld=0
|
||||
fi
|
||||
|
||||
lintWarningOld=$(echo $lintResultOld | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
||||
if ( [ -z $lintWarningOld ] ); then
|
||||
lintWarningOld=0
|
||||
fi
|
||||
|
||||
lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-lint/"$stableBranch".html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-lint/"$6".html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
|
||||
findbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"#Summary#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
||||
findbugsResultOld=$(curl 2>/dev/null https://www.kaminsky.me/nc-dev/$repository-findbugs/findbugs-summary-$stableBranch.html | tr "\"" "\'" | tr -d "\r\n" | sed s"#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html\">FindBugs</a>#" | tr "\"" "\'" | tr -d "\n")
|
||||
|
||||
curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage \" }"
|
||||
|
||||
|
||||
if [ $checkLibrary -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ $lintValue -eq 2 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit $lintValue
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -5,5 +5,5 @@
|
||||
if [ -z $3 ] ; then
|
||||
echo "master";
|
||||
else
|
||||
curl 2>/dev/null -u $1:$2 https://api.github.com/repos/nextcloud/android/pulls/$3 | grep \"ref\": | grep -v master | cut -d"\"" -f4
|
||||
curl 2>/dev/null -u $1:$2 https://api.github.com/repos/nextcloud/android/pulls/$3 | grep \"ref\": | grep -v '"master"' | cut -d"\"" -f4
|
||||
fi
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 94 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 83 warnings</span>
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/integrationTests
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
||||
ID=$3
|
||||
USER=$1
|
||||
PASS=$2
|
||||
@@ -8,12 +8,12 @@ TYPE=$4
|
||||
|
||||
if [ $TYPE = "IT" ]; then
|
||||
cd build/reports/androidTests/connected/flavors/GPLAY
|
||||
else
|
||||
else
|
||||
cd build/reports/tests/testGplayDebugUnitTest
|
||||
fi
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$ID/$(echo {} | sed s#\./##) \;
|
||||
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$ID/$(echo {} | sed s#\./##) --upload-file {} \;
|
||||
|
||||
echo "Uploaded failing tests to https://nextcloud.kaminsky.me/index.php/s/XqY52jBr9ZYfDiz -> $ID"
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$ID"
|
||||
exit 1
|
||||
@@ -25,8 +25,8 @@
|
||||
the normal release/debug builds.
|
||||
-->
|
||||
|
||||
<manifest
|
||||
package="${applicationId}.test"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>
|
||||
</manifest>
|
||||
<manifest xmlns:tools="http://schemas.android.com/tools"
|
||||
package="${applicationId}.test">
|
||||
|
||||
<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator" />
|
||||
</manifest>
|
||||
@@ -1,11 +1,6 @@
|
||||
package com.owncloud.android.screenshots;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.espresso.action.ViewActions;
|
||||
import android.support.test.espresso.contrib.DrawerActions;
|
||||
import android.support.test.espresso.matcher.PreferenceMatchers;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
@@ -20,15 +15,20 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import androidx.test.espresso.Espresso;
|
||||
import androidx.test.espresso.action.ViewActions;
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.matcher.PreferenceMatchers;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
import tools.fastlane.screengrab.Screengrab;
|
||||
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;
|
||||
import tools.fastlane.screengrab.locale.LocaleTestRule;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onData;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static androidx.test.espresso.Espresso.onData;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.anything;
|
||||
import static org.hamcrest.core.AnyOf.anyOf;
|
||||
|
||||
|
||||
@@ -21,18 +21,19 @@ package com.owncloud.android.uiautomator;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SdkSuppress;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
import android.support.test.uiautomator.UiObject;
|
||||
import android.support.test.uiautomator.UiObjectNotFoundException;
|
||||
import android.support.test.uiautomator.UiSelector;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SdkSuppress;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
import androidx.test.uiautomator.UiObject;
|
||||
import androidx.test.uiautomator.UiObjectNotFoundException;
|
||||
import androidx.test.uiautomator.UiSelector;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -19,31 +17,31 @@ import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
/**
|
||||
* Common base for all integration tests
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
public abstract class AbstractIT {
|
||||
|
||||
protected static OwnCloudClient client;
|
||||
protected static Account account;
|
||||
static Account account;
|
||||
protected static Context context;
|
||||
|
||||
private static final String username = "test";
|
||||
private static final String password = "test";
|
||||
private static final String baseUrl = "server";
|
||||
|
||||
public AbstractIT() {
|
||||
super(MainApp.class);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
try {
|
||||
context = MainApp.getAppContext();
|
||||
context = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
Account temp = new Account(username + "@" + baseUrl, MainApp.getAccountType(context));
|
||||
|
||||
@@ -62,7 +60,7 @@ public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(account, context);
|
||||
|
||||
createDummyFiles();
|
||||
@@ -77,14 +75,28 @@ public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
}
|
||||
}
|
||||
|
||||
protected FileDataStorageManager getStorageManager() {
|
||||
FileDataStorageManager getStorageManager() {
|
||||
return new FileDataStorageManager(account, context.getContentResolver());
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
|
||||
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + "/123.txt");
|
||||
createFile("empty.txt", 0);
|
||||
createFile("nonEmpty.txt", 100);
|
||||
createFile("chunkedFile.txt", 500000);
|
||||
}
|
||||
|
||||
private static void createFile(String name, int iteration) throws IOException {
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
||||
file.createNewFile();
|
||||
|
||||
FileWriter writer = new FileWriter(file);
|
||||
|
||||
for (int i = 0; i < iteration; i++) {
|
||||
writer.write("123123123123123123123123123\n");
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
@@ -9,17 +7,21 @@ import com.owncloud.android.operations.common.SyncOperation;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests related to file operations
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FileIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void testCreateFolder() {
|
||||
String path = "/testFolder/";
|
||||
|
||||
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -11,6 +9,10 @@ import com.owncloud.android.utils.FileStorageUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests related to file uploads
|
||||
*/
|
||||
@@ -19,18 +21,45 @@ import org.junit.runner.RunWith;
|
||||
public class UploadIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void testSimpleUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/123.txt",
|
||||
"/testUpload/1.txt", account.name);
|
||||
public void testEmptyUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
"/testUpload/empty.txt", account.name);
|
||||
|
||||
RemoteOperationResult result = testUpload(ocUpload);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonEmptyUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
"/testUpload/nonEmpty.txt", account.name);
|
||||
|
||||
RemoteOperationResult result = testUpload(ocUpload);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunkedUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/chunkedFile.txt",
|
||||
"/testUpload/chunkedFile.txt", account.name);
|
||||
|
||||
RemoteOperationResult result = testUpload(ocUpload);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
public RemoteOperationResult testUpload(OCUpload ocUpload) {
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
context,
|
||||
false,
|
||||
false
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
context,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
@@ -38,13 +67,12 @@ public class UploadIT extends AbstractIT {
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.isSuccess());
|
||||
return newUpload.execute(client, getStorageManager());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadInNonExistingFolder() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/123.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
"/testUpload/2/3/4/1.txt", account.name);
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
account,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -21,13 +21,14 @@
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
@@ -77,21 +78,20 @@ public class OCFileUnitTest {
|
||||
mFile.setFileId(ID);
|
||||
mFile.setParentId(PARENT_ID);
|
||||
mFile.setStoragePath(STORAGE_PATH);
|
||||
mFile.setMimetype(MIME_TYPE);
|
||||
mFile.setMimeType(MIME_TYPE);
|
||||
mFile.setFileLength(FILE_LENGTH);
|
||||
mFile.setCreationTimestamp(CREATION_TIMESTAMP);
|
||||
mFile.setModificationTimestamp(MODIFICATION_TIMESTAMP);
|
||||
mFile.setModificationTimestampAtLastSyncForData(MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA);
|
||||
mFile.setLastSyncDateForProperties(LAST_SYNC_DATE_FOR_PROPERTIES);
|
||||
mFile.setLastSyncDateForData(LAST_SYNC_DATE_FOR_DATA);
|
||||
mFile.setAvailableOffline(true);
|
||||
mFile.setEtag(ETAG);
|
||||
mFile.setShareViaLink(true);
|
||||
mFile.setShareWithSharee(true);
|
||||
mFile.setSharedViaLink(true);
|
||||
mFile.setSharedWithSharee(true);
|
||||
mFile.setPublicLink(PUBLIC_LINK);
|
||||
mFile.setPermissions(PERMISSIONS);
|
||||
mFile.setRemoteId(REMOTE_ID);
|
||||
mFile.setNeedsUpdateThumbnail(true);
|
||||
mFile.setUpdateThumbnailNeeded(true);
|
||||
mFile.setDownloading(true);
|
||||
mFile.setEtagInConflict(ETAG_IN_CONFLICT);
|
||||
|
||||
@@ -119,16 +119,14 @@ public class OCFileUnitTest {
|
||||
);
|
||||
assertThat(fileReadFromParcel.getLastSyncDateForProperties(), is(LAST_SYNC_DATE_FOR_PROPERTIES));
|
||||
assertThat(fileReadFromParcel.getLastSyncDateForData(), is(LAST_SYNC_DATE_FOR_DATA));
|
||||
assertThat(fileReadFromParcel.isAvailableOffline(), is(true));
|
||||
assertThat(fileReadFromParcel.getEtag(), is(ETAG));
|
||||
assertThat(fileReadFromParcel.isSharedViaLink(), is(true));
|
||||
assertThat(fileReadFromParcel.isSharedWithSharee(), is(true));
|
||||
assertThat(fileReadFromParcel.getPublicLink(), is(PUBLIC_LINK));
|
||||
assertThat(fileReadFromParcel.getPermissions(), is(PERMISSIONS));
|
||||
assertThat(fileReadFromParcel.getRemoteId(), is(REMOTE_ID));
|
||||
assertThat(fileReadFromParcel.needsUpdateThumbnail(), is(true));
|
||||
assertThat(fileReadFromParcel.isUpdateThumbnailNeeded(), is(true));
|
||||
assertThat(fileReadFromParcel.isDownloading(), is(true));
|
||||
assertThat(fileReadFromParcel.getEtagInConflict(), is(ETAG_IN_CONFLICT));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,6 @@ package com.owncloud.android.datamodel;
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
|
||||
@@ -17,6 +14,10 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
/**
|
||||
* Created by JARP on 6/7/17.
|
||||
*/
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
package com.owncloud.android.util;
|
||||
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
@@ -50,7 +48,10 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Svobodná (copyleft) aplikace Nextcloud pro Android, poskytující mobilní svobodu.
|
||||
|
||||
Funkce:
|
||||
* Snadno použitelné moderní rozhraní, hodící se k vzhledu vašeho serveru
|
||||
* Nahrávání souborů na Nextcloud server
|
||||
* Jejich sdílení s ostatními
|
||||
* Synchronizace vašich oblíbených souborů a složek
|
||||
* Hledání napříč všemi složkami na serveru
|
||||
* Automatické nahrávání fotek a videí pořízených vaším zařízením
|
||||
* Doručování oznámení
|
||||
* Podpora vícero účtů
|
||||
* Zabezpečený přístup k vašim datům pomocí otisku prstu nebo PIN kódu
|
||||
* Začlenění DAVdroid pro snadný přístup ke kalendáři & synchronizaci kontaktů
|
||||
|
||||
Jakékoli problémy prosím hlaste na https://github.com/nextcloud/android/issues a o aplikaci diskutujte na https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Ještě Nextcloud neznáte? Nextcloud je server pro soukromou synchronizaci souborů &, sdílení a komunikaci. Je to svobodný software a můžete ho buď provozovat sami nebo si pronajímat od nějaké společnosti. Tím vy vládnete svým fotkám, údajům v kalendáři a kontaktech, dokumentům a všemu ostatnímu.
|
||||
|
||||
Podívejte se na Nextcloud na https://nextcloud.com
|
||||
@@ -1 +1 @@
|
||||
Aplikace Nextcloud pro Android ti nabízí přístup ke všem souborům ve tvém Nextcl
|
||||
Aplikace Nextcloud pro Android poskytuje přístup ke všem souborům na vašem Nextc
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud Android programėlė suteikia jums mobiliąją prieigą prie jūsų visų Next
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -9,6 +9,6 @@ Funkcje:
|
||||
|
||||
Zgłaszaj błędy na https://github.com/nextcloud/android/issues i dyskutuj na temat tej aplikacji na https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Nie znasz jeszcze Nextcloud? Nextcloud jest prywatnym serwerem synchronizacji & współdzielenia plików oraz komunikacji. Jego źródła są całkowicie otwarte, więc możesz korzystać z niego na własnym serwerze albo możesz zapłacić za to firmie trzeciej. W ten sposób kontrolujesz swoje zdjęcia, kalendarz, dane kontaktowe, twoje dokumenty i inne dane.
|
||||
Nie znasz jeszcze Nextcloud? Nextcloud jest prywatnym serwerem synchronizacji współdzielenia plików oraz komunikacji. Jego źródła są całkowicie otwarte, więc możesz korzystać z niego na własnym serwerze albo możesz zapłacić za to firmie trzeciej. W ten sposób kontrolujesz swoje zdjęcia, kalendarz, dane kontaktowe, twoje dokumenty i inne dane.
|
||||
|
||||
Zobacz Nextcloud na https://nextcloud.com
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud Android-appen ger mobilåtkomst till alla filer på ditt Nextcloud.
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -26,10 +26,13 @@ import android.util.Log;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
|
||||
public class GooglePlayUtils {
|
||||
public final class GooglePlayUtils {
|
||||
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
|
||||
private static final String TAG = "GooglePlayUtils";
|
||||
|
||||
private GooglePlayUtils() {
|
||||
}
|
||||
|
||||
public static boolean checkPlayServices(Activity activity) {
|
||||
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
|
||||
int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
|
||||
|
||||
@@ -395,19 +395,11 @@ public final class PushUtils {
|
||||
PreferenceManager.setKeysMigration(context, true);
|
||||
} else {
|
||||
if (oldPrivateKeyFile.exists()) {
|
||||
try {
|
||||
FileStorageUtils.moveFile(oldPrivateKeyFile, privateKeyFile);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to move old private key to new location");
|
||||
}
|
||||
FileStorageUtils.moveFile(oldPrivateKeyFile, privateKeyFile);
|
||||
}
|
||||
|
||||
if (oldPublicKeyFile.exists()) {
|
||||
try {
|
||||
FileStorageUtils.moveFile(oldPublicKeyFile, publicKeyFile);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to move old public key to new location");
|
||||
}
|
||||
FileStorageUtils.moveFile(oldPublicKeyFile, publicKeyFile);
|
||||
}
|
||||
|
||||
if (privateKeyFile.exists() && publicKeyFile.exists()) {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<string name="google_app_id" translatable="false">1:829118773643:android:512449826e931d0e</string>
|
||||
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyAWIyOcLafaFp8PFL61h64cy1NNZW2cU_s</string>
|
||||
<string name="google_storage_bucket" translatable="false">nextcloud-a7dea.appspot.com</string>
|
||||
<string name="project_id" translatable="false">nextcloud-a7dea</string>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -64,7 +64,11 @@
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
|
||||
<!-- Apps that target Android 9 (API level 28) or higher and use foreground services
|
||||
must request the FOREGROUND_SERVICE permission -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
|
||||
<application
|
||||
@@ -106,10 +110,13 @@
|
||||
<activity android:name=".ui.activity.UploadFilesActivity" />
|
||||
<activity android:name=".ui.activity.ExternalSiteWebView"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
<activity
|
||||
android:name=".ui.activity.RichDocumentsWebView"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"/>
|
||||
<activity android:name=".ui.activity.ContactsPreferenceActivity"
|
||||
android:launchMode="singleInstance"/>
|
||||
<activity android:name=".ui.activity.ReceiveExternalFilesActivity"
|
||||
|
||||
|
||||
android:taskAffinity=""
|
||||
android:excludeFromRecents="true"
|
||||
android:theme="@style/Theme.ownCloud.NoActionBar">
|
||||
@@ -194,7 +201,7 @@
|
||||
|
||||
<!-- new provider used to generate URIs without file:// scheme (forbidden from Android 7) -->
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="@string/file_provider_authority"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
@@ -242,10 +249,12 @@
|
||||
<service android:name=".media.MediaService" />
|
||||
|
||||
<activity android:name=".ui.activity.PassCodeActivity" />
|
||||
<activity android:name=".ui.activity.RequestCredentialsActivity" />
|
||||
<activity
|
||||
android:name=".ui.activity.RequestCredentialsActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity android:name=".ui.activity.ConflictsResolveActivity"/>
|
||||
<activity android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity"/>
|
||||
|
||||
|
||||
<activity android:name=".ui.activity.LogHistoryActivity"/>
|
||||
|
||||
<activity android:name=".ui.errorhandling.ErrorShowActivity" />
|
||||
@@ -277,6 +286,12 @@
|
||||
<activity
|
||||
android:name=".ui.activity.FolderPickerActivity"
|
||||
android:label="@string/app_name" />
|
||||
<activity
|
||||
android:name=".ui.activity.FilePickerActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustResize"/>
|
||||
<activity
|
||||
android:name=".ui.activity.UploadPathActivity"
|
||||
android:label="@string/app_name" />
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Binder;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nextcloud.android.sso.aidl.IInputStreamService;
|
||||
@@ -49,13 +50,16 @@ import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND;
|
||||
@@ -111,7 +115,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
NextcloudRequest request = deserializeObjectAndCloseStream(is);
|
||||
httpStream = processRequest(request);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
Log_OC.e(TAG, "Error during Nextcloud request", e);
|
||||
exception = e;
|
||||
}
|
||||
|
||||
@@ -121,7 +125,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
InputStream resultStream = new java.io.SequenceInputStream(exceptionStream, httpStream);
|
||||
return ParcelFileDescriptorUtil.pipeFrom(resultStream, thread -> Log.d(TAG, "Done sending result"));
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
Log_OC.e(TAG, "Error while sending response back to client app", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -206,6 +210,11 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
method.setQueryString(convertMapToNVP(request.getParameter()));
|
||||
method.addRequestHeader("OCS-APIREQUEST", "true");
|
||||
|
||||
for(Map.Entry<String, List<String>> header : request.getHeader().entrySet()) {
|
||||
// https://stackoverflow.com/a/3097052
|
||||
method.addRequestHeader(header.getKey(), TextUtils.join(",", header.getValue()));
|
||||
}
|
||||
|
||||
client.setFollowRedirects(request.isFollowRedirects());
|
||||
int status = client.executeMethod(method);
|
||||
|
||||
@@ -213,7 +222,20 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
if (status >= HTTP_STATUS_CODE_OK && status < HTTP_STATUS_CODE_MULTIPLE_CHOICES) {
|
||||
return method.getResponseBodyAsStream();
|
||||
} else {
|
||||
throw new IllegalStateException(EXCEPTION_HTTP_REQUEST_FAILED, new IllegalStateException(String.valueOf(status)));
|
||||
StringBuilder total = new StringBuilder();
|
||||
InputStream inputStream = method.getResponseBodyAsStream();
|
||||
// If response body is available
|
||||
if (inputStream != null) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
total.append(line).append('\n');
|
||||
line = reader.readLine();
|
||||
}
|
||||
Log_OC.e(TAG, total.toString());
|
||||
}
|
||||
throw new IllegalStateException(EXCEPTION_HTTP_REQUEST_FAILED,
|
||||
new IllegalStateException(String.valueOf(status), new Throwable(total.toString())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +249,10 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
}
|
||||
|
||||
private boolean validateToken(String hash, String token) {
|
||||
if (hash.isEmpty() || !hash.contains("$")) {
|
||||
throw new IllegalStateException(EXCEPTION_INVALID_TOKEN);
|
||||
}
|
||||
|
||||
String salt = hash.split("\\$")[1]; // TODO extract "$"
|
||||
|
||||
String newHash = EncryptionUtils.generateSHA512(token, salt);
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
* @author masensio
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -35,11 +35,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.StrictMode;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -81,6 +76,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFERENCE_CONTACTS_AUTOMATIC_BACKUP;
|
||||
@@ -95,6 +95,7 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
|
||||
public class MainApp extends MultiDexApplication {
|
||||
|
||||
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_12;
|
||||
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_10;
|
||||
|
||||
private static final String TAG = MainApp.class.getSimpleName();
|
||||
|
||||
@@ -180,7 +181,6 @@ public class MainApp extends MultiDexApplication {
|
||||
.build()
|
||||
.schedule();
|
||||
|
||||
|
||||
// register global protection with pass code
|
||||
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
||||
|
||||
@@ -387,7 +387,7 @@ public class MainApp extends MultiDexApplication {
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Context getAppContext() {
|
||||
return MainApp.mContext;
|
||||
@@ -405,9 +405,9 @@ public class MainApp extends MultiDexApplication {
|
||||
MainApp.storagePath = path;
|
||||
}
|
||||
|
||||
// Methods to obtain Strings referring app_name
|
||||
// From AccountAuthenticator
|
||||
// public static final String ACCOUNT_TYPE = "owncloud";
|
||||
// Methods to obtain Strings referring app_name
|
||||
// From AccountAuthenticator
|
||||
// public static final String ACCOUNT_TYPE = "owncloud";
|
||||
public static String getAccountType(Context context) {
|
||||
return context.getResources().getString(R.string.account_type);
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class MainApp extends MultiDexApplication {
|
||||
return getAppContext().getResources().getString(R.string.authority);
|
||||
}
|
||||
|
||||
// From ProviderMeta
|
||||
// From ProviderMeta
|
||||
// public static final String DB_FILE = "owncloud.db";
|
||||
public static String getDBFile() {
|
||||
return getAppContext().getResources().getString(R.string.db_file);
|
||||
|
||||
@@ -19,16 +19,17 @@ package com.owncloud.android.authentication;
|
||||
import android.accounts.AccountAuthenticatorResponse;
|
||||
import android.accounts.AccountManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/*
|
||||
* Base class for implementing an Activity that is used to help implement an AbstractAccountAuthenticator.
|
||||
* If the AbstractAccountAuthenticator needs to use an activity to handle the request then it can have the activity extend
|
||||
* Base class for implementing an Activity that is used to help implement an AbstractAccountAuthenticator.
|
||||
* If the AbstractAccountAuthenticator needs to use an activity to handle the request then it can have the activity extend
|
||||
* AccountAuthenticatorActivity. The AbstractAccountAuthenticator passes in the response to the intent using the following:
|
||||
* intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
|
||||
*
|
||||
* The activity then sets the result that is to be handed to the response via setAccountAuthenticatorResult(android.os.Bundle).
|
||||
* This result will be sent as the result of the request when the activity finishes. If this is never set or if it is set to null
|
||||
*
|
||||
* The activity then sets the result that is to be handed to the response via setAccountAuthenticatorResult(android.os.Bundle).
|
||||
* This result will be sent as the result of the request when the activity finishes. If this is never set or if it is set to null
|
||||
* then error AccountManager.ERROR_CODE_CANCELED will be called on the response.
|
||||
*/
|
||||
|
||||
@@ -41,7 +42,7 @@ public class AccountAuthenticatorActivity extends AppCompatActivity {
|
||||
/**
|
||||
* Set the result that is to be sent as the result of the request that caused this Activity to be launched.
|
||||
* If result is null or this method is never called then the request will be canceled.
|
||||
*
|
||||
*
|
||||
* @param result this is returned as the result of the AbstractAccountAuthenticator request
|
||||
*/
|
||||
public final void setAccountAuthenticatorResult(Bundle result) {
|
||||
@@ -64,7 +65,7 @@ public class AccountAuthenticatorActivity extends AppCompatActivity {
|
||||
mAccountAuthenticatorResponse.onRequestContinued();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
|
||||
*/
|
||||
|
||||
@@ -24,8 +24,6 @@ import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -33,6 +31,9 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.ui.activity.ManageAccountsActivity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Helper class for dealing with accounts.
|
||||
*/
|
||||
@@ -50,10 +51,10 @@ public final class AccountUtils {
|
||||
/**
|
||||
* Can be used to get the currently selected ownCloud {@link Account} in the
|
||||
* application preferences.
|
||||
*
|
||||
*
|
||||
* @param context The current application {@link Context}
|
||||
* @return The ownCloud {@link Account} currently saved in preferences, or the first
|
||||
* {@link Account} available, if valid (still registered in the system as ownCloud
|
||||
* @return The ownCloud {@link Account} currently saved in preferences, or the first
|
||||
* {@link Account} available, if valid (still registered in the system as ownCloud
|
||||
* account). If none is available and valid, returns null.
|
||||
*/
|
||||
public static @Nullable Account getCurrentOwnCloudAccount(Context context) {
|
||||
@@ -96,7 +97,7 @@ public final class AccountUtils {
|
||||
return accountManager.getAccountsByType(MainApp.getAccountType(context));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean exists(Account account, Context context) {
|
||||
Account[] ocAccounts = getAccounts(context);
|
||||
|
||||
@@ -132,7 +133,7 @@ public final class AccountUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns owncloud account identified by accountName or null if it does not exist.
|
||||
* @param context the context
|
||||
@@ -176,20 +177,23 @@ public final class AccountUtils {
|
||||
/**
|
||||
* Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
|
||||
*
|
||||
* @param account ownCloud account
|
||||
* @return Version of the OC server corresponding to account, according to the data saved
|
||||
* in the system AccountManager
|
||||
* @param account ownCloud account
|
||||
* @return Version of the OC server corresponding to account, according to the data saved
|
||||
* in the system AccountManager
|
||||
*/
|
||||
public static @NonNull
|
||||
OwnCloudVersion getServerVersion(Account account) {
|
||||
OwnCloudVersion serverVersion = OwnCloudVersion.nextcloud_10;
|
||||
OwnCloudVersion serverVersion = MainApp.MINIMUM_SUPPORTED_SERVER_VERSION;
|
||||
|
||||
if (account != null) {
|
||||
AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
|
||||
String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
|
||||
|
||||
if (serverVersionStr != null) {
|
||||
serverVersion = new OwnCloudVersion(serverVersionStr);
|
||||
}
|
||||
}
|
||||
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +59,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
@@ -90,6 +83,8 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;
|
||||
@@ -132,6 +127,11 @@ import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
@@ -203,7 +203,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
private AccountManager mAccountMgr;
|
||||
private Uri mNewCapturedUriFromOAuth2Redirection;
|
||||
|
||||
/// Server PRE-Fragment elements
|
||||
/// Server PRE-Fragment elements
|
||||
private CustomEditText mHostUrlInput;
|
||||
private View mRefreshButton;
|
||||
private TextView mServerStatusView;
|
||||
@@ -217,7 +217,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private GetServerInfoOperation.ServerInfo mServerInfo = new GetServerInfoOperation.ServerInfo();
|
||||
|
||||
/// Authentication PRE-Fragment elements
|
||||
/// Authentication PRE-Fragment elements
|
||||
private CheckBox mOAuth2Check;
|
||||
private TextView mOAuthAuthEndpointText;
|
||||
private TextView mOAuthTokenEndpointText;
|
||||
@@ -237,7 +237,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private boolean mIsFirstAuthAttempt;
|
||||
|
||||
/// Identifier of operation in progress which result shouldn't be lost
|
||||
/// Identifier of operation in progress which result shouldn't be lost
|
||||
private long mWaitingForOpId = Long.MAX_VALUE;
|
||||
|
||||
private String basicTokenType;
|
||||
@@ -264,7 +264,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (savedInstanceState == null) {
|
||||
FirstRunActivity.runIfNeeded(this);
|
||||
}
|
||||
|
||||
|
||||
basicTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType(this));
|
||||
oauthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType(this));
|
||||
samlTokenType = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType(this));
|
||||
@@ -379,7 +379,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
mLoginWebView.getSettings().setAllowFileAccess(false);
|
||||
mLoginWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mLoginWebView.getSettings().setDomStorageEnabled(true);
|
||||
|
||||
|
||||
if (useGenericUserAgent) {
|
||||
mLoginWebView.getSettings().setUserAgentString(MainApp.getNextcloudUserAgent());
|
||||
} else {
|
||||
@@ -587,10 +587,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (mAuthTokenType == null) {
|
||||
if (mAccount != null) {
|
||||
boolean oAuthRequired = mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null;
|
||||
boolean samlWebSsoRequired = (
|
||||
mAccountMgr.getUserData
|
||||
(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null
|
||||
);
|
||||
boolean samlWebSsoRequired = mAccountMgr.getUserData
|
||||
(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
mAuthTokenType = chooseAuthTokenType(oAuthRequired, samlWebSsoRequired);
|
||||
|
||||
} else {
|
||||
@@ -1341,7 +1339,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
uri = uriBuilder.build();
|
||||
Log_OC.d(TAG, "Starting browser to view " + uri.toString());
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(i);
|
||||
|
||||
DisplayUtils.startIntentIfAppAvailable(i, this, R.string.no_browser_available);
|
||||
}
|
||||
|
||||
|
||||
@@ -1373,7 +1372,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (operation instanceof GetServerInfoOperation) {
|
||||
if (operation.hashCode() == mWaitingForOpId) {
|
||||
onGetServerInfoFinish(result);
|
||||
} // else nothing ; only the last check operation is considered;
|
||||
} // else nothing ; only the last check operation is considered;
|
||||
// multiple can be started if the user amends a URL quickly
|
||||
|
||||
} else if (operation instanceof OAuth2GetAccessToken) {
|
||||
@@ -1458,7 +1457,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
// 1. connection succeeded, and we know if it's SSL or not
|
||||
// 2. server is installed
|
||||
// 3. we got the server version
|
||||
// 4. we got the authentication method required by the server
|
||||
// 4. we got the authentication method required by the server
|
||||
mServerInfo = (GetServerInfoOperation.ServerInfo) (result.getData().get(0));
|
||||
|
||||
// show outdated warning
|
||||
@@ -1525,13 +1524,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
private boolean authSupported(AuthenticationMethod authMethod) {
|
||||
return ((basicTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(oauthTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(samlTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.SAML_WEB_SSO.equals(authMethod))
|
||||
);
|
||||
return (basicTokenType.equals(mAuthTokenType) && AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(oauthTokenType.equals(mAuthTokenType) && AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(samlTokenType.equals(mAuthTokenType) && AuthenticationMethod.SAML_WEB_SSO.equals(authMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1782,7 +1777,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
} else if (result.isServerFail() || result.isException()) {
|
||||
/// server errors or exceptions in authorization take to requiring a new check of
|
||||
/// server errors or exceptions in authorization take to requiring a new check of
|
||||
/// the server
|
||||
mServerIsChecked = true;
|
||||
mServerIsValid = false;
|
||||
@@ -1843,13 +1838,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
if (AccountTypeUtils.getAuthTokenTypeAccessToken(accountType).equals(mAuthTokenType)) {
|
||||
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);
|
||||
// the next line is necessary, notifications are calling directly to the
|
||||
// the next line is necessary, notifications are calling directly to the
|
||||
// AuthenticatorActivity to update, without AccountManager intervention
|
||||
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
|
||||
|
||||
} else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(accountType).equals(mAuthTokenType)) {
|
||||
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);
|
||||
// the next line is necessary; by now, notifications are calling directly to the
|
||||
// the next line is necessary; by now, notifications are calling directly to the
|
||||
// AuthenticatorActivity to update, without AccountManager intervention
|
||||
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
|
||||
|
||||
@@ -1944,7 +1939,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
/// prepare result to return to the Authenticator
|
||||
// TODO check again what the Authenticator makes with it; probably has the same
|
||||
// TODO check again what the Authenticator makes with it; probably has the same
|
||||
// effect as addAccountExplicitly, but it's not well done
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
|
||||
@@ -1953,7 +1948,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (isOAuth || isSaml) {
|
||||
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
|
||||
}
|
||||
/// add user data to the new account; TODO probably can be done in the last parameter
|
||||
/// add user data to the new account; TODO probably can be done in the last parameter
|
||||
// addAccountExplicitly, or in KEY_USERDATA
|
||||
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion());
|
||||
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mServerInfo.mBaseUrl);
|
||||
@@ -2059,7 +2054,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
/**
|
||||
* Called when the 'action' button in an IME is pressed ('enter' in software keyboard).
|
||||
*
|
||||
*
|
||||
* Used to trigger the authentication check when the user presses 'enter' after writing the
|
||||
* password, or to throw the server test when the only field on screen is the URL input field.
|
||||
*/
|
||||
@@ -2198,7 +2193,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
public void onSavedCertificate() {
|
||||
Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);
|
||||
if (fd == null) {
|
||||
// if SAML dialog is not shown,
|
||||
// if SAML dialog is not shown,
|
||||
// the SslDialog was shown due to an SSL error in the server check
|
||||
checkOcServer();
|
||||
}
|
||||
@@ -2222,7 +2217,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private void doOnResumeAndBound() {
|
||||
//Log_OC.e(TAG, "registering to listen for operation callbacks" );
|
||||
mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);
|
||||
mOperationsServiceBinder.addOperationListener(this, mHandler);
|
||||
if (mWaitingForOpId <= Integer.MAX_VALUE) {
|
||||
mOperationsServiceBinder.dispatchResultIfFinished((int) mWaitingForOpId, this);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio on 09/02/2015.
|
||||
@@ -43,11 +43,11 @@ public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOpera
|
||||
private static final String REMOTE_PATH = "/";
|
||||
private static final boolean SUCCESS_IF_ABSENT = false;
|
||||
|
||||
private Context mContext;
|
||||
private WeakReference<Context> mWeakContext;
|
||||
private final WeakReference<OnAuthenticatorTaskListener> mListener;
|
||||
|
||||
public AuthenticatorAsyncTask(Activity activity) {
|
||||
mContext = activity.getApplicationContext();
|
||||
mWeakContext = new WeakReference<>(activity.getApplicationContext());
|
||||
mListener = new WeakReference<>((OnAuthenticatorTaskListener)activity);
|
||||
}
|
||||
|
||||
@@ -55,21 +55,18 @@ public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOpera
|
||||
protected RemoteOperationResult doInBackground(Object... params) {
|
||||
|
||||
RemoteOperationResult result;
|
||||
if (params!= null && params.length==2) {
|
||||
if (params != null && params.length == 2 && mWeakContext.get() != null) {
|
||||
String url = (String)params[0];
|
||||
Context context = mWeakContext.get();
|
||||
OwnCloudCredentials credentials = (OwnCloudCredentials)params[1];
|
||||
|
||||
// Client
|
||||
Uri uri = Uri.parse(url);
|
||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, mContext, true);
|
||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, context, true);
|
||||
client.setCredentials(credentials);
|
||||
|
||||
// Operation - try credentials
|
||||
ExistenceCheckRemoteOperation operation = new ExistenceCheckRemoteOperation(
|
||||
REMOTE_PATH,
|
||||
mContext,
|
||||
SUCCESS_IF_ABSENT
|
||||
);
|
||||
ExistenceCheckRemoteOperation operation = new ExistenceCheckRemoteOperation(REMOTE_PATH, SUCCESS_IF_ABSENT);
|
||||
result = operation.execute(client);
|
||||
|
||||
if (operation.wasRedirected()) {
|
||||
|
||||
@@ -50,12 +50,11 @@ public final class PassCodeManager {
|
||||
// other activities may be exempted, if needed
|
||||
}
|
||||
|
||||
private static final int PASS_CODE_TIMEOUT = 1000;
|
||||
private static final int PASS_CODE_TIMEOUT = 5000;
|
||||
// keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
|
||||
|
||||
private static PassCodeManager passCodeManagerInstance;
|
||||
|
||||
private Long timestamp = 0L;
|
||||
private int visibleActivitiesCounter;
|
||||
|
||||
public static PassCodeManager getPassCodeManager() {
|
||||
@@ -79,7 +78,8 @@ public final class PassCodeManager {
|
||||
}
|
||||
|
||||
public void onActivityStarted(Activity activity) {
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested()) {
|
||||
Long timestamp = PreferenceManager.getLockTimestamp(activity);
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested(timestamp)) {
|
||||
|
||||
Intent i = new Intent(MainApp.getAppContext(), PassCodeActivity.class);
|
||||
i.setAction(PassCodeActivity.ACTION_CHECK);
|
||||
@@ -88,8 +88,7 @@ public final class PassCodeManager {
|
||||
}
|
||||
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && deviceCredentialsShouldBeRequested(activity) &&
|
||||
!DeviceCredentialUtils.tryEncrypt(activity)) {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && deviceCredentialsShouldBeRequested(timestamp, activity)) {
|
||||
Intent i = new Intent(MainApp.getAppContext(), RequestCredentialsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
||||
@@ -102,7 +101,7 @@ public final class PassCodeManager {
|
||||
if (visibleActivitiesCounter > 0) {
|
||||
visibleActivitiesCounter--;
|
||||
}
|
||||
setUnlockTimestamp();
|
||||
setUnlockTimestamp(activity);
|
||||
PowerManager powerMgr = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
|
||||
if ((passCodeIsEnabled() || deviceCredentialsAreEnabled(activity)) && powerMgr != null
|
||||
&& !powerMgr.isScreenOn()) {
|
||||
@@ -110,22 +109,23 @@ public final class PassCodeManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void setUnlockTimestamp() {
|
||||
timestamp = System.currentTimeMillis();
|
||||
private void setUnlockTimestamp(Activity activity) {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
PreferenceManager.setLockTimestamp(activity, timestamp);
|
||||
}
|
||||
|
||||
private boolean passCodeShouldBeRequested() {
|
||||
private boolean passCodeShouldBeRequested(Long timestamp) {
|
||||
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT &&
|
||||
visibleActivitiesCounter <= 0 && passCodeIsEnabled();
|
||||
visibleActivitiesCounter <= 0 && passCodeIsEnabled();
|
||||
}
|
||||
|
||||
private boolean passCodeIsEnabled() {
|
||||
return PreferenceManager.getLockPreference(MainApp.getAppContext()).equals(Preferences.LOCK_PASSCODE);
|
||||
}
|
||||
|
||||
private boolean deviceCredentialsShouldBeRequested(Activity activity) {
|
||||
private boolean deviceCredentialsShouldBeRequested(Long timestamp, Activity activity) {
|
||||
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT && visibleActivitiesCounter <= 0 &&
|
||||
deviceCredentialsAreEnabled(activity);
|
||||
deviceCredentialsAreEnabled(activity);
|
||||
}
|
||||
|
||||
private boolean deviceCredentialsAreEnabled(Activity activity) {
|
||||
|
||||
@@ -24,9 +24,16 @@ package com.owncloud.android.datamodel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Decrypted class representation of metadata json of folder metadata.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class DecryptedFolderMetadata {
|
||||
private Metadata metadata;
|
||||
private Map<String, DecryptedFile> files;
|
||||
@@ -36,170 +43,47 @@ public class DecryptedFolderMetadata {
|
||||
this.files = new HashMap<>();
|
||||
}
|
||||
|
||||
public DecryptedFolderMetadata(Metadata metadata, Map<String, DecryptedFile> files) {
|
||||
this.metadata = metadata;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(Metadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public Map<String, DecryptedFile> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setFiles(Map<String, DecryptedFile> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Metadata {
|
||||
private Map<Integer, String> metadataKeys; // each keys is encrypted on its own, decrypt on use
|
||||
private Sharing sharing;
|
||||
private int version;
|
||||
|
||||
public Map<Integer, String> getMetadataKeys() {
|
||||
return metadataKeys;
|
||||
}
|
||||
|
||||
public void setMetadataKeys(Map<Integer, String> metadataKeys) {
|
||||
this.metadataKeys = metadataKeys;
|
||||
}
|
||||
|
||||
public Sharing getSharing() {
|
||||
return sharing;
|
||||
}
|
||||
|
||||
public void setSharing(Sharing sharing) {
|
||||
this.sharing = sharing;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(version);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Encrypted {
|
||||
private Map<Integer, String> metadataKeys;
|
||||
|
||||
public Map<Integer, String> getMetadataKeys() {
|
||||
return metadataKeys;
|
||||
}
|
||||
|
||||
public void setMetadataKeys(Map<Integer, String> metadataKeys) {
|
||||
this.metadataKeys = metadataKeys;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Sharing {
|
||||
private Map<String, String> recipient;
|
||||
private String signature;
|
||||
|
||||
public Map<String, String> getRecipient() {
|
||||
return recipient;
|
||||
}
|
||||
|
||||
public void setRecipient(Map<String, String> recipient) {
|
||||
this.recipient = recipient;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class DecryptedFile {
|
||||
private Data encrypted;
|
||||
private String initializationVector;
|
||||
private String authenticationTag;
|
||||
private int metadataKey;
|
||||
|
||||
public Data getEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(Data encrypted) {
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
|
||||
public String getInitializationVector() {
|
||||
return initializationVector;
|
||||
}
|
||||
|
||||
public void setInitializationVector(String initializationVector) {
|
||||
this.initializationVector = initializationVector;
|
||||
}
|
||||
|
||||
public String getAuthenticationTag() {
|
||||
return authenticationTag;
|
||||
}
|
||||
|
||||
public void setAuthenticationTag(String authenticationTag) {
|
||||
this.authenticationTag = authenticationTag;
|
||||
}
|
||||
|
||||
public int getMetadataKey() {
|
||||
return metadataKey;
|
||||
}
|
||||
|
||||
public void setMetadataKey(int metadataKey) {
|
||||
this.metadataKey = metadataKey;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Data {
|
||||
private String key;
|
||||
private String filename;
|
||||
private String mimetype;
|
||||
private int version;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getMimetype() {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
public void setMimetype(String mimetype) {
|
||||
this.mimetype = mimetype;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,54 +22,19 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
@Parcel public class DecryptedPushMessage {
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Parcel
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DecryptedPushMessage {
|
||||
public String app;
|
||||
|
||||
public String type;
|
||||
|
||||
public String subject;
|
||||
|
||||
public String id;
|
||||
|
||||
public DecryptedPushMessage(String app, String type, String subject, String id) {
|
||||
this.app = app;
|
||||
this.type = type;
|
||||
this.subject = subject;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DecryptedPushMessage() {
|
||||
}
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public void setApp(String app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -23,71 +23,26 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Encrypted class representation of metadata json of folder metadata
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class EncryptedFolderMetadata {
|
||||
private DecryptedFolderMetadata.Metadata metadata;
|
||||
private Map<String, EncryptedFile> files;
|
||||
|
||||
public EncryptedFolderMetadata(DecryptedFolderMetadata.Metadata metadata, Map<String, EncryptedFile> files) {
|
||||
this.metadata = metadata;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public DecryptedFolderMetadata.Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(DecryptedFolderMetadata.Metadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public Map<String, EncryptedFile> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setFiles(Map<String, EncryptedFile> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class EncryptedFile {
|
||||
private String encrypted;
|
||||
private String initializationVector;
|
||||
private String authenticationTag;
|
||||
private int metadataKey;
|
||||
|
||||
public String getEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(String encrypted) {
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
|
||||
public String getInitializationVector() {
|
||||
return initializationVector;
|
||||
}
|
||||
|
||||
public void setInitializationVector(String initializationVector) {
|
||||
this.initializationVector = initializationVector;
|
||||
}
|
||||
|
||||
public String getAuthenticationTag() {
|
||||
return authenticationTag;
|
||||
}
|
||||
|
||||
public void setAuthenticationTag(String authenticationTag) {
|
||||
this.authenticationTag = authenticationTag;
|
||||
}
|
||||
|
||||
public int getMetadataKey() {
|
||||
return metadataKey;
|
||||
}
|
||||
|
||||
public void setMetadataKey(int metadataKey) {
|
||||
this.metadataKey = metadataKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
* Copyright (C) 2017 Nextcloud.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -23,7 +23,6 @@ import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
import com.owncloud.android.lib.common.ExternalLink;
|
||||
@@ -33,6 +32,8 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Database provider for handling the persistence aspects of {@link com.owncloud.android.lib.common.ExternalLink}s.
|
||||
*/
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2012 Bartek Przybylski
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -33,15 +33,15 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
|
||||
@@ -53,6 +53,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -61,51 +62,37 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public class FileDataStorageManager {
|
||||
private static final String TAG = FileDataStorageManager.class.getSimpleName();
|
||||
|
||||
public static final int ROOT_PARENT_ID = 0;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
private ContentProviderClient mContentProviderClient;
|
||||
private Account mAccount;
|
||||
private static final String AND = "=? AND ";
|
||||
private static final String FAILED_TO_INSERT_MSG = "Fail to insert insert file to database ";
|
||||
private static final String SENDING_TO_FILECONTENTPROVIDER_MSG = "Sending %d operations to FileContentProvider";
|
||||
private static final String EXCEPTION_MSG = "Exception in batch of operations ";
|
||||
|
||||
private static final String TAG = FileDataStorageManager.class.getSimpleName();
|
||||
public static final int ROOT_PARENT_ID = 0;
|
||||
|
||||
private ContentResolver contentResolver;
|
||||
private ContentProviderClient contentProviderClient;
|
||||
@Setter private Account account;
|
||||
|
||||
public FileDataStorageManager(Account account, ContentResolver cr) {
|
||||
mContentProviderClient = null;
|
||||
mContentResolver = cr;
|
||||
mAccount = account;
|
||||
contentProviderClient = null;
|
||||
contentResolver = cr;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public FileDataStorageManager(Account account, ContentProviderClient cp) {
|
||||
mContentProviderClient = cp;
|
||||
mContentResolver = null;
|
||||
mAccount = account;
|
||||
contentProviderClient = cp;
|
||||
contentResolver = null;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
|
||||
public void setAccount(Account account) {
|
||||
mAccount = account;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return mAccount;
|
||||
}
|
||||
|
||||
public ContentResolver getContentResolver() {
|
||||
return mContentResolver;
|
||||
}
|
||||
|
||||
public ContentProviderClient getContentProviderClient() {
|
||||
return mContentProviderClient;
|
||||
}
|
||||
|
||||
|
||||
public OCFile getFileByPath(String path) {
|
||||
Cursor c = getFileCursorForValue(ProviderTableMeta.FILE_PATH, path);
|
||||
OCFile file = null;
|
||||
@@ -119,7 +106,6 @@ public class FileDataStorageManager {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
public @Nullable
|
||||
OCFile getFileById(long id) {
|
||||
Cursor c = getFileCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
|
||||
@@ -130,7 +116,7 @@ public class FileDataStorageManager {
|
||||
c.close();
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
public OCFile getFileByLocalPath(String path) {
|
||||
Cursor c = getFileCursorForValue(ProviderTableMeta.FILE_STORAGE_PATH, path);
|
||||
OCFile file = null;
|
||||
@@ -172,7 +158,7 @@ public class FileDataStorageManager {
|
||||
|
||||
public List<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
|
||||
List<OCFile> ret = new ArrayList<>();
|
||||
|
||||
|
||||
if (folder != null) {
|
||||
// TODO better implementation, filtering in the access to database instead of here
|
||||
List<OCFile> tmp = getFolderContent(folder, onlyOnDevice);
|
||||
@@ -205,30 +191,29 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, file.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isAvailableOffline() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, file.getUnreadCommentsCount());
|
||||
|
||||
boolean sameRemotePath = fileExists(file.getRemotePath());
|
||||
if (sameRemotePath ||
|
||||
fileExists(file.getFileId())) { // for renamed files; no more delete and create
|
||||
|
||||
OCFile oldFile;
|
||||
|
||||
if (sameRemotePath) {
|
||||
oldFile = getFileByPath(file.getRemotePath());
|
||||
OCFile oldFile = getFileByPath(file.getRemotePath());
|
||||
file.setFileId(oldFile.getFileId());
|
||||
} else {
|
||||
oldFile = getFileById(file.getFileId());
|
||||
}
|
||||
|
||||
overridden = true;
|
||||
@@ -283,7 +268,7 @@ public class FileDataStorageManager {
|
||||
OCFile returnFile;
|
||||
if (parentFile == null) {
|
||||
// remote request
|
||||
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(parentPath);
|
||||
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(parentPath);
|
||||
RemoteOperationResult result = operation.execute(getAccount(), context);
|
||||
if (result.isSuccess()) {
|
||||
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
||||
@@ -362,13 +347,13 @@ public class FileDataStorageManager {
|
||||
String[] whereArgs;
|
||||
for (OCFile file : filesToRemove) {
|
||||
if (file.getParentId() == folder.getFileId()) {
|
||||
whereArgs = new String[]{mAccount.name, file.getRemotePath()};
|
||||
whereArgs = new String[]{account.name, file.getRemotePath()};
|
||||
if (file.isFolder()) {
|
||||
operations.add(ContentProviderOperation.newDelete(
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, file.getFileId()))
|
||||
.withSelection(where, whereArgs).build());
|
||||
|
||||
File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
|
||||
File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(account.name, file));
|
||||
if (localFolder.exists()) {
|
||||
removeLocalFolder(localFolder);
|
||||
}
|
||||
@@ -414,7 +399,7 @@ public class FileDataStorageManager {
|
||||
if (results != null) {
|
||||
long newId;
|
||||
Iterator<OCFile> filesIt = updatedFiles.iterator();
|
||||
OCFile file = null;
|
||||
OCFile file;
|
||||
for (ContentProviderResult result : results) {
|
||||
if (filesIt.hasNext()) {
|
||||
file = filesIt.next();
|
||||
@@ -445,18 +430,20 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_NAME, folder.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, folder.getParentId());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, folder.getRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, folder.isAvailableOffline() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, folder.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, folder.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, folder.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, folder.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.getIsFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, folder.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, folder.getUnreadCommentsCount());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -474,22 +461,25 @@ public class FileDataStorageManager {
|
||||
if (!file.isFolder()) {
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isAvailableOffline() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.getIsFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, file.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_MOUNT_TYPE, file.getMountType().ordinal());
|
||||
cv.put(ProviderTableMeta.FILE_HAS_PREVIEW, file.isPreviewAvailable() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, file.getUnreadCommentsCount());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -505,7 +495,7 @@ public class FileDataStorageManager {
|
||||
// ""+file.getFileId());
|
||||
Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, file.getFileId());
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, file.getRemotePath()};
|
||||
String[] whereArgs = new String[]{account.name, file.getRemotePath()};
|
||||
int deleted = 0;
|
||||
if (getContentProviderClient() != null) {
|
||||
try {
|
||||
@@ -557,10 +547,10 @@ public class FileDataStorageManager {
|
||||
}
|
||||
|
||||
private boolean removeFolderInDb(OCFile folder) {
|
||||
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, "" + folder.getFileId()); // URI
|
||||
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(folder.getFileId())); // URI
|
||||
// for recursive deletion
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, folder.getRemotePath()};
|
||||
String[] whereArgs = new String[]{account.name, folder.getRemotePath()};
|
||||
int deleted = 0;
|
||||
if (getContentProviderClient() != null) {
|
||||
try {
|
||||
@@ -576,7 +566,7 @@ public class FileDataStorageManager {
|
||||
|
||||
private boolean removeLocalFolder(OCFile folder) {
|
||||
boolean success = true;
|
||||
String localFolderPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, folder);
|
||||
String localFolderPath = FileStorageUtils.getDefaultSavePathFor(account.name, folder);
|
||||
File localFolder = new File(localFolderPath);
|
||||
if (localFolder.exists()) {
|
||||
// stage 1: remove the local files already registered in the files database
|
||||
@@ -600,7 +590,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
// stage 2: remove the folder itself and any local file inside out of sync;
|
||||
// stage 2: remove the folder itself and any local file inside out of sync;
|
||||
// for instance, after clearing the app cache or reinstalling
|
||||
success &= removeLocalFolder(localFolder);
|
||||
}
|
||||
@@ -646,7 +636,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
||||
new String[]{mAccount.name, file.getRemotePath() + "%"},
|
||||
new String[]{account.name, file.getRemotePath() + "%"},
|
||||
ProviderTableMeta.FILE_PATH + " ASC "
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
@@ -658,16 +648,16 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
||||
new String[]{mAccount.name, file.getRemotePath() + "%"},
|
||||
new String[]{account.name, file.getRemotePath() + "%"},
|
||||
ProviderTableMeta.FILE_PATH + " ASC "
|
||||
);
|
||||
}
|
||||
|
||||
/// 2. prepare a batch of update operations to change all the descendants
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>(c.getCount());
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
|
||||
List<String> originalPathsToTriggerMediaScan = new ArrayList<String>();
|
||||
List<String> newPathsToTriggerMediaScan = new ArrayList<String>();
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(account.name);
|
||||
List<String> originalPathsToTriggerMediaScan = new ArrayList<>();
|
||||
List<String> newPathsToTriggerMediaScan = new ArrayList<>();
|
||||
if (c.moveToFirst()) {
|
||||
int lengthOfOldPath = file.getRemotePath().length();
|
||||
int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
|
||||
@@ -717,8 +707,8 @@ public class FileDataStorageManager {
|
||||
Log_OC.e(TAG, "Fail to update " + file.getFileId() + " and descendants in database", e);
|
||||
}
|
||||
|
||||
/// 4. move in local file system
|
||||
String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file);
|
||||
/// 4. move in local file system
|
||||
String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(account.name, file);
|
||||
String targetLocalPath = defaultSavePath + targetPath;
|
||||
File localFile = new File(originalLocalPath);
|
||||
boolean renamed = false;
|
||||
@@ -750,10 +740,10 @@ public class FileDataStorageManager {
|
||||
public void copyLocalFile(OCFile file, String targetPath) {
|
||||
|
||||
if (file != null && file.fileExists() && !OCFile.ROOT_PATH.equals(file.getFileName())) {
|
||||
String localPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file);
|
||||
String localPath = FileStorageUtils.getDefaultSavePathFor(account.name, file);
|
||||
File localFile = new File(localPath);
|
||||
boolean copied = false;
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(account.name);
|
||||
if (localFile.exists()) {
|
||||
File targetFile = new File(defaultSavePath + targetPath);
|
||||
File targetFolder = targetFile.getParentFile();
|
||||
@@ -859,7 +849,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
|
||||
|
||||
c.close();
|
||||
}
|
||||
|
||||
@@ -869,7 +859,7 @@ public class FileDataStorageManager {
|
||||
|
||||
private OCFile createRootDir() {
|
||||
OCFile file = new OCFile(OCFile.ROOT_PATH);
|
||||
file.setMimetype(MimeType.DIRECTORY);
|
||||
file.setMimeType(MimeType.DIRECTORY);
|
||||
file.setParentId(FileDataStorageManager.ROOT_PARENT_ID);
|
||||
saveFile(file);
|
||||
return file;
|
||||
@@ -884,7 +874,7 @@ public class FileDataStorageManager {
|
||||
cmp_key + AND
|
||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||
+ "=?",
|
||||
new String[]{value, mAccount.name}, null);
|
||||
new String[]{value, account.name}, null);
|
||||
} else {
|
||||
try {
|
||||
c = getContentProviderClient().query(
|
||||
@@ -892,7 +882,7 @@ public class FileDataStorageManager {
|
||||
null,
|
||||
cmp_key + AND
|
||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
||||
new String[]{value, mAccount.name}, null);
|
||||
new String[]{value, account.name}, null);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Couldn't determine file existance, assuming non existance: " + e.getMessage(), e);
|
||||
return false;
|
||||
@@ -904,7 +894,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
|
||||
private Cursor getFileCursorForValue(String key, String value) {
|
||||
Cursor c = null;
|
||||
Cursor c;
|
||||
if (getContentResolver() != null) {
|
||||
c = getContentResolver()
|
||||
.query(ProviderTableMeta.CONTENT_URI,
|
||||
@@ -912,14 +902,14 @@ public class FileDataStorageManager {
|
||||
key + AND
|
||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||
+ "=?",
|
||||
new String[]{value, mAccount.name}, null);
|
||||
new String[]{value, account.name}, null);
|
||||
} else {
|
||||
try {
|
||||
c = getContentProviderClient().query(
|
||||
ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
key + AND + ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||
+ "=?", new String[]{value, mAccount.name},
|
||||
+ "=?", new String[]{value, account.name},
|
||||
null);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Could not get file details: " + e.getMessage(), e);
|
||||
@@ -947,13 +937,13 @@ public class FileDataStorageManager {
|
||||
file.setFileId(c.getLong(c.getColumnIndex(ProviderTableMeta._ID)));
|
||||
file.setParentId(c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_PARENT)));
|
||||
file.setEncryptedFileName(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ENCRYPTED_NAME)));
|
||||
file.setMimetype(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)));
|
||||
file.setMimeType(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)));
|
||||
file.setStoragePath(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
|
||||
if (file.getStoragePath() == null) {
|
||||
// try to find existing file and bind it with current account;
|
||||
// with the current update of SynchronizeFolderOperation, this won't be
|
||||
// necessary anymore after a full synchronization of the account
|
||||
File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
|
||||
File f = new File(FileStorageUtils.getDefaultSavePathFor(account.name, file));
|
||||
if (f.exists()) {
|
||||
file.setStoragePath(f.getAbsolutePath());
|
||||
file.setLastSyncDateForData(f.lastModified());
|
||||
@@ -966,14 +956,14 @@ public class FileDataStorageManager {
|
||||
c.getColumnIndex(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA)));
|
||||
file.setLastSyncDateForProperties(c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE)));
|
||||
file.setLastSyncDateForData(c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA)));
|
||||
file.setAvailableOffline(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1);
|
||||
file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG)));
|
||||
file.setShareViaLink(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1);
|
||||
file.setShareWithSharee(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1);
|
||||
file.setEtagOnServer(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG_ON_SERVER)));
|
||||
file.setSharedViaLink(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1);
|
||||
file.setSharedWithSharee(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1);
|
||||
file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK)));
|
||||
file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS)));
|
||||
file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID)));
|
||||
file.setNeedsUpdateThumbnail(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1);
|
||||
file.setUpdateThumbnailNeeded(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1);
|
||||
file.setDownloading(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_IS_DOWNLOADING)) == 1);
|
||||
file.setEtagInConflict(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG_IN_CONFLICT)));
|
||||
file.setFavorite(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_FAVORITE)) == 1);
|
||||
@@ -983,7 +973,10 @@ public class FileDataStorageManager {
|
||||
}
|
||||
file.setMountType(WebdavEntry.MountType.values()[c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.FILE_MOUNT_TYPE))]);
|
||||
file.setPreviewAvailable(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_HAS_PREVIEW)) == 1);
|
||||
file.setUnreadCommentsCount(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT)));
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -1000,16 +993,14 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
cv.put(
|
||||
ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
|
||||
share.getSharedWithDisplayName()
|
||||
);
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
|
||||
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
|
||||
if (shareExistsForRemoteId(share.getRemoteId())) {// for renamed files; no more delete and create
|
||||
overriden = true;
|
||||
@@ -1109,7 +1100,7 @@ public class FileDataStorageManager {
|
||||
null,
|
||||
key + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
||||
new String[]{value, mAccount.name},
|
||||
new String[]{value, account.name},
|
||||
null
|
||||
);
|
||||
} else {
|
||||
@@ -1118,7 +1109,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||
null,
|
||||
key + AND + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
||||
new String[]{value, mAccount.name},
|
||||
new String[]{value, account.name},
|
||||
null
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
@@ -1139,7 +1130,7 @@ public class FileDataStorageManager {
|
||||
* @return First {@link OCShare} instance found in DB bound to the file in 'path'
|
||||
*/
|
||||
public OCShare getFirstShareByPathAndType(String path, ShareType type, String shareWith) {
|
||||
Cursor cursor = null;
|
||||
Cursor cursor;
|
||||
if (shareWith == null) {
|
||||
shareWith = "";
|
||||
}
|
||||
@@ -1156,13 +1147,13 @@ public class FileDataStorageManager {
|
||||
selectionArgs = new String[]{
|
||||
path,
|
||||
Integer.toString(type.getValue()),
|
||||
mAccount.name
|
||||
account.name
|
||||
};
|
||||
} else {
|
||||
selectionArgs = new String[]{
|
||||
path,
|
||||
Integer.toString(type.getValue()),
|
||||
mAccount.name,
|
||||
account.name,
|
||||
shareWith
|
||||
};
|
||||
}
|
||||
@@ -1215,6 +1206,8 @@ public class FileDataStorageManager {
|
||||
share.setUserId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID)));
|
||||
share.setIdRemoteShared(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
|
||||
share.setIsPasswordProtected(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED)) == 1);
|
||||
share.setNote(c.getString(c.getColumnIndex(ProviderTableMeta.OCSHARES_NOTE)));
|
||||
share.setHideFileDownload(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD)) == 1);
|
||||
}
|
||||
return share;
|
||||
}
|
||||
@@ -1225,7 +1218,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name};
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
||||
@@ -1245,7 +1238,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PARENT + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, String.valueOf(folder.getFileId())};
|
||||
String[] whereArgs = new String[]{account.name, String.valueOf(folder.getFileId())};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
||||
@@ -1265,7 +1258,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, filePath};
|
||||
String[] whereArgs = new String[]{account.name, filePath};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
||||
@@ -1281,7 +1274,7 @@ public class FileDataStorageManager {
|
||||
|
||||
private void cleanShares() {
|
||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name};
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs);
|
||||
@@ -1313,16 +1306,14 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
cv.put(
|
||||
ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
|
||||
share.getSharedWithDisplayName()
|
||||
);
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
|
||||
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
|
||||
if (shareExistsForRemoteId(share.getRemoteId())) {
|
||||
// updating an existing file
|
||||
@@ -1386,28 +1377,22 @@ public class FileDataStorageManager {
|
||||
if (!file.isFolder()) {
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
|
||||
file.getLastSyncDateForData()
|
||||
);
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isAvailableOffline() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.getIsFavorite());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_UPDATE_THUMBNAIL,
|
||||
file.needsUpdateThumbnail() ? 1 : 0
|
||||
);
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_IS_DOWNLOADING,
|
||||
file.isDownloading() ? 1 : 0
|
||||
);
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
|
||||
boolean existsByPath = fileExists(file.getRemotePath());
|
||||
@@ -1454,7 +1439,7 @@ public class FileDataStorageManager {
|
||||
Uri share_uri = ProviderTableMeta.CONTENT_URI_SHARE;
|
||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
|
||||
ProviderTableMeta._ID + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, Long.toString(share.getId())};
|
||||
String[] whereArgs = new String[]{account.name, Long.toString(share.getId())};
|
||||
if (getContentProviderClient() != null) {
|
||||
try {
|
||||
getContentProviderClient().delete(share_uri, where, whereArgs);
|
||||
@@ -1525,7 +1510,7 @@ public class FileDataStorageManager {
|
||||
|
||||
public void removeSharesForFile(String remotePath) {
|
||||
resetShareFlagInAFile(remotePath);
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
|
||||
operations = prepareRemoveSharesInFile(remotePath, operations);
|
||||
// apply operations in batch
|
||||
if (operations.size() > 0) {
|
||||
@@ -1547,7 +1532,7 @@ public class FileDataStorageManager {
|
||||
|
||||
public void saveSharesInFolder(ArrayList<OCShare> shares, OCFile folder) {
|
||||
resetShareFlagsInFolder(folder);
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
|
||||
operations = prepareRemoveSharesInFolder(folder, operations);
|
||||
|
||||
if (shares != null) {
|
||||
@@ -1596,23 +1581,18 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
cv.put(
|
||||
ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
|
||||
share.getSharedWithDisplayName()
|
||||
);
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
|
||||
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
|
||||
// adding a new share resource
|
||||
operations.add(
|
||||
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE).
|
||||
withValues(cv).
|
||||
build()
|
||||
);
|
||||
operations.add(ContentProviderOperation.newInsert(
|
||||
ProviderTableMeta.CONTENT_URI_SHARE).withValues(cv).build());
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
@@ -1623,7 +1603,7 @@ public class FileDataStorageManager {
|
||||
if (folder != null) {
|
||||
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{"", mAccount.name};
|
||||
String[] whereArgs = new String[]{"", account.name};
|
||||
|
||||
List<OCFile> files = getFolderContent(folder, false);
|
||||
|
||||
@@ -1645,7 +1625,7 @@ public class FileDataStorageManager {
|
||||
|
||||
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{filePath, mAccount.name};
|
||||
String[] whereArgs = new String[]{filePath, account.name};
|
||||
|
||||
preparedOperations.add(
|
||||
ContentProviderOperation.newDelete(ProviderTableMeta.CONTENT_URI_SHARE).
|
||||
@@ -1664,31 +1644,30 @@ public class FileDataStorageManager {
|
||||
+ " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) ";
|
||||
String[] whereArgs = new String[]{filePath, accountName,
|
||||
Integer.toString(ShareType.USER.getValue()),
|
||||
Integer.toString(ShareType.GROUP.getValue()),
|
||||
Integer.toString(ShareType.EMAIL.getValue()),
|
||||
Integer.toString(ShareType.FEDERATED.getValue())};
|
||||
Integer.toString(ShareType.FEDERATED.getValue()),
|
||||
Integer.toString(ShareType.ROOM.getValue())};
|
||||
|
||||
Cursor cursor = null;
|
||||
if (getContentResolver() != null) {
|
||||
cursor = getContentResolver().query(
|
||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||
null, where, whereArgs, null);
|
||||
cursor = getContentResolver().query(ProviderTableMeta.CONTENT_URI_SHARE, null, where, whereArgs, null);
|
||||
} else {
|
||||
try {
|
||||
cursor = getContentProviderClient().query(
|
||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||
null, where, whereArgs, null);
|
||||
cursor = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI_SHARE, null, where,
|
||||
whereArgs, null);
|
||||
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage(), e);
|
||||
cursor = null;
|
||||
}
|
||||
}
|
||||
ArrayList<OCShare> shares = new ArrayList<OCShare>();
|
||||
OCShare share = null;
|
||||
ArrayList<OCShare> shares = new ArrayList<>();
|
||||
OCShare share;
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
@@ -1844,7 +1823,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI_FILE,
|
||||
new String[]{ProviderTableMeta._ID},
|
||||
whereForDescencentsInConflict,
|
||||
new String[]{mAccount.name, parentPath + "%"},
|
||||
new String[]{account.name, parentPath + "%"},
|
||||
null
|
||||
);
|
||||
} else {
|
||||
@@ -1853,7 +1832,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI_FILE,
|
||||
new String[]{ProviderTableMeta._ID},
|
||||
whereForDescencentsInConflict,
|
||||
new String[]{mAccount.name, parentPath + "%"},
|
||||
new String[]{account.name, parentPath + "%"},
|
||||
null
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
@@ -1868,7 +1847,7 @@ public class FileDataStorageManager {
|
||||
cv,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||
ProviderTableMeta.FILE_PATH + "=?",
|
||||
new String[]{mAccount.name, parentPath}
|
||||
new String[]{account.name, parentPath}
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
@@ -1877,7 +1856,7 @@ public class FileDataStorageManager {
|
||||
cv,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||
ProviderTableMeta.FILE_PATH + "=?"
|
||||
, new String[]{mAccount.name, parentPath}
|
||||
, new String[]{account.name, parentPath}
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e);
|
||||
@@ -1905,13 +1884,13 @@ public class FileDataStorageManager {
|
||||
|
||||
// Prepare capabilities data
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, mAccount.name);
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, account.name);
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR, capability.getVersionMayor());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MINOR, capability.getVersionMinor());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, capability.getVersionMicro());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, capability.getVersionString());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollinterval());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollInterval());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, capability.getFilesSharingApiEnabled().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
|
||||
capability.getFilesSharingPublicEnabled().getValue());
|
||||
@@ -1951,17 +1930,24 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN, capability.getServerBackgroundPlain()
|
||||
.getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACTIVITY, capability.isActivityEnabled().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
|
||||
TextUtils.join(",", capability.getRichDocumentsMimeTypeList()));
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, capability.getRichDocumentsDirectEditing()
|
||||
.getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichdocumentsTemplatesAvailable()
|
||||
.getValue());
|
||||
|
||||
if (capabilityExists(mAccount.name)) {
|
||||
if (capabilityExists(account.name)) {
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv,
|
||||
ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
||||
new String[]{mAccount.name});
|
||||
new String[]{account.name});
|
||||
} else {
|
||||
try {
|
||||
getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES,
|
||||
cv, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
||||
new String[]{mAccount.name});
|
||||
new String[]{account.name});
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e);
|
||||
}
|
||||
@@ -1983,7 +1969,7 @@ public class FileDataStorageManager {
|
||||
long new_id = Long.parseLong(result_uri.getPathSegments()
|
||||
.get(1));
|
||||
capability.setId(new_id);
|
||||
capability.setAccountName(mAccount.name);
|
||||
capability.setAccountName(account.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2024,7 +2010,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
|
||||
public OCCapability getCapability(String accountName) {
|
||||
OCCapability capability = null;
|
||||
OCCapability capability;
|
||||
Cursor c = getCapabilityCursorForAccount(accountName);
|
||||
|
||||
if (c.moveToFirst()) {
|
||||
@@ -2053,7 +2039,7 @@ public class FileDataStorageManager {
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_STRING)));
|
||||
capability.setVersionEdition(c.getString(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_EDITION)));
|
||||
capability.setCorePollinterval(c.getInt(c
|
||||
capability.setCorePollInterval(c.getInt(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL)));
|
||||
capability.setFilesSharingApiEnabled(CapabilityBooleanType.fromValue(c.getInt(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED))));
|
||||
@@ -2106,6 +2092,17 @@ public class FileDataStorageManager {
|
||||
c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN))));
|
||||
capability.setActivity(CapabilityBooleanType.fromValue(
|
||||
c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_ACTIVITY))));
|
||||
capability.setRichDocuments(CapabilityBooleanType.fromValue(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT))));
|
||||
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.fromValue(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING))));
|
||||
capability.setRichdocumentsTemplatesAvailable(CapabilityBooleanType.fromValue(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES))));
|
||||
String mimetypes = c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST));
|
||||
if (mimetypes == null) {
|
||||
mimetypes = "";
|
||||
}
|
||||
capability.setRichDocumentsMimeTypeList(Arrays.asList(mimetypes.split(",")));
|
||||
}
|
||||
return capability;
|
||||
}
|
||||
@@ -2214,7 +2211,7 @@ public class FileDataStorageManager {
|
||||
|
||||
public void deleteAllFiles() {
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name};
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_FILE, where, whereArgs);
|
||||
@@ -2223,7 +2220,7 @@ public class FileDataStorageManager {
|
||||
try {
|
||||
getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_FILE, where, whereArgs);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Exception in deleteAllFiles for account " + mAccount.name + ": " + e.getMessage(), e);
|
||||
Log_OC.e(TAG, "Exception in deleteAllFiles for account " + account.name + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2017 Mario Danic
|
||||
* Copyright (C) 2017 Nextcloud
|
||||
* Copyright (C) 2018 Andy Scherzinger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
@@ -20,98 +22,26 @@
|
||||
*/
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import androidx.annotation.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/*
|
||||
Model for filesystem data from the database
|
||||
/**
|
||||
* Model for filesystem data from the database.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FileSystemDataSet {
|
||||
|
||||
private int id;
|
||||
private String localPath;
|
||||
private long modifiedAt;
|
||||
private boolean isFolder;
|
||||
private boolean isSentForUpload;
|
||||
private boolean folder;
|
||||
private boolean sentForUpload;
|
||||
private long foundAt;
|
||||
private long syncedFolderId;
|
||||
@Nullable private String crc32;
|
||||
|
||||
public FileSystemDataSet() {
|
||||
}
|
||||
|
||||
public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean isFolder,
|
||||
boolean isSentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.modifiedAt = modifiedAt;
|
||||
this.isFolder = isFolder;
|
||||
this.isSentForUpload = isSentForUpload;
|
||||
this.foundAt = foundAt;
|
||||
this.syncedFolderId = syncedFolderId;
|
||||
this.crc32 = crc32;
|
||||
}
|
||||
|
||||
public String getCrc32() {
|
||||
return crc32;
|
||||
}
|
||||
|
||||
public void setCrc32(String crc32) {
|
||||
this.crc32 = crc32;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
public long getModifiedAt() {
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(long modifiedAt) {
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public boolean isFolder() {
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
public void setFolder(boolean folder) {
|
||||
isFolder = folder;
|
||||
}
|
||||
|
||||
public long getFoundAt() {
|
||||
return foundAt;
|
||||
}
|
||||
|
||||
public void setFoundAt(long foundAt) {
|
||||
this.foundAt = foundAt;
|
||||
}
|
||||
|
||||
public boolean isSentForUpload() {
|
||||
return isSentForUpload;
|
||||
}
|
||||
|
||||
public void setSentForUpload(boolean sentForUpload) {
|
||||
isSentForUpload = sentForUpload;
|
||||
}
|
||||
|
||||
public long getSyncedFolderId() {
|
||||
return syncedFolderId;
|
||||
}
|
||||
|
||||
public void setSyncedFolderId(long syncedFolderId) {
|
||||
this.syncedFolderId = syncedFolderId;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Types of media folder.
|
||||
*/
|
||||
@@ -29,7 +31,7 @@ public enum MediaFolderType {
|
||||
IMAGE(1),
|
||||
VIDEO(2);
|
||||
|
||||
private Integer id;
|
||||
@Getter private Integer id;
|
||||
|
||||
private static SparseArray<MediaFolderType> reverseMap = new SparseArray<>(3);
|
||||
|
||||
@@ -46,8 +48,4 @@ public enum MediaFolderType {
|
||||
public static MediaFolderType getById(Integer id) {
|
||||
return reverseMap.get(id);
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2018 Mario Danic
|
||||
* Copyright (C) 2018 Andy Scherzinger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
@@ -22,35 +24,15 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter @Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MediaFoldersModel {
|
||||
private List<String> imageMediaFolders;
|
||||
private List<String> videoMediaFolders;
|
||||
|
||||
/**
|
||||
* default constructor.
|
||||
*/
|
||||
public MediaFoldersModel() {
|
||||
// keep default constructor for GSON
|
||||
}
|
||||
|
||||
public MediaFoldersModel(List<String> imageMediaFolders, List<String> videoMediaFolders) {
|
||||
this.imageMediaFolders = imageMediaFolders;
|
||||
this.videoMediaFolders = videoMediaFolders;
|
||||
}
|
||||
|
||||
public List<String> getImageMediaFolders() {
|
||||
return imageMediaFolders;
|
||||
}
|
||||
|
||||
public void setImageMediaFolders(List<String> imageMediaFolders) {
|
||||
this.imageMediaFolders = imageMediaFolders;
|
||||
}
|
||||
|
||||
public List<String> getVideoMediaFolders() {
|
||||
return videoMediaFolders;
|
||||
}
|
||||
|
||||
public void setVideoMediaFolders(List<String> videoMediaFolders) {
|
||||
this.videoMediaFolders = videoMediaFolders;
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,9 @@ import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
@@ -119,9 +119,9 @@ public final class MediaProvider {
|
||||
MediaStore.MediaColumns.DATA));
|
||||
|
||||
// check if valid path
|
||||
if (filePath != null && filePath.lastIndexOf("/") > 0) {
|
||||
if (filePath != null && filePath.lastIndexOf('/') > 0) {
|
||||
mediaFolder.filePaths.add(filePath);
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf("/"));
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf('/'));
|
||||
}
|
||||
}
|
||||
cursorImages.close();
|
||||
@@ -185,8 +185,8 @@ public final class MediaProvider {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)) || getWithoutActivity) {
|
||||
cursorFolders = contentResolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, VIDEOS_FOLDER_PROJECTION,
|
||||
null, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<MediaFolder> mediaFolders = new ArrayList<>();
|
||||
String dataPath = MainApp.getStoragePath() + File.separator + MainApp.getDataFolder();
|
||||
|
||||
@@ -223,7 +223,7 @@ public final class MediaProvider {
|
||||
|
||||
if (filePath != null) {
|
||||
mediaFolder.filePaths.add(filePath);
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf("/"));
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf('/'));
|
||||
}
|
||||
}
|
||||
cursorVideos.close();
|
||||
|
||||
@@ -28,85 +28,71 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.FileProvider;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.FileProvider;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import third_parties.daveKoeller.AlphanumComparator;
|
||||
|
||||
public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
|
||||
|
||||
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
|
||||
|
||||
@Override
|
||||
public OCFile createFromParcel(Parcel source) {
|
||||
return new OCFile(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile[] newArray(int size) {
|
||||
return new OCFile[size];
|
||||
}
|
||||
};
|
||||
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S";
|
||||
private final static String PERMISSION_CAN_RESHARE = "R";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
public static final String ROOT_PATH = PATH_SEPARATOR;
|
||||
|
||||
private static final String TAG = OCFile.class.getSimpleName();
|
||||
|
||||
private long mId;
|
||||
private long mParentId;
|
||||
private long mLength;
|
||||
private long mCreationTimestamp;
|
||||
private long mModifiedTimestamp;
|
||||
private long mModifiedTimestampAtLastSyncForData;
|
||||
private String mRemotePath;
|
||||
private String mLocalPath;
|
||||
private String mMimeType;
|
||||
private boolean mNeedsUpdating;
|
||||
private long mLastSyncDateForProperties;
|
||||
private long mLastSyncDateForData;
|
||||
private boolean mAvailableOffline;
|
||||
|
||||
private String mEtag;
|
||||
|
||||
private boolean mShareByLink;
|
||||
private String mPublicLink;
|
||||
|
||||
private String mPermissions;
|
||||
private String mRemoteId;
|
||||
|
||||
private boolean mNeedsUpdateThumbnail;
|
||||
|
||||
private boolean mIsDownloading;
|
||||
|
||||
private String mEtagInConflict; // Save file etag in the server, when there is a conflict. No conflict = null
|
||||
|
||||
private boolean mShareWithSharee;
|
||||
|
||||
private boolean mIsFavorite;
|
||||
|
||||
private boolean mIsEncrypted;
|
||||
|
||||
private WebdavEntry.MountType mMountType;
|
||||
@Getter @Setter private long fileId; // android internal ID of the file
|
||||
@Getter @Setter private long parentId;
|
||||
@Getter @Setter private long fileLength;
|
||||
@Getter @Setter private long creationTimestamp; // UNIX timestamp of the time the file was created
|
||||
@Getter @Setter private long modificationTimestamp; // UNIX timestamp of the file modification time
|
||||
/** UNIX timestamp of the modification time, corresponding to the value returned by the server
|
||||
* in the last synchronization of THE CONTENTS of this file.
|
||||
*/
|
||||
@Getter @Setter private long modificationTimestampAtLastSyncForData;
|
||||
@Setter private String remotePath;
|
||||
private String localPath;
|
||||
@Getter @Setter private String mimeType;
|
||||
@Getter private boolean needsUpdatingWhileSaving;
|
||||
@Getter @Setter private long lastSyncDateForProperties;
|
||||
@Getter @Setter private long lastSyncDateForData;
|
||||
@Getter @Setter private boolean availableOffline;
|
||||
@Getter @Setter private boolean previewAvailable;
|
||||
@Getter private String etag;
|
||||
@Getter private String etagOnServer;
|
||||
@Getter @Setter private boolean sharedViaLink;
|
||||
@Getter @Setter private String publicLink;
|
||||
@Getter @Setter private String permissions;
|
||||
@Getter @Setter private String remoteId; // The fileid namespaced by the instance fileId, globally unique
|
||||
@Getter @Setter private boolean updateThumbnailNeeded;
|
||||
@Getter @Setter private boolean downloading;
|
||||
@Getter @Setter private String etagInConflict; // Only saves file etag in the server, when there is a conflict
|
||||
@Getter @Setter private boolean sharedWithSharee;
|
||||
@Getter @Setter private boolean favorite;
|
||||
@Getter @Setter private boolean encrypted;
|
||||
@Getter @Setter private WebdavEntry.MountType mountType;
|
||||
@Getter
|
||||
@Setter
|
||||
private int unreadCommentsCount;
|
||||
|
||||
/**
|
||||
* URI to the local path of the file contents, if stored in the device; cached after first call
|
||||
* to {@link #getStorageUri()}
|
||||
*/
|
||||
private Uri mLocalUri;
|
||||
private Uri localUri;
|
||||
|
||||
|
||||
/**
|
||||
@@ -114,8 +100,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* <p>
|
||||
* Cached after first call, until changed.
|
||||
*/
|
||||
private Uri mExposedFileUri;
|
||||
private String mEncryptedFileName;
|
||||
private Uri exposedFileUri;
|
||||
@Getter @Setter private String encryptedFileName;
|
||||
|
||||
|
||||
/**
|
||||
@@ -127,11 +113,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
*/
|
||||
public OCFile(String path) {
|
||||
resetData();
|
||||
mNeedsUpdating = false;
|
||||
needsUpdatingWhileSaving = false;
|
||||
if (path == null || path.length() <= 0 || !path.startsWith(PATH_SEPARATOR)) {
|
||||
throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path);
|
||||
}
|
||||
mRemotePath = path;
|
||||
remotePath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,90 +126,66 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @param source The source parcel
|
||||
*/
|
||||
private OCFile(Parcel source) {
|
||||
mId = source.readLong();
|
||||
mParentId = source.readLong();
|
||||
mLength = source.readLong();
|
||||
mCreationTimestamp = source.readLong();
|
||||
mModifiedTimestamp = source.readLong();
|
||||
mModifiedTimestampAtLastSyncForData = source.readLong();
|
||||
mRemotePath = source.readString();
|
||||
mLocalPath = source.readString();
|
||||
mMimeType = source.readString();
|
||||
mNeedsUpdating = source.readInt() == 0;
|
||||
mAvailableOffline = source.readInt() == 1;
|
||||
mLastSyncDateForProperties = source.readLong();
|
||||
mLastSyncDateForData = source.readLong();
|
||||
mEtag = source.readString();
|
||||
mShareByLink = source.readInt() == 1;
|
||||
mPublicLink = source.readString();
|
||||
mPermissions = source.readString();
|
||||
mRemoteId = source.readString();
|
||||
mNeedsUpdateThumbnail = source.readInt() == 1;
|
||||
mIsDownloading = source.readInt() == 1;
|
||||
mEtagInConflict = source.readString();
|
||||
mShareWithSharee = source.readInt() == 1;
|
||||
mIsFavorite = source.readInt() == 1;
|
||||
mIsEncrypted = source.readInt() == 1;
|
||||
mEncryptedFileName = source.readString();
|
||||
mMountType = (WebdavEntry.MountType) source.readSerializable();
|
||||
fileId = source.readLong();
|
||||
parentId = source.readLong();
|
||||
fileLength = source.readLong();
|
||||
creationTimestamp = source.readLong();
|
||||
modificationTimestamp = source.readLong();
|
||||
modificationTimestampAtLastSyncForData = source.readLong();
|
||||
remotePath = source.readString();
|
||||
localPath = source.readString();
|
||||
mimeType = source.readString();
|
||||
needsUpdatingWhileSaving = source.readInt() == 0;
|
||||
lastSyncDateForProperties = source.readLong();
|
||||
lastSyncDateForData = source.readLong();
|
||||
etag = source.readString();
|
||||
etagOnServer = source.readString();
|
||||
sharedViaLink = source.readInt() == 1;
|
||||
publicLink = source.readString();
|
||||
permissions = source.readString();
|
||||
remoteId = source.readString();
|
||||
updateThumbnailNeeded = source.readInt() == 1;
|
||||
downloading = source.readInt() == 1;
|
||||
etagInConflict = source.readString();
|
||||
sharedWithSharee = source.readInt() == 1;
|
||||
favorite = source.readInt() == 1;
|
||||
encrypted = source.readInt() == 1;
|
||||
encryptedFileName = source.readString();
|
||||
mountType = (WebdavEntry.MountType) source.readSerializable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(mId);
|
||||
dest.writeLong(mParentId);
|
||||
dest.writeLong(mLength);
|
||||
dest.writeLong(mCreationTimestamp);
|
||||
dest.writeLong(mModifiedTimestamp);
|
||||
dest.writeLong(mModifiedTimestampAtLastSyncForData);
|
||||
dest.writeString(mRemotePath);
|
||||
dest.writeString(mLocalPath);
|
||||
dest.writeString(mMimeType);
|
||||
dest.writeInt(mNeedsUpdating ? 1 : 0);
|
||||
dest.writeInt(mAvailableOffline ? 1 : 0);
|
||||
dest.writeLong(mLastSyncDateForProperties);
|
||||
dest.writeLong(mLastSyncDateForData);
|
||||
dest.writeString(mEtag);
|
||||
dest.writeInt(mShareByLink ? 1 : 0);
|
||||
dest.writeString(mPublicLink);
|
||||
dest.writeString(mPermissions);
|
||||
dest.writeString(mRemoteId);
|
||||
dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0);
|
||||
dest.writeInt(mIsDownloading ? 1 : 0);
|
||||
dest.writeString(mEtagInConflict);
|
||||
dest.writeInt(mShareWithSharee ? 1 : 0);
|
||||
dest.writeInt(mIsFavorite ? 1 : 0);
|
||||
dest.writeInt(mIsEncrypted ? 1 : 0);
|
||||
dest.writeString(mEncryptedFileName);
|
||||
dest.writeSerializable(mMountType);
|
||||
}
|
||||
|
||||
public boolean getIsFavorite() {
|
||||
return mIsFavorite;
|
||||
}
|
||||
|
||||
public void setFavorite(boolean mIsFavorite) {
|
||||
this.mIsFavorite = mIsFavorite;
|
||||
}
|
||||
|
||||
public boolean isEncrypted() {
|
||||
return mIsEncrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(boolean mIsEncrypted) {
|
||||
this.mIsEncrypted = mIsEncrypted;
|
||||
}
|
||||
/**
|
||||
* Gets the android internal ID of the file
|
||||
*
|
||||
* @return the android internal file ID
|
||||
*/
|
||||
public long getFileId() {
|
||||
return mId;
|
||||
dest.writeLong(fileId);
|
||||
dest.writeLong(parentId);
|
||||
dest.writeLong(fileLength);
|
||||
dest.writeLong(creationTimestamp);
|
||||
dest.writeLong(modificationTimestamp);
|
||||
dest.writeLong(modificationTimestampAtLastSyncForData);
|
||||
dest.writeString(remotePath);
|
||||
dest.writeString(localPath);
|
||||
dest.writeString(mimeType);
|
||||
dest.writeInt(needsUpdatingWhileSaving ? 1 : 0);
|
||||
dest.writeLong(lastSyncDateForProperties);
|
||||
dest.writeLong(lastSyncDateForData);
|
||||
dest.writeString(etag);
|
||||
dest.writeString(etagOnServer);
|
||||
dest.writeInt(sharedViaLink ? 1 : 0);
|
||||
dest.writeString(publicLink);
|
||||
dest.writeString(permissions);
|
||||
dest.writeString(remoteId);
|
||||
dest.writeInt(updateThumbnailNeeded ? 1 : 0);
|
||||
dest.writeInt(downloading ? 1 : 0);
|
||||
dest.writeString(etagInConflict);
|
||||
dest.writeInt(sharedWithSharee ? 1 : 0);
|
||||
dest.writeInt(favorite ? 1 : 0);
|
||||
dest.writeInt(encrypted ? 1 : 0);
|
||||
dest.writeString(encryptedFileName);
|
||||
dest.writeSerializable(mountType);
|
||||
}
|
||||
|
||||
public String getDecryptedRemotePath() {
|
||||
return mRemotePath;
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +195,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
*/
|
||||
public String getRemotePath() {
|
||||
if (isEncrypted() && !isFolder()) {
|
||||
String parentPath = new File(mRemotePath).getParent();
|
||||
String parentPath = new File(remotePath).getParent();
|
||||
|
||||
if (parentPath.endsWith("/")) {
|
||||
return parentPath + getEncryptedFileName();
|
||||
@@ -242,21 +204,17 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
}
|
||||
} else {
|
||||
if (isFolder()) {
|
||||
if (mRemotePath.endsWith("/")) {
|
||||
return mRemotePath;
|
||||
if (remotePath.endsWith("/")) {
|
||||
return remotePath;
|
||||
} else {
|
||||
return mRemotePath + "/";
|
||||
return remotePath + "/";
|
||||
}
|
||||
} else {
|
||||
return mRemotePath;
|
||||
return remotePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRemotePath(String path) {
|
||||
mRemotePath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check, whether or not this file exists in the database
|
||||
* already
|
||||
@@ -264,7 +222,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return true, if the file exists in the database
|
||||
*/
|
||||
public boolean fileExists() {
|
||||
return mId != -1;
|
||||
return fileId != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +231,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return true if it is a folder
|
||||
*/
|
||||
public boolean isFolder() {
|
||||
return mMimeType != null && mMimeType.equals(MimeType.DIRECTORY);
|
||||
return MimeType.DIRECTORY.equals(mimeType);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +242,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return OCFile this file
|
||||
*/
|
||||
public OCFile setFolder() {
|
||||
setMimetype(MimeType.DIRECTORY);
|
||||
setMimeType(MimeType.DIRECTORY);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -303,8 +261,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return true if it is
|
||||
*/
|
||||
public boolean existsOnDevice() {
|
||||
if (mLocalPath != null && mLocalPath.length() > 0) {
|
||||
return new File(mLocalPath).exists();
|
||||
if (localPath != null && localPath.length() > 0) {
|
||||
return new File(localPath).exists();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -315,7 +273,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return The local path to the file
|
||||
*/
|
||||
public String getStoragePath() {
|
||||
return mLocalPath;
|
||||
return localPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,52 +282,52 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return A URI to the local copy of the file, or NULL if not stored in the device
|
||||
*/
|
||||
public Uri getStorageUri() {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
if (localPath == null || localPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (mLocalUri == null) {
|
||||
if (localUri == null) {
|
||||
Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(ContentResolver.SCHEME_FILE);
|
||||
builder.path(mLocalPath);
|
||||
mLocalUri = builder.build();
|
||||
builder.path(localPath);
|
||||
localUri = builder.build();
|
||||
}
|
||||
return mLocalUri;
|
||||
return localUri;
|
||||
}
|
||||
|
||||
|
||||
public Uri getLegacyExposedFileUri(Context context) {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
public Uri getLegacyExposedFileUri() {
|
||||
if (localPath == null || localPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mExposedFileUri == null) {
|
||||
return Uri.parse(ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(mLocalPath));
|
||||
if (exposedFileUri == null) {
|
||||
return Uri.parse(ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(localPath));
|
||||
}
|
||||
|
||||
return mExposedFileUri;
|
||||
return exposedFileUri;
|
||||
|
||||
}
|
||||
/*
|
||||
Partly disabled because not all apps understand paths that we get via this method for now
|
||||
*/
|
||||
public Uri getExposedFileUri(Context context) {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
if (localPath == null || localPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (mExposedFileUri == null) {
|
||||
if (exposedFileUri == null) {
|
||||
try {
|
||||
mExposedFileUri = FileProvider.getUriForFile(
|
||||
exposedFileUri = FileProvider.getUriForFile(
|
||||
context,
|
||||
context.getString(R.string.file_provider_authority),
|
||||
new File(mLocalPath));
|
||||
new File(localPath));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// Could not share file using FileProvider URI scheme.
|
||||
// Fall back to legacy URI parsing.
|
||||
getLegacyExposedFileUri(context);
|
||||
getLegacyExposedFileUri();
|
||||
}
|
||||
}
|
||||
|
||||
return mExposedFileUri;
|
||||
|
||||
return exposedFileUri;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,82 +336,18 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @param storage_path to set
|
||||
*/
|
||||
public void setStoragePath(String storage_path) {
|
||||
mLocalPath = storage_path;
|
||||
mLocalUri = null;
|
||||
mExposedFileUri = null;
|
||||
localPath = storage_path;
|
||||
localUri = null;
|
||||
exposedFileUri = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a UNIX timestamp of the file creation time
|
||||
*
|
||||
* @return A UNIX timestamp of the time that file was created
|
||||
*/
|
||||
public long getCreationTimestamp() {
|
||||
return mCreationTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a UNIX timestamp of the time the file was created
|
||||
*
|
||||
* @param creation_timestamp to set
|
||||
*/
|
||||
public void setCreationTimestamp(long creation_timestamp) {
|
||||
mCreationTimestamp = creation_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a UNIX timestamp of the file modification time.
|
||||
*
|
||||
* @return A UNIX timestamp of the modification time, corresponding to the value returned by the server
|
||||
* in the last synchronization of the properties of this file.
|
||||
*/
|
||||
public long getModificationTimestamp() {
|
||||
return mModifiedTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a UNIX timestamp of the time the time the file was modified.
|
||||
* <p/>
|
||||
* To update with the value returned by the server in every synchronization of the properties
|
||||
* of this file.
|
||||
*
|
||||
* @param modification_timestamp to set
|
||||
*/
|
||||
public void setModificationTimestamp(long modification_timestamp) {
|
||||
mModifiedTimestamp = modification_timestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a UNIX timestamp of the file modification time.
|
||||
*
|
||||
* @return A UNIX timestamp of the modification time, corresponding to the value returned by the server
|
||||
* in the last synchronization of THE CONTENTS of this file.
|
||||
*/
|
||||
public long getModificationTimestampAtLastSyncForData() {
|
||||
return mModifiedTimestampAtLastSyncForData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a UNIX timestamp of the time the time the file was modified.
|
||||
* <p/>
|
||||
* To update with the value returned by the server in every synchronization of THE CONTENTS
|
||||
* of this file.
|
||||
*
|
||||
* @param modificationTimestamp to set
|
||||
*/
|
||||
public void setModificationTimestampAtLastSyncForData(long modificationTimestamp) {
|
||||
mModifiedTimestampAtLastSyncForData = modificationTimestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the filename and "/" for the root directory
|
||||
*
|
||||
* @return The name of the file
|
||||
*/
|
||||
public String getFileName() {
|
||||
File f = new File(mRemotePath);
|
||||
File f = new File(remotePath);
|
||||
return f.getName().length() == 0 ? ROOT_PATH : f.getName();
|
||||
}
|
||||
|
||||
@@ -464,121 +358,49 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* directory
|
||||
*/
|
||||
public void setFileName(String name) {
|
||||
Log_OC.d(TAG, "OCFile name changing from " + mRemotePath);
|
||||
Log_OC.d(TAG, "OCFile name changing from " + remotePath);
|
||||
if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) &&
|
||||
!mRemotePath.equals(ROOT_PATH)) {
|
||||
!ROOT_PATH.equals(remotePath)) {
|
||||
String parent = new File(this.getRemotePath()).getParent();
|
||||
parent = parent.endsWith(PATH_SEPARATOR) ? parent : parent + PATH_SEPARATOR;
|
||||
mRemotePath = parent + name;
|
||||
remotePath = parent + name;
|
||||
if (isFolder()) {
|
||||
mRemotePath += PATH_SEPARATOR;
|
||||
remotePath += PATH_SEPARATOR;
|
||||
}
|
||||
Log_OC.d(TAG, "OCFile name changed to " + mRemotePath);
|
||||
Log_OC.d(TAG, "OCFile name changed to " + remotePath);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEncryptedFileName(String name) {
|
||||
mEncryptedFileName = name;
|
||||
}
|
||||
|
||||
public String getEncryptedFileName() {
|
||||
return mEncryptedFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to get the MimeType
|
||||
*
|
||||
* @return the MimeType as a String
|
||||
*/
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return mMimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used internally. Reset all file properties
|
||||
*/
|
||||
private void resetData() {
|
||||
mId = -1;
|
||||
mRemotePath = null;
|
||||
mParentId = 0;
|
||||
mLocalPath = null;
|
||||
mMimeType = null;
|
||||
mLength = 0;
|
||||
mCreationTimestamp = 0;
|
||||
mModifiedTimestamp = 0;
|
||||
mModifiedTimestampAtLastSyncForData = 0;
|
||||
mLastSyncDateForProperties = 0;
|
||||
mLastSyncDateForData = 0;
|
||||
mAvailableOffline = false;
|
||||
mNeedsUpdating = false;
|
||||
mEtag = null;
|
||||
mShareByLink = false;
|
||||
mPublicLink = null;
|
||||
mPermissions = null;
|
||||
mRemoteId = null;
|
||||
mNeedsUpdateThumbnail = false;
|
||||
mIsDownloading = false;
|
||||
mEtagInConflict = null;
|
||||
mShareWithSharee = false;
|
||||
mIsFavorite = false;
|
||||
mIsEncrypted = false;
|
||||
mEncryptedFileName = null;
|
||||
mMountType = WebdavEntry.MountType.INTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the file
|
||||
*
|
||||
* @param file_id to set
|
||||
*/
|
||||
public void setFileId(long file_id) {
|
||||
mId = file_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Mime-Type of the
|
||||
*
|
||||
* @param mimetype to set
|
||||
*/
|
||||
public void setMimetype(String mimetype) {
|
||||
mMimeType = mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the parent folder
|
||||
*
|
||||
* @param parent_id to set
|
||||
*/
|
||||
public void setParentId(long parent_id) {
|
||||
mParentId = parent_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file size in bytes
|
||||
*
|
||||
* @param file_len to set
|
||||
*/
|
||||
public void setFileLength(long file_len) {
|
||||
mLength = file_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the file in bytes
|
||||
*
|
||||
* @return The filesize in bytes
|
||||
*/
|
||||
public long getFileLength() {
|
||||
return mLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the parent Folder
|
||||
*
|
||||
* @return The ID
|
||||
*/
|
||||
public long getParentId() {
|
||||
return mParentId;
|
||||
fileId = -1;
|
||||
remotePath = null;
|
||||
parentId = 0;
|
||||
localPath = null;
|
||||
mimeType = null;
|
||||
fileLength = 0;
|
||||
creationTimestamp = 0;
|
||||
modificationTimestamp = 0;
|
||||
modificationTimestampAtLastSyncForData = 0;
|
||||
lastSyncDateForProperties = 0;
|
||||
lastSyncDateForData = 0;
|
||||
needsUpdatingWhileSaving = false;
|
||||
etag = null;
|
||||
etagOnServer = null;
|
||||
sharedViaLink = false;
|
||||
publicLink = null;
|
||||
permissions = null;
|
||||
remoteId = null;
|
||||
updateThumbnailNeeded = false;
|
||||
downloading = false;
|
||||
etagInConflict = null;
|
||||
sharedWithSharee = false;
|
||||
favorite = false;
|
||||
encrypted = false;
|
||||
encryptedFileName = null;
|
||||
mountType = WebdavEntry.MountType.INTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,47 +413,6 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return parentPath.endsWith("/") ? parentPath : parentPath + "/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check, if this file needs updating
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean needsUpdatingWhileSaving() {
|
||||
return mNeedsUpdating;
|
||||
}
|
||||
|
||||
public boolean needsUpdateThumbnail() {
|
||||
return mNeedsUpdateThumbnail;
|
||||
}
|
||||
|
||||
public void setNeedsUpdateThumbnail(boolean needsUpdateThumbnail) {
|
||||
this.mNeedsUpdateThumbnail = needsUpdateThumbnail;
|
||||
}
|
||||
|
||||
public long getLastSyncDateForProperties() {
|
||||
return mLastSyncDateForProperties;
|
||||
}
|
||||
|
||||
public void setLastSyncDateForProperties(long lastSyncDate) {
|
||||
mLastSyncDateForProperties = lastSyncDate;
|
||||
}
|
||||
|
||||
public long getLastSyncDateForData() {
|
||||
return mLastSyncDateForData;
|
||||
}
|
||||
|
||||
public void setLastSyncDateForData(long lastSyncDate) {
|
||||
mLastSyncDateForData = lastSyncDate;
|
||||
}
|
||||
|
||||
public void setAvailableOffline(boolean availableOffline) {
|
||||
mAvailableOffline = availableOffline;
|
||||
}
|
||||
|
||||
public boolean isAvailableOffline() {
|
||||
return mAvailableOffline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return super.hashCode();
|
||||
@@ -660,51 +441,34 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
|
||||
OCFile ocFile = (OCFile) o;
|
||||
|
||||
return mId == ocFile.mId && mParentId == ocFile.mParentId;
|
||||
return fileId == ocFile.fileId && parentId == ocFile.parentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (int) (mId ^ (mId >>> 32)) + (int) (mParentId ^ (mParentId >>> 32));
|
||||
return 31 * (int) (fileId ^ (fileId >>> 32)) + (int) (parentId ^ (parentId >>> 32));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
|
||||
"parentId=%s, availableOffline=%s etag=%s favourite=%s]";
|
||||
return String.format(asString, mId, getFileName(), mMimeType, isDown(),
|
||||
mLocalPath, mRemotePath, mParentId, mAvailableOffline,
|
||||
mEtag, mIsFavorite);
|
||||
}
|
||||
|
||||
public String getEtag() {
|
||||
return mEtag;
|
||||
"parentId=%s, etag=%s, favourite=%s]";
|
||||
return String.format(asString, fileId, getFileName(), mimeType, isDown(), localPath, remotePath, parentId,
|
||||
etag, favorite);
|
||||
}
|
||||
|
||||
public void setEtag(String etag) {
|
||||
this.mEtag = (etag != null ? etag : "");
|
||||
this.etag = etag != null ? etag : "";
|
||||
}
|
||||
|
||||
|
||||
public boolean isSharedViaLink() {
|
||||
return mShareByLink;
|
||||
}
|
||||
|
||||
public void setShareViaLink(boolean shareByLink) {
|
||||
this.mShareByLink = shareByLink;
|
||||
}
|
||||
|
||||
public String getPublicLink() {
|
||||
return mPublicLink;
|
||||
}
|
||||
|
||||
public void setPublicLink(String publicLink) {
|
||||
this.mPublicLink = publicLink;
|
||||
public void setEtagOnServer(String etag) {
|
||||
this.etagOnServer = etag != null ? etag : "";
|
||||
}
|
||||
|
||||
public long getLocalModificationTimestamp() {
|
||||
if (mLocalPath != null && mLocalPath.length() > 0) {
|
||||
File f = new File(mLocalPath);
|
||||
if (localPath != null && localPath.length() > 0) {
|
||||
File f = new File(localPath);
|
||||
return f.lastModified();
|
||||
}
|
||||
return 0;
|
||||
@@ -714,65 +478,20 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return 'True' if the file is hidden
|
||||
*/
|
||||
public boolean isHidden() {
|
||||
return getFileName().startsWith(".");
|
||||
}
|
||||
|
||||
public String getPermissions() {
|
||||
return mPermissions;
|
||||
}
|
||||
|
||||
public void setPermissions(String permissions) {
|
||||
this.mPermissions = permissions;
|
||||
return getFileName().length() > 0 && getFileName().charAt(0) == '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* The fileid namespaced by the instance id, globally unique
|
||||
* The unique fileId for the file within the instance
|
||||
*
|
||||
* @return globally unique file id: file id + instance id
|
||||
*/
|
||||
public String getRemoteId() {
|
||||
return mRemoteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique id for the file within the instance
|
||||
*
|
||||
* @return file id, unique within the instance
|
||||
* @return file fileId, unique within the instance
|
||||
*/
|
||||
public String getLocalId() {
|
||||
return getRemoteId().substring(0, 8).replaceAll("^0*", "");
|
||||
}
|
||||
|
||||
public void setRemoteId(String remoteId) {
|
||||
this.mRemoteId = remoteId;
|
||||
}
|
||||
|
||||
public boolean isDownloading() {
|
||||
return mIsDownloading;
|
||||
}
|
||||
|
||||
public void setDownloading(boolean isDownloading) {
|
||||
this.mIsDownloading = isDownloading;
|
||||
}
|
||||
|
||||
public String getEtagInConflict() {
|
||||
return mEtagInConflict;
|
||||
}
|
||||
|
||||
public boolean isInConflict() {
|
||||
return mEtagInConflict != null && !mEtagInConflict.equals("");
|
||||
}
|
||||
|
||||
public void setEtagInConflict(String etagInConflict) {
|
||||
mEtagInConflict = etagInConflict;
|
||||
}
|
||||
|
||||
public boolean isSharedWithSharee() {
|
||||
return mShareWithSharee;
|
||||
}
|
||||
|
||||
public void setShareWithSharee(boolean shareWithSharee) {
|
||||
this.mShareWithSharee = shareWithSharee;
|
||||
return etagInConflict != null && !"".equals(etagInConflict);
|
||||
}
|
||||
|
||||
public boolean isSharedWithMe() {
|
||||
@@ -790,11 +509,16 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
|
||||
}
|
||||
|
||||
public WebdavEntry.MountType getMountType() {
|
||||
return mMountType;
|
||||
}
|
||||
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
|
||||
|
||||
public void setMountType(WebdavEntry.MountType mountType) {
|
||||
mMountType = mountType;
|
||||
}
|
||||
@Override
|
||||
public OCFile createFromParcel(Parcel source) {
|
||||
return new OCFile(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile[] newArray(int size) {
|
||||
return new OCFile[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2017 Mario Danic
|
||||
* Copyright (C) 2018 Andy Scherzinger
|
||||
*
|
||||
* 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
|
||||
@@ -20,62 +22,19 @@
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PushConfigurationState {
|
||||
public String pushToken;
|
||||
public String deviceIdentifier;
|
||||
public String deviceIdentifierSignature;
|
||||
public String userPublicKey;
|
||||
public boolean shouldBeDeleted;
|
||||
|
||||
public PushConfigurationState() {
|
||||
}
|
||||
|
||||
public PushConfigurationState(String pushToken, String deviceIdentifier, String deviceIdentifierSignature,
|
||||
String userPublicKey, boolean shouldBeDeleted) {
|
||||
this.pushToken = pushToken;
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
this.deviceIdentifierSignature = deviceIdentifierSignature;
|
||||
this.userPublicKey = userPublicKey;
|
||||
this.shouldBeDeleted = shouldBeDeleted;
|
||||
}
|
||||
|
||||
public String getPushToken() {
|
||||
return pushToken;
|
||||
}
|
||||
|
||||
public void setPushToken(String pushToken) {
|
||||
this.pushToken = pushToken;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifierSignature() {
|
||||
return deviceIdentifierSignature;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifierSignature(String deviceIdentifierSignature) {
|
||||
this.deviceIdentifierSignature = deviceIdentifierSignature;
|
||||
}
|
||||
|
||||
public String getUserPublicKey() {
|
||||
return userPublicKey;
|
||||
}
|
||||
|
||||
public void setUserPublicKey(String userPublicKey) {
|
||||
this.userPublicKey = userPublicKey;
|
||||
}
|
||||
|
||||
public boolean isShouldBeDeleted() {
|
||||
return shouldBeDeleted;
|
||||
}
|
||||
|
||||
public void setShouldBeDeleted(boolean shouldBeDeleted) {
|
||||
this.shouldBeDeleted = shouldBeDeleted;
|
||||
}
|
||||
}
|
||||
@@ -23,32 +23,17 @@ import android.accounts.Account;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Parcel
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SignatureVerification {
|
||||
public boolean signatureValid;
|
||||
public Account account;
|
||||
|
||||
public SignatureVerification() {
|
||||
}
|
||||
|
||||
public SignatureVerification(boolean signatureValid, Account account) {
|
||||
this.signatureValid = signatureValid;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public boolean isSignatureValid() {
|
||||
return signatureValid;
|
||||
}
|
||||
|
||||
public void setSignatureValid(boolean signatureValid) {
|
||||
this.signatureValid = signatureValid;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
@@ -23,12 +23,20 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Synced folder entity containing all information per synced folder.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class SyncedFolder implements Serializable, Cloneable {
|
||||
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
|
||||
private static final long serialVersionUID = -793476118299906429L;
|
||||
|
||||
private long id = UNPERSISTED_ID;
|
||||
private String localPath;
|
||||
private String remotePath;
|
||||
@@ -40,35 +48,6 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
private boolean enabled;
|
||||
private MediaFolderType type;
|
||||
|
||||
/**
|
||||
* constructor for already persisted entity.
|
||||
*
|
||||
* @param id the primary key
|
||||
* @param localPath local path
|
||||
* @param remotePath remote path
|
||||
* @param wifiOnly upload on wifi only flag
|
||||
* @param chargingOnly upload on charging only
|
||||
* @param subfolderByDate create sub-folders by date (month)
|
||||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
* @param enabled flag if synced folder config is active
|
||||
* @param type the type of the folder
|
||||
*/
|
||||
public SyncedFolder(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
MediaFolderType type) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.remotePath = remotePath;
|
||||
this.wifiOnly = wifiOnly;
|
||||
this.chargingOnly = chargingOnly;
|
||||
this.subfolderByDate = subfolderByDate;
|
||||
this.account = account;
|
||||
this.uploadAction = uploadAction;
|
||||
this.enabled = enabled;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor for new, to be persisted entity.
|
||||
*
|
||||
@@ -103,84 +82,4 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
public String getRemotePath() {
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
public void setRemotePath(String remotePath) {
|
||||
this.remotePath = remotePath;
|
||||
}
|
||||
|
||||
public Boolean getWifiOnly() {
|
||||
return wifiOnly;
|
||||
}
|
||||
|
||||
public void setWifiOnly(Boolean wifiOnly) {
|
||||
this.wifiOnly = wifiOnly;
|
||||
}
|
||||
|
||||
public Boolean getChargingOnly() {
|
||||
return chargingOnly;
|
||||
}
|
||||
|
||||
public void setChargingOnly(Boolean chargingOnly) {
|
||||
this.chargingOnly = chargingOnly;
|
||||
}
|
||||
|
||||
public Boolean getSubfolderByDate() {
|
||||
return subfolderByDate;
|
||||
}
|
||||
|
||||
public void setSubfolderByDate(Boolean subfolderByDate) {
|
||||
this.subfolderByDate = subfolderByDate;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Integer getUploadAction() {
|
||||
return uploadAction;
|
||||
}
|
||||
|
||||
public void setUploadAction(Integer uploadAction) {
|
||||
this.uploadAction = uploadAction;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public MediaFolderType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MediaFolderType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
@@ -23,10 +23,15 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Display item specialization for synced folder objects to be displayed in a list/grid view adding further
|
||||
* information to be displayed in the UI but not part of the persisted underlying {@link SyncedFolder} object.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
private List<String> filePaths;
|
||||
private String folderName;
|
||||
@@ -65,28 +70,4 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public List<String> getFilePaths() {
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
public void setFilePaths(List<String> filePaths) {
|
||||
this.filePaths = filePaths;
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
return folderName;
|
||||
}
|
||||
|
||||
public void setFolderName(String folderName) {
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public long getNumberOfFiles() {
|
||||
return numberOfFiles;
|
||||
}
|
||||
|
||||
public void setNumberOfFiles(long numberOfFiles) {
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.owncloud.android.db.PreferenceManager;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
@@ -37,6 +36,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Database provider for handling the persistence aspects of {@link SyncedFolder}s.
|
||||
*/
|
||||
@@ -182,12 +183,12 @@ public class SyncedFolderProvider extends Observable {
|
||||
|
||||
SyncedFolder result = null;
|
||||
Cursor cursor = mContentResolver.query(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + " == \"" + localPath + "\"" + " AND " +
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " == " + account.name,
|
||||
null,
|
||||
null
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + "=? AND " +
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " =? ",
|
||||
new String[]{localPath, account.name},
|
||||
null
|
||||
);
|
||||
|
||||
if (cursor != null && cursor.getCount() == 1) {
|
||||
@@ -209,54 +210,17 @@ public class SyncedFolderProvider extends Observable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* find a synced folder by local path.
|
||||
*
|
||||
* @param localPath the local path of the local folder
|
||||
* @return the synced folder if found, else null
|
||||
*/
|
||||
public SyncedFolder findByLocalPath(String localPath) {
|
||||
SyncedFolder result = null;
|
||||
Cursor cursor = mContentResolver.query(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + " == \"" + localPath + "\"",
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
if (cursor != null && cursor.getCount() == 1) {
|
||||
result = createSyncedFolderFromCursor(cursor);
|
||||
} else {
|
||||
if (cursor == null) {
|
||||
Log_OC.e(TAG, "Sync folder db cursor for local path=" + localPath + " in NULL.");
|
||||
} else {
|
||||
Log_OC.e(TAG, cursor.getCount() + " items for local path=" + localPath
|
||||
+ " available in sync folder db. Expected 1. Failed to update sync folder db.");
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all synced folders for an account
|
||||
*
|
||||
* @param account whose synced folders should be deleted
|
||||
*/
|
||||
public int deleteSyncFoldersForAccount(Account account) {
|
||||
int result = mContentResolver.delete(
|
||||
return mContentResolver.delete(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " = ?",
|
||||
new String[]{String.valueOf(account.name)}
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,14 +309,12 @@ public class SyncedFolderProvider extends Observable {
|
||||
|
||||
ContentValues cv = createContentValuesFromSyncedFolder(syncedFolder);
|
||||
|
||||
int result = mContentResolver.update(
|
||||
return mContentResolver.update(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
cv,
|
||||
ProviderMeta.ProviderTableMeta._ID + "=?",
|
||||
new String[]{String.valueOf(syncedFolder.getId())}
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Template for creating a file from it via RichDocuments app
|
||||
*/
|
||||
|
||||
@Parcel
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Template {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String thumbnailLink;
|
||||
private String type;
|
||||
private String extension;
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Display;
|
||||
import android.view.MenuItem;
|
||||
@@ -51,8 +50,8 @@ import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.files.TrashbinFile;
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
import com.owncloud.android.ui.adapter.DiskLruImageCache;
|
||||
import com.owncloud.android.ui.fragment.FileFragment;
|
||||
@@ -73,6 +72,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
@@ -90,13 +90,13 @@ public final class ThumbnailsCacheManager {
|
||||
private static final String ETAG = "ETag";
|
||||
|
||||
private static final Object mThumbnailsDiskCacheLock = new Object();
|
||||
private static DiskLruImageCache mThumbnailCache = null;
|
||||
private static DiskLruImageCache mThumbnailCache;
|
||||
private static boolean mThumbnailCacheStarting = true;
|
||||
|
||||
private static final int DISK_CACHE_SIZE = 1024 * 1024 * 200; // 200MB
|
||||
private static final CompressFormat mCompressFormat = CompressFormat.JPEG;
|
||||
private static final int mCompressQuality = 70;
|
||||
private static OwnCloudClient mClient = null;
|
||||
private static OwnCloudClient mClient;
|
||||
|
||||
public static final Bitmap mDefaultImg = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
|
||||
R.drawable.file_image);
|
||||
@@ -106,7 +106,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
private ThumbnailsCacheManager() {
|
||||
}
|
||||
|
||||
|
||||
public static class InitDiskCacheTask extends AsyncTask<File, Void, Void> {
|
||||
@Override
|
||||
protected Void doInBackground(File... params) {
|
||||
@@ -115,7 +115,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
if (mThumbnailCache == null) {
|
||||
try {
|
||||
// Check if media is mounted or storage is built-in, if so,
|
||||
// Check if media is mounted or storage is built-in, if so,
|
||||
// try and use external cache dir; otherwise use internal cache dir
|
||||
File cacheDir = MainApp.getAppContext().getExternalCacheDir();
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
|
||||
public static void addBitmapToCache(String key, Bitmap bitmap) {
|
||||
synchronized (mThumbnailsDiskCacheLock) {
|
||||
if (mThumbnailCache != null) {
|
||||
@@ -265,7 +265,7 @@ public final class ThumbnailsCacheManager {
|
||||
thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null || file.needsUpdateThumbnail()) {
|
||||
if (thumbnail == null || file.isUpdateThumbnailNeeded()) {
|
||||
Point p = getScreenDimension();
|
||||
int pxW = p.x;
|
||||
int pxH = p.y;
|
||||
@@ -281,7 +281,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
|
||||
|
||||
file.setNeedsUpdateThumbnail(false);
|
||||
file.setUpdateThumbnailNeeded(false);
|
||||
storageManager.saveFile(file);
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public final class ThumbnailsCacheManager {
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ public final class ThumbnailsCacheManager {
|
||||
private static Account mAccount;
|
||||
private List<ThumbnailGenerationTask> mAsyncTasks;
|
||||
private Object mFile;
|
||||
private String mImageKey = null;
|
||||
private String mImageKey;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private GetMethod getMethod;
|
||||
|
||||
@@ -397,7 +397,7 @@ public final class ThumbnailsCacheManager {
|
||||
Account account, List<ThumbnailGenerationTask> asyncTasks)
|
||||
throws IllegalArgumentException {
|
||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||
mImageViewReference = new WeakReference<ImageView>(imageView);
|
||||
mImageViewReference = new WeakReference<>(imageView);
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView) {
|
||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||
mImageViewReference = new WeakReference<ImageView>(imageView);
|
||||
mImageViewReference = new WeakReference<>(imageView);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("Dm")
|
||||
@@ -504,7 +504,7 @@ public final class ThumbnailsCacheManager {
|
||||
thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null || (file instanceof OCFile && ((OCFile) file).needsUpdateThumbnail())) {
|
||||
if (thumbnail == null || (file instanceof OCFile && ((OCFile) file).isUpdateThumbnailNeeded())) {
|
||||
int pxW;
|
||||
int pxH;
|
||||
pxW = pxH = getThumbnailDimension();
|
||||
@@ -528,7 +528,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, ocFile.getStoragePath(), pxW, pxH);
|
||||
|
||||
ocFile.setNeedsUpdateThumbnail(false);
|
||||
ocFile.setUpdateThumbnailNeeded(false);
|
||||
mStorageManager.saveFile(ocFile);
|
||||
}
|
||||
}
|
||||
@@ -555,7 +555,7 @@ public final class ThumbnailsCacheManager {
|
||||
uri = mClient.getBaseUri() + "/index.php/apps/files_trashbin/preview?fileId=" +
|
||||
file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
|
||||
}
|
||||
|
||||
|
||||
Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
|
||||
getMethod = new GetMethod(uri);
|
||||
getMethod.setRequestHeader("Cookie",
|
||||
@@ -865,7 +865,7 @@ public final class ThumbnailsCacheManager {
|
||||
Log_OC.d("Avatar", "URI: " + uri);
|
||||
get = new GetMethod(uri);
|
||||
|
||||
// only use eTag if available and corresponding avatar is still there
|
||||
// only use eTag if available and corresponding avatar is still there
|
||||
// (might be deleted from cache)
|
||||
if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
|
||||
get.setRequestHeader("If-None-Match", eTag);
|
||||
@@ -1166,4 +1166,4 @@ public final class ThumbnailsCacheManager {
|
||||
addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
@@ -40,6 +39,8 @@ import com.owncloud.android.operations.UploadFileOperation;
|
||||
import java.util.Calendar;
|
||||
import java.util.Observable;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Database helper for storing list of files to be uploaded, including status
|
||||
* information for each file.
|
||||
@@ -343,7 +344,7 @@ public class UploadsStorageManager extends Observable {
|
||||
|
||||
if (account != null) {
|
||||
return getUploads(
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value +
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_FOR_WIFI.getValue() +
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
@@ -353,8 +354,7 @@ public class UploadsStorageManager extends Observable {
|
||||
" OR " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"==" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
" AND " + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
new String[]{account.name}
|
||||
);
|
||||
account.name);
|
||||
} else {
|
||||
return new OCUpload[0];
|
||||
}
|
||||
@@ -375,7 +375,7 @@ public class UploadsStorageManager extends Observable {
|
||||
"==" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
" ) AND " + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"!= " + UploadResult.VIRUS_DETECTED.getValue()
|
||||
, new String[]{String.valueOf(UploadStatus.UPLOAD_FAILED.value)});
|
||||
, String.valueOf(UploadStatus.UPLOAD_FAILED.value));
|
||||
}
|
||||
|
||||
public OCUpload[] getFinishedUploadsForCurrentAccount() {
|
||||
@@ -383,7 +383,7 @@ public class UploadsStorageManager extends Observable {
|
||||
|
||||
if (account != null) {
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", new String[]{account.name});
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?", account.name);
|
||||
} else {
|
||||
return new OCUpload[0];
|
||||
}
|
||||
@@ -411,8 +411,7 @@ public class UploadsStorageManager extends Observable {
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "== ?",
|
||||
new String[]{account.name}
|
||||
);
|
||||
account.name);
|
||||
} else {
|
||||
return new OCUpload[0];
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
* Copyright (C) 2017 Nextcloud GmbH.
|
||||
* <p>
|
||||
*
|
||||
* 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.
|
||||
* <p>
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* <p>
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -24,7 +24,6 @@ package com.owncloud.android.datamodel;
|
||||
/**
|
||||
* Type for virtual folders
|
||||
*/
|
||||
|
||||
public enum VirtualFolderType {
|
||||
FAVORITE, PHOTOS, NONE
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -21,9 +21,17 @@
|
||||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
@Getter @Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StoragePoint implements Comparable<StoragePoint> {
|
||||
public enum StorageType {
|
||||
INTERNAL, EXTERNAL
|
||||
@@ -33,51 +41,13 @@ public class StoragePoint implements Comparable<StoragePoint> {
|
||||
PRIVATE, PUBLIC
|
||||
}
|
||||
|
||||
private String mDescription;
|
||||
private String mPath;
|
||||
private StorageType mStorageType;
|
||||
private PrivacyType mPrivacyType;
|
||||
|
||||
public StoragePoint() {
|
||||
}
|
||||
|
||||
public StoragePoint(String mDescription, String mPath, StorageType mStorageType, PrivacyType privacyType) {
|
||||
this.mDescription = mDescription;
|
||||
this.mPath = mPath;
|
||||
this.mStorageType = mStorageType;
|
||||
this.mPrivacyType = privacyType;
|
||||
}
|
||||
|
||||
public StorageType getStorageType() {
|
||||
return mStorageType;
|
||||
}
|
||||
|
||||
public PrivacyType getPrivacyType() {
|
||||
return mPrivacyType;
|
||||
}
|
||||
public String getPath() { return mPath; }
|
||||
public String getDescription() { return mDescription; }
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.mDescription = description;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.mPath = path;
|
||||
}
|
||||
|
||||
public void setStorageType(StorageType storageType) {
|
||||
this.mStorageType = storageType;
|
||||
}
|
||||
|
||||
public void setPrivacyType(PrivacyType privacyType) {
|
||||
this.mPrivacyType = privacyType;
|
||||
}
|
||||
private String description;
|
||||
private String path;
|
||||
private StorageType storageType;
|
||||
private PrivacyType privacyType;
|
||||
|
||||
@Override
|
||||
public int compareTo(StoragePoint another) {
|
||||
return mPath.compareTo(another.getPath());
|
||||
return path.compareTo(another.getPath());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
|
||||
if (!line.toLowerCase(Locale.US).contains("asec") && sPattern.matcher(line).matches()) {
|
||||
String parts[] = line.split(" ");
|
||||
for (String path : parts) {
|
||||
if (path.startsWith("/") && !path.toLowerCase(Locale.US).contains("vold")) {
|
||||
if (path.length() > 0 && path.charAt(0) == '/' && !path.toLowerCase(Locale.US).contains("vold")) {
|
||||
result.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Stores all information in order to start upload operations. PersistentUploadObject can
|
||||
* be stored persistently by {@link UploadsStorageManager}.
|
||||
@@ -47,85 +50,85 @@ public class OCUpload implements Parcelable {
|
||||
|
||||
private static final String TAG = OCUpload.class.getSimpleName();
|
||||
|
||||
private long id;
|
||||
@Getter @Setter private long uploadId;
|
||||
|
||||
/**
|
||||
* Absolute path in the local file system to the file to be uploaded.
|
||||
*/
|
||||
private String localPath;
|
||||
@Getter @Setter private String localPath;
|
||||
|
||||
/**
|
||||
* Absolute path in the remote account to set to the uploaded file (not for its parent folder!)
|
||||
*/
|
||||
private String remotePath;
|
||||
@Getter @Setter private String remotePath;
|
||||
|
||||
/**
|
||||
* Name of Owncloud account to upload file to.
|
||||
*/
|
||||
private String accountName;
|
||||
@Getter private String accountName;
|
||||
|
||||
/**
|
||||
* File size.
|
||||
*/
|
||||
private long fileSize;
|
||||
@Getter @Setter private long fileSize;
|
||||
|
||||
/**
|
||||
* Local action for upload. (0 - COPY, 1 - MOVE, 2 - FORGET)
|
||||
*/
|
||||
private int localAction;
|
||||
@Getter @Setter private int localAction;
|
||||
|
||||
/**
|
||||
* Overwrite destination file?
|
||||
*/
|
||||
private boolean forceOverwrite;
|
||||
@Getter @Setter private boolean forceOverwrite;
|
||||
|
||||
/**
|
||||
* Create destination folder?
|
||||
*/
|
||||
private boolean createRemoteFolder;
|
||||
@Getter @Setter private boolean createRemoteFolder;
|
||||
|
||||
/**
|
||||
* Status of upload (later, in_progress, ...).
|
||||
*/
|
||||
private UploadStatus uploadStatus;
|
||||
@Getter private UploadStatus uploadStatus;
|
||||
|
||||
/**
|
||||
* Result from last upload operation. Can be null.
|
||||
*/
|
||||
private UploadResult lastResult;
|
||||
@Getter private UploadResult lastResult;
|
||||
|
||||
/**
|
||||
* Defines the origin of the upload; see constants CREATED_ in {@link UploadFileOperation}
|
||||
*/
|
||||
private int createdBy;
|
||||
@Getter @Setter private int createdBy;
|
||||
|
||||
/**
|
||||
* When the upload ended
|
||||
*/
|
||||
private long uploadEndTimeStamp;
|
||||
@Getter @Setter private long uploadEndTimestamp;
|
||||
|
||||
/**
|
||||
* Upload only via wifi?
|
||||
*/
|
||||
private boolean useWifiOnly;
|
||||
@Getter @Setter private boolean useWifiOnly;
|
||||
|
||||
/**
|
||||
* Upload only if phone being charged?
|
||||
*/
|
||||
private boolean whileChargingOnly;
|
||||
@Getter @Setter private boolean whileChargingOnly;
|
||||
|
||||
/**
|
||||
* Token to unlock E2E folder
|
||||
*/
|
||||
private String folderUnlockToken;
|
||||
@Getter @Setter private String folderUnlockToken;
|
||||
|
||||
/**
|
||||
* temporary values, used for sorting
|
||||
*/
|
||||
private UploadStatus fixedUploadStatus;
|
||||
private boolean fixedUploadingNow;
|
||||
private long fixedUploadEndTimeStamp;
|
||||
private long fixedId;
|
||||
@Getter private UploadStatus fixedUploadStatus;
|
||||
@Getter private boolean fixedUploadingNow;
|
||||
@Getter private long fixedUploadEndTimeStamp;
|
||||
@Getter private long fixedUploadId;
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
@@ -168,7 +171,7 @@ public class OCUpload implements Parcelable {
|
||||
localPath = "";
|
||||
accountName = "";
|
||||
fileSize = -1;
|
||||
id = -1;
|
||||
uploadId = -1;
|
||||
localAction = FileUploader.LOCAL_BEHAVIOUR_COPY;
|
||||
forceOverwrite = false;
|
||||
createRemoteFolder = false;
|
||||
@@ -183,26 +186,11 @@ public class OCUpload implements Parcelable {
|
||||
public void setDataFixed(FileUploader.FileUploaderBinder binder) {
|
||||
fixedUploadStatus = uploadStatus;
|
||||
fixedUploadingNow = binder != null && binder.isUploadingNow(this);
|
||||
fixedUploadEndTimeStamp = uploadEndTimeStamp;
|
||||
fixedId = id;
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
public void setUploadId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getUploadId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uploadStatus
|
||||
*/
|
||||
public UploadStatus getUploadStatus() {
|
||||
return uploadStatus;
|
||||
fixedUploadEndTimeStamp = uploadEndTimestamp;
|
||||
fixedUploadId = uploadId;
|
||||
}
|
||||
|
||||
// custom Getters & Setters
|
||||
/**
|
||||
* Sets uploadStatus AND SETS lastResult = null;
|
||||
* @param uploadStatus the uploadStatus to set
|
||||
@@ -212,13 +200,6 @@ public class OCUpload implements Parcelable {
|
||||
setLastResult(UploadResult.UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastResult
|
||||
*/
|
||||
public UploadResult getLastResult() {
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastResult the lastResult to set
|
||||
*/
|
||||
@@ -226,44 +207,6 @@ public class OCUpload implements Parcelable {
|
||||
this.lastResult = lastResult != null ? lastResult : UploadResult.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the localPath
|
||||
*/
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the remotePath
|
||||
*/
|
||||
public String getRemotePath() {
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param remotePath the remotePath
|
||||
*/
|
||||
public void setRemotePath(String remotePath) {
|
||||
this.remotePath = remotePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return File size
|
||||
*/
|
||||
public long getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mimeType
|
||||
*/
|
||||
@@ -272,77 +215,12 @@ public class OCUpload implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the localAction
|
||||
*/
|
||||
public int getLocalAction() {
|
||||
return localAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param localAction the localAction to set
|
||||
*/
|
||||
public void setLocalAction(int localAction) {
|
||||
this.localAction = localAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forceOverwrite
|
||||
*/
|
||||
public boolean isForceOverwrite() {
|
||||
return forceOverwrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forceOverwrite the forceOverwrite to set
|
||||
*/
|
||||
public void setForceOverwrite(boolean forceOverwrite) {
|
||||
this.forceOverwrite = forceOverwrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isCreateRemoteFolder
|
||||
*/
|
||||
public boolean isCreateRemoteFolder() {
|
||||
return createRemoteFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createRemoteFolder the createRemoteFolder to set
|
||||
*/
|
||||
public void setCreateRemoteFolder(boolean createRemoteFolder) {
|
||||
this.createRemoteFolder = createRemoteFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the accountName
|
||||
*/
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns owncloud account as {@link Account} object.
|
||||
* Returns owncloud account as {@link Account} object.
|
||||
*/
|
||||
public Account getAccount(Context context) {
|
||||
return AccountUtils.getOwnCloudAccountByName(context, getAccountName());
|
||||
}
|
||||
|
||||
public void setCreatedBy(int createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public int getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setUploadEndTimestamp(long uploadEndTimestamp) {
|
||||
uploadEndTimeStamp = uploadEndTimestamp;
|
||||
}
|
||||
|
||||
public long getUploadEndTimestamp() {
|
||||
return uploadEndTimeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugging purposes only.
|
||||
*/
|
||||
@@ -373,36 +251,6 @@ public class OCUpload implements Parcelable {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the isUseWifiOnly
|
||||
*/
|
||||
public boolean isUseWifiOnly() {
|
||||
return useWifiOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param useWifiOnly the useWifiOnly to set
|
||||
*/
|
||||
public void setUseWifiOnly(boolean useWifiOnly) {
|
||||
this.useWifiOnly = useWifiOnly;
|
||||
}
|
||||
|
||||
public void setWhileChargingOnly(boolean whileChargingOnly) {
|
||||
this.whileChargingOnly = whileChargingOnly;
|
||||
}
|
||||
|
||||
public boolean isWhileChargingOnly() {
|
||||
return whileChargingOnly;
|
||||
}
|
||||
|
||||
public void setFolderUnlockToken(String token) {
|
||||
folderUnlockToken = token;
|
||||
}
|
||||
|
||||
public String getFolderUnlockToken() {
|
||||
return folderUnlockToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconstruct from parcel
|
||||
*
|
||||
@@ -413,7 +261,7 @@ public class OCUpload implements Parcelable {
|
||||
}
|
||||
|
||||
private void readFromParcel(Parcel source) {
|
||||
id = source.readLong();
|
||||
uploadId = source.readLong();
|
||||
localPath = source.readString();
|
||||
remotePath = source.readString();
|
||||
accountName = source.readString();
|
||||
@@ -425,7 +273,7 @@ public class OCUpload implements Parcelable {
|
||||
} catch (IllegalArgumentException x) {
|
||||
uploadStatus = UploadStatus.UPLOAD_IN_PROGRESS;
|
||||
}
|
||||
uploadEndTimeStamp = source.readLong();
|
||||
uploadEndTimestamp = source.readLong();
|
||||
try {
|
||||
lastResult = UploadResult.valueOf(source.readString());
|
||||
} catch (IllegalArgumentException x) {
|
||||
@@ -444,7 +292,7 @@ public class OCUpload implements Parcelable {
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(id);
|
||||
dest.writeLong(uploadId);
|
||||
dest.writeString(localPath);
|
||||
dest.writeString(remotePath);
|
||||
dest.writeString(accountName);
|
||||
@@ -452,7 +300,7 @@ public class OCUpload implements Parcelable {
|
||||
dest.writeInt(forceOverwrite ? 1 : 0);
|
||||
dest.writeInt(createRemoteFolder ? 1 : 0);
|
||||
dest.writeString(uploadStatus.name());
|
||||
dest.writeLong(uploadEndTimeStamp);
|
||||
dest.writeLong(uploadEndTimestamp);
|
||||
dest.writeString(lastResult == null ? "" : lastResult.name());
|
||||
dest.writeInt(createdBy);
|
||||
dest.writeInt(useWifiOnly ? 1 : 0);
|
||||
@@ -460,21 +308,5 @@ public class OCUpload implements Parcelable {
|
||||
dest.writeString(folderUnlockToken);
|
||||
}
|
||||
|
||||
public UploadStatus getFixedUploadStatus() {
|
||||
return fixedUploadStatus;
|
||||
}
|
||||
|
||||
public boolean isFixedUploadingNow() {
|
||||
return fixedUploadingNow;
|
||||
}
|
||||
|
||||
public long getFixedUploadEndTimestamp() {
|
||||
return fixedUploadEndTimeStamp;
|
||||
}
|
||||
|
||||
public Long getFixedUploadId() {
|
||||
return fixedId;
|
||||
}
|
||||
|
||||
enum CanUploadFileNowStatus {NOW, LATER, FILE_GONE, ERROR}
|
||||
}
|
||||
@@ -3,16 +3,16 @@
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -42,6 +42,7 @@ public final class PreferenceManager {
|
||||
* Value handled by the app without direct access in the UI.
|
||||
*/
|
||||
private static final String AUTO_PREF__LAST_UPLOAD_PATH = "last_upload_path";
|
||||
private static final String AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH = "upload_from_local_last_path";
|
||||
private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_MAP_URL = "prefs_upload_file_extension_map_url";
|
||||
private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_URL = "prefs_upload_file_extension_url";
|
||||
private static final String AUTO_PREF__UPLOADER_BEHAVIOR = "prefs_uploader_behaviour";
|
||||
@@ -64,6 +65,7 @@ public final class PreferenceManager {
|
||||
private static final String PREF__AUTO_UPLOAD_INIT = "autoUploadInit";
|
||||
private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
|
||||
private static final String PREF__FOLDER_LAYOUT = "folder_layout";
|
||||
public static final String PREF__LOCK_TIMESTAMP = "lock_timestamp";
|
||||
|
||||
private PreferenceManager() {
|
||||
}
|
||||
@@ -186,6 +188,27 @@ public final class PreferenceManager {
|
||||
saveStringPreference(context, AUTO_PREF__LAST_UPLOAD_PATH, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last local path where the user selected to do an upload from.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @return path Absolute path to a folder, as previously stored by
|
||||
* {@link #setUploadFromLocalLastPath(Context, String)}, or empty String if never saved before.
|
||||
*/
|
||||
public static String getUploadFromLocalLastPath(Context context) {
|
||||
return getDefaultSharedPreferences(context).getString(AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the path where the user selected to do the last local upload of a file from.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param path Absolute path to a folder.
|
||||
*/
|
||||
public static void setUploadFromLocalLastPath(Context context, String path) {
|
||||
saveStringPreference(context, AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lock preference configured by the user.
|
||||
*
|
||||
@@ -211,7 +234,7 @@ public final class PreferenceManager {
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to preferences manager.
|
||||
* @param folder Folder
|
||||
* @return preference value, default is
|
||||
* @return preference value, default is
|
||||
* {@link com.owncloud.android.ui.fragment.OCFileListFragment#FOLDER_LAYOUT_LIST}
|
||||
*/
|
||||
public static String getFolderLayout(Context context, OCFile folder) {
|
||||
@@ -235,19 +258,57 @@ public final class PreferenceManager {
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
|
||||
*/
|
||||
public static FileSortOrder getSortOrder(Context context, OCFile folder) {
|
||||
public static FileSortOrder getSortOrderByFolder(Context context, OCFile folder) {
|
||||
return FileSortOrder.sortOrders.get(getFolderPreference(context, PREF__FOLDER_SORT_ORDER, folder,
|
||||
FileSortOrder.sort_a_to_z.mName));
|
||||
FileSortOrder.sort_a_to_z.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preferred folder sort order.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param sortOrder the sort order
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param sortOrder the sort order
|
||||
*/
|
||||
public static void setSortOrder(Context context, OCFile folder, FileSortOrder sortOrder) {
|
||||
setFolderPreference(context, PREF__FOLDER_SORT_ORDER, folder, sortOrder.mName);
|
||||
setFolderPreference(context, PREF__FOLDER_SORT_ORDER, folder, sortOrder.name);
|
||||
}
|
||||
|
||||
public static FileSortOrder getSortOrderByType(Context context, FileSortOrder.Type type) {
|
||||
return getSortOrderByType(context, type, FileSortOrder.sort_a_to_z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preferred folder sort order.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
|
||||
*/
|
||||
public static FileSortOrder getSortOrderByType(Context context, FileSortOrder.Type type,
|
||||
FileSortOrder defaultOrder) {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
|
||||
if (account == null) {
|
||||
return defaultOrder;
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type);
|
||||
|
||||
return value.isEmpty() ? defaultOrder : FileSortOrder.sortOrders.get(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preferred folder sort order.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param sortOrder the sort order
|
||||
*/
|
||||
public static void setSortOrder(Context context, FileSortOrder.Type type, FileSortOrder sortOrder) {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
dataProvider.storeOrUpdateKeyValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,14 +328,14 @@ public final class PreferenceManager {
|
||||
if (account == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
FileDataStorageManager storageManager = ((ComponentsGetter)context).getStorageManager();
|
||||
|
||||
if (storageManager == null) {
|
||||
storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
}
|
||||
|
||||
|
||||
String value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, folder));
|
||||
while (folder != null && value.isEmpty()) {
|
||||
folder = storageManager.getFileById(folder.getParentId());
|
||||
@@ -283,6 +344,29 @@ public final class PreferenceManager {
|
||||
return value.isEmpty() ? defaultValue : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preference value for a view.
|
||||
*
|
||||
* @param context Context object.
|
||||
* @param preferenceName Name of the preference to lookup.
|
||||
* @param type view which view
|
||||
* @param defaultValue Fallback value in case nothing is set.
|
||||
* @return Preference value
|
||||
*/
|
||||
public static String getTypePreference(Context context, String preferenceName, String type, String defaultValue) {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
|
||||
if (account == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(account.name, preferenceName + "_" + type);
|
||||
|
||||
return value.isEmpty() ? defaultValue : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preference value for a folder.
|
||||
*
|
||||
@@ -300,7 +384,7 @@ public final class PreferenceManager {
|
||||
private static String getKeyFromFolder(String preferenceName, OCFile folder) {
|
||||
final String folderIdString = String.valueOf(folder != null ? folder.getFileId() :
|
||||
FileDataStorageManager.ROOT_PARENT_ID);
|
||||
|
||||
|
||||
return preferenceName + "_" + folderIdString;
|
||||
}
|
||||
|
||||
@@ -449,6 +533,14 @@ public final class PreferenceManager {
|
||||
saveIntPreference(context, AUTO_PREF__LAST_SEEN_VERSION_CODE, versionCode);
|
||||
}
|
||||
|
||||
public static long getLockTimestamp(Context context) {
|
||||
return getDefaultSharedPreferences(context).getLong(PREF__LOCK_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
public static void setLockTimestamp(Context context, long timestamp) {
|
||||
saveLongPreference(context, PREF__LOCK_TIMESTAMP, timestamp);
|
||||
}
|
||||
|
||||
private static void saveBooleanPreference(Context context, String key, boolean value) {
|
||||
SharedPreferences.Editor appPreferences = getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
||||
appPreferences.putBoolean(key, value).apply();
|
||||
@@ -475,6 +567,11 @@ public final class PreferenceManager {
|
||||
appPreferences.putFloat(key, value).apply();
|
||||
}
|
||||
|
||||
private static void saveLongPreference(Context context, String key, long value) {
|
||||
SharedPreferences.Editor appPreferences = getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
||||
appPreferences.putLong(key, value).apply();
|
||||
}
|
||||
|
||||
public static SharedPreferences getDefaultSharedPreferences(Context context) {
|
||||
return android.preference.PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.owncloud.android.MainApp;
|
||||
public class ProviderMeta {
|
||||
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 34;
|
||||
public static final int DB_VERSION = 42;
|
||||
|
||||
private ProviderMeta() {
|
||||
}
|
||||
@@ -92,6 +92,7 @@ public class ProviderMeta {
|
||||
public static final String FILE_LAST_SYNC_DATE_FOR_DATA = "last_sync_date_for_data";
|
||||
public static final String FILE_KEEP_IN_SYNC = "keep_in_sync";
|
||||
public static final String FILE_ETAG = "etag";
|
||||
public static final String FILE_ETAG_ON_SERVER = "etag_on_server";
|
||||
public static final String FILE_SHARED_VIA_LINK = "share_by_link";
|
||||
public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";
|
||||
public static final String FILE_PUBLIC_LINK = "public_link";
|
||||
@@ -103,13 +104,17 @@ public class ProviderMeta {
|
||||
public static final String FILE_FAVORITE = "favorite";
|
||||
public static final String FILE_IS_ENCRYPTED = "is_encrypted";
|
||||
public static final String FILE_MOUNT_TYPE = "mount_type";
|
||||
public static final String FILE_HAS_PREVIEW = "has_preview";
|
||||
public static final String FILE_UNREAD_COMMENTS_COUNT = "unread_comments_count";
|
||||
|
||||
public static final String [] FILE_ALL_COLUMNS = {_ID, FILE_PARENT, FILE_NAME
|
||||
, FILE_CREATION, FILE_MODIFIED,
|
||||
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, FILE_CONTENT_LENGTH, FILE_CONTENT_TYPE, FILE_STORAGE_PATH,
|
||||
FILE_PATH, FILE_ACCOUNT_OWNER, FILE_LAST_SYNC_DATE, FILE_LAST_SYNC_DATE_FOR_DATA, FILE_KEEP_IN_SYNC,
|
||||
FILE_ETAG, FILE_SHARED_VIA_LINK, FILE_SHARED_WITH_SHAREE, FILE_PUBLIC_LINK, FILE_PERMISSIONS,
|
||||
FILE_REMOTE_ID, FILE_UPDATE_THUMBNAIL, FILE_IS_DOWNLOADING, FILE_ETAG_IN_CONFLICT, FILE_FAVORITE};
|
||||
public static final String[] FILE_ALL_COLUMNS = {
|
||||
_ID, FILE_PARENT, FILE_NAME, FILE_CREATION, FILE_MODIFIED,
|
||||
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, FILE_CONTENT_LENGTH, FILE_CONTENT_TYPE, FILE_STORAGE_PATH,
|
||||
FILE_PATH, FILE_ACCOUNT_OWNER, FILE_LAST_SYNC_DATE, FILE_LAST_SYNC_DATE_FOR_DATA, FILE_ETAG,
|
||||
FILE_ETAG_ON_SERVER, FILE_SHARED_VIA_LINK, FILE_SHARED_WITH_SHAREE, FILE_PUBLIC_LINK, FILE_PERMISSIONS,
|
||||
FILE_REMOTE_ID, FILE_UPDATE_THUMBNAIL, FILE_IS_DOWNLOADING, FILE_ETAG_IN_CONFLICT, FILE_FAVORITE,
|
||||
FILE_IS_ENCRYPTED, FILE_MOUNT_TYPE, FILE_HAS_PREVIEW, FILE_UNREAD_COMMENTS_COUNT
|
||||
};
|
||||
|
||||
public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc";
|
||||
|
||||
@@ -129,6 +134,8 @@ public class ProviderMeta {
|
||||
public static final String OCSHARES_ID_REMOTE_SHARED = "id_remote_shared";
|
||||
public static final String OCSHARES_ACCOUNT_OWNER = "owner_share";
|
||||
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_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE
|
||||
+ " collate nocase asc";
|
||||
@@ -169,9 +176,12 @@ public class ProviderMeta {
|
||||
public static final String CAPABILITIES_SERVER_SLOGAN = "server_slogan";
|
||||
public static final String CAPABILITIES_SERVER_BACKGROUND_DEFAULT = "background_default";
|
||||
public static final String CAPABILITIES_SERVER_BACKGROUND_PLAIN = "background_plain";
|
||||
|
||||
public static final String CAPABILITIES_END_TO_END_ENCRYPTION = "end_to_end_encryption";
|
||||
public static final String CAPABILITIES_ACTIVITY = "activity";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT = "richdocument";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST = "richdocument_mimetype_list";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING = "richdocument_direct_editing";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT_TEMPLATES = "richdocument_direct_templates";
|
||||
|
||||
public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
|
||||
+ " collate nocase asc";
|
||||
|
||||
@@ -27,15 +27,17 @@ import android.os.Parcelable;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
* @author Tobias Kaminsky
|
||||
*/
|
||||
public class FeatureItem implements Parcelable {
|
||||
private static final int DO_NOT_SHOW = -1;
|
||||
private int image;
|
||||
private int titleText;
|
||||
private int contentText;
|
||||
@Getter private int image;
|
||||
@Getter private int titleText;
|
||||
@Getter private int contentText;
|
||||
private boolean contentCentered;
|
||||
private boolean bulletList;
|
||||
|
||||
@@ -51,26 +53,14 @@ public class FeatureItem implements Parcelable {
|
||||
return image != DO_NOT_SHOW;
|
||||
}
|
||||
|
||||
public int getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public boolean shouldShowTitleText() {
|
||||
return titleText != DO_NOT_SHOW && titleText != R.string.empty;
|
||||
}
|
||||
|
||||
public int getTitleText() {
|
||||
return titleText;
|
||||
}
|
||||
|
||||
public boolean shouldShowContentText() {
|
||||
return contentText != DO_NOT_SHOW && contentText != R.string.empty;
|
||||
}
|
||||
|
||||
public int getContentText() {
|
||||
return contentText;
|
||||
}
|
||||
|
||||
public boolean shouldContentCentered() {
|
||||
return contentCentered;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.files;
|
||||
|
||||
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.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateFileFromTemplateOperation extends RemoteOperation {
|
||||
private static final String TAG = CreateFileFromTemplateOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String NEW_FROM_TEMPLATE_URL = "/ocs/v2.php/apps/richdocuments/api/v1/templates/new";
|
||||
|
||||
private String path;
|
||||
private int templateId;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public CreateFileFromTemplateOperation(String path, int templateId) {
|
||||
this.path = path;
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
|
||||
postMethod = new PostMethod(client.getBaseUri() + NEW_FROM_TEMPLATE_URL + JSON_FORMAT);
|
||||
postMethod.setParameter("path", path);
|
||||
postMethod.setParameter("template", String.valueOf(templateId));
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString("url");
|
||||
|
||||
ArrayList<Object> templateArray = new ArrayList<>();
|
||||
templateArray.add(url);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setData(templateArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Create file from template " + templateId + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.files;
|
||||
|
||||
import com.owncloud.android.datamodel.Template;
|
||||
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.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.ChooseTemplateDialogFragment;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FetchTemplateOperation extends RemoteOperation {
|
||||
private static final String TAG = FetchTemplateOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String TEMPLATE_URL = "/ocs/v2.php/apps/richdocuments/api/v1/templates/";
|
||||
|
||||
private ChooseTemplateDialogFragment.Type type;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public FetchTemplateOperation(ChooseTemplateDialogFragment.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
GetMethod getMethod = null;
|
||||
|
||||
try {
|
||||
|
||||
getMethod = new GetMethod(client.getBaseUri() + TEMPLATE_URL + type.toString().toLowerCase(Locale.ENGLISH) +
|
||||
JSON_FORMAT);
|
||||
|
||||
// remote request
|
||||
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(getMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = getMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
JSONArray templates = respJSON.getJSONObject(NODE_OCS).getJSONArray(NODE_DATA);
|
||||
|
||||
ArrayList<Object> templateArray = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < templates.length(); i++) {
|
||||
JSONObject templateObject = templates.getJSONObject(i);
|
||||
|
||||
templateArray.add(new Template(templateObject.getInt("id"),
|
||||
templateObject.getString("name"),
|
||||
templateObject.optString("preview"),
|
||||
templateObject.getString("type"),
|
||||
templateObject.getString("extension")));
|
||||
}
|
||||
|
||||
result = new RemoteOperationResult(true, getMethod);
|
||||
result.setData(templateArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, getMethod);
|
||||
client.exhaustResponse(getMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Get templates for typ " + type + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (getMethod != null) {
|
||||
getMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.ui.activity.RichDocumentsWebView;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -44,7 +45,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Filters out the file actions available in a given {@link Menu} for a given {@link OCFile}
|
||||
* according to the current state of the latest.
|
||||
* according to the current state of the latest.
|
||||
*/
|
||||
public class FileMenuFilter {
|
||||
|
||||
@@ -177,19 +178,19 @@ public class FileMenuFilter {
|
||||
filterSync(toShow, toHide, synchronizing);
|
||||
filterShareFile(toShow, toHide, capability);
|
||||
filterDetails(toShow, toHide);
|
||||
filterKeepAvailableOffline(toShow, toHide, synchronizing);
|
||||
filterDontKeepAvailableOffline(toShow, toHide, synchronizing);
|
||||
filterFavorite(toShow, toHide, synchronizing);
|
||||
filterUnfavorite(toShow, toHide, synchronizing);
|
||||
filterEncrypt(toShow, toHide, endToEndEncryptionEnabled);
|
||||
filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
|
||||
filterSetPictureAs(toShow, toHide);
|
||||
filterStream(toShow, toHide);
|
||||
filterOpenAsRichDocument(toShow, toHide, capability);
|
||||
}
|
||||
|
||||
private void filterShareFile(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
||||
if (containsEncryptedFile() || (!isShareViaLinkAllowed() && !isShareWithUsersAllowed()) ||
|
||||
!isSingleSelection() || !isShareApiEnabled(capability) || mOverflowMenu) {
|
||||
!isSingleSelection() || !isShareApiEnabled(capability) || !mFiles.iterator().next().canReshare()
|
||||
|| mOverflowMenu) {
|
||||
toHide.add(R.id.action_send_share_file);
|
||||
} else {
|
||||
toShow.add(R.id.action_send_share_file);
|
||||
@@ -204,22 +205,6 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterKeepAvailableOffline(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (!allFiles() || synchronizing || allKeptAvailableOffline()) {
|
||||
toHide.add(R.id.action_keep_files_offline);
|
||||
} else {
|
||||
toShow.add(R.id.action_keep_files_offline);
|
||||
}
|
||||
}
|
||||
|
||||
private void filterDontKeepAvailableOffline(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (!allFiles() || synchronizing || allNotKeptAvailableOffline()) {
|
||||
toHide.add(R.id.action_unset_keep_files_offline);
|
||||
} else {
|
||||
toShow.add(R.id.action_unset_keep_files_offline);
|
||||
}
|
||||
}
|
||||
|
||||
private void filterFavorite(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (mFiles.isEmpty() || synchronizing || allFavorites()) {
|
||||
toHide.add(R.id.action_favorite);
|
||||
@@ -262,6 +247,16 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterOpenAsRichDocument(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
||||
if (isSingleFile() && android.os.Build.VERSION.SDK_INT >= RichDocumentsWebView.MINIMUM_API &&
|
||||
capability.getRichDocumentsMimeTypeList().contains(mFiles.iterator().next().getMimeType()) &&
|
||||
capability.getRichDocumentsDirectEditing().isTrue()) {
|
||||
toShow.add(R.id.action_open_file_as_richdocument);
|
||||
} else {
|
||||
toHide.add(R.id.action_open_file_as_richdocument);
|
||||
}
|
||||
}
|
||||
|
||||
private void filterSync(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (mFiles.isEmpty() || (!anyFileDown() && !containsFolder()) || synchronizing) {
|
||||
toHide.add(R.id.action_sync_file);
|
||||
@@ -484,18 +479,9 @@ public class FileMenuFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allKeptAvailableOffline() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (!file.isAvailableOffline()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean allFavorites() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (!file.getIsFavorite()) {
|
||||
if (!file.isFavorite()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -504,16 +490,7 @@ public class FileMenuFilter {
|
||||
|
||||
private boolean allNotFavorites() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (file.getIsFavorite()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean allNotKeptAvailableOffline() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (file.isAvailableOffline()) {
|
||||
if (file.isFavorite()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
@@ -70,6 +69,8 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
public class FileDownloader extends Service
|
||||
implements OnDatatransferProgressListener, OnAccountsUpdateListener {
|
||||
|
||||
@@ -321,10 +322,7 @@ public class FileDownloader extends Service
|
||||
* @param file A file that could be in the queue of downloads.
|
||||
*/
|
||||
public boolean isDownloading(Account account, OCFile file) {
|
||||
if (account == null || file == null) {
|
||||
return false;
|
||||
}
|
||||
return (mPendingDownloads.contains(account.name, file.getRemotePath()));
|
||||
return account != null && file != null && mPendingDownloads.contains(account.name, file.getRemotePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -495,11 +493,11 @@ public class FileDownloader extends Service
|
||||
long syncDate = System.currentTimeMillis();
|
||||
file.setLastSyncDateForProperties(syncDate);
|
||||
file.setLastSyncDateForData(syncDate);
|
||||
file.setNeedsUpdateThumbnail(true);
|
||||
file.setUpdateThumbnailNeeded(true);
|
||||
file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp());
|
||||
file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp());
|
||||
file.setEtag(mCurrentDownload.getEtag());
|
||||
file.setMimetype(mCurrentDownload.getMimeType());
|
||||
file.setMimeType(mCurrentDownload.getMimeType());
|
||||
file.setStoragePath(mCurrentDownload.getSavePath());
|
||||
file.setFileLength(new File(mCurrentDownload.getSavePath()).length());
|
||||
file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
|
||||
@@ -531,7 +529,7 @@ public class FileDownloader extends Service
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
|
||||
}
|
||||
|
||||
|
||||
/// includes a pending intent in the notification showing the details view of the file
|
||||
Intent showDetailsIntent = null;
|
||||
if (PreviewImageFragment.canBePreviewed(download.getFile())) {
|
||||
@@ -572,7 +570,7 @@ public class FileDownloader extends Service
|
||||
if (mNotificationManager == null) {
|
||||
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
if (mNotificationManager != null) {
|
||||
mNotificationManager.notify(R.string.downloader_download_in_progress_ticker,
|
||||
mNotificationBuilder.build());
|
||||
@@ -599,8 +597,8 @@ public class FileDownloader extends Service
|
||||
}
|
||||
|
||||
if (!downloadResult.isCancelled()) {
|
||||
int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker :
|
||||
R.string.downloader_download_failed_ticker;
|
||||
int tickerId = downloadResult.isSuccess() ?
|
||||
R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
|
||||
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(downloadResult.getCode());
|
||||
tickerId = needsToUpdateCredentials ?
|
||||
|
||||
@@ -42,7 +42,6 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Process;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.evernote.android.job.JobRequest;
|
||||
@@ -84,6 +83,8 @@ import java.util.Vector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
/**
|
||||
* Service for uploading files. Invoke using context.startService(...).
|
||||
*
|
||||
@@ -525,7 +526,7 @@ public class FileUploader extends Service
|
||||
Log_OC.d(TAG, "Starting command with id " + startId);
|
||||
|
||||
startForeground(FOREGROUND_SERVICE_ID, mNotification);
|
||||
|
||||
|
||||
if (intent == null) {
|
||||
Log_OC.e(TAG, "Intent is null");
|
||||
return Service.START_NOT_STICKY;
|
||||
@@ -961,15 +962,15 @@ public class FileUploader extends Service
|
||||
totalToTransfer, fileName);
|
||||
|
||||
if (MainApp.getAppContext() != null) {
|
||||
if (mCurrentUpload.getIsWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
|
||||
if (mCurrentUpload.isWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
|
||||
equals(JobRequest.NetworkType.UNMETERED)) {
|
||||
cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
|
||||
, ResultCode.DELAYED_FOR_WIFI);
|
||||
} else if (mCurrentUpload.getIsChargingRequired() &&
|
||||
} else if (mCurrentUpload.isChargingRequired() &&
|
||||
!Device.getBatteryStatus(MainApp.getAppContext()).isCharging()) {
|
||||
cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
|
||||
, ResultCode.DELAYED_FOR_CHARGING);
|
||||
} else if (!mCurrentUpload.getIsIgnoringPowerSaveMode() &&
|
||||
} else if (!mCurrentUpload.isIgnoringPowerSaveMode() &&
|
||||
PowerUtils.isPowerSaveMode(MainApp.getAppContext())) {
|
||||
cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
|
||||
, ResultCode.DELAYED_IN_POWER_SAVE_MODE);
|
||||
@@ -1166,7 +1167,7 @@ public class FileUploader extends Service
|
||||
if (mNotificationManager == null) {
|
||||
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
|
||||
} // else wait until the upload really start (onTransferProgress is called), so that if it's discarded
|
||||
// due to lack of Wifi, no notification is shown
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
@@ -50,6 +49,8 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import static android.content.Context.ACCOUNT_SERVICE;
|
||||
import static com.owncloud.android.ui.activity.ManageAccountsActivity.PENDING_FOR_REMOVAL;
|
||||
|
||||
@@ -119,7 +120,7 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
|
||||
filesystemDataProvider.deleteAllEntriesForSyncedFolder(Long.toString(syncedFolderId));
|
||||
}
|
||||
|
||||
// delete stored E2E keys
|
||||
// delete stored E2E keys
|
||||
arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PRIVATE_KEY);
|
||||
arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PUBLIC_KEY);
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.format.DateFormat;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
@@ -56,6 +55,8 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Job that backup contacts to /Contacts-Backup and deletes files older than x days
|
||||
*/
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
* Copyright (C) 2017 Nextcloud GmbH.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -24,7 +24,6 @@ package com.owncloud.android.jobs;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
@@ -38,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import ezvcard.Ezvcard;
|
||||
import ezvcard.VCard;
|
||||
import third_parties.ezvcard_android.ContactOperations;
|
||||
@@ -88,8 +88,8 @@ public class ContactsImportJob extends Job {
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
VCard vCard = vCards.get(intArray[i]);
|
||||
for (int checkedItem : intArray) {
|
||||
VCard vCard = vCards.get(checkedItem);
|
||||
if (ContactListFragment.getDisplayName(vCard).length() != 0) {
|
||||
if (!ownContactList.containsKey(vCard)) {
|
||||
operations.insertContact(vCard);
|
||||
|
||||
@@ -27,8 +27,6 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.media.ExifInterface;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
@@ -58,6 +56,9 @@ import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
/*
|
||||
Job that:
|
||||
- restarts existing jobs if required
|
||||
@@ -68,6 +69,7 @@ public class FilesSyncJob extends Job {
|
||||
public static final String TAG = "FilesSyncJob";
|
||||
public static final String SKIP_CUSTOM = "skipCustom";
|
||||
public static final String OVERRIDE_POWER_SAVING = "overridePowerSaving";
|
||||
private static final String WAKELOCK_TAG_SEPARATION = ":";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -77,8 +79,9 @@ public class FilesSyncJob extends Job {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
||||
wakeLock.acquire();
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG);
|
||||
wakeLock.acquire(10 * 60 * 1000);
|
||||
}
|
||||
|
||||
PersistableBundleCompat bundle = params.getExtras();
|
||||
@@ -130,18 +133,23 @@ public class FilesSyncJob extends Job {
|
||||
Integer uploadAction;
|
||||
boolean needsCharging;
|
||||
boolean needsWifi;
|
||||
File file;
|
||||
ArbitraryDataProvider arbitraryDataProvider;
|
||||
Account account = AccountUtils.getOwnCloudAccountByName(context, syncedFolder.getAccount());
|
||||
|
||||
if (lightVersion) {
|
||||
arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
} else {
|
||||
arbitraryDataProvider = null;
|
||||
}
|
||||
|
||||
for (String path : filesystemDataProvider.getFilesForUpload(syncedFolder.getLocalPath(),
|
||||
Long.toString(syncedFolder.getId()))) {
|
||||
File file = new File(path);
|
||||
file = new File(path);
|
||||
Long lastModificationTime = calculateLastModificationTime(file, syncedFolder, sFormatter);
|
||||
String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.getAbsolutePath());
|
||||
|
||||
if (lightVersion) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(
|
||||
context.getContentResolver());
|
||||
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging);
|
||||
needsWifi = account == null || arbitraryDataProvider.getBooleanValue(account.name,
|
||||
Preferences.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
|
||||
|
||||
@@ -30,8 +30,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.media.RingtoneManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
@@ -51,6 +49,9 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
public class MediaFoldersDetectionJob extends Job {
|
||||
public static final String TAG = "MediaFoldersDetectionJob";
|
||||
|
||||
@@ -71,10 +72,8 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
String arbitraryDataString;
|
||||
MediaFoldersModel mediaFoldersModel;
|
||||
|
||||
List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1,
|
||||
null, true);
|
||||
List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null,
|
||||
true);
|
||||
List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true);
|
||||
List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true);
|
||||
|
||||
List<String> imageMediaFolderPaths = new ArrayList<>();
|
||||
List<String> videoMediaFolderPaths = new ArrayList<>();
|
||||
@@ -109,24 +108,22 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
|
||||
for (Account account : accountList) {
|
||||
for (String imageMediaFolder : imageMediaFolderPaths) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder,
|
||||
account) == null) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder, account) == null) {
|
||||
sendNotification(String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_photos)),
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1,
|
||||
imageMediaFolder.length()),
|
||||
account, imageMediaFolder, 1);
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1
|
||||
),
|
||||
account, imageMediaFolder, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (String videoMediaFolder : videoMediaFolderPaths) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder,
|
||||
account) == null) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder, account) == null) {
|
||||
sendNotification(String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos)),
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1,
|
||||
videoMediaFolder.length()),
|
||||
account, videoMediaFolder, 2);
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1
|
||||
),
|
||||
account, videoMediaFolder, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,14 +131,14 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
|
||||
} else {
|
||||
mediaFoldersModel = new 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;
|
||||
}
|
||||
|
||||
private void sendNotification(String contentTitle, String subtitle, Account account,
|
||||
String path, int type) {
|
||||
private void sendNotification(String contentTitle, String subtitle, Account account, String path, int type) {
|
||||
Context context = getContext();
|
||||
Intent intent = new Intent(getContext(), SyncedFoldersActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
@@ -24,7 +24,6 @@ package com.owncloud.android.jobs;
|
||||
import android.app.job.JobParameters;
|
||||
import android.app.job.JobService;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.evernote.android.job.JobRequest;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
@@ -32,6 +31,8 @@ import com.owncloud.android.datamodel.SyncedFolderProvider;
|
||||
import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.PowerUtils;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
/*
|
||||
Job that triggers new FilesSyncJob in case new photo or video were detected
|
||||
and starts a job to find new media folders
|
||||
|
||||
@@ -27,8 +27,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.media.RingtoneManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
@@ -51,6 +49,9 @@ import java.security.PrivateKey;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
public class NotificationJob extends Job {
|
||||
public static final String TAG = "NotificationJob";
|
||||
|
||||
|
||||
@@ -21,11 +21,8 @@ package com.owncloud.android.jobs;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.JobManager;
|
||||
@@ -35,26 +32,28 @@ import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.ProviderMeta;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.CheckEtagRemoteOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||
import com.owncloud.android.ui.activity.ConflictsResolveActivity;
|
||||
import com.owncloud.android.utils.ConnectivityUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.PowerUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class OfflineSyncJob extends Job {
|
||||
public static final String TAG = "OfflineSyncJob";
|
||||
|
||||
private List<OfflineFile> offlineFileList = new ArrayList<>();
|
||||
private static final String WAKELOCK_TAG_SEPARATION = ":";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Result onRunJob(@NonNull Params params) {
|
||||
final Context context = MainApp.getAppContext();
|
||||
final Context context = getContext();
|
||||
|
||||
PowerManager.WakeLock wakeLock = null;
|
||||
if (!PowerUtils.isPowerSaveMode(context) &&
|
||||
@@ -69,57 +68,27 @@ public class OfflineSyncJob extends Job {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
||||
wakeLock.acquire();
|
||||
|
||||
if (powerManager != null) {
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG);
|
||||
wakeLock.acquire(10 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Cursor cursorOnKeptInSync = context.getContentResolver().query(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.FILE_KEEP_IN_SYNC + " = ?",
|
||||
new String[]{String.valueOf(1)},
|
||||
null
|
||||
);
|
||||
Account[] accounts = AccountUtils.getAccounts(context);
|
||||
|
||||
if (cursorOnKeptInSync != null) {
|
||||
if (cursorOnKeptInSync.moveToFirst()) {
|
||||
for (Account account : accounts) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account,
|
||||
getContext().getContentResolver());
|
||||
|
||||
String localPath = "";
|
||||
String accountName = "";
|
||||
Account account = null;
|
||||
do {
|
||||
localPath = cursorOnKeptInSync.getString(cursorOnKeptInSync
|
||||
.getColumnIndex(ProviderMeta.ProviderTableMeta.FILE_STORAGE_PATH));
|
||||
accountName = cursorOnKeptInSync.getString(cursorOnKeptInSync
|
||||
.getColumnIndex(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER));
|
||||
|
||||
account = new Account(accountName, MainApp.getAccountType(getContext()));
|
||||
if (!AccountUtils.exists(account, context) || localPath == null || localPath.length() <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
offlineFileList.add(new OfflineFile(localPath, account));
|
||||
|
||||
} while (cursorOnKeptInSync.moveToNext());
|
||||
OCFile ocRoot = storageManager.getFileByPath("/");
|
||||
|
||||
if (ocRoot.getStoragePath() == null) {
|
||||
break;
|
||||
}
|
||||
cursorOnKeptInSync.close();
|
||||
}
|
||||
|
||||
FileDataStorageManager storageManager;
|
||||
for (OfflineFile offlineFile : offlineFileList) {
|
||||
storageManager = new FileDataStorageManager(offlineFile.getAccount(), context.getContentResolver());
|
||||
OCFile file = storageManager.getFileByLocalPath(offlineFile.getLocalPath());
|
||||
SynchronizeFileOperation sfo =
|
||||
new SynchronizeFileOperation(file, null, offlineFile.getAccount(), true, context);
|
||||
RemoteOperationResult result = sfo.execute(storageManager, context);
|
||||
if (result.getCode() == RemoteOperationResult.ResultCode.SYNC_CONFLICT) {
|
||||
Intent i = new Intent(context, ConflictsResolveActivity.class);
|
||||
i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.putExtra(ConflictsResolveActivity.EXTRA_FILE, file);
|
||||
i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, offlineFile.getAccount());
|
||||
context.startActivity(i);
|
||||
}
|
||||
recursive(new File(ocRoot.getStoragePath()), storageManager, account);
|
||||
}
|
||||
|
||||
if (wakeLock != null) {
|
||||
@@ -130,30 +99,72 @@ public class OfflineSyncJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void recursive(File folder, FileDataStorageManager storageManager, Account account) {
|
||||
String downloadFolder = FileStorageUtils.getSavePath(account.name);
|
||||
String folderName = folder.getAbsolutePath().replaceFirst(downloadFolder, "") + "/";
|
||||
Log_OC.d(TAG, folderName + ": enter");
|
||||
|
||||
private class OfflineFile {
|
||||
private String localPath;
|
||||
private Account account;
|
||||
|
||||
private OfflineFile(String localPath, Account account) {
|
||||
this.localPath = localPath;
|
||||
this.account = account;
|
||||
// exit
|
||||
if (folder.listFiles() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
OCFile ocFolder = storageManager.getFileByPath(folderName);
|
||||
Log_OC.d(TAG, folderName + ": currentEtag: " + ocFolder.getEtag());
|
||||
|
||||
// check for etag change, if false, skip
|
||||
CheckEtagRemoteOperation checkEtagOperation = new CheckEtagRemoteOperation(ocFolder.getRemotePath(),
|
||||
ocFolder.getEtagOnServer());
|
||||
RemoteOperationResult result = checkEtagOperation.execute(account, getContext());
|
||||
|
||||
// eTag changed, sync file
|
||||
switch (result.getCode()) {
|
||||
case ETAG_UNCHANGED:
|
||||
Log_OC.d(TAG, folderName + ": eTag unchanged");
|
||||
return;
|
||||
|
||||
case FILE_NOT_FOUND:
|
||||
boolean removalResult = storageManager.removeFolder(ocFolder, true, true);
|
||||
if (!removalResult) {
|
||||
Log_OC.e(TAG, "removal of " + ocFolder.getStoragePath() + " failed: file not found");
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
case ETAG_CHANGED:
|
||||
Log_OC.d(TAG, folderName + ": eTag changed");
|
||||
break;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
// iterate over downloaded files
|
||||
File[] files = folder.listFiles(File::isFile);
|
||||
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
OCFile ocFile = storageManager.getFileByLocalPath(file.getPath());
|
||||
SynchronizeFileOperation synchronizeFileOperation = new SynchronizeFileOperation(ocFile.getRemotePath(),
|
||||
account, true, getContext());
|
||||
|
||||
synchronizeFileOperation.execute(storageManager, getContext());
|
||||
}
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return account;
|
||||
// recursive into folder
|
||||
File[] subfolders = folder.listFiles(File::isDirectory);
|
||||
|
||||
if (subfolders != null) {
|
||||
for (File subfolder : subfolders) {
|
||||
recursive(subfolder, storageManager, account);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
// update eTag
|
||||
try {
|
||||
String updatedEtag = (String) result.getData().get(0);
|
||||
ocFolder.setEtagOnServer(updatedEtag);
|
||||
storageManager.saveFile(ocFolder);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Failed to update etag on " + folder.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import android.net.wifi.WifiManager.WifiLock;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
@@ -61,9 +60,11 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
|
||||
/**
|
||||
* Service that handles media playback, both audio and video.
|
||||
* Service that handles media playback, both audio and video.
|
||||
*
|
||||
* Waits for Intents which signal the service to perform specific operations: Play, Pause,
|
||||
* Rewind, etc.
|
||||
@@ -181,14 +182,14 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
} else if (extra == MediaPlayer.MEDIA_ERROR_IO) {
|
||||
/* Added in API level 17
|
||||
File or network related operation errors.
|
||||
Constant Value: -1004 (0xfffffc14)
|
||||
Constant Value: -1004 (0xfffffc14)
|
||||
*/
|
||||
messageId = R.string.media_err_io;
|
||||
|
||||
} else if (extra == MediaPlayer.MEDIA_ERROR_MALFORMED) {
|
||||
/* Added in API level 17
|
||||
Bitstream is not conforming to the related coding standard or file spec.
|
||||
Constant Value: -1007 (0xfffffc11)
|
||||
Constant Value: -1007 (0xfffffc11)
|
||||
*/
|
||||
messageId = R.string.media_err_malformed;
|
||||
|
||||
@@ -217,7 +218,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
Added in API level 1
|
||||
Media server died. In this case, the application must release the MediaPlayer
|
||||
object and instantiate a new one.
|
||||
Constant Value: 100 (0x00000064)
|
||||
Constant Value: 100 (0x00000064)
|
||||
*/
|
||||
messageId = R.string.media_err_unknown;
|
||||
}
|
||||
@@ -268,9 +269,9 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
/**
|
||||
* Processes a request to play a media file received as a parameter
|
||||
*
|
||||
* TODO If a new request is received when a file is being prepared, it is ignored. Is this what we want?
|
||||
* TODO If a new request is received when a file is being prepared, it is ignored. Is this what we want?
|
||||
*
|
||||
* @param intent Intent received in the request with the data to identify the file to play.
|
||||
* @param intent Intent received in the request with the data to identify the file to play.
|
||||
*/
|
||||
private void processPlayFileRequest(Intent intent) {
|
||||
if (mState != State.PREPARING) {
|
||||
@@ -327,7 +328,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request to pause the current playback
|
||||
* Processes a request to pause the current playback
|
||||
*/
|
||||
protected void processPauseRequest() {
|
||||
if (mState == State.PLAYING) {
|
||||
@@ -393,7 +394,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
|
||||
|
||||
/**
|
||||
* Reconfigures MediaPlayer according to audio focus settings and starts/restarts it.
|
||||
* Reconfigures MediaPlayer according to audio focus settings and starts/restarts it.
|
||||
*/
|
||||
protected void configAndStartMediaPlayer() {
|
||||
if (mPlayer == null) {
|
||||
@@ -421,7 +422,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
|
||||
|
||||
/**
|
||||
* Requests the audio focus to the Audio Manager
|
||||
* Requests the audio focus to the Audio Manager
|
||||
*/
|
||||
private void tryToGetAudioFocus() {
|
||||
if (mAudioFocus != AudioFocus.FOCUS
|
||||
@@ -436,7 +437,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
|
||||
|
||||
/**
|
||||
* Starts playing the current media file.
|
||||
* Starts playing the current media file.
|
||||
*/
|
||||
protected void playMedia() {
|
||||
mState = State.STOPPED;
|
||||
@@ -501,7 +502,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
|
||||
|
||||
/**
|
||||
* Called when media player is done preparing.
|
||||
* Called when media player is done preparing.
|
||||
*
|
||||
* Time to start.
|
||||
*/
|
||||
@@ -589,7 +590,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when there's an error playing media.
|
||||
* Called when there's an error playing media.
|
||||
*
|
||||
* Warns the user about the error and resets the media player.
|
||||
*/
|
||||
@@ -646,7 +647,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
|
||||
|
||||
/**
|
||||
* Provides a binder object that clients can use to perform operations on the MediaPlayer managed by the MediaService.
|
||||
* Provides a binder object that clients can use to perform operations on the MediaPlayer managed by the MediaService.
|
||||
*/
|
||||
@Override
|
||||
public IBinder onBind(Intent arg) {
|
||||
@@ -671,7 +672,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
/**
|
||||
* Accesses the current MediaPlayer instance in the service.
|
||||
*
|
||||
* To be handled carefully. Visibility is protected to be accessed only
|
||||
* To be handled carefully. Visibility is protected to be accessed only
|
||||
*
|
||||
* @return Current MediaPlayer instance handled by MediaService.
|
||||
*/
|
||||
|
||||
@@ -21,38 +21,18 @@
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Restore a {@link com.owncloud.android.lib.resources.files.FileVersion}.
|
||||
* Comment file
|
||||
*/
|
||||
public class CommentFileOperation extends SyncOperation {
|
||||
|
||||
private static final String TAG = CommentFileOperation.class.getSimpleName();
|
||||
private static final int POST_READ_TIMEOUT = 30000;
|
||||
private static final int POST_CONNECTION_TIMEOUT = 5000;
|
||||
|
||||
private static final String ACTOR_ID = "actorId";
|
||||
private static final String ACTOR_TYPE = "actorType";
|
||||
private static final String ACTOR_TYPE_VALUE = "users";
|
||||
private static final String VERB = "verb";
|
||||
private static final String VERB_VALUE = "comment";
|
||||
private static final String MESSAGE = "message";
|
||||
|
||||
private String message;
|
||||
private String fileId;
|
||||
private String userId;
|
||||
@@ -76,37 +56,12 @@ public class CommentFileOperation extends SyncOperation {
|
||||
*/
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId, userId).execute(client, true);
|
||||
|
||||
RemoteOperationResult result;
|
||||
try {
|
||||
String url = client.getNewWebdavUri() + "/comments/files/" + fileId;
|
||||
PostMethod postMethod = new PostMethod(url);
|
||||
postMethod.addRequestHeader("Content-type", "application/json");
|
||||
|
||||
Map<String, String> values = new HashMap<>();
|
||||
values.put(ACTOR_ID, userId);
|
||||
values.put(ACTOR_TYPE, ACTOR_TYPE_VALUE);
|
||||
values.put(VERB, VERB_VALUE);
|
||||
values.put(MESSAGE, message);
|
||||
|
||||
String json = new GsonBuilder().create().toJson(values, Map.class);
|
||||
|
||||
postMethod.setRequestEntity(new StringRequestEntity(json));
|
||||
|
||||
int status = client.executeMethod(postMethod, POST_READ_TIMEOUT, POST_CONNECTION_TIMEOUT);
|
||||
|
||||
result = new RemoteOperationResult(isSuccess(status), postMethod);
|
||||
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
} catch (IOException e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log.e(TAG, "Post comment to file with id " + fileId + " failed: " + result.getLogMessage(), e);
|
||||
if (!result.isSuccess()) {
|
||||
Log_OC.e(this, "File with Id " + fileId + " could not be commented");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isSuccess(int status) {
|
||||
return status == HttpStatus.SC_CREATED;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.resources.files.CopyRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.CopyFileRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
|
||||
@@ -74,13 +74,7 @@ public class CopyFileOperation extends SyncOperation {
|
||||
if (mFile.isFolder()) {
|
||||
targetPath += OCFile.PATH_SEPARATOR;
|
||||
}
|
||||
CopyRemoteFileOperation operation = new CopyRemoteFileOperation(
|
||||
mSrcPath,
|
||||
targetPath,
|
||||
false
|
||||
);
|
||||
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
RemoteOperationResult result = new CopyFileRemoteOperation(mSrcPath, targetPath, false).execute(client);
|
||||
|
||||
/// 3. local copy
|
||||
if (result.isSuccess()) {
|
||||
|
||||
@@ -27,9 +27,9 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
@@ -40,16 +40,16 @@ import com.owncloud.android.utils.MimeType;
|
||||
* Save the new folder in Database
|
||||
*/
|
||||
public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener{
|
||||
|
||||
|
||||
private static final String TAG = CreateFolderOperation.class.getSimpleName();
|
||||
|
||||
|
||||
protected String mRemotePath;
|
||||
private boolean mCreateFullPath;
|
||||
private RemoteFile createdRemoteFolder;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param createFullPath 'True' means that all the ancestor folders should be created
|
||||
* if don't exist yet.
|
||||
*/
|
||||
@@ -61,29 +61,28 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mRemotePath, mCreateFullPath);
|
||||
RemoteOperationResult result = operation.execute(client, true);
|
||||
|
||||
RemoteOperationResult result = new CreateFolderRemoteOperation(mRemotePath, mCreateFullPath).execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
ReadRemoteFolderOperation remoteFolderOperation = new ReadRemoteFolderOperation(mRemotePath);
|
||||
RemoteOperationResult remoteFolderOperationResult = remoteFolderOperation.execute(client, true);
|
||||
RemoteOperationResult remoteFolderOperationResult = new ReadFolderRemoteOperation(mRemotePath)
|
||||
.execute(client, true);
|
||||
|
||||
createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0);
|
||||
saveFolderInDB();
|
||||
} else {
|
||||
Log_OC.e(TAG, mRemotePath + " hasn't been created");
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
|
||||
if (operation instanceof CreateRemoteFolderOperation) {
|
||||
if (operation instanceof CreateFolderRemoteOperation) {
|
||||
onCreateRemoteFolderOperationFinish(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onCreateRemoteFolderOperationFinish(RemoteOperationResult result) {
|
||||
if (result.isSuccess()) {
|
||||
saveFolderInDB();
|
||||
@@ -99,7 +98,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
if (mCreateFullPath && getStorageManager().
|
||||
getFileByPath(FileStorageUtils.getParentPath(mRemotePath)) == null){// When parent
|
||||
// of remote path
|
||||
// is not created
|
||||
// is not created
|
||||
String[] subFolders = mRemotePath.split("/");
|
||||
String composedRemotePath = "/";
|
||||
|
||||
@@ -113,7 +112,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
}
|
||||
} else { // Create directory on DB
|
||||
OCFile newDir = new OCFile(mRemotePath);
|
||||
newDir.setMimetype(MimeType.DIRECTORY);
|
||||
newDir.setMimeType(MimeType.DIRECTORY);
|
||||
long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(mRemotePath)).getFileId();
|
||||
newDir.setParentId(parentId);
|
||||
newDir.setRemoteId(createdRemoteFolder.getRemoteId());
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
createOp.setGetShareDetails(true);
|
||||
result = createOp.execute(client);
|
||||
}
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (result.getData().size() > 0) {
|
||||
Object item = result.getData().get(0);
|
||||
@@ -106,10 +106,10 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
@@ -128,12 +128,12 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
getStorageManager().saveShare(share);
|
||||
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
OCFile file = getStorageManager().getFileByPath(mPath);
|
||||
if (file!=null) {
|
||||
file.setPublicLink(share.getShareLink());
|
||||
file.setShareViaLink(true);
|
||||
file.setSharedViaLink(true);
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio
|
||||
@@ -31,6 +31,10 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a new private share for a given file.
|
||||
*/
|
||||
@@ -43,6 +47,9 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
private ShareType mShareType;
|
||||
private int mPermissions;
|
||||
|
||||
private static final List<ShareType> supportedShareTypes = new ArrayList<>(Arrays.asList(ShareType.USER,
|
||||
ShareType.GROUP, ShareType.FEDERATED, ShareType.EMAIL, ShareType.ROOM));
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -54,8 +61,7 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
* https://doc.owncloud.org/server/8.2/developer_manual/core/ocs-share-api.html .
|
||||
*/
|
||||
public CreateShareWithShareeOperation(String path, String shareeName, ShareType shareType, int permissions) {
|
||||
if (!ShareType.USER.equals(shareType) && !ShareType.GROUP.equals(shareType)
|
||||
&& !ShareType.FEDERATED.equals(shareType) && !ShareType.EMAIL.equals(shareType)) {
|
||||
if (!supportedShareTypes.contains(shareType)) {
|
||||
throw new IllegalArgumentException("Illegal share type " + shareType);
|
||||
}
|
||||
mPath = path;
|
||||
@@ -78,15 +84,15 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
operation.setGetShareDetails(true);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
|
||||
|
||||
|
||||
if (result.isSuccess() && result.getData().size() > 0) {
|
||||
OCShare share = (OCShare) result.getData().get(0);
|
||||
updateData(share);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
@@ -97,13 +103,12 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
share.setIsFolder(mPath.endsWith(FileUtils.PATH_SEPARATOR));
|
||||
|
||||
getStorageManager().saveShare(share);
|
||||
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
OCFile file = getStorageManager().getFileByPath(mPath);
|
||||
if (file!=null) {
|
||||
file.setShareWithSharee(true); // TODO - this should be done by the FileContentProvider, as part of getStorageManager().saveShare(share)
|
||||
file.setSharedWithSharee(true); // TODO - this should be done by the FileContentProvider, as part of getStorageManager().saveShare(share)
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -34,7 +34,7 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.DownloadFileRemoteOperation;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* Remote mDownloadOperation performing the download of a file to an ownCloud server
|
||||
*/
|
||||
public class DownloadFileOperation extends RemoteOperation {
|
||||
|
||||
|
||||
private static final String TAG = DownloadFileOperation.class.getSimpleName();
|
||||
private Account mAccount;
|
||||
|
||||
@@ -60,13 +60,13 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
private long mModificationTimestamp;
|
||||
private String mEtag = "";
|
||||
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
||||
|
||||
private DownloadRemoteFileOperation mDownloadOperation;
|
||||
|
||||
private DownloadFileRemoteOperation mDownloadOperation;
|
||||
private String mActivityName;
|
||||
private String mPackageName;
|
||||
|
||||
|
||||
public DownloadFileOperation(Account account, OCFile file, String behaviour, String activityName,
|
||||
public DownloadFileOperation(Account account, OCFile file, String behaviour, String activityName,
|
||||
String packageName, Context context) {
|
||||
if (account == null) {
|
||||
throw new IllegalArgumentException("Illegal null account in DownloadFileOperation " +
|
||||
@@ -76,7 +76,7 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
throw new IllegalArgumentException("Illegal null file in DownloadFileOperation " +
|
||||
"creation");
|
||||
}
|
||||
|
||||
|
||||
mAccount = account;
|
||||
mFile = file;
|
||||
mBehaviour = behaviour;
|
||||
@@ -89,7 +89,7 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
public Account getAccount() {
|
||||
return mAccount;
|
||||
}
|
||||
|
||||
|
||||
public OCFile getFile() {
|
||||
return mFile;
|
||||
}
|
||||
@@ -107,15 +107,15 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
}
|
||||
return FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
|
||||
}
|
||||
|
||||
|
||||
public String getTmpPath() {
|
||||
return FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
|
||||
}
|
||||
|
||||
|
||||
public String getTmpFolder() {
|
||||
return FileStorageUtils.getTemporalPath(mAccount.name);
|
||||
}
|
||||
|
||||
|
||||
public String getRemotePath() {
|
||||
return mFile.getRemotePath();
|
||||
}
|
||||
@@ -138,14 +138,13 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
}
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
|
||||
public long getSize() {
|
||||
return mFile.getFileLength();
|
||||
}
|
||||
|
||||
|
||||
public long getModificationTimestamp() {
|
||||
return (mModificationTimestamp > 0) ? mModificationTimestamp :
|
||||
mFile.getModificationTimestamp();
|
||||
return mModificationTimestamp > 0 ? mModificationTimestamp : mFile.getModificationTimestamp();
|
||||
}
|
||||
|
||||
public String getEtag() {
|
||||
@@ -169,14 +168,14 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
File tmpFile = new File(getTmpPath());
|
||||
|
||||
String tmpFolder = getTmpFolder();
|
||||
|
||||
mDownloadOperation = new DownloadRemoteFileOperation(mFile.getRemotePath(), tmpFolder);
|
||||
|
||||
mDownloadOperation = new DownloadFileRemoteOperation(mFile.getRemotePath(), tmpFolder);
|
||||
Iterator<OnDatatransferProgressListener> listener = mDataTransferListeners.iterator();
|
||||
while (listener.hasNext()) {
|
||||
mDownloadOperation.addDatatransferProgressListener(listener.next());
|
||||
}
|
||||
result = mDownloadOperation.execute(client, client.useNextcloudUserAgent());
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
mModificationTimestamp = mDownloadOperation.getModificationTimestamp();
|
||||
mEtag = mDownloadOperation.getEtag();
|
||||
@@ -218,7 +217,7 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
}
|
||||
Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " +
|
||||
result.getLogMessage());
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -235,7 +234,7 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
mDataTransferListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeDatatransferProgressListener(OnDatatransferProgressListener listener) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.remove(listener);
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Empty trashbin.
|
||||
*/
|
||||
public class EmptyTrashbinFileOperation extends SyncOperation {
|
||||
|
||||
private static final String TAG = EmptyTrashbinFileOperation.class.getSimpleName();
|
||||
private static final int RESTORE_READ_TIMEOUT = 30000;
|
||||
private static final int RESTORE_CONNECTION_TIMEOUT = 5000;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param userId to access correct trashbin
|
||||
*/
|
||||
public EmptyTrashbinFileOperation(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the operation.
|
||||
*
|
||||
* @param client Client object to communicate with the remote Nextcloud server.
|
||||
*/
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
|
||||
RemoteOperationResult result;
|
||||
try {
|
||||
DeleteMethod delete = new DeleteMethod(client.getNewWebdavUri() + "/trashbin/" + userId + "/trash");
|
||||
int status = client.executeMethod(delete, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT);
|
||||
|
||||
result = new RemoteOperationResult(isSuccess(status), delete);
|
||||
|
||||
client.exhaustResponse(delete.getResponseBodyAsStream());
|
||||
} catch (IOException e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log.e(TAG, "Empty trashbin failed: " + result.getLogMessage(), e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isSuccess(int status) {
|
||||
return status == HttpStatus.SC_NO_CONTENT;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class GetServerInfoOperation extends RemoteOperation {
|
||||
if (result.isSuccess()) {
|
||||
// second: get authentication method required by the server
|
||||
mResultData.mVersion = (OwnCloudVersion)(result.getData().get(0));
|
||||
mResultData.mIsSslConn = (result.getCode() == ResultCode.OK_SSL);
|
||||
mResultData.mIsSslConn = result.getCode() == ResultCode.OK_SSL;
|
||||
mResultData.mBaseUrl = normalizeProtocolPrefix(mUrl, mResultData.mIsSslConn);
|
||||
RemoteOperationResult detectAuthResult = detectAuthorizationMethod(client);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.resources.files.MoveRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.MoveFileRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
|
||||
@@ -31,16 +31,16 @@ import com.owncloud.android.operations.common.SyncOperation;
|
||||
* Operation mmoving an {@link OCFile} to a different folder.
|
||||
*/
|
||||
public class MoveFileOperation extends SyncOperation {
|
||||
|
||||
|
||||
//private static final String TAG = MoveFileOperation.class.getSimpleName();
|
||||
|
||||
|
||||
private String mSrcPath;
|
||||
private String mTargetParentPath;
|
||||
private OCFile mFile;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param srcPath Remote path of the {@link OCFile} to move.
|
||||
* @param targetParentPath Path to the folder where the file will be moved into.
|
||||
*/
|
||||
@@ -50,13 +50,13 @@ public class MoveFileOperation extends SyncOperation {
|
||||
if (!mTargetParentPath.endsWith(OCFile.PATH_SEPARATOR)) {
|
||||
mTargetParentPath += OCFile.PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
|
||||
mFile = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation.
|
||||
*
|
||||
*
|
||||
* @param client Client object to communicate with the remote ownCloud server.
|
||||
*/
|
||||
@Override
|
||||
@@ -69,27 +69,22 @@ public class MoveFileOperation extends SyncOperation {
|
||||
if (mFile == null) {
|
||||
return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
/// 2. remote move
|
||||
String targetPath = mTargetParentPath + mFile.getFileName();
|
||||
if (mFile.isFolder()) {
|
||||
targetPath += OCFile.PATH_SEPARATOR;
|
||||
}
|
||||
MoveRemoteFileOperation operation = new MoveRemoteFileOperation(
|
||||
mSrcPath,
|
||||
targetPath,
|
||||
false
|
||||
);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
|
||||
RemoteOperationResult result = new MoveFileRemoteOperation(mSrcPath, targetPath, false).execute(client);
|
||||
|
||||
/// 3. local move
|
||||
if (result.isSuccess()) {
|
||||
getStorageManager().moveLocalFile(mFile, targetPath, mTargetParentPath);
|
||||
}
|
||||
}
|
||||
// TODO handle ResultCode.PARTIAL_MOVE_DONE in client Activity, for the moment
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -22,8 +22,6 @@ package com.owncloud.android.operations;
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.owncloud.android.datamodel.DecryptedFolderMetadata;
|
||||
@@ -34,9 +32,9 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
@@ -52,12 +50,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Remote operation performing the synchronization of the list of files contained
|
||||
* Remote operation performing the synchronization of the list of files contained
|
||||
* in a folder identified with its remote path.
|
||||
*
|
||||
* Fetches the list and properties of the files contained in the given folder, including their
|
||||
* Fetches the list and properties of the files contained in the given folder, including their
|
||||
* properties, and updates the local database with them.
|
||||
*
|
||||
* Does NOT enter in the child folders to synchronize their contents also.
|
||||
@@ -97,8 +98,8 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
private int mFailsInKeptInSyncFound;
|
||||
|
||||
/**
|
||||
* Map of remote and local paths to files that where locally stored in a location
|
||||
* out of the ownCloud folder and couldn't be copied automatically into it
|
||||
* Map of remote and local paths to files that where locally stored in a location
|
||||
* out of the ownCloud folder and couldn't be copied automatically into it
|
||||
**/
|
||||
private Map<String, String> mForgottenLocalFiles;
|
||||
|
||||
@@ -122,13 +123,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
*
|
||||
* @param folder Folder to synchronize.
|
||||
* @param currentSyncTime Time stamp for the synchronization process in progress.
|
||||
* @param syncFullAccount 'True' means that this operation is part of a full account
|
||||
* @param syncFullAccount 'True' means that this operation is part of a full account
|
||||
* synchronization.
|
||||
* @param ignoreETag 'True' means that the content of the remote folder should
|
||||
* be fetched and updated even though the 'eTag' did not
|
||||
* change.
|
||||
* be fetched and updated even though the 'eTag' did not
|
||||
* change.
|
||||
* @param dataStorageManager Interface with the local database.
|
||||
* @param account ownCloud account where the folder is located.
|
||||
* @param account ownCloud account where the folder is located.
|
||||
* @param context Application context.
|
||||
*/
|
||||
public RefreshFolderOperation(OCFile folder,
|
||||
@@ -163,7 +164,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of files and folders contained in the synchronized folder,
|
||||
* Returns the list of files and folders contained in the synchronized folder,
|
||||
* if called after synchronization is complete.
|
||||
*
|
||||
* @return List of files and folders contained in the synchronized folder.
|
||||
@@ -195,7 +196,6 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
if (mRemoteFolderChanged) {
|
||||
result = fetchAndSyncRemoteFolder(client);
|
||||
} else {
|
||||
fetchKeptInSyncFilesToSyncFromLocalData();
|
||||
mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
if (result.isSuccess() && !mSyncFullAccount) {
|
||||
refreshSharesForFolder(client); // share result is ignored
|
||||
refreshSharesForFolder(client); // share result is ignored
|
||||
}
|
||||
|
||||
if (!mSyncFullAccount) {
|
||||
@@ -262,9 +262,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
Log_OC.d(TAG, "Checking changes in " + mAccount.name + remotePath);
|
||||
|
||||
// remote request
|
||||
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
|
||||
result = operation.execute(client, true);
|
||||
// remote request
|
||||
result = new ReadFileRemoteOperation(remotePath).execute(client, true);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
||||
|
||||
@@ -305,8 +305,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
private RemoteOperationResult fetchAndSyncRemoteFolder(OwnCloudClient client) {
|
||||
String remotePath = mLocalFolder.getRemotePath();
|
||||
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
|
||||
RemoteOperationResult result = operation.execute(client, true);
|
||||
RemoteOperationResult result = new ReadFolderRemoteOperation(remotePath).execute(client, true);
|
||||
Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
@@ -349,7 +348,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
// get 'fresh data' from the database
|
||||
mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
|
||||
|
||||
// parse data from remote folder
|
||||
// parse data from remote folder
|
||||
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) folderAndFiles.get(0));
|
||||
remoteFolder.setParentId(mLocalFolder.getParentId());
|
||||
remoteFolder.setFileId(mLocalFolder.getFileId());
|
||||
@@ -387,7 +386,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
updatedFile = FileStorageUtils.fillOCFile(r);
|
||||
updatedFile.setParentId(mLocalFolder.getFileId());
|
||||
|
||||
// retrieve local data for the read file
|
||||
// retrieve local data for the read file
|
||||
localFile = localFilesMap.remove(remoteFile.getRemotePath());
|
||||
|
||||
// add to updatedFile data about LOCAL STATE (not existing in server)
|
||||
@@ -399,13 +398,6 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
// check and fix, if needed, local storage path
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(updatedFile, mAccount);
|
||||
|
||||
// prepare content synchronization for kept-in-sync files
|
||||
if (updatedFile.isAvailableOffline()) {
|
||||
mFilesToSyncContents.add(
|
||||
new SynchronizeFileOperation(localFile, remoteFile, mAccount, true, mContext)
|
||||
);
|
||||
}
|
||||
|
||||
// update file name for encrypted files
|
||||
if (metadata != null) {
|
||||
updateFileNameForEncryptedFile(metadata, updatedFile);
|
||||
@@ -414,7 +406,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
// we parse content, so either the folder itself or its direct parent (which we check) must be encrypted
|
||||
boolean encrypted = updatedFile.isEncrypted() || mLocalFolder.isEncrypted();
|
||||
updatedFile.setEncrypted(encrypted);
|
||||
|
||||
|
||||
updatedFiles.add(updatedFile);
|
||||
}
|
||||
|
||||
@@ -444,9 +436,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
updatedFile.setFileName(decryptedFileName);
|
||||
|
||||
if (mimetype == null || mimetype.isEmpty()) {
|
||||
updatedFile.setMimetype("application/octet-stream");
|
||||
updatedFile.setMimeType("application/octet-stream");
|
||||
} else {
|
||||
updatedFile.setMimetype(mimetype);
|
||||
updatedFile.setMimeType(mimetype);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
Log_OC.e(TAG, "Metadata for file " + updatedFile.getFileId() + " not found!");
|
||||
@@ -456,7 +448,6 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
private void setLocalFileDataOnUpdatedFile(OCFile remoteFile, OCFile localFile, OCFile updatedFile, boolean remoteFolderChanged) {
|
||||
if (localFile != null) {
|
||||
updatedFile.setFileId(localFile.getFileId());
|
||||
updatedFile.setAvailableOffline(localFile.isAvailableOffline());
|
||||
updatedFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
|
||||
updatedFile.setModificationTimestampAtLastSyncForData(
|
||||
localFile.getModificationTimestampAtLastSyncForData()
|
||||
@@ -477,17 +468,20 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
} else if (remoteFolderChanged && MimeTypeUtil.isImage(remoteFile) &&
|
||||
remoteFile.getModificationTimestamp() !=
|
||||
localFile.getModificationTimestamp()) {
|
||||
updatedFile.setNeedsUpdateThumbnail(true);
|
||||
updatedFile.setUpdateThumbnailNeeded(true);
|
||||
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
|
||||
}
|
||||
|
||||
updatedFile.setPublicLink(localFile.getPublicLink());
|
||||
updatedFile.setShareViaLink(localFile.isSharedViaLink());
|
||||
updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
|
||||
updatedFile.setSharedViaLink(localFile.isSharedViaLink());
|
||||
updatedFile.setSharedWithSharee(localFile.isSharedWithSharee());
|
||||
} else {
|
||||
// remote eTag will not be updated unless file CONTENTS are synchronized
|
||||
updatedFile.setEtag("");
|
||||
}
|
||||
|
||||
// eTag on Server is used for thumbnail validation
|
||||
updatedFile.setEtagOnServer(remoteFile.getEtag());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -509,7 +503,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
* Performs a list of synchronization operations, determining if a download or upload is needed
|
||||
* or if exists conflict due to changes both in local and remote contents of the each file.
|
||||
*
|
||||
* If download or upload is needed, request the operation to the corresponding service and goes
|
||||
* If download or upload is needed, request the operation to the corresponding service and goes
|
||||
* on.
|
||||
*
|
||||
* @param filesToSyncContents Synchronization operations to execute.
|
||||
@@ -545,7 +539,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
|
||||
// remote request
|
||||
// remote request
|
||||
GetRemoteSharesForFileOperation operation =
|
||||
new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), true, true);
|
||||
result = operation.execute(client);
|
||||
@@ -592,24 +586,5 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
intent.setPackage(mContext.getPackageName());
|
||||
mContext.sendStickyBroadcast(intent);
|
||||
//LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
||||
private void fetchKeptInSyncFilesToSyncFromLocalData() {
|
||||
List<OCFile> children = mStorageManager.getFolderContent(mLocalFolder, false);
|
||||
for (OCFile child : children) {
|
||||
if (!child.isFolder() && child.isAvailableOffline() && !child.isInConflict()) {
|
||||
SynchronizeFileOperation operation = new SynchronizeFileOperation(
|
||||
child,
|
||||
child, // cheating with the remote file to get an update to server; to refactor
|
||||
mAccount,
|
||||
true,
|
||||
mContext
|
||||
);
|
||||
mFilesToSyncContents.add(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,7 @@ 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.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
|
||||
@@ -46,14 +46,14 @@ public class RemoveFileOperation extends SyncOperation {
|
||||
private Account account;
|
||||
private boolean inBackground;
|
||||
private Context context;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param remotePath RemotePath of the OCFile instance describing the remote file or
|
||||
*
|
||||
* @param remotePath RemotePath of the OCFile instance describing the remote file or
|
||||
* folder to remove from the server
|
||||
* @param onlyLocalCopy When 'true', and a local copy of the file exists, only this is
|
||||
* @param onlyLocalCopy When 'true', and a local copy of the file exists, only this is
|
||||
* removed.
|
||||
*/
|
||||
public RemoveFileOperation(String remotePath, boolean onlyLocalCopy, Account account, boolean inBackground,
|
||||
@@ -64,11 +64,11 @@ public class RemoveFileOperation extends SyncOperation {
|
||||
this.inBackground = inBackground;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the file to remove (or removed, if the operation was successfully performed).
|
||||
*
|
||||
*
|
||||
* @return File to remove or already removed.
|
||||
*/
|
||||
public OCFile getFile() {
|
||||
@@ -78,10 +78,10 @@ public class RemoveFileOperation extends SyncOperation {
|
||||
public boolean isInBackground() {
|
||||
return inBackground;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the remove operation
|
||||
*
|
||||
*
|
||||
* @param client Client object to communicate with the remote ownCloud server.
|
||||
*/
|
||||
@Override
|
||||
@@ -103,25 +103,25 @@ public class RemoveFileOperation extends SyncOperation {
|
||||
operation = new RemoveRemoteEncryptedFileOperation(remotePath, parent.getLocalId(), account, context,
|
||||
fileToRemove.getEncryptedFileName());
|
||||
} else {
|
||||
operation = new RemoveRemoteFileOperation(remotePath);
|
||||
operation = new RemoveFileRemoteOperation(remotePath);
|
||||
}
|
||||
result = operation.execute(client);
|
||||
if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) {
|
||||
localRemovalFailed = !(getStorageManager().removeFile(fileToRemove, true, true));
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
localRemovalFailed = !(getStorageManager().removeFile(fileToRemove, false, true));
|
||||
if (!localRemovalFailed) {
|
||||
result = new RemoteOperationResult(ResultCode.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (localRemovalFailed) {
|
||||
result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_REMOVED);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+15
-16
@@ -24,7 +24,6 @@ package com.owncloud.android.operations;
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -35,15 +34,17 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.GetMetadataOperation;
|
||||
import com.owncloud.android.lib.resources.files.LockFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.UnlockFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.UpdateMetadataOperation;
|
||||
import com.owncloud.android.lib.resources.e2ee.GetMetadataRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.e2ee.LockFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.e2ee.UnlockFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.e2ee.UpdateMetadataRemoteOperation;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
/**
|
||||
* Remote operation performing the removal of a remote encrypted file or folder
|
||||
*/
|
||||
@@ -67,8 +68,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||
* @param remotePath RemotePath of the remote file or folder to remove from the server
|
||||
* @param parentId local id of parent folder
|
||||
*/
|
||||
public RemoveRemoteEncryptedFileOperation(String remotePath, String parentId, Account account, Context context,
|
||||
String fileName) {
|
||||
RemoveRemoteEncryptedFileOperation(String remotePath, String parentId, Account account, Context context,
|
||||
String fileName) {
|
||||
this.remotePath = remotePath;
|
||||
this.parentId = parentId;
|
||||
this.account = account;
|
||||
@@ -93,8 +94,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||
|
||||
try {
|
||||
// Lock folder
|
||||
LockFileOperation lockFileOperation = new LockFileOperation(parentId);
|
||||
RemoteOperationResult lockFileOperationResult = lockFileOperation.execute(client, true);
|
||||
RemoteOperationResult lockFileOperationResult = new LockFileRemoteOperation(parentId).execute(client, true);
|
||||
|
||||
if (lockFileOperationResult.isSuccess()) {
|
||||
token = (String) lockFileOperationResult.getData().get(0);
|
||||
@@ -105,8 +105,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
// refresh metadata
|
||||
GetMetadataOperation getMetadataOperation = new GetMetadataOperation(parentId);
|
||||
RemoteOperationResult getMetadataOperationResult = getMetadataOperation.execute(client, true);
|
||||
RemoteOperationResult getMetadataOperationResult = new GetMetadataRemoteOperation(parentId)
|
||||
.execute(client, true);
|
||||
|
||||
if (getMetadataOperationResult.isSuccess()) {
|
||||
// decrypt metadata
|
||||
@@ -137,9 +137,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||
String serializedFolderMetadata = EncryptionUtils.serializeJSON(encryptedFolderMetadata);
|
||||
|
||||
// upload metadata
|
||||
UpdateMetadataOperation storeMetadataOperation = new UpdateMetadataOperation(parentId,
|
||||
serializedFolderMetadata, token);
|
||||
RemoteOperationResult uploadMetadataOperationResult = storeMetadataOperation.execute(client, true);
|
||||
RemoteOperationResult uploadMetadataOperationResult = new UpdateMetadataRemoteOperation(parentId,
|
||||
serializedFolderMetadata, token).execute(client, true);
|
||||
|
||||
if (!uploadMetadataOperationResult.isSuccess()) {
|
||||
throw new RemoteOperationFailedException("Metadata not uploaded!");
|
||||
@@ -158,8 +157,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
|
||||
|
||||
// unlock file
|
||||
if (token != null) {
|
||||
UnlockFileOperation unlockFileOperation = new UnlockFileOperation(parentId, token);
|
||||
RemoteOperationResult unlockFileOperationResult = unlockFileOperation.execute(client, true);
|
||||
RemoteOperationResult unlockFileOperationResult = new UnlockFileRemoteOperation(parentId, token)
|
||||
.execute(client, true);
|
||||
|
||||
if (!unlockFileOperationResult.isSuccess()) {
|
||||
Log_OC.e(TAG, "Failed to unlock " + parentId);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -27,7 +27,7 @@ import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.RenameRemoteFileOperation;
|
||||
import com.owncloud.android.lib.resources.files.RenameFileRemoteOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
@@ -39,17 +39,17 @@ import java.io.IOException;
|
||||
* Remote operation performing the rename of a remote file (or folder?) in the ownCloud server.
|
||||
*/
|
||||
public class RenameFileOperation extends SyncOperation {
|
||||
|
||||
|
||||
private static final String TAG = RenameFileOperation.class.getSimpleName();
|
||||
|
||||
|
||||
private OCFile mFile;
|
||||
private String mRemotePath;
|
||||
private String mNewName;
|
||||
private String mNewRemotePath;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param remotePath RemotePath of the OCFile instance describing the remote file or
|
||||
* folder to rename
|
||||
* @param newName New name to set as the name of file.
|
||||
@@ -59,29 +59,29 @@ public class RenameFileOperation extends SyncOperation {
|
||||
mNewName = newName;
|
||||
mNewRemotePath = null;
|
||||
}
|
||||
|
||||
|
||||
public OCFile getFile() {
|
||||
return mFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Performs the rename operation.
|
||||
*
|
||||
*
|
||||
* @param client Client object to communicate with the remote ownCloud server.
|
||||
*/
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = null;
|
||||
|
||||
|
||||
mFile = getStorageManager().getFileByPath(mRemotePath);
|
||||
|
||||
|
||||
// check if the new name is valid in the local file system
|
||||
try {
|
||||
if (!isValidNewName()) {
|
||||
return new RemoteOperationResult(ResultCode.INVALID_LOCAL_FILE_NAME);
|
||||
}
|
||||
String parent = (new File(mFile.getRemotePath())).getParent();
|
||||
String parent = new File(mFile.getRemotePath()).getParent();
|
||||
parent = parent.endsWith(OCFile.PATH_SEPARATOR) ? parent : parent + OCFile.PATH_SEPARATOR;
|
||||
mNewRemotePath = parent + mNewName;
|
||||
if (mFile.isFolder()) {
|
||||
@@ -92,11 +92,9 @@ public class RenameFileOperation extends SyncOperation {
|
||||
if (getStorageManager().getFileByPath(mNewRemotePath) != null) {
|
||||
return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE);
|
||||
}
|
||||
|
||||
RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(),
|
||||
mFile.getRemotePath(),
|
||||
mNewName, mFile.isFolder());
|
||||
result = operation.execute(client);
|
||||
|
||||
result = new RenameFileRemoteOperation(mFile.getFileName(), mFile.getRemotePath(), mNewName,
|
||||
mFile.isFolder()).execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (mFile.isFolder()) {
|
||||
@@ -107,7 +105,7 @@ public class RenameFileOperation extends SyncOperation {
|
||||
saveLocalFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ?
|
||||
mNewName : mNewRemotePath) + ": " +
|
||||
@@ -141,22 +139,22 @@ public class RenameFileOperation extends SyncOperation {
|
||||
// can't be updated
|
||||
// TODO - study conditions when this could be a problem
|
||||
}
|
||||
|
||||
|
||||
getStorageManager().saveFile(mFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the new name to set is valid in the file system
|
||||
*
|
||||
* Checks if the new name to set is valid in the file system
|
||||
*
|
||||
* The only way to be sure is trying to create a file with that name. It's made in the
|
||||
* temporal directory for downloads, out of any account, and then removed.
|
||||
*
|
||||
*
|
||||
* IMPORTANT: The test must be made in the same file system where files are download.
|
||||
* The internal storage could be formatted with a different file system.
|
||||
*
|
||||
*
|
||||
* TODO move this method, and maybe FileDownload.get***Path(), to a class with utilities
|
||||
* specific for the interactions with the file system
|
||||
*
|
||||
*
|
||||
* @return 'True' if a temporal file named with the name to set could be
|
||||
* created in the file system where local files are stored.
|
||||
* @throws IOException When the temporal folder can not be created.
|
||||
@@ -182,11 +180,11 @@ public class RenameFileOperation extends SyncOperation {
|
||||
return false;
|
||||
}
|
||||
boolean result = testFile.exists() && testFile.isFile();
|
||||
|
||||
|
||||
// cleaning ; result is ignored, since there is not much we could do in case of failure,
|
||||
// but repeat and repeat...
|
||||
testFile.delete();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 409 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user