Compare commits
1112
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a76f6a6a1f | ||
|
|
743caeb681 | ||
|
|
0f50e2f712 | ||
|
|
ce10a3a2bf | ||
|
|
2bb1ae76af | ||
|
|
023c62e5cd | ||
|
|
0117f72b1e | ||
|
|
2060bbe484 | ||
|
|
32742cb5f7 | ||
|
|
5455c9bd9b | ||
|
|
1958adea92 | ||
|
|
2076bc4101 | ||
|
|
43a48eddc3 | ||
|
|
6ccc7d5bf7 | ||
|
|
68c27fa15b | ||
|
|
8b05449dae | ||
|
|
f4cc4ca045 | ||
|
|
b9acfc62cc | ||
|
|
5aa5394d62 | ||
|
|
86be405468 | ||
|
|
0ca55c4750 | ||
|
|
6072328c3a | ||
|
|
5eab12e8bc | ||
|
|
c0c8570ec6 | ||
|
|
50b8438af1 | ||
|
|
bbf71f8e3c | ||
|
|
be55403760 | ||
|
|
b8864a7b3a | ||
|
|
7abce00274 | ||
|
|
f50eaf4b73 | ||
|
|
91d739acf9 | ||
|
|
abaccf6349 | ||
|
|
1e7b01ac0b | ||
|
|
33daaf4625 | ||
|
|
5c294f5fa7 | ||
|
|
700a813bb2 | ||
|
|
3a66b8ea11 | ||
|
|
61e788ea35 | ||
|
|
3115d0b6a8 | ||
|
|
3751f3fd87 | ||
|
|
7401f17ac7 | ||
|
|
11360b355c | ||
|
|
574350f8ee | ||
|
|
e89cbbc8cb | ||
|
|
af4df95121 | ||
|
|
2b83d960d2 | ||
|
|
dae83866e7 | ||
|
|
f290682fe9 | ||
|
|
1241123a3f | ||
|
|
b38398c1c1 | ||
|
|
33218b7489 | ||
|
|
412bffd8b4 | ||
|
|
21a2d7491c | ||
|
|
aa12f3948a | ||
|
|
2735dd7448 | ||
|
|
185885b98b | ||
|
|
3844bdeec6 | ||
|
|
674d743435 | ||
|
|
004d7457f4 | ||
|
|
70bd1d971a | ||
|
|
48ec307f80 | ||
|
|
0bdb093115 | ||
|
|
cc4ac9bee4 | ||
|
|
45d37750a9 | ||
|
|
8a095c4e46 | ||
|
|
20088c58b9 | ||
|
|
06740c9016 | ||
|
|
06a0be21b0 | ||
|
|
90e1a0e432 | ||
|
|
b7a1a18bcc | ||
|
|
e6983a6169 | ||
|
|
7a144d1d93 | ||
|
|
d4023f1b48 | ||
|
|
5426a72d34 | ||
|
|
39643efe60 | ||
|
|
ad6c31017b | ||
|
|
e7a9a06289 | ||
|
|
7a0c64052d | ||
|
|
51361e594a | ||
|
|
cf24691642 | ||
|
|
8ce7411cc4 | ||
|
|
2a94a4f5cd | ||
|
|
b2f37db196 | ||
|
|
6d96355bd4 | ||
|
|
e5322e8112 | ||
|
|
0674521b95 | ||
|
|
c7eb8988e2 | ||
|
|
11f42601eb | ||
|
|
5ee7cffd84 | ||
|
|
34d534d601 | ||
|
|
3a2d3e0cbc | ||
|
|
49a99d89fa | ||
|
|
449d1c3545 | ||
|
|
7bd5b75cd9 | ||
|
|
d7696ea07b | ||
|
|
ff652fcb6e | ||
|
|
2b9c190be0 | ||
|
|
d4a7c387e4 | ||
|
|
9c07c50e8c | ||
|
|
bbe77bf40e | ||
|
|
96cb943f7d | ||
|
|
691f2020b9 | ||
|
|
933c55057e | ||
|
|
a6a7eb425a | ||
|
|
7d9d40e2a4 | ||
|
|
2cfbb1a113 | ||
|
|
b6928a8a58 | ||
|
|
f1f9cdeaf4 | ||
|
|
d379ab9753 | ||
|
|
010088dff5 | ||
|
|
14fef753bd | ||
|
|
35d68cc543 | ||
|
|
911a23cdb8 | ||
|
|
f4c475cc40 | ||
|
|
a0598e97e8 | ||
|
|
3221f2f7ab | ||
|
|
0763a6dc86 | ||
|
|
f8bfacebf8 | ||
|
|
cfaa13a354 | ||
|
|
6ccaa98f6e | ||
|
|
f8b8674216 | ||
|
|
8b2915f917 | ||
|
|
3a5766f3b7 | ||
|
|
93367166a4 | ||
|
|
2860e283c3 | ||
|
|
77ae68c142 | ||
|
|
ba4d1b6b2e | ||
|
|
2d0cc3404b | ||
|
|
9bdb6bc0b2 | ||
|
|
f1e4cc9297 | ||
|
|
a5fe8d7021 | ||
|
|
3e5d8eb65d | ||
|
|
884cf7120d | ||
|
|
1817ea91d5 | ||
|
|
2bee524490 | ||
|
|
7246cf0d36 | ||
|
|
b0f50cf513 | ||
|
|
64fbfd1b1a | ||
|
|
5bf6753ce3 | ||
|
|
e6514e6f19 | ||
|
|
aee3149319 | ||
|
|
41bf8f6000 | ||
|
|
cc6df72b71 | ||
|
|
596d27053d | ||
|
|
f5d1e32650 | ||
|
|
da6d07dc01 | ||
|
|
f35583f972 | ||
|
|
cd702b0476 | ||
|
|
17a7215fd7 | ||
|
|
01366e9fea | ||
|
|
60117173ab | ||
|
|
eefd06d1b4 | ||
|
|
b26126e860 | ||
|
|
067d29618c | ||
|
|
5fe394d880 | ||
|
|
8c113d104e | ||
|
|
9c47dbae94 | ||
|
|
6d8c69f84f | ||
|
|
78701b6cb4 | ||
|
|
bbea7ca25e | ||
|
|
47ff8887f6 | ||
|
|
714d66b094 | ||
|
|
dc9137baa2 | ||
|
|
c54a4c4b58 | ||
|
|
aeb26f1df8 | ||
|
|
14216857e0 | ||
|
|
2c8e25e4c5 | ||
|
|
67a1dbd1d3 | ||
|
|
cd4a3b0e40 | ||
|
|
8508b6e087 | ||
|
|
abadf12b34 | ||
|
|
a08bccf52c | ||
|
|
e176697bb0 | ||
|
|
e2d0ef9543 | ||
|
|
c48d46c1a1 | ||
|
|
d4f2f60205 | ||
|
|
15588caf3e | ||
|
|
c714e9dbf1 | ||
|
|
3a7d11269e | ||
|
|
b7c600ceb0 | ||
|
|
8e418990d8 | ||
|
|
77b3e0b87f | ||
|
|
408768fe68 | ||
|
|
0ed7bb81c9 | ||
|
|
c507443e07 | ||
|
|
d29759bd39 | ||
|
|
1a384ce6fa | ||
|
|
70782cfa87 | ||
|
|
32084225a1 | ||
|
|
342642108b | ||
|
|
74a4087e83 | ||
|
|
a8d64cc7c8 | ||
|
|
f81c9f3f46 | ||
|
|
13d118fe53 | ||
|
|
4a1d21ebcb | ||
|
|
1c26ca53ee | ||
|
|
3de6a81c8c | ||
|
|
8cd27d3609 | ||
|
|
b47365b969 | ||
|
|
0e4fc703d2 | ||
|
|
12f3784129 | ||
|
|
280bee125a | ||
|
|
4f602fe9b2 | ||
|
|
22cfd14d76 | ||
|
|
bb619da1fc | ||
|
|
e35894de57 | ||
|
|
dc5e49ecf7 | ||
|
|
be6de28c10 | ||
|
|
4453d4e743 | ||
|
|
30494030e2 | ||
|
|
906836dec6 | ||
|
|
f5142b3500 | ||
|
|
0fb606f178 | ||
|
|
7fd0847296 | ||
|
|
5ca93caf13 | ||
|
|
dee96e0e81 | ||
|
|
8c2decf6f3 | ||
|
|
493eab1d88 | ||
|
|
9cca391dbd | ||
|
|
0e85a81811 | ||
|
|
20ae8cbc3e | ||
|
|
97eeb9a50a | ||
|
|
e5ffe3bf1d | ||
|
|
da9938beea | ||
|
|
6e3cb94bcb | ||
|
|
a31dede44c | ||
|
|
0a9431439a | ||
|
|
bfede15b81 | ||
|
|
668a2ade4a | ||
|
|
296506ce61 | ||
|
|
b46e9a89ae | ||
|
|
788621ddb4 | ||
|
|
f14f6cb528 | ||
|
|
2fade8210a | ||
|
|
11548cd889 | ||
|
|
ee990006b7 | ||
|
|
1661888b0d | ||
|
|
e47daa2a07 | ||
|
|
a0a089d0b0 | ||
|
|
c8e558fdb2 | ||
|
|
3440c8f431 | ||
|
|
284000a0c2 | ||
|
|
a5e0f4e546 | ||
|
|
438c9ca358 | ||
|
|
d4931fb71c | ||
|
|
36894c179f | ||
|
|
c60067146f | ||
|
|
08bf11fc47 | ||
|
|
6bc444ae51 | ||
|
|
3c00d5e18b | ||
|
|
27c669a319 | ||
|
|
33d69d5aca | ||
|
|
ca514a8a8a | ||
|
|
0802ca07f4 | ||
|
|
59f3255ecd | ||
|
|
52d29c241a | ||
|
|
16663f9b7b | ||
|
|
6f85844587 | ||
|
|
04b9782c57 | ||
|
|
36e8870ef1 | ||
|
|
7db6df6654 | ||
|
|
6efa55f09a | ||
|
|
9eeff8323e | ||
|
|
ddbcdb084c | ||
|
|
e802659c0c | ||
|
|
25fe01ab43 | ||
|
|
b20cbbd5f5 | ||
|
|
b4b8614c33 | ||
|
|
c1d23005a7 | ||
|
|
e102fa6a11 | ||
|
|
bf5400841d | ||
|
|
219587f1c2 | ||
|
|
a22bdd387d | ||
|
|
aefa37ff2e | ||
|
|
41eb72306c | ||
|
|
50e01fe256 | ||
|
|
bb370e8467 | ||
|
|
46d231fa9b | ||
|
|
4b17913271 | ||
|
|
3eb1c79a3e | ||
|
|
6e16f4874c | ||
|
|
2e51293f70 | ||
|
|
f5a4983384 | ||
|
|
06ab182c96 | ||
|
|
dd9c094cc4 | ||
|
|
de442fa508 | ||
|
|
9c76de1e72 | ||
|
|
0785bae437 | ||
|
|
e13ecad3a4 | ||
|
|
e564917cfc | ||
|
|
8f9eaa90ed | ||
|
|
e8aee23c33 | ||
|
|
6dd6959f5b | ||
|
|
bbdf6313e7 | ||
|
|
dfd6fdfd75 | ||
|
|
b5e24ae623 | ||
|
|
61753c6f20 | ||
|
|
d6ba5b2900 | ||
|
|
86c0fac7c1 | ||
|
|
69b48d72f3 | ||
|
|
c57ad1a52f | ||
|
|
c73ec19aae | ||
|
|
f60bd6291c | ||
|
|
e28aec5bd4 | ||
|
|
0e57cf845d | ||
|
|
70681271a0 | ||
|
|
60d72c9990 | ||
|
|
61069b36a4 | ||
|
|
4e98d9e39e | ||
|
|
6b0ed3f312 | ||
|
|
9873834024 | ||
|
|
c13258371e | ||
|
|
2a9f17492a | ||
|
|
5a3e682cc6 | ||
|
|
f873a1fe65 | ||
|
|
e9e9e56841 | ||
|
|
6606fb3867 | ||
|
|
2792cb409b | ||
|
|
9729847c8e | ||
|
|
0314ceb071 | ||
|
|
2e6f069c18 | ||
|
|
094d7f5129 | ||
|
|
d22c9c8346 | ||
|
|
640206f2a5 | ||
|
|
576dc13e8f | ||
|
|
87b12e8218 | ||
|
|
112318024d | ||
|
|
bbaf1bfb13 | ||
|
|
21add7252c | ||
|
|
6a307d4a98 | ||
|
|
4a8bc91d8c | ||
|
|
92ef82afbc | ||
|
|
2affe52783 | ||
|
|
14a7e87bdd | ||
|
|
66e1f00d42 | ||
|
|
c9917ded8e | ||
|
|
6d9fabb398 | ||
|
|
57311cf2b8 | ||
|
|
90ae4ed1e2 | ||
|
|
4b4391e145 | ||
|
|
4dfe198732 | ||
|
|
65336213a6 | ||
|
|
5fbc88c212 | ||
|
|
c74248938a | ||
|
|
e5b56f3d93 | ||
|
|
011d83b508 | ||
|
|
0a3d4d559e | ||
|
|
af99094219 | ||
|
|
cb2de5ca71 | ||
|
|
12f8c055ac | ||
|
|
3b0efbb2a7 | ||
|
|
d90384b34b | ||
|
|
5ee406f451 | ||
|
|
880ef3b489 | ||
|
|
a6cc236992 | ||
|
|
cfec844cb8 | ||
|
|
8a7eb8e96a | ||
|
|
0f03ff9b36 | ||
|
|
b2bef4a86a | ||
|
|
538347cc47 | ||
|
|
27793020bc | ||
|
|
6aec6dd706 | ||
|
|
59689586c9 | ||
|
|
964eda3d5a | ||
|
|
1d72b071b5 | ||
|
|
80f3b69c6b | ||
|
|
b32b929265 | ||
|
|
72d2968837 | ||
|
|
1b845af5d0 | ||
|
|
d131d51ac4 | ||
|
|
155baeba00 | ||
|
|
a6717a26a0 | ||
|
|
9a4474ce11 | ||
|
|
c61bbc56b3 | ||
|
|
ceb5192d8f | ||
|
|
b6b4f7402e | ||
|
|
84d0af9537 | ||
|
|
2387bedc31 | ||
|
|
e4de160952 | ||
|
|
9bedf98111 | ||
|
|
eb3964e51b | ||
|
|
e966354e00 | ||
|
|
9b72cb711d | ||
|
|
081fd2de3e | ||
|
|
a33c9e3984 | ||
|
|
ab0c803107 | ||
|
|
c826703a84 | ||
|
|
c45225ac76 | ||
|
|
bfdc3fdac0 | ||
|
|
d187b32076 | ||
|
|
b31ae1e912 | ||
|
|
8a0c586fd9 | ||
|
|
a2065c7405 | ||
|
|
34b3d8e93a | ||
|
|
dc29cfa08d | ||
|
|
27f03e293f | ||
|
|
d42213bc70 | ||
|
|
89ae720bd5 | ||
|
|
40b88b7276 | ||
|
|
6261c237fc | ||
|
|
3a3e569b2f | ||
|
|
cf271fbc86 | ||
|
|
38f6b1162d | ||
|
|
481bc5034e | ||
|
|
a5237804e2 | ||
|
|
1ca3def0e2 | ||
|
|
71b9587106 | ||
|
|
cdf67ea5d1 | ||
|
|
d794a4ea68 | ||
|
|
bb58bfc867 | ||
|
|
eeb4ee68f8 | ||
|
|
8e493f58f7 | ||
|
|
75048833c7 | ||
|
|
79a6e4577c | ||
|
|
9515547226 | ||
|
|
4a96afbf0b | ||
|
|
8e2d30121f | ||
|
|
3928505536 | ||
|
|
f003013ab2 | ||
|
|
711ac95132 | ||
|
|
855a2b039c | ||
|
|
a8ad36f74e | ||
|
|
0deebb16b2 | ||
|
|
c94921cc90 | ||
|
|
3de3923dd1 | ||
|
|
cbf4037f9a | ||
|
|
e19f0f76f7 | ||
|
|
3407a43daf | ||
|
|
100b1cc1bd | ||
|
|
092ce03c8c | ||
|
|
a0ffc6d808 | ||
|
|
f1c4597931 | ||
|
|
cb1540babd | ||
|
|
bb39a362eb | ||
|
|
88de01d562 | ||
|
|
f0f607b63a | ||
|
|
977c769171 | ||
|
|
e00e92fe98 | ||
|
|
4897cbf9bc | ||
|
|
42a75aba57 | ||
|
|
fd173bfb0c | ||
|
|
30a7812896 | ||
|
|
42d17f3427 | ||
|
|
a8094e5e47 | ||
|
|
c2a87d52cd | ||
|
|
9e648a209e | ||
|
|
b3d95bfe86 | ||
|
|
c48a77dcf9 | ||
|
|
b38b4b0cda | ||
|
|
43f2dd5aa2 | ||
|
|
cdbd188acc | ||
|
|
2e28745f2d | ||
|
|
f5810ac82b | ||
|
|
17193a75b6 | ||
|
|
629fa25f37 | ||
|
|
e6273a1093 | ||
|
|
bf7c204d65 | ||
|
|
48b6bb6c92 | ||
|
|
152efbceee | ||
|
|
b0769ee806 | ||
|
|
58a0791874 | ||
|
|
049b76d391 | ||
|
|
0799091a38 | ||
|
|
fdd7de2aca | ||
|
|
d6986a84dd | ||
|
|
6b88b78cf8 | ||
|
|
be0d313c17 | ||
|
|
9879cb4a4e | ||
|
|
6c296c95f2 | ||
|
|
c10a951574 | ||
|
|
844d8029ae | ||
|
|
bce8e8e5d3 | ||
|
|
acf08e6b06 | ||
|
|
285f7149ff | ||
|
|
9741714f3c | ||
|
|
3aca64edc4 | ||
|
|
9342d513b5 | ||
|
|
84f97998de | ||
|
|
4c98df9982 | ||
|
|
d5299bb2ec | ||
|
|
9d6f749260 | ||
|
|
3829520576 | ||
|
|
4c5e9e9b34 | ||
|
|
264fa809ed | ||
|
|
1c5736eb09 | ||
|
|
67e76d7941 | ||
|
|
4e6f9388b3 | ||
|
|
b179d8a8e4 | ||
|
|
042c726e84 | ||
|
|
0e19a4fad4 | ||
|
|
357f5ad3a3 | ||
|
|
4ccb511527 | ||
|
|
022781bcba | ||
|
|
0670f5ef96 | ||
|
|
4777331d22 | ||
|
|
f842aee1e7 | ||
|
|
4c6bef3007 | ||
|
|
26a3d290af | ||
|
|
1e9b3a6c5a | ||
|
|
c6ee037696 | ||
|
|
cf85700306 | ||
|
|
aea628901b | ||
|
|
d572720213 | ||
|
|
cf11c59ef5 | ||
|
|
f4a58d155a | ||
|
|
9cda7dba1e | ||
|
|
6ec4f5fb43 | ||
|
|
36277a1022 | ||
|
|
11cf668518 | ||
|
|
50794f080e | ||
|
|
9e76f369b6 | ||
|
|
e3948cac07 | ||
|
|
11f4710d39 | ||
|
|
433c91c185 | ||
|
|
53a028b171 | ||
|
|
cbacc0800a | ||
|
|
eb9df06870 | ||
|
|
e9adcdca0c | ||
|
|
2b76712b9d | ||
|
|
017d9a8b90 | ||
|
|
873282de67 | ||
|
|
0837f9308b | ||
|
|
950b7defb4 | ||
|
|
49ee63ae14 | ||
|
|
3a6ebbc94d | ||
|
|
9e4d1bfeb1 | ||
|
|
4a8f00156f | ||
|
|
249a86bb63 | ||
|
|
90a979a21e | ||
|
|
d7d77fc31e | ||
|
|
8b502a38e1 | ||
|
|
ec81a8f873 | ||
|
|
e4f92f28ca | ||
|
|
54f92773df | ||
|
|
9fd7370487 | ||
|
|
44e085e00d | ||
|
|
0f1e301a70 | ||
|
|
b0d5ac3caf | ||
|
|
b24d3f44a3 | ||
|
|
eed4cbefa8 | ||
|
|
4a80d4427b | ||
|
|
dd68a068c5 | ||
|
|
0396e4ec27 | ||
|
|
afd1ad88bb | ||
|
|
77286696fa | ||
|
|
e067cd3d68 | ||
|
|
609d9b41e2 | ||
|
|
f61a14d7bb | ||
|
|
cc96746cdf | ||
|
|
199e540e33 | ||
|
|
ff6a0363a4 | ||
|
|
1381b0cb8b | ||
|
|
690ce0bf17 | ||
|
|
b044cf2bf1 | ||
|
|
480986dd55 | ||
|
|
d3b463712d | ||
|
|
dc1302ab08 | ||
|
|
9552795549 | ||
|
|
714f392b5a | ||
|
|
5379bcd904 | ||
|
|
32b0767bd3 | ||
|
|
6b6e2e3a8d | ||
|
|
35801debc3 | ||
|
|
c6d22e1b63 | ||
|
|
694e3d3bf7 | ||
|
|
c9c55b0572 | ||
|
|
aa6639bf15 | ||
|
|
8871d275db | ||
|
|
0b51bd865b | ||
|
|
cc11ce3b7e | ||
|
|
0872984809 | ||
|
|
2a9767c966 | ||
|
|
aafa21103c | ||
|
|
42ae98f437 | ||
|
|
3c460db776 | ||
|
|
2319d176ca | ||
|
|
20591959ef | ||
|
|
f2778991fa | ||
|
|
6562e77bc6 | ||
|
|
07ab717b3b | ||
|
|
abb074ba22 | ||
|
|
50d3f0044b | ||
|
|
4f3b19f7a5 | ||
|
|
ddb3038dfa | ||
|
|
6629b69c45 | ||
|
|
b351b6b4da | ||
|
|
50fef3a9b8 | ||
|
|
95443beefd | ||
|
|
bd0e722614 | ||
|
|
32f5dd6f0e | ||
|
|
a9e9a6703b | ||
|
|
af06e18a78 | ||
|
|
87f28bf582 | ||
|
|
554707f160 | ||
|
|
4a69bd6e48 | ||
|
|
5247cdecfb | ||
|
|
2ec93db911 | ||
|
|
abaa4d9837 | ||
|
|
d3ccc9c5c7 | ||
|
|
d2d6cfb8e6 | ||
|
|
89ee4b053b | ||
|
|
61236650f3 | ||
|
|
48028aa95c | ||
|
|
fcfa8c252d | ||
|
|
c0554790be | ||
|
|
c5af1f6f33 | ||
|
|
373977f02a | ||
|
|
49c68ce5fe | ||
|
|
9438fe1af7 | ||
|
|
753089b435 | ||
|
|
46bc3cef2e | ||
|
|
e06822bcbe | ||
|
|
2f3455fef8 | ||
|
|
580a31a158 | ||
|
|
15d4cc3e68 | ||
|
|
6c2b71d556 | ||
|
|
ef80977380 | ||
|
|
35ccaf986b | ||
|
|
331d221195 | ||
|
|
656de55999 | ||
|
|
67f5bc3374 | ||
|
|
09f3ad0316 | ||
|
|
09b7841122 | ||
|
|
5e2fe56b91 | ||
|
|
036b6e919c | ||
|
|
aac4e654f6 | ||
|
|
e060cf5320 | ||
|
|
70695231b7 | ||
|
|
63426411f8 | ||
|
|
1c8d8e906b | ||
|
|
d06bfccb99 | ||
|
|
ac2d79489c | ||
|
|
ba7702f830 | ||
|
|
dadb642fe4 | ||
|
|
9086dc86d2 | ||
|
|
b8e462e144 | ||
|
|
f2c50f269b | ||
|
|
e9b7bd48e2 | ||
|
|
ed7ce28775 | ||
|
|
591609a0a3 | ||
|
|
e1bbf8389f | ||
|
|
4ff7957e14 | ||
|
|
7e36db34a0 | ||
|
|
6fd946db25 | ||
|
|
c971e5847b | ||
|
|
7db102d45b | ||
|
|
369275e93c | ||
|
|
53c9d6c229 | ||
|
|
c6e2077dee | ||
|
|
ef2bab5195 | ||
|
|
ca9013df4a | ||
|
|
d021138d38 | ||
|
|
7be013ca62 | ||
|
|
d9d115d59b | ||
|
|
aad96b8d56 | ||
|
|
16f1612cba | ||
|
|
4928b18d45 | ||
|
|
8acc7855f6 | ||
|
|
30267ee233 | ||
|
|
740337e974 | ||
|
|
04a79a33d5 | ||
|
|
b984f57a30 | ||
|
|
a8a34e335f | ||
|
|
f18ceee722 | ||
|
|
7abdc65d02 | ||
|
|
03e7d172ee | ||
|
|
49eac34881 | ||
|
|
c0b4e3fefc | ||
|
|
b77e1a2c03 | ||
|
|
0212ba87cf | ||
|
|
a8797f7020 | ||
|
|
d4e7e96e0b | ||
|
|
dd2b15fcd1 | ||
|
|
f819f1ab65 | ||
|
|
db2b38cc01 | ||
|
|
6976f78e23 | ||
|
|
a93cec205f | ||
|
|
999c8f00c5 | ||
|
|
a4cc4a365f | ||
|
|
ffa3a82b82 | ||
|
|
ff0eadbdcf | ||
|
|
b0eda3af81 | ||
|
|
80682ea362 | ||
|
|
0f8aeb75fc | ||
|
|
988b272b47 | ||
|
|
ca631c7d29 | ||
|
|
235541cda3 | ||
|
|
7492dda92b | ||
|
|
0faf153c40 | ||
|
|
7877ed9d26 | ||
|
|
8a6cd4f3c9 | ||
|
|
584070bd8e | ||
|
|
1f90ad4cdc | ||
|
|
680490179c | ||
|
|
4f6eda1809 | ||
|
|
7cf1adc1a6 | ||
|
|
ed866f538f | ||
|
|
8241cc6e38 | ||
|
|
3c5b51c276 | ||
|
|
7d9d776f31 | ||
|
|
02050d4c52 | ||
|
|
6da797a1ae | ||
|
|
b902cb3d32 | ||
|
|
7769ede981 | ||
|
|
64598588db | ||
|
|
4dd80b6309 | ||
|
|
b5ce3be66b | ||
|
|
9c0ea05c8b | ||
|
|
018c2e5468 | ||
|
|
7439335174 | ||
|
|
5eed20a24a | ||
|
|
4c2f99bc6e | ||
|
|
04e0ad39e2 | ||
|
|
255b65cd44 | ||
|
|
78477cffa3 | ||
|
|
87ac140685 | ||
|
|
14390f05e2 | ||
|
|
57adf0543a | ||
|
|
cd960f06e6 | ||
|
|
ad6b2c5478 | ||
|
|
924bc28e4b | ||
|
|
8ed4653925 | ||
|
|
51cae82224 | ||
|
|
92c51fe802 | ||
|
|
69b0761208 | ||
|
|
f68b6b4e6c | ||
|
|
c68752f759 | ||
|
|
5ba5d8a937 | ||
|
|
e9d6a461e0 | ||
|
|
9dbc7edd1d | ||
|
|
0f38a9de47 | ||
|
|
2206a6772b | ||
|
|
8d4ed90a9d | ||
|
|
586a351cdc | ||
|
|
21e27d625d | ||
|
|
97eed58230 | ||
|
|
e6652f8bcd | ||
|
|
c50f4bf567 | ||
|
|
5dfc099147 | ||
|
|
7b6ea731f4 | ||
|
|
747ff5407b | ||
|
|
0f4425ef09 | ||
|
|
cdfabae001 | ||
|
|
890238d1e5 | ||
|
|
e36e90e8ba | ||
|
|
61f07db253 | ||
|
|
cff9cdbe3c | ||
|
|
785177b001 | ||
|
|
b0c720b5f4 | ||
|
|
3dc38fba0e | ||
|
|
a9a9910ecd | ||
|
|
e84f4a246c | ||
|
|
f738a562ba | ||
|
|
494dfb7442 | ||
|
|
391e1e6f9b | ||
|
|
a2206b67cb | ||
|
|
4f85abe760 | ||
|
|
eecd63a80b | ||
|
|
b0b9900dda | ||
|
|
07926d0f52 | ||
|
|
4b4ea553dc | ||
|
|
6955808770 | ||
|
|
7bd68c951c | ||
|
|
97b90367a4 | ||
|
|
e95ecbae4e | ||
|
|
f83b5dd29a | ||
|
|
567c58cc3c | ||
|
|
4d87d8712e | ||
|
|
7de8d437f4 | ||
|
|
7a0b5980b1 | ||
|
|
9b47c9a259 | ||
|
|
3e49e5d61c | ||
|
|
42c52e3409 | ||
|
|
23dd26f941 | ||
|
|
f52faf99f2 | ||
|
|
11d20b964d | ||
|
|
4468b4847e | ||
|
|
457c1c35d4 | ||
|
|
0e25e23aaa | ||
|
|
cbeede01d3 | ||
|
|
d4be9cec2b | ||
|
|
989d97ba90 | ||
|
|
88f73e59b4 | ||
|
|
97dfab9b58 | ||
|
|
35814caf3a | ||
|
|
bac081f83e | ||
|
|
b70ed367a9 | ||
|
|
cd6300bf82 | ||
|
|
fe51fd3575 | ||
|
|
c3b9ddbfa7 | ||
|
|
d5fe88edbb | ||
|
|
31ee90680c | ||
|
|
5d7cd6cfab | ||
|
|
08ddaf56bf | ||
|
|
d42a68d9cf | ||
|
|
518e4d69b9 | ||
|
|
114f85d7b2 | ||
|
|
91763cf627 | ||
|
|
6b8f61db7c | ||
|
|
e0f674efae | ||
|
|
73adcb094c | ||
|
|
f7ef0437f3 | ||
|
|
b523815982 | ||
|
|
eba69374ae | ||
|
|
88b8010e3a | ||
|
|
7d3c27a706 | ||
|
|
2e54324ea4 | ||
|
|
ba00e6b22a | ||
|
|
cda250e965 | ||
|
|
9925efe3a6 | ||
|
|
377efbe6d5 | ||
|
|
56a595b7ef | ||
|
|
b636f68a84 | ||
|
|
0cfb3d83e1 | ||
|
|
365a7a5527 | ||
|
|
f4dc0650c7 | ||
|
|
c3bd723899 | ||
|
|
b7b764938e | ||
|
|
9448d2895d | ||
|
|
19c6f48f22 | ||
|
|
93cdda6799 | ||
|
|
3983c8e9cc | ||
|
|
f9786381f7 | ||
|
|
b568e75c37 | ||
|
|
227313012e | ||
|
|
6de832cd36 | ||
|
|
37daec8028 | ||
|
|
f1d3213345 | ||
|
|
80c46e810f | ||
|
|
8bb2211ced | ||
|
|
2325c7d02e | ||
|
|
9824fc995f | ||
|
|
e79378dd12 | ||
|
|
6c1ba4a038 | ||
|
|
0da6f5ebfb | ||
|
|
65bbf8877b | ||
|
|
56c16156ec | ||
|
|
d275d3fade | ||
|
|
648de3ec59 | ||
|
|
08457113a6 | ||
|
|
5a890f41d6 | ||
|
|
49759b383f | ||
|
|
1cf49f2cdb | ||
|
|
57b55ba02d | ||
|
|
61deaaa6f5 | ||
|
|
01a5bd0935 | ||
|
|
186d23f0ae | ||
|
|
50bb148a4a | ||
|
|
43ce841be7 | ||
|
|
dc03103f27 | ||
|
|
f286320209 | ||
|
|
68a7e95ea1 | ||
|
|
89233d3144 | ||
|
|
4e2092234f | ||
|
|
f059fdeb90 | ||
|
|
c0349cc15b | ||
|
|
754265a353 | ||
|
|
96714b7111 | ||
|
|
9d4fcd910a | ||
|
|
28dd44e2aa | ||
|
|
b4e1634fd4 | ||
|
|
91bb6ce98e | ||
|
|
d1fc3efbdb | ||
|
|
27f7982966 | ||
|
|
6a84fc7f42 | ||
|
|
3a9f9d7f6c | ||
|
|
983d6b52a1 | ||
|
|
40212c30ca | ||
|
|
c4dd4bdb19 | ||
|
|
7a9c063d5b | ||
|
|
b9e4c34178 | ||
|
|
05d25d2d2b | ||
|
|
3b483ea266 | ||
|
|
c087f8e262 | ||
|
|
c9b9f3d770 | ||
|
|
a420292386 | ||
|
|
cd8ef6a3f7 | ||
|
|
8c82961e2a | ||
|
|
676f9e80e5 | ||
|
|
3f2269146b | ||
|
|
9e866184ed | ||
|
|
db2c2112e6 | ||
|
|
de2e440b02 | ||
|
|
7197284bb1 | ||
|
|
6c72ebb7c2 | ||
|
|
2fac8c8e75 | ||
|
|
a1fbaca58e | ||
|
|
b54aff2aa9 | ||
|
|
c1c3951e7d | ||
|
|
c0ab6fee79 | ||
|
|
c87874f81d | ||
|
|
a13277103f | ||
|
|
7f008a3720 | ||
|
|
9540497d5a | ||
|
|
f5f178ea63 | ||
|
|
d2cfb2b582 | ||
|
|
6b3717cb42 | ||
|
|
b73bdb1550 | ||
|
|
e1a37e2698 | ||
|
|
956d1fe10f | ||
|
|
aa1f83b99d | ||
|
|
9e38a0650d | ||
|
|
86494403f0 | ||
|
|
2fa538d2e6 | ||
|
|
ceca98c31a | ||
|
|
95829a47fb | ||
|
|
68335ebd7a | ||
|
|
7eb1ffda06 | ||
|
|
d1eb57d3eb | ||
|
|
4692271cc6 | ||
|
|
40459c97ac | ||
|
|
391c395e77 | ||
|
|
ebadfc4ddc | ||
|
|
3f982adab7 | ||
|
|
07d254a626 | ||
|
|
9211fe3045 | ||
|
|
1e2b088c31 | ||
|
|
5c95cd8fd5 | ||
|
|
5552989bab | ||
|
|
ba4fc10e28 | ||
|
|
0cb22d0d74 | ||
|
|
3cb58f3248 | ||
|
|
9eccfb392a | ||
|
|
932e23c17f | ||
|
|
eb43c927cd | ||
|
|
81c05d3062 | ||
|
|
fa29933a5f | ||
|
|
e93750abc0 | ||
|
|
5b26ed9ef2 | ||
|
|
8ce4ef4316 | ||
|
|
a337017dfc | ||
|
|
770bea24d0 | ||
|
|
ffe71cd8ac | ||
|
|
14377b31b5 | ||
|
|
cecde81a7f | ||
|
|
89f86ef921 | ||
|
|
7356e934af | ||
|
|
5b60a58961 | ||
|
|
c0ed0fc6cd | ||
|
|
e581c54dcd | ||
|
|
52ca8ff557 | ||
|
|
4f92023e2e | ||
|
|
eef79d954d | ||
|
|
fd523d73e2 | ||
|
|
b30386c990 | ||
|
|
a0f784650d | ||
|
|
c37b0001f0 | ||
|
|
f0cdf41eb7 | ||
|
|
2b7b05342b | ||
|
|
92209aa473 | ||
|
|
347d3c1d20 | ||
|
|
d3e10c0968 | ||
|
|
77d8123c14 | ||
|
|
f2ab75b538 | ||
|
|
a9c8502eb8 | ||
|
|
adddd35935 | ||
|
|
25c32bf7a3 | ||
|
|
989038c219 | ||
|
|
8874973322 | ||
|
|
65b84696b8 | ||
|
|
057ac4ce0c | ||
|
|
28e2fcf5cf | ||
|
|
9cd9245713 | ||
|
|
4b2c74f539 | ||
|
|
95144c6348 | ||
|
|
decbc0d0cf | ||
|
|
3912404957 | ||
|
|
5f021f538b | ||
|
|
ded1eded33 | ||
|
|
ce033bfb04 | ||
|
|
36a0b453ae | ||
|
|
5e913b8dc4 | ||
|
|
7683ca0d27 | ||
|
|
2948ae64e9 | ||
|
|
6d4894d555 | ||
|
|
6cc1613cfe | ||
|
|
ed366057b3 | ||
|
|
81ce007748 | ||
|
|
ed0e5ccac1 | ||
|
|
5c66499031 | ||
|
|
d064ec9ee0 | ||
|
|
c613af6945 | ||
|
|
37e90934ea | ||
|
|
09f85c43b2 | ||
|
|
0b2c271578 | ||
|
|
1003b354e1 | ||
|
|
050af1980c | ||
|
|
bc2fdba432 | ||
|
|
6a0b463ed2 | ||
|
|
927bd632ad | ||
|
|
534dc129bd | ||
|
|
df1ddfa3e5 | ||
|
|
3646a40a97 | ||
|
|
4e89f465c4 | ||
|
|
383f111c69 | ||
|
|
3162c6f0e9 | ||
|
|
e92ca085cc | ||
|
|
47dd8a86db | ||
|
|
20ff953cdf | ||
|
|
d887c43bf7 | ||
|
|
c264e95644 | ||
|
|
b604384d7d | ||
|
|
a2dc9cd6da | ||
|
|
518da6f7e5 | ||
|
|
b598d87317 | ||
|
|
37db1b801b | ||
|
|
2df9158b53 | ||
|
|
c4a1b243fd | ||
|
|
9c1a7de3cd | ||
|
|
12f38b3ab5 | ||
|
|
928f837b73 | ||
|
|
4b65bb695a | ||
|
|
ec304224d1 | ||
|
|
a544aee913 | ||
|
|
050219a409 | ||
|
|
e6daf81dad | ||
|
|
a760315fb5 | ||
|
|
89e25aa73d | ||
|
|
a9c23fa784 | ||
|
|
bee18e19a5 | ||
|
|
7f73b009d6 | ||
|
|
f15e473213 | ||
|
|
0cd4e964ae | ||
|
|
56b1904804 | ||
|
|
505305fe63 | ||
|
|
53ad5662f3 | ||
|
|
bebb1c96e4 | ||
|
|
82a4aa0b86 | ||
|
|
d47c77e6ad | ||
|
|
3f2a7c9c73 | ||
|
|
9476844ad8 | ||
|
|
39f58f37a8 | ||
|
|
08e0f43499 | ||
|
|
9bc7c1f571 | ||
|
|
ad695f50a4 | ||
|
|
222bd1d22e | ||
|
|
63d00366f3 | ||
|
|
e9683847a6 | ||
|
|
dca5032bba | ||
|
|
ef8890f82a | ||
|
|
07cd1edd91 | ||
|
|
de63fe5973 | ||
|
|
351d08cd1a | ||
|
|
283ff16926 | ||
|
|
31ab3d05b1 | ||
|
|
7b51a44e29 | ||
|
|
b2acf708e4 | ||
|
|
ecadcf7544 | ||
|
|
ed06a4cf77 | ||
|
|
b00f80b44e | ||
|
|
f90eac0efd | ||
|
|
0be315cc32 | ||
|
|
7c6d9fbb0c | ||
|
|
ab7b350f4f | ||
|
|
0ae0bf2ed8 | ||
|
|
fa8fbe2694 | ||
|
|
6923ac226d | ||
|
|
764f1ec2b4 | ||
|
|
459a46122a | ||
|
|
45e730c0d0 | ||
|
|
f77da19615 | ||
|
|
1e8329ad8e | ||
|
|
b03d08efbf | ||
|
|
694904c33d | ||
|
|
e5476eb235 | ||
|
|
271a9e1156 | ||
|
|
f5143776f8 | ||
|
|
1b24c81318 | ||
|
|
51948a6d4c | ||
|
|
360bd0f0f4 | ||
|
|
8bead4264f | ||
|
|
c4b5790efd | ||
|
|
bb36468ab9 | ||
|
|
51a347424c | ||
|
|
4a17021b7e | ||
|
|
4183d45797 | ||
|
|
75bba75db2 | ||
|
|
1c99bc602e | ||
|
|
9a439185d5 | ||
|
|
00ccbf92bc | ||
|
|
a09190f264 | ||
|
|
7da02afdfc | ||
|
|
ced57ae113 | ||
|
|
c7c8bc7489 | ||
|
|
0be1ed226c | ||
|
|
4cbd2d3553 | ||
|
|
0792241850 | ||
|
|
4e5ebe2680 | ||
|
|
e38d085594 | ||
|
|
8e79aaf170 | ||
|
|
34fa392afb | ||
|
|
2acfa9cc6a | ||
|
|
1c0f90adc4 | ||
|
|
521fd1d8b2 | ||
|
|
8b9e2b774f | ||
|
|
170ede9d0b | ||
|
|
fcf0e7637b | ||
|
|
665280315a | ||
|
|
d7a25445b0 | ||
|
|
779d453573 | ||
|
|
353d887089 | ||
|
|
9016cc8b5e | ||
|
|
c07fabbfc1 | ||
|
|
f80b062e86 | ||
|
|
b3867cbf8a | ||
|
|
059b9bd783 | ||
|
|
17ce20ca5f | ||
|
|
ff90e9c091 | ||
|
|
7ae5968e68 | ||
|
|
c1b5549b9b | ||
|
|
48676b02c4 | ||
|
|
2eab0777c4 |
No files matched your search
@@ -0,0 +1,130 @@
|
||||
---
|
||||
name: android-java-to-kotlin
|
||||
description: >
|
||||
Use when finishing a Java-to-Kotlin conversion in an Android project, when the user
|
||||
mentions "java to kotlin", "j2k", "convert java", "migrate java to kotlin", "finish the
|
||||
conversion", "make it idiomatic", or when a freshly IDE-converted .kt file needs to be
|
||||
turned into clean, modern, idiomatic Kotlin. The developer first runs the IDE converter
|
||||
(Android Studio: Code > Convert Java File to Kotlin File), then this skill drives the
|
||||
second pass: idiomatic cleanup, fail-fast control flow, coroutines/lifecycleScope,
|
||||
modern Android APIs, function decomposition, and a behaviour-locking test.
|
||||
license: AGPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
metadata:
|
||||
author: Nextcloud Android
|
||||
version: "1.0.0"
|
||||
---
|
||||
|
||||
# Android Java to Kotlin Conversion (Second Pass)
|
||||
|
||||
The IDE converter produces Kotlin that *compiles* but is not *idiomatic*: platform types
|
||||
everywhere, one giant function per lifecycle callback, nested `if`/`else`, `new Thread`,
|
||||
`switch`, `TextUtils.isEmpty`, magic numbers. This skill drives the disciplined second
|
||||
pass that turns that output into clean, modern, testable Kotlin — **without changing
|
||||
observable behaviour** — and then writes a test that proves behaviour is unchanged.
|
||||
|
||||
## The Two-Person Workflow
|
||||
|
||||
This skill assumes a hand-off:
|
||||
|
||||
1. **Developer** runs the mechanical IDE conversion (`Code > Convert Java File to Kotlin
|
||||
File`, or ⌥⇧⌘K), producing a `.kt` file that compiles but is not idiomatic.
|
||||
2. **You (Claude)** drive everything after that:
|
||||
|
||||
Step 0 Baseline → Step 1 Idiomatic pass → Step 2 Behaviour-locking test → Step 3
|
||||
Verify. If Step 3 fails or behaviour drifts, loop back to Step 1.
|
||||
|
||||
If you are handed a `.java` file instead, first apply a faithful 1:1 translation to reach
|
||||
the same starting point, then continue.
|
||||
|
||||
## The Prime Directive: Behaviour Must Not Change
|
||||
|
||||
Every transformation in this skill is **behaviour-preserving**. You are refactoring for
|
||||
readability, safety, and modern API usage — not adding features or fixing bugs. If you
|
||||
spot a real bug, surface it to the developer; do not silently "fix" it inside a
|
||||
conversion. The behaviour-locking test in Step 3 exists to keep you honest.
|
||||
|
||||
## Step 0: Establish Baseline
|
||||
|
||||
Before editing anything:
|
||||
|
||||
1. Read the whole `.kt` file (and, if you can, the original `.java` via
|
||||
`git show <rev>:<path>.java` or the IDE's local history) to understand *what it does*.
|
||||
2. Write down the **public/observable surface** you must keep intact:
|
||||
- Lifecycle callbacks (`onCreate`, `onViewCreated`, `onSaveInstanceState`, …) and their
|
||||
ordering of side-effects.
|
||||
- Any Parcelable/Bundle keys, intent extras, and `newInstance(...)` factory shapes.
|
||||
3. Note threading: which work runs off the main thread today (`Thread`, `AsyncTask`,
|
||||
`runOnUiThread`, executors) — this maps to coroutines in Step 2.
|
||||
|
||||
## Step 1: Idiomatic Pass
|
||||
|
||||
Apply, in this order, then re-check the invariants:
|
||||
|
||||
1. **Kill platform types.** Give every `!` platform type an explicit nullable/non-null
|
||||
type based on the Java source and call sites.
|
||||
2. **Fail fast.** Replace nested `if`/`else` pyramids and null-checks with guard clauses
|
||||
and `require`/`requireNotNull`/`?: return`. See [FAIL-FAST.md](references/FAIL-FAST.md).
|
||||
3. **Decompose.** Break each oversized lifecycle callback / `setupView`-style method into
|
||||
small, single-purpose private functions named for their intent. See
|
||||
[ANDROID-IDIOMS.md](references/ANDROID-IDIOMS.md).
|
||||
4. **Modern concurrency.** Replace `new Thread`, `AsyncTask`, `runOnUiThread`, and
|
||||
callback pairs with `lifecycleScope` + `suspend` + `withContext`. See
|
||||
[CONCURRENCY.md](references/CONCURRENCY.md).
|
||||
5. **Modern Android + Kotlin idioms.** Scope functions (`run`/`apply`/`let`), extension
|
||||
functions, `when`/`partition`/`filter` over `switch`, string templates, `isNullOrEmpty`,
|
||||
view/KTX extensions. See [ANDROID-IDIOMS.md](references/ANDROID-IDIOMS.md). Retire
|
||||
deprecated Android APIs (`onActivityResult`, options-menu overrides,
|
||||
`java.util.Observable`) — see [DEPRECATED-APIS.md](references/DEPRECATED-APIS.md).
|
||||
6. **Project conventions.** SPDX header, no magic numbers (`companion object` +
|
||||
`const val`), resources not hardcoded strings, ≤300 lines/file, ≤120 cols. See
|
||||
[PROJECT-CONVENTIONS.md](references/PROJECT-CONVENTIONS.md).
|
||||
7. **Testability seams.** Extract pure logic (URL building, permission math, partitioning)
|
||||
into functions you can unit-test; mark with `@VisibleForTesting` where they must stay
|
||||
`internal`/`private`-ish but be reachable from tests.
|
||||
|
||||
Do NOT expand scope. Unrelated files stay untouched (AGENTS.md / AI policy).
|
||||
|
||||
## Step 2: Write a Behaviour-Locking Test (Mandatory)
|
||||
|
||||
A conversion is not complete until a test proves behaviour is unchanged. See
|
||||
[TESTING.md](references/TESTING.md) for the decision tree. In short:
|
||||
|
||||
- **Pure functions you extracted** (e.g. link builders, `isReshareForbidden`,
|
||||
partitioning) → fast JVM unit tests in `app/src/test/` (JUnit4 + mockito-kotlin).
|
||||
- **Fragment/Activity/DB behaviour** → instrumented test in `app/src/androidTest/`
|
||||
extending the project's base test class, or a Robolectric test where the project uses it.
|
||||
- Prefer testing the **seams you just created**. If the Java original had no test, your
|
||||
new test is the characterization test that locks current behaviour.
|
||||
|
||||
Every test file gets the SPDX header and follows the project's test conventions.
|
||||
|
||||
## Step 3: Verify
|
||||
|
||||
Run and report real output — never claim green without evidence:
|
||||
|
||||
```bash
|
||||
# Formatting + static analysis on the changed files
|
||||
./gradlew spotlessKotlinCheck detektGplayDebug lintGplayDebug spotbugsGplayDebug
|
||||
|
||||
# Unit tests
|
||||
./gradlew jacocoTestGplayDebugUnitTest
|
||||
|
||||
# Instrumented tests (if you wrote one), scoped to the class
|
||||
./gradlew createGplayDebugCoverageReport -Pcoverage=true \
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=<fully.qualified.TestClass>
|
||||
```
|
||||
|
||||
## Worked Example
|
||||
|
||||
[assets/worked-example.md](assets/worked-example.md) is a real before/after from
|
||||
`FileDetailSharingFragment` (871-line Java fragment → idiomatic Kotlin) showing each
|
||||
transformation class in context. Read it when you need a concrete pattern.
|
||||
|
||||
## Batch Conversion
|
||||
|
||||
Convert one file at a time, leaf dependencies first. Report progress per file. Warn the
|
||||
developer before a change set grows into several thousand lines — split into focused PRs
|
||||
(AGENTS.md). Each commit needs `Assisted-by: <agent>:<model>`; only the human adds
|
||||
`Signed-off-by`.
|
||||
@@ -0,0 +1,163 @@
|
||||
# Worked Example: FileDetailSharingFragment
|
||||
|
||||
A real conversion of an 871-line Java fragment
|
||||
(`com.owncloud.android.ui.fragment.FileDetailSharingFragment`) into idiomatic Kotlin. Each
|
||||
section shows one transformation class from the skill, in context. Behaviour is unchanged
|
||||
throughout; the only new capability (`@VisibleForTesting createInternalLink`) is a
|
||||
testability seam that returns the same URL the Java produced.
|
||||
|
||||
## A. SPDX Header Rewrite
|
||||
|
||||
```diff
|
||||
-/*
|
||||
- * Nextcloud Android client application
|
||||
- *
|
||||
- * @author Andy Scherzinger
|
||||
- * ...
|
||||
- * Copyright (C) 2018 Andy Scherzinger
|
||||
- * SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
- */
|
||||
+/*
|
||||
+ * Nextcloud - Android Client
|
||||
+ *
|
||||
+ * SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
+ * SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
+ */
|
||||
```
|
||||
|
||||
## B. Fail-Fast Preconditions
|
||||
|
||||
```diff
|
||||
-if (file == null) throw new IllegalArgumentException("File may not be null");
|
||||
-if (user == null) throw new IllegalArgumentException("Account may not be null");
|
||||
-fileActivity = (FileActivity) getActivity();
|
||||
-if (fileActivity == null) throw new IllegalArgumentException("FileActivity may not be null");
|
||||
+fileActivity = (activity as FileActivity?)
|
||||
+requireNotNull(file) { "File may not be null" }
|
||||
+requireNotNull(user) { "Account may not be null" }
|
||||
+requireNotNull(fileActivity) { "FileActivity may not be null" }
|
||||
```
|
||||
|
||||
## C. Decomposition of `onViewCreated`
|
||||
|
||||
The Java `onViewCreated` inlined adapter creation (duplicated for internal/external),
|
||||
layout managers, listeners, and the fetch kick-off. It became a readable sequence plus
|
||||
extracted helpers `getUserId()`, `setupInternalShares()`, `setupExternalShares()`,
|
||||
`createShareListAdapter(userId, type)`, `startAnimation()`. The two near-identical adapter
|
||||
blocks collapsed into one parameterized factory:
|
||||
|
||||
```kotlin
|
||||
private fun createShareListAdapter(userId: String, type: SharesType): ShareeListAdapter =
|
||||
ShareeListAdapter(
|
||||
fileActivity!!, ArrayList(), this, userId, user, viewThemeUtils,
|
||||
(file?.isEncrypted == true), type
|
||||
).apply { setHasStableIds(true) }
|
||||
```
|
||||
|
||||
## D. `new Thread` + `runOnUiThread` → `lifecycleScope` + `suspend`
|
||||
|
||||
```diff
|
||||
-private void fetchE2EECounter(Runnable onComplete) {
|
||||
- new Thread(() -> {
|
||||
- try { ... fileDataStorageManager.saveFile(file); }
|
||||
- catch (Exception e) { Log_OC.e(TAG, "..." + e.getMessage()); }
|
||||
- Activity a = getActivity();
|
||||
- if (a != null) a.runOnUiThread(onComplete);
|
||||
- }).start();
|
||||
-}
|
||||
+private suspend fun fetchE2EECounter(): Boolean = withContext(Dispatchers.IO) {
|
||||
+ return@withContext try {
|
||||
+ val client = clientFactory.create(user)
|
||||
+ val metadata = RefreshFolderOperation.getDecryptedFolderMetadata(true, file, client, user, requireContext())
|
||||
+ if (metadata is DecryptedFolderMetadataFile) {
|
||||
+ file?.setE2eCounter(metadata.metadata.counter)
|
||||
+ fileDataStorageManager?.saveFile(file)
|
||||
+ }
|
||||
+ true
|
||||
+ } catch (e: Exception) {
|
||||
+ Log_OC.e(TAG, "Error refreshing E2E counter: " + e.message)
|
||||
+ false
|
||||
+ }
|
||||
+}
|
||||
```
|
||||
|
||||
Caller now `lifecycleScope.launch { if (!fetchE2EECounter()) return@launch; withContext(Main){ ... } }`.
|
||||
The callback-pair `fetchSharees(onSuccess, onError)` was likewise turned into a `suspend`
|
||||
call returning `Boolean`.
|
||||
|
||||
## E. `switch` Bucketing → `partition` + Set
|
||||
|
||||
```diff
|
||||
-for (OCShare share : shares) {
|
||||
- if (share.getShareType() != null) {
|
||||
- switch (share.getShareType()) {
|
||||
- case PUBLIC_LINK: case FEDERATED_GROUP: case FEDERATED: case EMAIL:
|
||||
- externalShares.add(share); break;
|
||||
- default: internalShares.add(share); break;
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
+private val externalShareTypes = setOf(
|
||||
+ ShareType.PUBLIC_LINK, ShareType.FEDERATED_GROUP, ShareType.FEDERATED, ShareType.EMAIL
|
||||
+)
|
||||
+val (external, internal) = shares
|
||||
+ .filter { it.shareType != null }
|
||||
+ .partition { it.shareType in externalShareTypes }
|
||||
```
|
||||
|
||||
## F. Nested `if` Cursor Handling → Guard Clauses
|
||||
|
||||
The three-level-nested `handleContactResult` became flat sequential guards, each showing
|
||||
the snackbar + log and returning, with `cursor.close()` preserved on every path. See
|
||||
[FAIL-FAST.md](../references/FAIL-FAST.md) section "Deeply Nested".
|
||||
|
||||
## G. Scope Functions & KTX
|
||||
|
||||
```diff
|
||||
-final LinearLayout shimmerLayout = binding.shimmerLayout.getRoot();
|
||||
-shimmerLayout.clearAnimation();
|
||||
-shimmerLayout.setVisibility(View.GONE);
|
||||
-binding.shareContainer.setVisibility(View.VISIBLE);
|
||||
+binding?.run {
|
||||
+ shimmerLayout.root.run { clearAnimation(); visibility = View.GONE }
|
||||
+ shareContainer.visibility = View.VISIBLE
|
||||
+}
|
||||
```
|
||||
|
||||
```diff
|
||||
-for (int i = 0; i < viewGroup.getChildCount(); i++) { toggleSearchViewEnable(viewGroup.getChildAt(i), enable); }
|
||||
+for (i in 0..<view.size) { toggleSearchViewEnable(view.getChildAt(i), enable) } // androidx.core.view.size
|
||||
```
|
||||
|
||||
## H. Constants + Companion + `@JvmStatic`
|
||||
|
||||
```diff
|
||||
-private static final String TAG = "FileDetailSharingFragment";
|
||||
-ViewExtensionsKt.setVisibleIf(binding.sharesListInternalShowAll, adapter.shares.size() > 3);
|
||||
+companion object {
|
||||
+ private const val TAG = "FileDetailSharingFragment"
|
||||
+ private const val MIN_SHOW_ALL_VISIBLE_ITEM_COUNT = 3
|
||||
+ @JvmStatic fun newInstance(file: OCFile?, user: User?) = FileDetailSharingFragment().apply { ... }
|
||||
+}
|
||||
+binding.sharesListInternalShowAll.setVisibleIf(internalShares.size > MIN_SHOW_ALL_VISIBLE_ITEM_COUNT)
|
||||
```
|
||||
|
||||
## I. Testability Seam
|
||||
|
||||
`createInternalLink` was inlined string concatenation in Java. It was extracted to a pure
|
||||
`@VisibleForTesting internal fun createInternalLink(user, file, capabilities): String` that
|
||||
returns the identical URL — enabling the unit test in
|
||||
[TESTING.md](../references/TESTING.md) without a device.
|
||||
|
||||
## J. Detekt Suppression (Last Resort)
|
||||
|
||||
The class is genuinely large and can't be fully split within one conversion, so a
|
||||
file-level suppression documents the debt honestly:
|
||||
|
||||
```kotlin
|
||||
@Suppress("TooManyFunctions", "LargeClass", "TooGenericExceptionCaught", "ReturnCount")
|
||||
class FileDetailSharingFragment : Fragment(), ... {
|
||||
```
|
||||
|
||||
Prefer real decomposition; use this only when splitting is out of scope, and tell the
|
||||
developer.
|
||||
@@ -0,0 +1,170 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Android + Kotlin Idioms
|
||||
|
||||
Transformations applied during the idiomatic pass. Every one is behaviour-preserving.
|
||||
Examples are drawn from a real fragment conversion.
|
||||
|
||||
## 1. Decompose Oversized Functions
|
||||
|
||||
The IDE keeps the Java structure: one enormous `onViewCreated`/`setupView` that inflates,
|
||||
themes, wires listeners, and kicks off loading in a single 80-line block. Split by
|
||||
intent into small private functions. The lifecycle callback becomes a readable table of
|
||||
contents.
|
||||
|
||||
```kotlin
|
||||
// BEFORE: onViewCreated does everything inline (adapters, layout managers, listeners, fetch)
|
||||
|
||||
// AFTER
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
fileActivity ?: return
|
||||
fileDataStorageManager = fileActivity?.storageManager
|
||||
fileOperationsHelper = fileActivity?.fileOperationsHelper
|
||||
|
||||
startAnimation()
|
||||
val userId = getUserId()
|
||||
setupInternalShares(userId)
|
||||
setupExternalShares(userId)
|
||||
binding?.pickContactEmailBtn?.setOnClickListener { checkContactPermission() }
|
||||
fetchSharees()
|
||||
setupView()
|
||||
}
|
||||
```
|
||||
|
||||
Rules:
|
||||
- One function = one reason to change. Name it for *what it accomplishes*
|
||||
(`setupInternalShares`, `themeView`, `disableE2EEShareForV1`), not *how*.
|
||||
- Factor duplicated blocks into a parameterized helper
|
||||
(`createShareListAdapter(userId, SharesType.INTERNAL)`).
|
||||
- Keep files ≤300 lines (project rule). Heavy decomposition sometimes means splitting a
|
||||
god-class into collaborators — raise that with the developer rather than exceeding 300.
|
||||
|
||||
## 2. Scope Functions Over Repetition
|
||||
|
||||
Replace repeated `binding.x` / `viewThemeUtils.material.y` chains with `run`/`apply`/`with`.
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
viewThemeUtils.material.themeSearchCardView(binding.searchCardWrapper);
|
||||
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.sendCopyBtn);
|
||||
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.sharesListInternalShowAll);
|
||||
|
||||
// AFTER
|
||||
binding.run {
|
||||
viewThemeUtils.material.run {
|
||||
themeSearchCardView(searchCardWrapper)
|
||||
colorMaterialButtonPrimaryOutlined(sendCopyBtn)
|
||||
colorMaterialButtonPrimaryBorderless(sharesListInternalShowAll)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Use `apply {}` when configuring and returning the receiver:
|
||||
|
||||
```kotlin
|
||||
ShareeListAdapter(fileActivity!!, ArrayList(), this, userId, user, viewThemeUtils, encrypted, type)
|
||||
.apply { setHasStableIds(true) }
|
||||
```
|
||||
|
||||
## 3. `switch` → `when` / `filter` + `partition`
|
||||
|
||||
Collapse a `switch` that sorts items into buckets into a declarative pipeline with a
|
||||
constant `Set`.
|
||||
|
||||
```kotlin
|
||||
// BEFORE: for-loop with switch(shareType) adding to internalShares / externalShares
|
||||
|
||||
// AFTER
|
||||
private val externalShareTypes = setOf(
|
||||
ShareType.PUBLIC_LINK, ShareType.FEDERATED_GROUP, ShareType.FEDERATED, ShareType.EMAIL
|
||||
)
|
||||
|
||||
val (external, internal) = shares
|
||||
.filter { it.shareType != null }
|
||||
.partition { it.shareType in externalShareTypes }
|
||||
```
|
||||
|
||||
## 4. Extension Functions & KTX
|
||||
|
||||
Import members directly and lean on AndroidX KTX instead of verbose Java utilities.
|
||||
|
||||
| Java / verbose | Idiomatic Kotlin |
|
||||
|---|---|
|
||||
| `TextUtils.isEmpty(s)` | `s.isNullOrEmpty()` |
|
||||
| `BundleExtensionsKt.getParcelableArgument(b, k, T.class)` | `b.getParcelableArgument(k, T::class.java)` |
|
||||
| `for (int i = 0; i < vg.getChildCount(); i++)` | `for (i in 0..<view.size)` (`androidx.core.view.size`) |
|
||||
| manual getter/setter methods | Kotlin property access (`view.visibility = View.GONE`) |
|
||||
| `private int x; public int getX()` (read-only to callers) | `var columnsCount = 0; private set` |
|
||||
| empty override method body | `= Unit` single-expression body |
|
||||
| free-standing util call | receiver extension (`externalShares.mergeDistinctByToken(publicShares)`) |
|
||||
|
||||
Domain-specific extensions read best as receivers on the relevant type:
|
||||
|
||||
```kotlin
|
||||
private fun OCCapability?.isPasswordEnforced(): Boolean =
|
||||
this?.filesSharingPublicPasswordEnforced?.isTrue == true &&
|
||||
filesSharingPublicAskForOptionalPassword.isTrue
|
||||
```
|
||||
|
||||
## 5. Null Safety Instead of Platform Types
|
||||
|
||||
The IDE leaves `!` platform types and defensive Java null-checks. Replace with `?.`,
|
||||
`?:`, and Kotlin's `require`/`requireNotNull`. A nullable `binding` (cleared in
|
||||
`onDestroyView`) is the canonical Android case — guard it with `?.` / `?: return`.
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
if (binding == null) return;
|
||||
final LinearLayout shimmer = binding.shimmerLayout.getRoot();
|
||||
shimmer.clearAnimation();
|
||||
|
||||
// AFTER
|
||||
binding?.run {
|
||||
shimmerLayout.root.run {
|
||||
clearAnimation()
|
||||
visibility = View.GONE
|
||||
}
|
||||
shareContainer.visibility = View.VISIBLE
|
||||
}
|
||||
```
|
||||
|
||||
## 6. Constants & Companion Object
|
||||
|
||||
Move `static final` and magic literals into a `companion object`; use `const val` for
|
||||
compile-time constants. Add `@JvmStatic` to factory methods still called from Java.
|
||||
|
||||
```kotlin
|
||||
companion object {
|
||||
private const val TAG = "FileDetailSharingFragment"
|
||||
private const val ARG_FILE = "FILE"
|
||||
private const val MIN_SHOW_ALL_VISIBLE_ITEM_COUNT = 3
|
||||
private const val INTERNAL_LINK_PATH_PRETTY = "/f/"
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(file: OCFile?, user: User?) = FileDetailSharingFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(ARG_FILE, file)
|
||||
putParcelable(ARG_USER, user)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 7. Detekt Suppressions Are a Last Resort
|
||||
|
||||
If a legacy god-class genuinely cannot be split within the conversion's scope, a
|
||||
file/class-level `@Suppress("TooManyFunctions", "LargeClass", ...)` is acceptable — but
|
||||
prefer real decomposition and tell the developer what you suppressed and why.
|
||||
|
||||
## 8. `// region` Organization
|
||||
|
||||
For large classes, grouping members under `// region <name>` / `// endregion` (lifecycle,
|
||||
private methods, overrides, companion) aids IDE folding. This is IDE structure, not a
|
||||
decorative divider. Match the surrounding file's existing style; do not introduce ASCII
|
||||
banner comments (`// ==== ====`), which the project forbids.
|
||||
@@ -0,0 +1,213 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Concurrency: Java Threads → Coroutines & `lifecycleScope`
|
||||
|
||||
Replace `new Thread`, `AsyncTask`, executors, and `runOnUiThread`/`Handler.post`
|
||||
callback-passing with structured coroutines scoped to the component lifecycle. This is
|
||||
behaviour-preserving *and* fixes leaks: `lifecycleScope`/`viewModelScope` cancel
|
||||
automatically when the owner is destroyed, so no work touches a dead view.
|
||||
|
||||
## Choose the Right Scope
|
||||
|
||||
| Context | Scope |
|
||||
|---|---|
|
||||
| `Fragment` (UI work tied to view) | `viewLifecycleOwner.lifecycleScope` (preferred) or `lifecycleScope` |
|
||||
| `Activity` | `lifecycleScope` |
|
||||
| `ViewModel` | `viewModelScope` |
|
||||
| No lifecycle owner | inject a `CoroutineScope` / use a repository suspend fun |
|
||||
|
||||
Use `Dispatchers.IO` for disk/network/DB, `Dispatchers.Main` (or `withContext(Main)`) to
|
||||
touch views.
|
||||
|
||||
## `AsyncTask` → Coroutines
|
||||
|
||||
`AsyncTask` is deprecated. Map its callbacks onto a single `launch`:
|
||||
|
||||
| `AsyncTask` | Coroutine |
|
||||
|---|---|
|
||||
| `onPreExecute()` | code before `withContext(IO)` (runs on Main) |
|
||||
| `doInBackground()` | `withContext(Dispatchers.IO) { ... }` |
|
||||
| `onPostExecute(result)` | code after, back on `Dispatchers.Main` |
|
||||
| `isCancelled()` | `isActive` (or `ensureActive()`) |
|
||||
| `cancel(true)` | `job.cancel()` |
|
||||
| the `AsyncTask` instance field | the returned `Job` |
|
||||
|
||||
A self-contained task class stops extending `AsyncTask` and holds the lifecycle owner so
|
||||
its scope cancels with the screen:
|
||||
|
||||
```kotlin
|
||||
// BEFORE: class GallerySearchTask extends AsyncTask<Void, Void, Result> { ... }
|
||||
class GallerySearchTask(
|
||||
private val fragment: GalleryFragment,
|
||||
private val user: User,
|
||||
private val storageManager: FileDataStorageManager,
|
||||
private val endDate: Long,
|
||||
private val limit: Int
|
||||
) {
|
||||
fun execute(): Job = fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||
if (!isActive) return@launch
|
||||
val context = fragment.context ?: return@launch
|
||||
val result = performSearch(context)
|
||||
withContext(Dispatchers.Main) {
|
||||
fragment.searchCompleted(result.emptySearch, result.lastTimestamp)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The caller keeps the `Job` and cancels it with the view:
|
||||
|
||||
```kotlin
|
||||
private var photoSearchTask: Job? = null
|
||||
// ...
|
||||
photoSearchTask = GallerySearchTask(this, user, storageManager, endDate, limit).execute()
|
||||
|
||||
override fun onDestroyView() {
|
||||
photoSearchTask?.cancel()
|
||||
photoSearchTask = null
|
||||
}
|
||||
```
|
||||
|
||||
Because `lifecycleScope` cancels on destroy, the old `WeakReference<Fragment>` leak-guard
|
||||
disappears — a direct `fragment` reference plus `fragment.context ?: return@launch` is
|
||||
enough. (PR #16908)
|
||||
|
||||
## `AsyncTask` Behind a Callback API → `runCatching` + `fold`
|
||||
|
||||
When a service method hid an `AsyncTask` that set mutable fields (a boolean success flag,
|
||||
`errorMessage`, result fields) and dispatched them in `onPostExecute`, keep the public
|
||||
callback signature but drive it from a coroutine. Return an **immutable** result from the
|
||||
background function and branch with `fold`:
|
||||
|
||||
```kotlin
|
||||
private data class ActivitiesResult(
|
||||
val activities: List<Any>,
|
||||
val client: NextcloudClient,
|
||||
val lastGiven: Long
|
||||
)
|
||||
|
||||
override fun getActivities(lastGiven: Long, callback: ActivitiesServiceCallback) {
|
||||
scope.launch {
|
||||
runCatching { withContext(Dispatchers.IO) { fetchActivities(lastGiven) } }
|
||||
.fold(
|
||||
onSuccess = { (activities, client, updated) ->
|
||||
callback.onLoaded(activities, client, updated)
|
||||
},
|
||||
onFailure = { callback.onError(it.message ?: "") }
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`runCatching` / `fold` replaces the boolean-success + `errorMessage`-field idiom; the
|
||||
background function `fetchActivities` throws on failure instead of returning `false`, and
|
||||
the immutable `ActivitiesResult` destructures straight into `onSuccess`. (PR #16654)
|
||||
|
||||
> **Scope caveat:** that PR launched on an ad-hoc `CoroutineScope(Dispatchers.Main)` with
|
||||
> no lifecycle owner — it never cancels and can leak. Prefer an injected `CoroutineScope`
|
||||
> or expose a `suspend` function the presenter runs on `lifecycleScope` / `viewModelScope`.
|
||||
> Flag ad-hoc scopes in review.
|
||||
|
||||
## `new Thread { ... runOnUiThread(...) }` → `lifecycleScope.launch` + `withContext`
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
private void fetchE2EECounter(Runnable onComplete) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
OwnCloudClient client = clientFactory.create(user);
|
||||
Object metadata = RefreshFolderOperation.getDecryptedFolderMetadata(true, file, client, user, ctx);
|
||||
if (metadata instanceof DecryptedFolderMetadataFile m) {
|
||||
file.setE2eCounter(m.getMetadata().getCounter());
|
||||
fileDataStorageManager.saveFile(file);
|
||||
}
|
||||
} catch (Exception e) { Log_OC.e(TAG, "..." + e.getMessage()); }
|
||||
Activity a = getActivity();
|
||||
if (a != null) a.runOnUiThread(onComplete);
|
||||
}).start();
|
||||
}
|
||||
|
||||
// AFTER: background work is a suspend fun on IO; the UI reaction runs on Main
|
||||
private suspend fun fetchE2EECounter(): Boolean = withContext(Dispatchers.IO) {
|
||||
return@withContext try {
|
||||
val context = requireContext()
|
||||
val client = clientFactory.create(user)
|
||||
val metadata = RefreshFolderOperation.getDecryptedFolderMetadata(true, file, client, user, context)
|
||||
if (metadata is DecryptedFolderMetadataFile) {
|
||||
file?.setE2eCounter(metadata.metadata.counter)
|
||||
fileDataStorageManager?.saveFile(file)
|
||||
}
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Error refreshing E2E counter: " + e.message)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// caller
|
||||
lifecycleScope.launch {
|
||||
val ok = fetchE2EECounter()
|
||||
if (!ok) return@launch
|
||||
withContext(Dispatchers.Main) { /* update views */ }
|
||||
}
|
||||
```
|
||||
|
||||
Notes:
|
||||
- The old code returned nothing and drove the UI via a `Runnable`. The idiomatic version
|
||||
returns a `Boolean` result and lets the caller decide — same observable outcome, no
|
||||
callback threading.
|
||||
- `getActivity() != null` guard becomes `lifecycleScope` cancellation + `binding?`/`?:
|
||||
return` guards. Preserve any "is the view still alive?" check as a `binding == null`
|
||||
guard inside `launch`.
|
||||
|
||||
## Callback-Pair API → `suspend` Result
|
||||
|
||||
Repositories that took `onSuccess`/`onError` lambdas become `suspend` functions returning
|
||||
a result, awaited inside a coroutine.
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
shareRepository.fetchSharees(remotePath, onSuccess = { ... }, onError = { ... });
|
||||
|
||||
// AFTER
|
||||
lifecycleScope.launch {
|
||||
val result = shareRepository.fetchSharees(remotePath)
|
||||
if (binding == null) return@launch
|
||||
if (result) { refreshSharesFromDB(); stopLoadingAnimationAndShowShareContainer() }
|
||||
else { stopLoadingAnimationAndShowShareContainer(); showError() }
|
||||
}
|
||||
```
|
||||
|
||||
## Moving DB/IO off the Main Thread
|
||||
|
||||
Wrap the blocking DB read in `withContext(Dispatchers.IO)` and hop back to `Main` to touch
|
||||
adapters/views. This can be a *behaviour improvement* (fewer main-thread stalls) — flag it
|
||||
to the developer if the Java version was doing DB work on the main thread synchronously,
|
||||
since timing changes can be observable (e.g. tests that assumed synchronous population).
|
||||
|
||||
```kotlin
|
||||
private suspend fun loadAndPartitionShares(): Pair<List<OCShare>, List<OCShare>> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val shares = fileDataStorageManager?.getSharesWithForAFile(file?.remotePath, user?.accountName)
|
||||
?: emptyList()
|
||||
val (external, internal) = shares.filter { it.shareType != null }
|
||||
.partition { it.shareType in externalShareTypes }
|
||||
internal to external
|
||||
}
|
||||
```
|
||||
|
||||
## Pitfalls
|
||||
|
||||
- Never launch on `GlobalScope` — it outlives the screen and leaks.
|
||||
- An ad-hoc `CoroutineScope(Dispatchers.Main)` created inside a service/presenter has the
|
||||
same problem: no lifecycle owner, no cancellation, a leak. Use an injected scope or a
|
||||
`suspend` function the caller runs on `lifecycleScope` / `viewModelScope`.
|
||||
- Keep `try/catch` semantics: coroutine cancellation throws `CancellationException`;
|
||||
rethrow it (don't swallow in a broad `catch (e: Exception)` that logs and continues) or
|
||||
catch `Exception` only around the real work, not around the whole `launch`.
|
||||
- Preserve exception-to-UI mapping exactly (same snackbar, same log tag/message).
|
||||
@@ -0,0 +1,85 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Retiring Deprecated Android APIs During Conversion
|
||||
|
||||
A Java→Kotlin conversion is the right moment to replace deprecated Android APIs the IDE
|
||||
converter leaves untouched. Each replacement below is behaviour-preserving. Examples are
|
||||
real conversions (nextcloud/android PRs #16878, #16792).
|
||||
|
||||
## `startActivityForResult` / `onActivityResult` → Activity Result API
|
||||
|
||||
The request-code + `onActivityResult` protocol is deprecated. Register a launcher at
|
||||
construction time and receive the result in its callback.
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
startActivityForResult(action, SELECT_LOCATION_REQUEST_CODE)
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == SELECT_LOCATION_REQUEST_CODE && data != null) { handle(data) }
|
||||
}
|
||||
|
||||
// AFTER
|
||||
private val folderPickerLauncher = registerForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
handle(result.data)
|
||||
}
|
||||
}
|
||||
|
||||
// launch it:
|
||||
folderPickerLauncher.launch(intent)
|
||||
```
|
||||
|
||||
Type-safe, no manual request-code bookkeeping, and it survives process death because
|
||||
registration is declarative. Register during initialization (a field initializer or
|
||||
`onCreate`/`onViewCreated`) — never inside a click handler, or the registration is lost.
|
||||
|
||||
## `onCreateOptionsMenu` / `onOptionsItemSelected` → `MenuProvider`
|
||||
|
||||
`setHasOptionsMenu(true)` plus the two menu overrides are deprecated on `Fragment`. Add a
|
||||
`MenuProvider` bound to the view lifecycle instead.
|
||||
|
||||
```kotlin
|
||||
// AFTER
|
||||
val menuHost: MenuHost = requireActivity()
|
||||
menuHost.addMenuProvider(object : MenuProvider {
|
||||
override fun onCreateMenu(menu: Menu, inflater: MenuInflater) =
|
||||
inflater.inflate(R.menu.gallery_menu, menu)
|
||||
|
||||
override fun onMenuItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
||||
R.id.action_select_all -> { selectAll(); true }
|
||||
else -> false
|
||||
}
|
||||
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
|
||||
```
|
||||
|
||||
Passing `viewLifecycleOwner` + `Lifecycle.State.RESUMED` auto-adds and removes the menu as
|
||||
the view's lifecycle changes — no leak, no manual `setHasOptionsMenu`. (PR #16878)
|
||||
|
||||
## `java.util.Observable` — Keep or Migrate?
|
||||
|
||||
`java.util.Observable` / `Observer` are deprecated (Java 9+). But a conversion is
|
||||
behaviour-locked, so **do not** silently swap the notification mechanism — existing Java
|
||||
observers rely on `setChanged()` / `notifyObservers()`. PR #16792 deliberately KEPT it:
|
||||
|
||||
```kotlin
|
||||
class UploadsStorageManager(...) : Observable() {
|
||||
fun notifyObserversNow() {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
setChanged()
|
||||
notifyObservers()
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Migrating to `StateFlow` / `SharedFlow` changes the observation contract and every call
|
||||
site — that is a separate, opt-in refactor, not part of a 1:1 conversion. Note the
|
||||
deprecation, propose the flow migration as a follow-up, and keep the current mechanism
|
||||
unless the developer scopes the larger change.
|
||||
@@ -0,0 +1,115 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Fail Fast: Guard Clauses Over Nested `if`/`else`
|
||||
|
||||
The IDE preserves Java's nested-`if` pyramids. Invert them into guard clauses that return
|
||||
(or throw) early, leaving the happy path at the lowest indentation. Behaviour is
|
||||
identical — the branches are the same, only the shape changes.
|
||||
|
||||
## Precondition Checks → `require` / `requireNotNull`
|
||||
|
||||
`requireNotNull` returns the smart-cast non-null value AND throws
|
||||
`IllegalArgumentException` with the message — exactly matching the Java `if (x == null)
|
||||
throw new IllegalArgumentException(...)`.
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
if (file == null) throw IllegalArgumentException("File may not be null");
|
||||
if (user == null) throw IllegalArgumentException("Account may not be null");
|
||||
fileActivity = (FileActivity) getActivity();
|
||||
if (fileActivity == null) throw IllegalArgumentException("FileActivity may not be null");
|
||||
|
||||
// AFTER
|
||||
fileActivity = activity as? FileActivity
|
||||
requireNotNull(file) { "File may not be null" }
|
||||
requireNotNull(user) { "Account may not be null" }
|
||||
requireNotNull(fileActivity) { "FileActivity may not be null" }
|
||||
```
|
||||
|
||||
Use `require(condition) { msg }` for boolean preconditions:
|
||||
|
||||
```kotlin
|
||||
require(activity is FileActivity) { "Calling activity must be of type FileActivity" }
|
||||
```
|
||||
|
||||
`check`/`checkNotNull` are the `IllegalStateException` equivalents — use them when the Java
|
||||
threw `IllegalStateException`. Match the original exception type; that is observable
|
||||
behaviour.
|
||||
|
||||
## Early Return Over Nested Success Path
|
||||
|
||||
```kotlin
|
||||
// BEFORE
|
||||
private void checkShareViaUser() {
|
||||
if (!MDMConfig.INSTANCE.shareViaUser(requireContext())) {
|
||||
binding.searchContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// AFTER
|
||||
private fun checkShareViaUser() {
|
||||
if (shareViaUser(requireContext())) return
|
||||
binding?.searchContainer?.visibility = View.GONE
|
||||
}
|
||||
```
|
||||
|
||||
## Deeply Nested `if`/`else` → Sequential Guards
|
||||
|
||||
The most valuable transformation. A cursor-handling method nested three levels deep
|
||||
becomes a flat sequence of guard clauses, each handling one failure and returning.
|
||||
|
||||
```kotlin
|
||||
// BEFORE: if (cursor != null) { if (moveToFirst()) { if (columnIndex != -1) {...} else ... } else ... } else ...
|
||||
|
||||
// AFTER
|
||||
private fun handleContactResult(contactUri: Uri) {
|
||||
val cursor = fileActivity?.contentResolver?.query(contactUri, projection, null, null, null)
|
||||
if (cursor == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed)
|
||||
Log_OC.e(TAG, "Failed to pick email address as Cursor is null.")
|
||||
return
|
||||
}
|
||||
if (!cursor.moveToFirst()) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed)
|
||||
Log_OC.e(TAG, "Failed to pick email address as no Email found.")
|
||||
return
|
||||
}
|
||||
val columnIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS)
|
||||
if (columnIndex == -1) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed)
|
||||
Log_OC.e(TAG, "Failed to pick email address.")
|
||||
cursor.close()
|
||||
return
|
||||
}
|
||||
val email = cursor.getString(columnIndex)
|
||||
// ... happy path at base indentation
|
||||
cursor.close()
|
||||
}
|
||||
```
|
||||
|
||||
Watch the cleanup: if the Java relied on falling through to a single `cursor.close()`,
|
||||
each early return must still close it (or wrap in `use {}`). Missing that changes
|
||||
behaviour (resource leak) — verify it.
|
||||
|
||||
## Nullable-Guard Idioms
|
||||
|
||||
```kotlin
|
||||
val activity = fileActivity ?: return
|
||||
val clientRepository = activity.clientRepository ?: return
|
||||
val remotePath = file?.remotePath ?: return
|
||||
```
|
||||
|
||||
Each `?: return` collapses one Java `if (x == null) return;`. Chain them at the top of the
|
||||
function so the body works with non-null smart-cast locals.
|
||||
|
||||
## When NOT to Invert
|
||||
|
||||
- Do not turn a genuine two-branch decision (both branches do real work) into a guard if
|
||||
it obscures the symmetry — a `when`/`if-else` expression is clearer there.
|
||||
- Do not change the *order* of side-effects while inverting; the snackbar/log calls above
|
||||
must fire in the same cases as before.
|
||||
@@ -0,0 +1,79 @@
|
||||
# Project Conventions (Nextcloud Android)
|
||||
|
||||
Apply these during Step 2 so the converted file passes review and the quality gates. They
|
||||
are enforced by `spotlessKotlinCheck`, `detekt`, `lint`, and `spotbugsGplayDebug`.
|
||||
|
||||
## SPDX Header (every new/renamed file)
|
||||
|
||||
The IDE keeps the old license block. Replace it with the current template. The year is the
|
||||
year the Kotlin file is created. New contributions are `AGPL-3.0-or-later`; keep
|
||||
`OR GPL-2.0-only` only if the original file carried it.
|
||||
|
||||
```kotlin
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: <YEAR> Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
```
|
||||
|
||||
If the developer wants personal attribution (as in the real conversion), the form
|
||||
`SPDX-FileCopyrightText: <YEAR> <Name> <email>` is also used — match what the developer
|
||||
asks for; default to the "Nextcloud GmbH and Nextcloud contributors" line.
|
||||
|
||||
## Structural Rules
|
||||
|
||||
- **≤300 lines per file.** If decomposition pushes past it, split responsibilities into
|
||||
separate files/collaborators and tell the developer. A file/class-level
|
||||
`@Suppress("LargeClass", "TooManyFunctions")` is a last resort for legacy god-classes.
|
||||
- **≤120 columns per line.**
|
||||
- **One top-level type per file.** Extract models, states, sealed classes, and listener
|
||||
interfaces into their own files rather than nesting many types in one.
|
||||
- **Exactly one trailing newline** at end of file.
|
||||
|
||||
## No Magic Numbers / Hardcoded Resources
|
||||
|
||||
- Extract literals into named `const val` in a `companion object`
|
||||
(`MIN_SHOW_ALL_VISIBLE_ITEM_COUNT = 3`, `INTERNAL_LINK_PATH_PRETTY = "/f/"`).
|
||||
- Strings, colors, dimens come from resources (`R.string.*`, `R.dimen.*`), never inline.
|
||||
- Only `app/src/main/res/values/strings.xml` may be edited for strings; never touch
|
||||
`values-*` translation folders.
|
||||
|
||||
## Comments & Naming
|
||||
|
||||
- No decorative divider comments (`// ==== ====`, `// ---- Title ----`). `// region` /
|
||||
`// endregion` for IDE folding is allowed and should match the file's existing style.
|
||||
- Names carry the explanation, not comments. If a name needs a comment to be understood,
|
||||
rename or decompose instead. Do not add KDoc to a function just because it is new.
|
||||
- Preserve genuinely informative Javadoc as KDoc (invariant 4); drop noise. A comment
|
||||
earns its place only for a non-obvious invariant, a platform/server workaround, or an
|
||||
ordering requirement — and it explains **why**, never **what**.
|
||||
- Never narrate the conversion itself: no "was a Java thread, now a coroutine", no
|
||||
"changed from X to Y", no references to the PR, the issue, or this conversation.
|
||||
Comments describe the code as it stands. That history belongs in the commit message.
|
||||
- Do not use multiple boolean flags to model state — use an `enum`/sealed class.
|
||||
|
||||
## Modern Java Interop
|
||||
|
||||
When the file still has Java callers, keep the Java-facing API clean:
|
||||
`@JvmStatic` for factory/companion functions, `@JvmField` for exposed constants,
|
||||
`@JvmOverloads` for defaulted params, `@Throws` for checked exceptions.
|
||||
|
||||
## Git & Commits (developer-driven)
|
||||
|
||||
- Preserve history: the rename `git mv Foo.java Foo.kt` should be a **separate commit**
|
||||
from the content change so `git blame` follows through.
|
||||
- Conventional Commits (`refactor(sharing): convert FileDetailSharingFragment to Kotlin`).
|
||||
- Every AI-assisted commit needs an `Assisted-by: <agent>:<model>` trailer.
|
||||
- Only the human contributor adds `Signed-off-by` (DCO). You must never add it, and never
|
||||
open PRs/issues autonomously (AI policy).
|
||||
|
||||
## Quality Gate
|
||||
|
||||
```bash
|
||||
./gradlew spotlessKotlinCheck detektGplayDebug lintGplayDebug spotbugsGplayDebug \
|
||||
jacocoTestGplayDebugUnitTest
|
||||
```
|
||||
|
||||
Fix every finding in the files you changed before declaring done.
|
||||
@@ -0,0 +1,107 @@
|
||||
# Behaviour-Locking Tests (Mandatory Step)
|
||||
|
||||
A conversion is not done until a test proves behaviour did not change. If the Java class
|
||||
already had tests, they are your primary safety net — run them and keep them green. If it
|
||||
had none, you must add a **characterization test** that pins the current behaviour so the
|
||||
refactor is provably safe.
|
||||
|
||||
## Decision Tree
|
||||
|
||||
```dot
|
||||
digraph test_choice {
|
||||
rankdir=LR;
|
||||
"What are you locking?" -> "Pure logic (no Android SDK)" [label="fn returns a value"];
|
||||
"What are you locking?" -> "Component behaviour" [label="Fragment/Activity/DB/View"];
|
||||
"Pure logic (no Android SDK)" -> "JVM unit test app/src/test/ (JUnit4 + mockito-kotlin)";
|
||||
"Component behaviour" -> "Robolectric unit test (if project uses it)";
|
||||
"Component behaviour" -> "Instrumented test app/src/androidTest/ extends base IT class";
|
||||
}
|
||||
```
|
||||
|
||||
**Prefer the seams you just created.** The idiomatic pass extracts pure functions
|
||||
(link builders, permission math, partitioning, `isReshareForbidden`) specifically so they
|
||||
can be unit-tested fast without a device. Test those first; they give the most behaviour
|
||||
coverage per second.
|
||||
|
||||
## 1. JVM Unit Tests — Pure Functions
|
||||
|
||||
Location: `app/src/test/`. Fast, no emulator. Command:
|
||||
`./gradlew jacocoTestGplayDebugUnitTest`.
|
||||
|
||||
Mark the function `@VisibleForTesting internal` so the test module can reach it while it
|
||||
stays out of the public API.
|
||||
|
||||
```kotlin
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
class FileDetailSharingFragmentTest {
|
||||
|
||||
@Test
|
||||
fun `internal link uses pretty path when modRewrite is on`() {
|
||||
val user = mock<User> { whenever(it.server.uri).thenReturn(URI("https://cloud.example")) }
|
||||
val file = mock<OCFile> { whenever(it.localId).thenReturn(42L) }
|
||||
val caps = mock<OCCapability> { whenever(it.modRewriteWorking.isTrue).thenReturn(true) }
|
||||
|
||||
val link = FileDetailSharingFragment().createInternalLink(user, file, caps)
|
||||
|
||||
assertEquals("https://cloud.example/f/42", link)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `internal link falls back to index php path when modRewrite is off`() {
|
||||
// ... same setup with modRewriteWorking.isTrue == false
|
||||
// assertEquals("https://cloud.example/index.php/f/42", link)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The point: run this test's logic against **both** the pre-conversion and post-conversion
|
||||
code paths mentally (or, if the Java is still on disk, literally) and confirm the assertion
|
||||
holds for both. That is what "behaviour must not change" means concretely.
|
||||
|
||||
## 2. Instrumented Tests — Component Behaviour
|
||||
|
||||
Location: `app/src/androidTest/`. For Fragment/Activity/DB behaviour that needs the Android
|
||||
runtime. Extend the project's base test class (`AbstractOnServerIT` when server
|
||||
communication is required) and follow its conventions (separate test user, etc.).
|
||||
|
||||
```bash
|
||||
./gradlew createGplayDebugCoverageReport -Pcoverage=true \
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.ui.fragment.FileDetailSharingFragmentIT
|
||||
```
|
||||
|
||||
Use `@VisibleForTesting` hooks the original exposed (e.g. a `search(query)` or
|
||||
`showSharingMenuActionSheet(share)` method) to drive and assert UI state, exactly as the
|
||||
existing IT suite does. Do not weaken visibility further than the Java original did.
|
||||
|
||||
## 3. What to Assert
|
||||
|
||||
Lock the observable contract, not the implementation:
|
||||
- Same return values / thrown exception types for the same inputs (including the
|
||||
`require`/`requireNotNull` messages if callers depend on them).
|
||||
- Same Bundle keys, intent extras, and `newInstance` argument wiring.
|
||||
- Same branch outcomes (e.g. "reshare forbidden when FEDERATED", "show-all button visible
|
||||
only when > 3 shares").
|
||||
- For coroutine conversions, assert the end state, and use the project's test dispatcher /
|
||||
`runTest` so async work is deterministic — never assert on wall-clock timing.
|
||||
|
||||
## 4. Guardrails
|
||||
|
||||
- Every new test file gets the SPDX header and ends with exactly one trailing newline.
|
||||
- Do not modify unrelated tests to make yours pass.
|
||||
- Report actual test output. If a test reveals the conversion changed behaviour, fix the
|
||||
conversion — do not adjust the test to match the drift.
|
||||
- If a genuine pre-existing bug is uncovered, surface it to the developer separately; do
|
||||
not fold a behaviour change into the conversion.
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:resolute@sha256:b7f48194d4d8b763a478a621cdc81c27be222ba2206ca3ca6bc42b49685f3d9e
|
||||
FROM ubuntu:resolute@sha256:513c074113a871b51a8d16ab445c88779d6452d937a164fb5cc479f32668a41d
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
|
||||
@@ -23,4 +23,4 @@ B | A
|
||||
|
||||
## 🤖 AI (if applicable)
|
||||
|
||||
- [ ] The content of this PR was partly or fully generated using AI
|
||||
- [ ] The content of this PR was partly or fully generated using AI (N/A)
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
@@ -51,13 +51,13 @@ jobs:
|
||||
echo "repo=${{ github.event.pull_request.head.repo.full_name }}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
|
||||
@@ -6,6 +6,8 @@ name: "Assemble"
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
@@ -16,23 +18,34 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
flavor:
|
||||
name: flavor (${{ matrix.flavor }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
include:
|
||||
- flavor: Generic
|
||||
tasks: assembleGenericDebug
|
||||
- flavor: Gplay
|
||||
tasks: assembleGplayDebug assembleGplayRelease
|
||||
- flavor: Huawei
|
||||
tasks: assembleHuaweiDebug
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||
- uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
|
||||
echo "org.gradle.caching=true" >> gradle.properties
|
||||
echo "org.gradle.parallel=true" >> gradle.properties
|
||||
echo "org.gradle.configureondemand=true" >> gradle.properties
|
||||
./gradlew assemble${{ matrix.flavor }}
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m"
|
||||
echo "kotlin.daemon.jvmargs=-Xmx3g -XX:+UseParallelGC -XX:MaxMetaspaceSize=512m"
|
||||
echo "org.gradle.workers.max=2"
|
||||
} >> gradle.properties
|
||||
./gradlew ${{ matrix.tasks }}
|
||||
|
||||
@@ -26,7 +26,7 @@ permissions:
|
||||
jobs:
|
||||
auto-approve:
|
||||
name: Auto approve sync
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest-low
|
||||
if: ${{ contains(github.event.pull_request.labels.*.name, 'sync') && github.actor == 'nextcloud-android-bot' }}
|
||||
steps:
|
||||
- name: Disabled on forks
|
||||
|
||||
@@ -6,6 +6,8 @@ name: Check
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
@@ -22,11 +24,13 @@ jobs:
|
||||
matrix:
|
||||
task: [ detekt, spotlessKotlinCheck, lint ]
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
- name: Check ${{ matrix.task }}
|
||||
run: ./gradlew ${{ matrix.task }}
|
||||
@@ -20,6 +20,10 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: codeql-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
@@ -34,7 +38,7 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set Swap Space
|
||||
@@ -43,18 +47,17 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- name: Assemble
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew --no-daemon assembleDebug
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
- name: Compile sources
|
||||
run: ./gradlew --no-daemon --no-build-cache :app:compileGplayDebugSources
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
@@ -20,7 +20,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
detectNewJavaFiles:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- id: file_changes
|
||||
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b # v1.2.4
|
||||
|
||||
@@ -20,9 +20,9 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
|
||||
@@ -27,10 +27,10 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
server: [ master ] # [ stable22, stable33, master ]
|
||||
server: [ stable22, stable35, master ]
|
||||
api-level: [ 29 ] # [ 21, 36 ]
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: configure server
|
||||
run: |
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
docker exec server /usr/local/bin/run.sh
|
||||
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
- name: gplay
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
|
||||
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
cmake: 4.1.2
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ permissions:
|
||||
jobs:
|
||||
pr-feedback:
|
||||
if: ${{ github.repository_owner == 'nextcloud' }}
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- name: The get-github-handles-from-website action
|
||||
uses: marcelklehr/get-github-handles-from-website-action@06b2239db0a48fe1484ba0bfd966a3ab81a08308 # v1.0.1
|
||||
|
||||
+42
-11
@@ -24,19 +24,20 @@ jobs:
|
||||
id: check-secrets
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
|
||||
- name: Build QA
|
||||
id: build-qa
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
KS_PASS: ${{ secrets.KS_PASS }}
|
||||
@@ -46,40 +47,70 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > "$HOME/.gradle/gradle.properties"
|
||||
echo "org.gradle.caching=true; org.gradle.parallel=true; org.gradle.configureondemand=true" >> "$HOME/.gradle/gradle.properties"
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.caching=true"
|
||||
echo "org.gradle.parallel=true"
|
||||
echo "org.gradle.configureondemand=true"
|
||||
} > "$HOME/.gradle/gradle.properties"
|
||||
[ -e app/build.gradle ] && sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" "app/build.gradle"
|
||||
[ -e app/build.gradle ] && sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" "app/build.gradle"
|
||||
[ -e app/build.gradle.kts ] && sed -i "/qa/,/\}/ s/versionCode .*/versionCode = ${{github.event.number}} /" "app/build.gradle.kts"
|
||||
[ -e app/build.gradle.kts ] && sed -i "/qa/,/\}/ s/versionName .*/versionName = \"${{github.event.number}}\"/" "app/build.gradle.kts"
|
||||
./gradlew assembleQaDebug
|
||||
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:"$KS_PASS" --key-pass pass:"$KEY_PASS" --ks-key-alias key0 --ks ".github/workflows/QA_keystore.jks" app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
apk=$(find app/build/outputs/apk/qa/debug -name '*qa-debug*.apk' | head -n1)
|
||||
echo "apk-path=$apk" >> "$GITHUB_OUTPUT"
|
||||
echo "apk-name=$(basename "$apk")" >> "$GITHUB_OUTPUT"
|
||||
echo "apk-size=$(du -h "$apk" | cut -f1)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload APK
|
||||
id: upload-apk
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
|
||||
with:
|
||||
path: app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
path: ${{ steps.build-qa.outputs.apk-path }}
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
archive: false
|
||||
|
||||
- name: Create QR Code
|
||||
- name: Create QR code
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
ARTIFACT_URL: ${{ steps.upload-apk.outputs.artifact-url }}
|
||||
run: |
|
||||
sudo apt-get -y install qrencode
|
||||
qrencode -o qr.png "${{ steps.upload-apk.outputs.artifact-url }}"
|
||||
qrencode -s 8 -o qr.png "$ARTIFACT_URL"
|
||||
|
||||
- name: Upload QR
|
||||
- name: Upload QR code
|
||||
id: upload-qr
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
|
||||
with:
|
||||
path: qr.png
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
archive: false
|
||||
|
||||
- name: Comment PR
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: thollander/actions-comment-pull-request@e4a76dd2b0a3c2027c3fd84147a67c22ee4c90fa
|
||||
with:
|
||||
comment-tag: qa-apk
|
||||
mode: upsert
|
||||
message: |
|
||||
APK file: ${{ steps.upload-apk.outputs.artifact-url }}
|
||||
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
|
||||
 (please click on link to get QR code displayed)
|
||||
### :iphone: QA build
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Download** | [${{ steps.build-qa.outputs.apk-name }}](${{ steps.upload-apk.outputs.artifact-url }}) |
|
||||
| **QR code** | [Open the QR code for this download](${{ steps.upload-qr.outputs.artifact-url }}) |
|
||||
| **Commit** | ${{ github.event.pull_request.head.sha }} |
|
||||
| **Version** | `${{ github.event.number }}` |
|
||||
| **Available until** | 7 days after this build |
|
||||
|
||||
The QA build installs alongside a released Nextcloud app, so you can keep
|
||||
using your existing install while testing.
|
||||
|
||||
Downloading the file requires a GitHub account, so open this link on the
|
||||
device you want to test on, or transfer the APK to it.
|
||||
@@ -25,7 +25,7 @@ concurrency:
|
||||
jobs:
|
||||
auto-approve-merge:
|
||||
if: github.event.pull_request.user.login == 'renovate[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest-low
|
||||
permissions:
|
||||
# for hmarr/auto-approve-action to approve PRs
|
||||
pull-requests: write
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -42,6 +42,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -1,109 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
|
||||
name: "Screenshot Test"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: screenshot-test-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
screenshot:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
scheme: [ Light ]
|
||||
color: [ blue ]
|
||||
api-level: [ 28 ]
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
|
||||
- name: Enable KVM group perms
|
||||
run: |
|
||||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger --name-match=kvm
|
||||
|
||||
- name: create AVD and generate snapshot for caching
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
arch: x86
|
||||
sdcard-path-or-size: 100M
|
||||
target: google_apis
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
|
||||
script: echo "Generated AVD snapshot for caching."
|
||||
|
||||
- name: Configure gradle daemon
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > $HOME/.gradle/gradle.properties
|
||||
echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties
|
||||
echo "org.gradle.parallel=true" >> $HOME/.gradle/gradle.properties
|
||||
echo "org.gradle.configureondemand=true" >> $HOME/.gradle/gradle.properties
|
||||
|
||||
- name: Build generic flavor
|
||||
run: ./gradlew assembleGenericDebug
|
||||
|
||||
- name: Delete old comments
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
|
||||
|
||||
- name: Run screenshot tests
|
||||
env:
|
||||
SHOT_TEST: "true"
|
||||
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
arch: x86
|
||||
sdcard-path-or-size: 100M
|
||||
target: google_apis
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
|
||||
script: ./gradlew uninstallAll genericDebugExecuteScreenshotTests -Dorg.gradle.jvmargs="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.nio.channels=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED" -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
|
||||
- name: upload failing results
|
||||
if: ${{ failure() }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
|
||||
- name: Archive Espresso results
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
path: app/build/reports
|
||||
retention-days: 4
|
||||
@@ -15,12 +15,12 @@ permissions: read-all
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest-low
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
||||
- uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
|
||||
with:
|
||||
days-before-stale: 28
|
||||
days-before-close: 14
|
||||
|
||||
@@ -22,10 +22,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
|
||||
- name: Run unit tests with coverage
|
||||
run: ./gradlew jacocoTestGplayDebugUnitTest
|
||||
|
||||
Generated
-25
@@ -2,31 +2,6 @@
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
||||
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
||||
<value />
|
||||
</option>
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="android" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="com" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="junit" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="net" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="org" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="java" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="javax" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
<emptyLine />
|
||||
</value>
|
||||
</option>
|
||||
<option name="RIGHT_MARGIN" value="120" />
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
|
||||
@@ -30,6 +30,13 @@ Java, Kotlin, XML, Jetpack Compose are the key technologies used for building th
|
||||
- `./app/src/test/` Unit tests (small, isolated tests without Android SDK)
|
||||
- `./app/src/androidTest/` Instrumented tests (require Android SDK)
|
||||
- `./app/src/main/res/values/` Translations. Only update `./app/src/main/res/values/strings.xml`. Do not modify any other translation files or folders. Ignore all `values-*` directories (e.g., `values-es`, `values-fr`).
|
||||
- `./.claude/skills/` Reusable agent skills. Each subdirectory is one skill with a `SKILL.md` entry point plus `references/` and `assets/`.
|
||||
|
||||
## Agent Skills
|
||||
|
||||
Project-specific skills live in `./.claude/skills/<skill-name>/`. Load a skill when the task matches its trigger.
|
||||
|
||||
- **`android-java-to-kotlin`** (`./.claude/skills/android-java-to-kotlin/SKILL.md`) — Completes a Java-to-Kotlin conversion in this Android app. Use it when finishing a conversion, when the user mentions "java to kotlin", "j2k", "convert java", or "make it idiomatic", or when a freshly IDE-converted `.kt` file needs cleanup. The workflow is two-person: the developer first runs the Android Studio converter (`Code > Convert Java File to Kotlin File`), then the agent drives the idiomatic second pass — fail-fast control flow, function decomposition, `lifecycleScope`/coroutines instead of Java threads, modern Android APIs, and project conventions (SPDX headers, no magic numbers, `@JvmStatic`). The conversion must preserve behaviour, and the agent must write a behaviour-locking test before declaring it done.
|
||||
|
||||
## General Guidance
|
||||
|
||||
@@ -178,9 +185,7 @@ All contributions generated or assisted by this agent must fully comply with:
|
||||
- Line length: **120 characters**
|
||||
- Standard Android Studio formatter with EditorConfig.
|
||||
- Kotlin preferred for new code; legacy Java still present.
|
||||
- Do not use decorative section-divider comments of any kind (e.g. `// ── Title ───`, `// ------`, `// ======`).
|
||||
- Every new file must end with exactly one empty trailing line (no more, no less).
|
||||
- Do not add comments, documentation for every function you created instead make it self explanatory as much as possible.
|
||||
- Create models, states in different files instead of doing it one single file.
|
||||
- Do not use magic numbers.
|
||||
- Apply fail fast principle instead of using nested if-else statements.
|
||||
@@ -188,3 +193,26 @@ All contributions generated or assisted by this agent must fully comply with:
|
||||
- Use modern Java for Java classes. Optionals, virtual threads, records, streams if necessary.
|
||||
- Avoid hardcoded strings, colors, dimensions. Use resources.
|
||||
- Run lint, spotbugsGplayDebug, detekt, spotlessKotlinCheck and fix findings inside the files that have been changed.
|
||||
|
||||
## Comments
|
||||
|
||||
Names carry the explanation, not comments. A function or variable whose purpose is not obvious from its
|
||||
name is a naming problem or a decomposition problem — rename it or split it, do not describe it in a comment.
|
||||
Assume the reader knows Kotlin, Java and the Android framework.
|
||||
|
||||
Write a comment only when the code cannot carry the information itself: a non-obvious invariant, a workaround
|
||||
for a platform or server bug, an ordering requirement, or a decision whose alternatives look equally valid and
|
||||
are not. When you do write one, explain **why**, never **what**.
|
||||
|
||||
Never write:
|
||||
|
||||
- Comments that restate the code (`// increase the counter` above `counter++`).
|
||||
- KDoc/Javadoc added to a function just because the function is new.
|
||||
- Narration of the change or its history: "changed from X to Y", "previously this failed", "this is not a
|
||||
permanent failure so we now retry", "fixes the crash reported in the issue". Comments describe the code as
|
||||
it is today. A reader six months from now has no access to the issue, the PR discussion, or the conversation
|
||||
that produced the change — that context belongs in the commit message and the PR description.
|
||||
- Decorative section-divider comments of any kind (e.g. `// ── Title ───`, `// ------`, `// ======`).
|
||||
`// region` / `// endregion` for IDE folding is allowed where the file already uses it.
|
||||
|
||||
Existing comments that are still accurate stay. Delete the ones the change makes wrong or obsolete.
|
||||
+69
-55
@@ -8,8 +8,8 @@ GEM
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1265.0)
|
||||
aws-sdk-core (3.252.0)
|
||||
aws-partitions (1.1287.0)
|
||||
aws-sdk-core (3.257.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
@@ -17,11 +17,12 @@ GEM
|
||||
bigdecimal
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
aws-sdk-kms (1.129.0)
|
||||
aws-sdk-core (~> 3, >= 3.248.0)
|
||||
rexml (~> 3.4, >= 3.4.2)
|
||||
aws-sdk-kms (1.132.0)
|
||||
aws-sdk-core (~> 3, >= 3.256.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.226.0)
|
||||
aws-sdk-core (~> 3, >= 3.248.0)
|
||||
aws-sdk-s3 (1.232.0)
|
||||
aws-sdk-core (~> 3, >= 3.256.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.12.1)
|
||||
@@ -36,44 +37,31 @@ GEM
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
csv (3.3.5)
|
||||
csv (3.3.6)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
domain_name (0.6.20240107)
|
||||
domain_name (0.6.20260907)
|
||||
dotenv (2.8.1)
|
||||
emoji_regex (3.2.3)
|
||||
erb (6.0.7)
|
||||
excon (0.112.0)
|
||||
faraday (1.10.6)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
faraday-retry (~> 1.0)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday (2.14.4)
|
||||
faraday-net_http (>= 2.0, < 3.5)
|
||||
json
|
||||
logger
|
||||
faraday-cookie_jar (0.0.8)
|
||||
faraday (>= 0.8.0)
|
||||
http-cookie (>= 1.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.1)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-follow_redirects (0.5.0)
|
||||
faraday (>= 1, < 3)
|
||||
faraday-multipart (1.2.0)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.4)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
faraday-net_http (2.1.0)
|
||||
faraday-retry (2.4.0)
|
||||
faraday (~> 2.0)
|
||||
fastimage (2.4.1)
|
||||
fastlane (2.237.0)
|
||||
fastlane (2.240.1)
|
||||
CFPropertyList (>= 2.3, < 5.0.0)
|
||||
abbrev (~> 0.1)
|
||||
addressable (>= 2.9.0, < 3.0.0)
|
||||
@@ -83,24 +71,27 @@ GEM
|
||||
base64 (~> 0.2)
|
||||
benchmark (>= 0.1.0)
|
||||
bundler (>= 2.4.0, < 5.0.0)
|
||||
cgi (~> 0.4)
|
||||
colored (~> 1.2)
|
||||
commander (~> 4.6)
|
||||
csv (~> 3.3)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 2.0.0)
|
||||
faraday (~> 1.0)
|
||||
faraday-cookie_jar (~> 0.0.6)
|
||||
faraday_middleware (~> 1.0)
|
||||
faraday (~> 2.7)
|
||||
faraday-cookie_jar (~> 0.0.8)
|
||||
faraday-follow_redirects (~> 0.3)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-retry (~> 2.0)
|
||||
fastimage (>= 2.1.0, < 3.0.0)
|
||||
fastlane-sirp (>= 1.1.0)
|
||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||
google-apis-androidpublisher_v3 (~> 0.3)
|
||||
google-apis-androidpublisher_v3 (~> 0.99)
|
||||
google-apis-playcustomapp_v1 (~> 0.1)
|
||||
google-cloud-env (>= 1.6.0, < 2.3.0)
|
||||
google-cloud-env (>= 1.6.0, < 2.4.0)
|
||||
google-cloud-storage (~> 1.31)
|
||||
highline (~> 2.0)
|
||||
http-cookie (~> 1.0.5)
|
||||
irb (>= 1.8)
|
||||
json (< 3.0.0)
|
||||
jwt (>= 2.10.3, < 4)
|
||||
logger (>= 1.6, < 2.0)
|
||||
@@ -113,11 +104,11 @@ GEM
|
||||
optparse (>= 0.1.1, < 1.0.0)
|
||||
ostruct (>= 0.1.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
rubyzip (>= 2.0.0, < 3.0.0)
|
||||
security (= 0.1.5)
|
||||
rubyzip (>= 3.4.0, < 4.0.0)
|
||||
security (~> 0.3)
|
||||
simctl (~> 1.6.3)
|
||||
terminal-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-table (~> 3)
|
||||
terminal-table (~> 4)
|
||||
tty-screen (>= 0.6.3, < 1.0.0)
|
||||
tty-spinner (>= 0.8.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
@@ -128,7 +119,7 @@ GEM
|
||||
cgi
|
||||
fastlane-sirp (1.1.0)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.104.0)
|
||||
google-apis-androidpublisher_v3 (0.108.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-core (0.18.0)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
@@ -142,15 +133,15 @@ GEM
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-playcustomapp_v1 (0.18.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-storage_v1 (0.64.0)
|
||||
google-apis-storage_v1 (0.67.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-cloud-core (1.9.0)
|
||||
google-cloud-env (>= 1.0, < 3.a)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (2.2.2)
|
||||
google-cloud-env (2.3.1)
|
||||
base64 (~> 0.2)
|
||||
faraday (>= 1.0, < 3.a)
|
||||
google-cloud-errors (1.6.0)
|
||||
google-cloud-errors (1.7.0)
|
||||
google-cloud-storage (1.62.0)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
@@ -161,7 +152,7 @@ GEM
|
||||
googleauth (~> 1.9)
|
||||
mini_mime (~> 1.0)
|
||||
google-logging-utils (0.2.0)
|
||||
googleauth (1.17.1)
|
||||
googleauth (1.17.4)
|
||||
faraday (>= 1.0, < 3.a)
|
||||
google-cloud-env (~> 2.2)
|
||||
google-logging-utils (~> 0.1)
|
||||
@@ -170,18 +161,24 @@ GEM
|
||||
pstore (~> 0.1)
|
||||
signet (>= 0.16, < 2.a)
|
||||
highline (2.0.3)
|
||||
http-cookie (1.0.8)
|
||||
http-cookie (1.1.6)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
io-console (0.9.3)
|
||||
irb (1.18.0)
|
||||
pp (>= 0.6.0)
|
||||
prism (>= 1.3.0)
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
jmespath (1.6.2)
|
||||
json (2.20.0)
|
||||
json (2.21.2)
|
||||
jwt (2.10.3)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.21.1)
|
||||
multi_json (1.21.2)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
@@ -191,9 +188,24 @@ GEM
|
||||
os (1.1.4)
|
||||
ostruct (0.6.3)
|
||||
plist (3.7.2)
|
||||
pp (0.6.4)
|
||||
prettyprint
|
||||
prettyprint (0.2.0)
|
||||
prism (1.9.0)
|
||||
pstore (0.2.1)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.4.2)
|
||||
rbs (4.2.0)
|
||||
logger
|
||||
prism (>= 1.6.0)
|
||||
tsort
|
||||
rdoc (8.0.0)
|
||||
erb
|
||||
prism (>= 1.6.0)
|
||||
rbs (>= 4.0.0)
|
||||
tsort
|
||||
reline (0.7.0)
|
||||
io-console (~> 0.5)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
@@ -201,9 +213,8 @@ GEM
|
||||
retriable (3.8.0)
|
||||
rexml (3.4.4)
|
||||
rouge (3.28.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
rubyzip (3.6.0)
|
||||
security (0.3.0)
|
||||
signet (0.22.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
@@ -212,9 +223,10 @@ GEM
|
||||
CFPropertyList
|
||||
naturally
|
||||
terminal-notifier (2.0.0)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
terminal-table (4.0.0)
|
||||
unicode-display_width (>= 1.1.1, < 4)
|
||||
trailblazer-option (0.1.2)
|
||||
tsort (0.2.0)
|
||||
tty-cursor (0.7.1)
|
||||
tty-screen (0.8.2)
|
||||
tty-spinner (0.9.3)
|
||||
@@ -222,12 +234,14 @@ GEM
|
||||
uber (0.1.0)
|
||||
unicode-display_width (2.6.0)
|
||||
word_wrap (1.0.0)
|
||||
xcodeproj (1.27.0)
|
||||
xcodeproj (1.28.1)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
base64
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.4.0)
|
||||
nkf
|
||||
rexml (>= 3.3.6, < 4.0)
|
||||
xcpretty (0.4.1)
|
||||
rouge (~> 3.28.0)
|
||||
|
||||
+44
-19
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2025 Jimly Asshiddiqy <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
@@ -43,23 +44,32 @@ configurations.configureEach {
|
||||
exclude(group = "org.jetbrains", module = "annotations-java5")
|
||||
|
||||
resolutionStrategy {
|
||||
force(libs.objenesis)
|
||||
|
||||
eachDependency {
|
||||
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
|
||||
useVersion(libs.versions.checker.get())
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
} else if (requested.group == "org.jacoco") {
|
||||
useVersion(libs.versions.jacoco.get())
|
||||
} else if (requested.group == "commons-logging" && requested.name == "commons-logging") {
|
||||
useTarget(libs.slfj)
|
||||
when (requested.group) {
|
||||
"org.checkerframework" if requested.name != "checker-compat-qual" -> {
|
||||
useVersion(libs.versions.checker.get())
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
}
|
||||
"org.jacoco" -> {
|
||||
useVersion(libs.versions.jacoco.get())
|
||||
}
|
||||
"commons-logging" if requested.name == "commons-logging" -> {
|
||||
useTarget(libs.slfj)
|
||||
}
|
||||
"org.hamcrest" -> {
|
||||
useVersion("2.2")
|
||||
because(
|
||||
"Align hamcrest on compile and runtime. 1.3 (via junit) exposes fixed-arity " +
|
||||
"anyOf/allOf overloads that 2.2 (via androidx.test) removed, causing NoSuchMethodError."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
val versionMajor = 34
|
||||
val versionMajor = 35
|
||||
val versionMinor = 1
|
||||
val versionPatch = 0
|
||||
val versionBuild = 50 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
@@ -108,7 +118,7 @@ android {
|
||||
compileSdk = 37
|
||||
|
||||
ndk {
|
||||
abiFilters += listOf("arm64-v8a", "x86_64")
|
||||
abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
||||
}
|
||||
|
||||
buildConfigField("boolean", "CI", ciBuild.toString())
|
||||
@@ -266,6 +276,7 @@ spotbugs {
|
||||
}
|
||||
|
||||
tasks.register<Checkstyle>("checkstyle") {
|
||||
description = "Runs Checkstyle static analysis on the Java sources to enforce the project's coding style."
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
setConfigProperties(
|
||||
"checkstyleSuppressionsPath" to file("${rootProject.rootDir}/suppressions.xml").absolutePath
|
||||
@@ -277,6 +288,7 @@ tasks.register<Checkstyle>("checkstyle") {
|
||||
}
|
||||
|
||||
tasks.register<Pmd>("pmd") {
|
||||
description = "Runs PMD static analysis on the Java sources to detect common programming flaws and bad practices."
|
||||
ruleSetFiles = files("${rootProject.rootDir}/ruleset.xml")
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = emptyList()
|
||||
@@ -332,6 +344,17 @@ tasks.named("check").configure {
|
||||
dependsOn("checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt")
|
||||
}
|
||||
|
||||
val kspConfiguration = "ksp"
|
||||
val kspAndroidTestConfiguration = "kspAndroidTest"
|
||||
val gplayImplementationConfiguration = "gplayImplementation"
|
||||
val huaweiImplementationConfiguration = "huaweiImplementation"
|
||||
val qaImplementationConfiguration = "qaImplementation"
|
||||
val appScanConfigurations = listOf(
|
||||
gplayImplementationConfiguration,
|
||||
huaweiImplementationConfiguration,
|
||||
qaImplementationConfiguration
|
||||
)
|
||||
|
||||
dependencies {
|
||||
// region Nextcloud library
|
||||
implementation(libs.android.library) {
|
||||
@@ -429,10 +452,10 @@ dependencies {
|
||||
// endregion
|
||||
|
||||
// region AppScan, document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
// To enable the feature for another variant, add it here.
|
||||
"gplayImplementation"(project(":appscan"))
|
||||
"huaweiImplementation"(project(":appscan"))
|
||||
"qaImplementation"(project(":appscan"))
|
||||
// To enable the feature for another variant, add its "<variant>Implementation" here.
|
||||
appScanConfigurations.forEach { configuration ->
|
||||
add(configuration, project(":appscan"))
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region SpotBugs
|
||||
@@ -444,9 +467,10 @@ dependencies {
|
||||
implementation(libs.dagger)
|
||||
implementation(libs.dagger.android)
|
||||
implementation(libs.dagger.android.support)
|
||||
ksp(libs.dagger.compiler)
|
||||
ksp(libs.dagger.processor)
|
||||
kspAndroidTest(libs.dagger.compiler)
|
||||
listOf(kspConfiguration, kspAndroidTestConfiguration).forEach { configuration ->
|
||||
add(configuration, libs.dagger.compiler)
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Crypto
|
||||
@@ -476,7 +500,7 @@ dependencies {
|
||||
|
||||
// region iCal4j
|
||||
implementation(libs.ical4j) {
|
||||
listOf("org.apache.commons", "commons-logging").forEach { groupName -> exclude(group = groupName) }
|
||||
exclude(group = "commons-logging")
|
||||
}
|
||||
// endregion
|
||||
|
||||
@@ -502,6 +526,7 @@ dependencies {
|
||||
|
||||
// region Kotlin
|
||||
implementation(libs.kotlin.stdlib)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
// endregion
|
||||
|
||||
// region Stateless
|
||||
@@ -509,7 +534,7 @@ dependencies {
|
||||
// endregion
|
||||
|
||||
// region Google Play dependencies, upon each update first test: new registration, receive push
|
||||
"gplayImplementation"(libs.bundles.gplay)
|
||||
add(gplayImplementationConfiguration, libs.bundles.gplay)
|
||||
// endregion
|
||||
|
||||
// region common
|
||||
|
||||
@@ -76,6 +76,11 @@
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<!-- Dagger factories generated for media3 @UnstableApi types cannot carry an @OptIn annotation. -->
|
||||
<issue id="UnsafeOptInUsageError" severity="error">
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<issue id="ObsoleteLintCustomCheck" severity="warning">
|
||||
<ignore path="**/fragment-1.2.5/**/lint.jar" />
|
||||
<ignore path="**/work-runtime-2.**/**/lint.jar" />
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -33,8 +33,7 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
@@ -61,12 +60,8 @@ class SettingsActivityIT : AbstractIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun showMnemonic() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val intent = Intent().apply {
|
||||
putExtra(RequestCredentialsActivity.KEY_CHECK_RESULT, RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE)
|
||||
}
|
||||
@@ -76,13 +71,10 @@ class SettingsActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.handleMnemonicRequest(intent)
|
||||
}
|
||||
|
||||
Looper.myLooper()?.quitSafely()
|
||||
Assert.assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.nextcloud.client.assistant
|
||||
|
||||
import com.nextcloud.client.assistant.repository.remote.AssistantRemoteRepositoryImpl
|
||||
import com.nextcloud.test.SinceServer
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
@@ -17,6 +18,7 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
@SinceServer(majorVersion = 28)
|
||||
class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
|
||||
private var sut: AssistantRemoteRepositoryImpl? = null
|
||||
@@ -87,17 +89,13 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
|
||||
testCreateTask()
|
||||
|
||||
sleep(120)
|
||||
|
||||
runBlocking {
|
||||
val taskList = sut?.getTaskList("assistant")
|
||||
assertTrue(taskList != null)
|
||||
|
||||
sleep(120)
|
||||
val taskId = taskList?.firstOrNull()?.id ?: return@runBlocking
|
||||
|
||||
assert((taskList?.size ?: 0) > 0)
|
||||
|
||||
val result = sut?.deleteTask(taskList!!.first().id)
|
||||
val result = sut?.deleteTask(taskId)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.test
|
||||
|
||||
import android.os.ParcelFileDescriptor
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
|
||||
/**
|
||||
* Disables system animations for the duration of the test.
|
||||
*
|
||||
* Espresso requires that no view keeps requesting layout while it waits for the root window. Animated components such
|
||||
* as [com.google.android.material.snackbar.Snackbar] keep animating unless the global animation scales are set to zero.
|
||||
* The Gradle `animationsDisabled` option only passes `--no-window-animation`, which leaves `animator_duration_scale`
|
||||
* untouched, so animations still run on CI. This rule zeroes all scales directly via a shell command.
|
||||
*/
|
||||
class DisableAnimationsRule : TestRule {
|
||||
|
||||
override fun apply(base: Statement, description: Description): Statement = object : Statement() {
|
||||
override fun evaluate() {
|
||||
setAnimationScale("0.0")
|
||||
try {
|
||||
base.evaluate()
|
||||
} finally {
|
||||
setAnimationScale("1.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setAnimationScale(scale: String) {
|
||||
val uiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation
|
||||
SCALE_SETTINGS.forEach { setting ->
|
||||
val descriptor = uiAutomation.executeShellCommand("settings put global $setting $scale")
|
||||
ParcelFileDescriptor.AutoCloseInputStream(descriptor).use { it.readBytes() }
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val SCALE_SETTINGS = listOf(
|
||||
"window_animation_scale",
|
||||
"transition_animation_scale",
|
||||
"animator_duration_scale"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ package com.nextcloud.test
|
||||
import androidx.test.espresso.IdlingResource
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.test
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
|
||||
annotation class Flaky(val reason: String)
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.test
|
||||
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runner.manipulation.Filter
|
||||
|
||||
class FlakyTestFilter : Filter() {
|
||||
override fun shouldRun(description: Description): Boolean = when {
|
||||
description.isTest -> !description.isFlaky()
|
||||
else -> description.children.any { shouldRun(it) }
|
||||
}
|
||||
|
||||
override fun describe(): String = "skip tests annotated with @Flaky"
|
||||
|
||||
private fun Description.isFlaky(): Boolean {
|
||||
val onMethod = getAnnotation(Flaky::class.java) != null
|
||||
val onClass = testClass?.isAnnotationPresent(Flaky::class.java) == true
|
||||
return onMethod || onClass
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.test
|
||||
|
||||
import android.Manifest
|
||||
import android.os.Build
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
|
||||
/**
|
||||
* Grants the runtime permissions UI tests need, matching what the manifest actually declares:
|
||||
*
|
||||
* - WRITE_EXTERNAL_STORAGE is capped at maxSdkVersion="29", so on API 30+ the app never requests it
|
||||
* and granting it throws "has not requested permission WRITE_EXTERNAL_STORAGE". It is therefore
|
||||
* granted only when SDK_INT <= 29.
|
||||
* - POST_NOTIFICATIONS only exists on API 33+, so granting it on lower API levels fails with
|
||||
* "Unknown permission" and it is granted only from TIRAMISU onwards.
|
||||
*/
|
||||
object GrantTestPermissionRule {
|
||||
|
||||
fun grantStorageAndNotification(): GrantPermissionRule {
|
||||
val permissions = buildList {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
add(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
}
|
||||
@Suppress("SpreadOperator")
|
||||
return GrantPermissionRule.grant(*permissions.toTypedArray())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.test
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runner.manipulation.Filter
|
||||
|
||||
class ServerVersionFilter : Filter() {
|
||||
|
||||
private val serverVersion: Int? by lazy {
|
||||
InstrumentationRegistry
|
||||
.getArguments()
|
||||
.getString(SERVER_VERSION_ARGUMENT)
|
||||
?.toIntOrNull()
|
||||
}
|
||||
|
||||
override fun shouldRun(description: Description): Boolean {
|
||||
val currentVersion = serverVersion ?: return true
|
||||
|
||||
return when {
|
||||
description.isTest -> description.requiredServerVersion() <= currentVersion
|
||||
else -> description.children.any { shouldRun(it) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun describe(): String = "skip tests annotated with @SinceServer above server version $serverVersion"
|
||||
|
||||
private fun Description.requiredServerVersion(): Int {
|
||||
val onMethod = getAnnotation(SinceServer::class.java)?.majorVersion ?: ANY_SERVER
|
||||
val onClass = testClass?.getAnnotation(SinceServer::class.java)?.majorVersion ?: ANY_SERVER
|
||||
return maxOf(onMethod, onClass)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val SERVER_VERSION_ARGUMENT = "TEST_SERVER_VERSION"
|
||||
private const val ANY_SERVER = 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.test
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
|
||||
annotation class SinceServer(val majorVersion: Int)
|
||||
@@ -27,10 +27,7 @@ import org.junit.Test
|
||||
class SetOnlineStatusBottomSheetIT : AbstractIT() {
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
|
||||
@Test
|
||||
fun open() {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
@@ -16,6 +15,8 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.GrantTestPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.users.ClearAt
|
||||
@@ -28,12 +29,10 @@ import org.junit.Test
|
||||
|
||||
class SetStatusMessageBottomSheetIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
val permissionRule: GrantPermissionRule = GrantTestPermissionRule.grantStorageAndNotification()
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Bottom sheet is occasionally not rendered before the assertions run")
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import com.nextcloud.test.SinceServer
|
||||
import com.nextcloud.utils.autoRename.AutoRename
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.datamodel.e2e.v2.decrypted.DecryptedFile
|
||||
@@ -18,6 +19,7 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@SinceServer(majorVersion = 30)
|
||||
class AutoRenameTests : AbstractOnServerIT() {
|
||||
|
||||
private var capability: OCCapability = fileDataStorageManager.getCapability(account.name)
|
||||
|
||||
@@ -8,6 +8,7 @@ package com.nextcloud.utils
|
||||
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -29,176 +30,131 @@ class FileHelperTest {
|
||||
testDirectory.deleteRecursively()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenNullDirectoryShouldReturnEmptyList() {
|
||||
val result = FileHelper.listDirectoryEntries(null, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
private fun collectPages(directory: File?, pageSize: Int, fetchFolders: Boolean): List<List<File>> {
|
||||
val pages = mutableListOf<List<File>>()
|
||||
|
||||
runBlocking {
|
||||
FileHelper.forEachDirectoryPage(directory, pageSize, fetchFolders) { page ->
|
||||
pages.add(page)
|
||||
}
|
||||
}
|
||||
|
||||
return pages
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenNonExistentDirectoryShouldReturnEmptyList() {
|
||||
fun testForEachDirectoryPageWhenGivenNullDirectoryShouldReportNoPage() {
|
||||
assertTrue(collectPages(null, 10, false).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testForEachDirectoryPageWhenGivenNonExistentDirectoryShouldReportNoPage() {
|
||||
val nonExistent = File(testDirectory, "does_not_exist")
|
||||
val result = FileHelper.listDirectoryEntries(nonExistent, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
|
||||
assertTrue(collectPages(nonExistent, 10, false).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenFileInsteadOfDirectoryShouldReturnEmptyList() {
|
||||
fun testForEachDirectoryPageWhenGivenFileInsteadOfDirectoryShouldReportNoPage() {
|
||||
val file = File(testDirectory, "test.txt")
|
||||
file.createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(file, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
|
||||
assertTrue(collectPages(file, 10, false).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenEmptyDirectoryShouldReturnEmptyList() {
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
fun testForEachDirectoryPageWhenGivenEmptyDirectoryShouldReportNoPage() {
|
||||
assertTrue(collectPages(testDirectory, 10, false).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFoldersShouldReturnOnlyFolders() {
|
||||
fun testForEachDirectoryPageWhenPageSizeIsZeroShouldReportNoPage() {
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
assertTrue(collectPages(testDirectory, 0, false).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testForEachDirectoryPageWhenFetchingFoldersShouldReportOnlyFolders() {
|
||||
File(testDirectory, "folder1").mkdir()
|
||||
File(testDirectory, "folder2").mkdir()
|
||||
File(testDirectory, "file1.txt").createNewFile()
|
||||
File(testDirectory, "file2.txt").createNewFile()
|
||||
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, true)
|
||||
val entries = collectPages(testDirectory, 10, true).flatten()
|
||||
|
||||
assertEquals(2, result.size)
|
||||
assertTrue(result.all { it.isDirectory })
|
||||
assertEquals(2, entries.size)
|
||||
assertTrue(entries.all { it.isDirectory })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFilesShouldReturnOnlyFiles() {
|
||||
fun testForEachDirectoryPageWhenFetchingFilesShouldReportOnlyFiles() {
|
||||
File(testDirectory, "folder1").mkdir()
|
||||
File(testDirectory, "folder2").mkdir()
|
||||
File(testDirectory, "file1.txt").createNewFile()
|
||||
File(testDirectory, "file2.txt").createNewFile()
|
||||
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, false)
|
||||
val entries = collectPages(testDirectory, 10, false).flatten()
|
||||
|
||||
assertEquals(2, result.size)
|
||||
assertTrue(result.all { it.isFile })
|
||||
assertEquals(2, entries.size)
|
||||
assertTrue(entries.all { it.isFile })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenStartIndexProvidedShouldSkipCorrectNumberOfItems() {
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 2, 10, false)
|
||||
assertEquals(3, result.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenMaxItemsProvidedShouldLimitResults() {
|
||||
for (i in 1..10) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 5, false)
|
||||
assertEquals(5, result.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenStartIndexAndMaxItemsShouldReturnCorrectSubset() {
|
||||
for (i in 1..10) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 3, 4, false)
|
||||
assertEquals(4, result.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenStartIndexBeyondAvailableShouldReturnEmptyList() {
|
||||
for (i in 1..3) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 10, 5, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenMaxItemsBeyondAvailableShouldReturnAllItems() {
|
||||
for (i in 1..3) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 100, false)
|
||||
assertEquals(3, result.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFoldersWithOffsetShouldSkipCorrectly() {
|
||||
fun testForEachDirectoryPageWhenGivenOnlyFoldersAndFetchingFilesShouldReportNoPage() {
|
||||
for (i in 1..5) File(testDirectory, "folder$i").mkdir()
|
||||
|
||||
assertTrue(collectPages(testDirectory, 10, false).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testForEachDirectoryPageWhenGivenOnlyFilesAndFetchingFoldersShouldReportNoPage() {
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
assertTrue(collectPages(testDirectory, 10, true).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testForEachDirectoryPageWhenPageSizeExceedsContentShouldReportSinglePage() {
|
||||
for (i in 1..3) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 2, 10, true)
|
||||
val pages = collectPages(testDirectory, 100, false)
|
||||
|
||||
assertEquals(3, result.size)
|
||||
assertTrue(result.all { it.isDirectory })
|
||||
assertEquals(1, pages.size)
|
||||
assertEquals(3, pages.first().size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFilesWithOffsetShouldSkipCorrectly() {
|
||||
for (i in 1..3) File(testDirectory, "folder$i").mkdir()
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
fun testForEachDirectoryPageWhenPaginatingFoldersShouldFillEveryPageButTheLast() {
|
||||
for (i in 1..10) File(testDirectory, "folder$i").mkdir()
|
||||
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 2, 10, false)
|
||||
val pages = collectPages(testDirectory, 3, true)
|
||||
|
||||
assertEquals(3, result.size)
|
||||
assertTrue(result.all { it.isFile })
|
||||
assertEquals(listOf(3, 3, 3, 1), pages.map { it.size })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenOnlyFoldersAndFetchingFilesShouldReturnEmptyList() {
|
||||
for (i in 1..5) File(testDirectory, "folder$i").mkdir()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
fun testForEachDirectoryPageWhenContentIsAMultipleOfPageSizeShouldNotReportAnEmptyPage() {
|
||||
for (i in 1..9) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
val pages = collectPages(testDirectory, 3, false)
|
||||
|
||||
assertEquals(listOf(3, 3, 3), pages.map { it.size })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenOnlyFilesAndFetchingFoldersShouldReturnEmptyList() {
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, true)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenMaxItemsIsZeroShouldReturnEmptyList() {
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 0, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenMixedContentShouldFilterCorrectly() {
|
||||
fun testForEachDirectoryPageWhenGivenMixedContentShouldReportEveryEntryExactlyOnce() {
|
||||
for (i in 1..3) File(testDirectory, "folder$i").mkdir()
|
||||
for (i in 1..7) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
val folders = FileHelper.listDirectoryEntries(testDirectory, 0, 10, true)
|
||||
val files = FileHelper.listDirectoryEntries(testDirectory, 0, 10, false)
|
||||
val folders = collectPages(testDirectory, 2, true).flatten()
|
||||
val files = collectPages(testDirectory, 2, false).flatten()
|
||||
|
||||
assertEquals(3, folders.size)
|
||||
assertEquals(7, files.size)
|
||||
assertEquals(folders.size, folders.distinct().size)
|
||||
assertEquals(files.size, files.distinct().size)
|
||||
assertTrue(folders.all { it.isDirectory })
|
||||
assertTrue(files.all { it.isFile })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenPaginatingFoldersShouldWorkCorrectly() {
|
||||
for (i in 1..10) File(testDirectory, "folder$i").mkdir()
|
||||
|
||||
val page1 = FileHelper.listDirectoryEntries(testDirectory, 0, 3, true)
|
||||
val page2 = FileHelper.listDirectoryEntries(testDirectory, 3, 3, true)
|
||||
val page3 = FileHelper.listDirectoryEntries(testDirectory, 6, 3, true)
|
||||
val page4 = FileHelper.listDirectoryEntries(testDirectory, 9, 3, true)
|
||||
|
||||
assertEquals(3, page1.size)
|
||||
assertEquals(3, page2.size)
|
||||
assertEquals(3, page3.size)
|
||||
assertEquals(1, page4.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenPaginatingFilesShouldWorkCorrectly() {
|
||||
for (i in 1..10) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
val page1 = FileHelper.listDirectoryEntries(testDirectory, 0, 4, false)
|
||||
val page2 = FileHelper.listDirectoryEntries(testDirectory, 4, 4, false)
|
||||
val page3 = FileHelper.listDirectoryEntries(testDirectory, 8, 4, false)
|
||||
|
||||
assertEquals(4, page1.size)
|
||||
assertEquals(4, page2.size)
|
||||
assertEquals(2, page3.size)
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import com.nextcloud.test.SinceServer
|
||||
import com.nextcloud.utils.fileNameValidator.FileNameValidator
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
@@ -42,6 +43,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testInvalidCharacter() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -53,6 +55,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testReservedName() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -61,6 +64,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testForbiddenFilenameExtension() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -141,6 +145,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testFolderPathWithReservedName() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -152,6 +157,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testFilePathWithReservedName() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -163,6 +169,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testFolderPathWithInvalidCharacter() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -174,6 +181,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testFilePathWithInvalidCharacter() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -203,6 +211,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testFilePathWithNestedFolder() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@@ -222,6 +231,7 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 30)
|
||||
fun testOnlyFolderPathWithOneReservedName() {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_30)
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import com.nextcloud.client.device.BatteryStatus
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
|
||||
object PowerManagementFactory {
|
||||
@JvmStatic
|
||||
val mock: PowerManagementService = object : PowerManagementService {
|
||||
override val isIgnoringOptimization: Boolean
|
||||
get() = true
|
||||
override val isPowerSavingEnabled: Boolean
|
||||
get() = false
|
||||
override val battery: BatteryStatus
|
||||
get() = BatteryStatus(false, 0)
|
||||
override val blocksAutoUpload: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Suppress("MagicNumber")
|
||||
val mockCharging: PowerManagementService = object : PowerManagementService {
|
||||
override val isIgnoringOptimization: Boolean
|
||||
get() = true
|
||||
override val isPowerSavingEnabled: Boolean
|
||||
get() = false
|
||||
override val battery: BatteryStatus
|
||||
get() = BatteryStatus(true, 100)
|
||||
override val blocksAutoUpload: Boolean
|
||||
get() = false
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.nextcloud.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.text.format.DateUtils
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.database.entity.UploadEntity
|
||||
@@ -16,11 +17,14 @@ import com.nextcloud.client.database.entity.toOCUpload
|
||||
import com.nextcloud.client.database.entity.toUploadEntity
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class UploadDateTests {
|
||||
|
||||
@@ -30,17 +34,32 @@ class UploadDateTests {
|
||||
private const val ONE_HOUR = 60 * ONE_MINUTE
|
||||
private const val ONE_DAY = 24 * ONE_HOUR
|
||||
|
||||
private const val ONE_YEAR = 365L * ONE_DAY
|
||||
private const val ONE_MONTH = 30L * ONE_DAY
|
||||
private const val ONE_WEEK = 7L * ONE_DAY
|
||||
private const val TWO_HOURS = 2L * ONE_HOUR
|
||||
private const val ONE_AND_A_HALF_MINUTES = ONE_MINUTE + THIRTY_SECONDS
|
||||
private const val TWO_AND_A_HALF_HOURS = 2 * ONE_HOUR + ONE_HOUR / 2
|
||||
private const val TWO_DAYS = 2 * ONE_DAY
|
||||
private const val ONE_WEEK = 7 * ONE_DAY
|
||||
private const val ONE_MONTH = 30 * ONE_DAY
|
||||
private const val ONE_YEAR = 365 * ONE_DAY
|
||||
|
||||
private const val DATE_AND_TIME_PARTS = 2
|
||||
private const val TIME_OF_DAY_SEPARATOR = ":"
|
||||
private const val NARROW_NO_BREAK_SPACE = ' '
|
||||
private const val NO_BREAK_SPACE = ' '
|
||||
}
|
||||
|
||||
private lateinit var context: Context
|
||||
private lateinit var systemLocale: Locale
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
systemLocale = Locale.getDefault()
|
||||
Locale.setDefault(Locale.US)
|
||||
context = InstrumentationRegistry.getInstrumentation().targetContext.localized(Locale.US)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Locale.setDefault(systemLocale)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,189 +101,139 @@ class UploadDateTests {
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsSecondsAgoForRecentPast() {
|
||||
val result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
System.currentTimeMillis() - THIRTY_SECONDS,
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
assertRelativeDateTimeString(
|
||||
time = System.currentTimeMillis() - THIRTY_SECONDS,
|
||||
expected = context.getString(R.string.file_list_seconds_ago)
|
||||
)
|
||||
assertEquals(context.getString(R.string.file_list_seconds_ago), result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsFutureAsAbsoluteWhenShowFutureIsFalse() {
|
||||
val time = System.currentTimeMillis() + ONE_MINUTE
|
||||
val expected = java.text.DateFormat.getDateTimeInstance().format(Date(time))
|
||||
val time = System.currentTimeMillis() + ONE_AND_A_HALF_MINUTES
|
||||
|
||||
val result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
time,
|
||||
DateUtils.SECOND_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0,
|
||||
false
|
||||
assertRelativeDateTimeString(
|
||||
time = time,
|
||||
expected = DateFormat.getDateTimeInstance().format(Date(time))
|
||||
)
|
||||
assertEquals(expected, result.toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsFutureAsRelativeWhenShowFutureIsTrue() {
|
||||
val expected = "In 1 minute"
|
||||
val time = System.currentTimeMillis() + ONE_MINUTE
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.MINUTE_IN_MILLIS, showFuture = true)
|
||||
assertRelativeDateTimeString(
|
||||
time = System.currentTimeMillis() + ONE_AND_A_HALF_MINUTES,
|
||||
expected = "In 1 minute",
|
||||
showFuture = true
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsRelativeStringForHoursAgo() {
|
||||
val expected = "2 hours ago"
|
||||
val time = System.currentTimeMillis() - TWO_HOURS
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.SECOND_IN_MILLIS)
|
||||
assertRelativeDateTimeString(
|
||||
time = System.currentTimeMillis() - TWO_AND_A_HALF_HOURS,
|
||||
expected = "2 hours ago",
|
||||
minResolution = DateUtils.SECOND_IN_MILLIS
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsAbbreviatedStringForOneWeekAgo() {
|
||||
val time = System.currentTimeMillis() - ONE_WEEK
|
||||
val expectedString = DateUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
time,
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
).toString()
|
||||
val parts = expectedString.split(",")
|
||||
val expected = if (parts.size == 2) {
|
||||
if (parts[1].contains(":") && !parts[0].contains(":")) parts[0].trim() else parts[1].trim()
|
||||
} else {
|
||||
expectedString
|
||||
}
|
||||
|
||||
assertRelativeDateTimeString(time, expected)
|
||||
fun getRelativeDateTimeStringReturnsTodayForNow() {
|
||||
assertRelativeDateTimeString(
|
||||
time = System.currentTimeMillis(),
|
||||
expected = "Today",
|
||||
minResolution = DateUtils.DAY_IN_MILLIS
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsAbbreviatedStringForOneMonthAgo() {
|
||||
val time = System.currentTimeMillis() - ONE_MONTH
|
||||
val expectedString = DateUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
time,
|
||||
DateUtils.SECOND_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
).toString()
|
||||
val parts = expectedString.split(",")
|
||||
val expected = if (parts.size == 2) {
|
||||
if (parts[1].contains(":") && !parts[0].contains(":")) parts[0].trim() else parts[1].trim()
|
||||
} else {
|
||||
expectedString
|
||||
}
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.SECOND_IN_MILLIS)
|
||||
fun getRelativeDateTimeStringReturnsYesterdayForOneDayAgo() {
|
||||
assertRelativeDateTimeString(
|
||||
time = System.currentTimeMillis() - ONE_DAY,
|
||||
expected = "Yesterday",
|
||||
minResolution = DateUtils.DAY_IN_MILLIS
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsAbsoluteStringForOneYearAgo() {
|
||||
val time = System.currentTimeMillis() - ONE_YEAR
|
||||
val expectedString = DateUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
time,
|
||||
DateUtils.SECOND_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
).toString()
|
||||
val parts = expectedString.split(",")
|
||||
val expected = if (parts.size == 2) {
|
||||
if (parts[1].contains(":") && !parts[0].contains(":")) parts[0].trim() else parts[1].trim()
|
||||
} else {
|
||||
expectedString
|
||||
}
|
||||
|
||||
assertRelativeDateTimeString(time, expected, DateUtils.SECOND_IN_MILLIS)
|
||||
fun getRelativeDateTimeStringReturnsDaysAgoForTwoDaysAgo() {
|
||||
assertRelativeDateTimeString(
|
||||
time = System.currentTimeMillis() - TWO_DAYS,
|
||||
expected = "2 days ago",
|
||||
minResolution = DateUtils.DAY_IN_MILLIS
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
@Test
|
||||
fun getRelativeDateTimeStringReturnsDaysForDayInMillis() {
|
||||
var testTimestamp = System.currentTimeMillis()
|
||||
var expected = "Today"
|
||||
var result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
testTimestamp,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0,
|
||||
false
|
||||
)
|
||||
assertEquals(expected, result)
|
||||
fun getRelativeDateTimeStringDropsTimeOfDayForOneWeekAgo() {
|
||||
assertDateWithoutTimeOfDay(System.currentTimeMillis() - ONE_WEEK, DateUtils.MINUTE_IN_MILLIS)
|
||||
}
|
||||
|
||||
testTimestamp = System.currentTimeMillis() - DateUtils.DAY_IN_MILLIS
|
||||
expected = "Yesterday"
|
||||
result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
testTimestamp,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0,
|
||||
false
|
||||
)
|
||||
assertEquals(expected, result)
|
||||
@Test
|
||||
fun getRelativeDateTimeStringDropsTimeOfDayForOneWeekAgoWithDayResolution() {
|
||||
assertDateWithoutTimeOfDay(System.currentTimeMillis() - ONE_WEEK, DateUtils.DAY_IN_MILLIS)
|
||||
}
|
||||
|
||||
testTimestamp = System.currentTimeMillis() - 2 * DateUtils.DAY_IN_MILLIS
|
||||
expected = "2 days ago"
|
||||
result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
testTimestamp,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0,
|
||||
false
|
||||
)
|
||||
assertEquals(expected, result)
|
||||
@Test
|
||||
fun getRelativeDateTimeStringDropsTimeOfDayForOneMonthAgo() {
|
||||
assertDateWithoutTimeOfDay(System.currentTimeMillis() - ONE_MONTH, DateUtils.SECOND_IN_MILLIS)
|
||||
}
|
||||
|
||||
testTimestamp = System.currentTimeMillis() - 7 * DateUtils.DAY_IN_MILLIS
|
||||
val expectedString = DateUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
testTimestamp,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
).toString()
|
||||
val parts = expectedString.split(",")
|
||||
expected = if (parts.size == 2) {
|
||||
if (parts[1].contains(":") && !parts[0].contains(":")) parts[0].trim() else parts[1].trim()
|
||||
} else {
|
||||
expectedString
|
||||
}
|
||||
result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
testTimestamp,
|
||||
DateUtils.DAY_IN_MILLIS,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0,
|
||||
false
|
||||
)
|
||||
assertEquals(expected, result)
|
||||
@Test
|
||||
fun getRelativeDateTimeStringDropsTimeOfDayForOneYearAgo() {
|
||||
assertDateWithoutTimeOfDay(System.currentTimeMillis() - ONE_YEAR, DateUtils.SECOND_IN_MILLIS)
|
||||
}
|
||||
|
||||
private fun assertRelativeDateTimeString(
|
||||
time: Long,
|
||||
expected: String,
|
||||
minResolution: Long = DateUtils.MINUTE_IN_MILLIS,
|
||||
transitionResolution: Long = DateUtils.WEEK_IN_MILLIS,
|
||||
showFuture: Boolean = false
|
||||
) {
|
||||
val result = DisplayUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
time,
|
||||
minResolution,
|
||||
transitionResolution,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0,
|
||||
showFuture
|
||||
)
|
||||
assertEquals(expected.normalizeResult(), result.toString().normalizeResult())
|
||||
|
||||
assertEquals(expected.normalizeSpaces(), result.toString().normalizeSpaces())
|
||||
}
|
||||
|
||||
private fun String.normalizeResult(): String = replace('\u202F', ' ').replace('\u00A0', ' ')
|
||||
private fun assertDateWithoutTimeOfDay(time: Long, minResolution: Long) = assertRelativeDateTimeString(
|
||||
time = time,
|
||||
expected = platformDateClause(time, minResolution),
|
||||
minResolution = minResolution
|
||||
)
|
||||
|
||||
private fun platformDateClause(time: Long, minResolution: Long): String {
|
||||
val platformString = DateUtils.getRelativeDateTimeString(
|
||||
context,
|
||||
time,
|
||||
minResolution,
|
||||
DateUtils.WEEK_IN_MILLIS,
|
||||
0
|
||||
).toString()
|
||||
|
||||
val parts = platformString.split(",").map(String::trim)
|
||||
if (parts.size != DATE_AND_TIME_PARTS) {
|
||||
return platformString
|
||||
}
|
||||
|
||||
val (date, timeOfDay) = parts
|
||||
return when {
|
||||
timeOfDay.hasTimeOfDay() && !date.hasTimeOfDay() -> date
|
||||
date.hasTimeOfDay() && !timeOfDay.hasTimeOfDay() -> timeOfDay
|
||||
else -> platformString
|
||||
}
|
||||
}
|
||||
|
||||
private fun Context.localized(locale: Locale): Context {
|
||||
val configuration = Configuration(resources.configuration).apply { setLocale(locale) }
|
||||
return createConfigurationContext(configuration)
|
||||
}
|
||||
|
||||
private fun String.hasTimeOfDay(): Boolean = contains(TIME_OF_DAY_SEPARATOR)
|
||||
|
||||
private fun String.normalizeSpaces(): String = replace(NARROW_NO_BREAK_SPACE, ' ').replace(NO_BREAK_SPACE, ' ')
|
||||
}
|
||||
@@ -6,16 +6,12 @@
|
||||
*/
|
||||
package com.nmc.android.ui
|
||||
|
||||
import android.view.View
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -24,29 +20,21 @@ class LauncherActivityIT : AbstractIT() {
|
||||
|
||||
@Test
|
||||
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
|
||||
launchActivity<LauncherActivity>().use { scenario ->
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
onView(
|
||||
withId(R.id.splashScreenBold)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
onView(
|
||||
withId(R.id.splashScreenNormal)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
launchActivity<LauncherActivity>().onActivity { activity ->
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility)
|
||||
assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenBold).visibility)
|
||||
assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenNormal).visibility)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSplashScreenWithTitlesShouldShowTitles() {
|
||||
launchActivity<LauncherActivity>().use { scenario ->
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
launchActivity<LauncherActivity>().onActivity { activity ->
|
||||
activity.setSplashTitles("Example", "Cloud")
|
||||
|
||||
scenario.onActivity {
|
||||
it.setSplashTitles("Example", "Cloud")
|
||||
}
|
||||
|
||||
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
|
||||
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
|
||||
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility)
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenBold).visibility)
|
||||
assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenNormal).visibility)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,7 @@ import com.nextcloud.android.common.ui.theme.MaterialSchemesImpl;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.device.BatteryStatus;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.utils.PowerManagementFactory;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
||||
import com.nextcloud.client.network.ConnectivityManagerFactory;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
@@ -73,7 +72,6 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
@@ -367,24 +365,7 @@ public abstract class AbstractIT {
|
||||
}
|
||||
|
||||
public void uploadOCUpload(OCUpload ocUpload) {
|
||||
PowerManagementService powerManagementServiceMock = new PowerManagementService() {
|
||||
@Override
|
||||
public boolean isIgnoringOptimization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
return new BatteryStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
final var powerManagementServiceMock = PowerManagementFactory.getMock();
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(accountManager,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
@@ -16,8 +16,7 @@ import android.os.Bundle;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.device.BatteryStatus;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.utils.PowerManagementFactory;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
@@ -45,7 +44,6 @@ import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -205,24 +203,7 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
}
|
||||
|
||||
public void uploadOCUpload(OCUpload ocUpload, int localBehaviour) {
|
||||
PowerManagementService powerManagementServiceMock = new PowerManagementService() {
|
||||
@Override
|
||||
public boolean isIgnoringOptimization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
return new BatteryStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
final var powerManagementServiceMock = PowerManagementFactory.getMock();
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(accountManager,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.utils.PowerManagementFactory
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
|
||||
class GrantFolderExistenceTests : AbstractOnServerIT() {
|
||||
|
||||
private val root = "/autoupload/"
|
||||
private val yearFolder = root + "2026/"
|
||||
private val monthFolder = yearFolder + "07/"
|
||||
|
||||
private val uploadsStorageManager = UploadsStorageManager(
|
||||
UserAccountManagerImpl.fromContext(targetContext),
|
||||
targetContext.contentResolver
|
||||
)
|
||||
|
||||
private val powerManagementServiceMock = PowerManagementFactory.mock
|
||||
|
||||
@Before
|
||||
@Throws(IOException::class)
|
||||
fun before() {
|
||||
createDummyFiles()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUploadFileThenDeleteYearFolderOnServerOnlyThenUploadAgainShouldRecreateMonthFolderAndReturnOk() {
|
||||
uploadAndAssertSuccess("first.txt")
|
||||
|
||||
assertTrue("month folder should exist on server", existsOnServer(monthFolder))
|
||||
assertNotNull("month folder should be cached locally", storageManager.getFileByDecryptedRemotePath(monthFolder))
|
||||
|
||||
removeOnServer(yearFolder)
|
||||
|
||||
assertFalse("month folder should be deleted", existsOnServer(monthFolder))
|
||||
assertNotNull(
|
||||
"app still has a cached entry for the removed folder",
|
||||
storageManager.getFileByDecryptedRemotePath(monthFolder)
|
||||
)
|
||||
|
||||
// attempting upload to the same folder
|
||||
val result = upload("nonEmpty.txt", monthFolder + "nonEmpty.txt")
|
||||
|
||||
assertEquals(
|
||||
"upload must not fail with a conflict, the missing folder has to be recreated",
|
||||
RemoteOperationResult.ResultCode.OK,
|
||||
result.code
|
||||
)
|
||||
assertTrue("month folder should be recreated on server", existsOnServer(monthFolder))
|
||||
assertTrue("uploaded file should exist on server", existsOnServer(monthFolder + "nonEmpty.txt"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUploadFileThenDeleteRootOnServerOnlyThenUploadAgainShouldRecreateAllFolderLevelsAndReturnOk() {
|
||||
uploadAndAssertSuccess("first.txt")
|
||||
|
||||
removeOnServer(root)
|
||||
assertFalse(existsOnServer(root))
|
||||
|
||||
val result = upload("nonEmpty.txt", monthFolder + "nonEmpty.txt")
|
||||
|
||||
assertEquals(
|
||||
"every missing folder level has to be recreated",
|
||||
RemoteOperationResult.ResultCode.OK,
|
||||
result.code
|
||||
)
|
||||
assertTrue(existsOnServer(yearFolder))
|
||||
assertTrue(existsOnServer(monthFolder))
|
||||
assertTrue(existsOnServer(monthFolder + "nonEmpty.txt"))
|
||||
}
|
||||
|
||||
private fun uploadAndAssertSuccess(filename: String) {
|
||||
val result = upload(filename, monthFolder + filename)
|
||||
assertTrue(result.logMessage, result.isSuccess)
|
||||
assertTrue("uploaded file should exist on server", existsOnServer(monthFolder + filename))
|
||||
}
|
||||
|
||||
private fun removeOnServer(remotePath: String) {
|
||||
// the server keeps a transient lock on a just uploaded file, so a DELETE on one of its
|
||||
// parent folders answers 423 until that lock expires
|
||||
repeat(REMOVE_ATTEMPTS) {
|
||||
if (RemoveFileRemoteOperation(remotePath).execute(client).isSuccess) {
|
||||
return
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
}
|
||||
|
||||
fail("$remotePath should be removed on server")
|
||||
}
|
||||
|
||||
private fun existsOnServer(remotePath: String): Boolean =
|
||||
ExistenceCheckRemoteOperation(remotePath, false).execute(client).isSuccess
|
||||
|
||||
private fun upload(localFileName: String, remotePath: String): RemoteOperationResult<*> {
|
||||
val localFile = createFile(localFileName, FILE_LINE_COUNT)
|
||||
assertTrue("local file must exist before uploading", localFile.exists())
|
||||
|
||||
val ocUpload = OCUpload(
|
||||
localFile.absolutePath,
|
||||
remotePath,
|
||||
account.name
|
||||
).apply {
|
||||
isCreateRemoteFolder = true
|
||||
createdBy = UploadFileOperation.CREATED_AS_INSTANT_PICTURE
|
||||
}
|
||||
|
||||
return UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
NameCollisionPolicy.ASK_USER,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
).execute(client)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val FILE_LINE_COUNT = 100
|
||||
private const val REMOVE_ATTEMPTS = 5
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,7 @@ class ScreenshotsIT : AbstractIT() {
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
@Test
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
package com.owncloud.android;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.device.BatteryStatus;
|
||||
import com.nextcloud.utils.PowerManagementFactory;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
||||
import com.nextcloud.client.network.ConnectivityManagerFactory;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.test.SinceServer;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
@@ -38,8 +39,6 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
@@ -55,22 +54,7 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
new UploadsStorageManager(UserAccountManagerImpl.fromContext(targetContext),
|
||||
targetContext.getContentResolver());
|
||||
|
||||
private PowerManagementService powerManagementServiceMock = new PowerManagementService() {
|
||||
@Override
|
||||
public boolean isIgnoringOptimization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
return new BatteryStatus(false, 0);
|
||||
}
|
||||
};
|
||||
private final PowerManagementService powerManagementServiceMock = PowerManagementFactory.getMock();
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
@@ -208,24 +192,7 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
|
||||
@Test
|
||||
public void testUploadOnChargingOnlyAndCharging() {
|
||||
PowerManagementService powerManagementServiceMock = new PowerManagementService() {
|
||||
@Override
|
||||
public boolean isIgnoringOptimization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
return new BatteryStatus(true, 100);
|
||||
}
|
||||
};
|
||||
|
||||
final var powerManagementServiceMock = PowerManagementFactory.getMockCharging();
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "charging.txt", account.name);
|
||||
ocUpload.setWhileChargingOnly(true);
|
||||
@@ -355,6 +322,7 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 27)
|
||||
public void testCreationAndUploadTimestamp() throws IOException, AccountUtils.AccountNotFoundException {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_27);
|
||||
|
||||
@@ -409,6 +377,7 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SinceServer(majorVersion = 27)
|
||||
public void testMetadata() throws IOException, AccountUtils.AccountNotFoundException {
|
||||
testOnlyOnServer(NextcloudVersion.nextcloud_27);
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ class FileMenuFilterIT : AbstractIT() {
|
||||
every { mockComponentsGetter.operationsServiceBinder } returns mockOperationsServiceBinder
|
||||
every { mockStorageManager.getFileById(any()) } returns OCFile("/")
|
||||
every { mockStorageManager.getFolderContent(any(), any()) } returns ArrayList<OCFile>()
|
||||
every { mockStorageManager.isReadOnly(any()) } returns false
|
||||
every { mockArbitraryDataProvider.getValue(any<User>(), any()) } returns ""
|
||||
editorUtils = EditorUtils(mockArbitraryDataProvider)
|
||||
}
|
||||
@@ -330,6 +331,96 @@ class FileMenuFilterIT : AbstractIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_openWithOnlyOffice_onlyForDownloadedFiles() {
|
||||
every {
|
||||
mockArbitraryDataProvider.getValue(any<User>(), ArbitraryDataProvider.DIRECT_EDITING)
|
||||
} returns ONLYOFFICE_DIRECT_EDITING_JSON
|
||||
|
||||
configureCapability(OCCapability())
|
||||
|
||||
val downloadedFile = OCFile("/downloaded.docx").apply {
|
||||
mimeType = OFFICE_MIMETYPE
|
||||
storagePath = getDummyFile("downloaded.docx").absolutePath
|
||||
}
|
||||
val onlineOnlyFile = OCFile("/online.docx").apply {
|
||||
mimeType = OFFICE_MIMETYPE
|
||||
}
|
||||
|
||||
launchActivity<TestActivity>().use {
|
||||
it.onActivity { activity ->
|
||||
val filterFactory = FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)
|
||||
|
||||
val downloadedToHide = filterFactory
|
||||
.newInstance(downloadedFile, mockComponentsGetter, true, user)
|
||||
.getToHide(false)
|
||||
assertFalse(downloadedToHide.contains(R.id.action_open_in_web_editor))
|
||||
|
||||
val onlineToHide = filterFactory
|
||||
.newInstance(onlineOnlyFile, mockComponentsGetter, true, user)
|
||||
.getToHide(false)
|
||||
assertTrue(onlineToHide.contains(R.id.action_open_in_web_editor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_readOnlyFile_hidesModifyingActions() {
|
||||
configureCapability(
|
||||
OCCapability().apply {
|
||||
endToEndEncryption = CapabilityBooleanType.TRUE
|
||||
filesLockingVersion = "1.0"
|
||||
}
|
||||
)
|
||||
|
||||
every { mockStorageManager.isReadOnly(any()) } returns true
|
||||
|
||||
val file = OCFile("/readOnly.txt").apply {
|
||||
permissions = FULL_PERMISSIONS
|
||||
}
|
||||
|
||||
launchActivity<TestActivity>().use {
|
||||
it.onActivity { activity ->
|
||||
val filterFactory = FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)
|
||||
|
||||
val toHide = filterFactory
|
||||
.newInstance(file, mockComponentsGetter, true, user)
|
||||
.getToHide(false)
|
||||
|
||||
READ_ONLY_HIDDEN_ACTIONS.forEach { action ->
|
||||
assertTrue(toHide.contains(action))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_writableFile_keepsModifyingActions() {
|
||||
configureCapability(
|
||||
OCCapability().apply {
|
||||
filesLockingVersion = "1.0"
|
||||
}
|
||||
)
|
||||
|
||||
val file = OCFile("/writable.txt").apply {
|
||||
permissions = FULL_PERMISSIONS
|
||||
}
|
||||
|
||||
launchActivity<TestActivity>().use {
|
||||
it.onActivity { activity ->
|
||||
val filterFactory = FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)
|
||||
|
||||
val toHide = filterFactory
|
||||
.newInstance(file, mockComponentsGetter, true, user)
|
||||
.getToHide(false)
|
||||
|
||||
WRITABLE_VISIBLE_ACTIONS.forEach { action ->
|
||||
assertFalse(toHide.contains(action))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private data class ExpectedLockVisibilities(val lockFile: Boolean, val unlockFile: Boolean)
|
||||
|
||||
private fun configureCapability(capability: OCCapability) {
|
||||
@@ -363,4 +454,48 @@ class FileMenuFilterIT : AbstractIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val FULL_PERMISSIONS = "RGDNVW"
|
||||
|
||||
private val READ_ONLY_HIDDEN_ACTIONS = listOf(
|
||||
R.id.action_remove_file,
|
||||
R.id.action_rename_file,
|
||||
R.id.action_move_or_copy,
|
||||
R.id.action_edit,
|
||||
R.id.action_encrypted,
|
||||
R.id.action_unset_encrypted,
|
||||
R.id.action_lock_file,
|
||||
R.id.action_unlock_file,
|
||||
R.id.action_favorite,
|
||||
R.id.action_unset_favorite
|
||||
)
|
||||
|
||||
private val WRITABLE_VISIBLE_ACTIONS = listOf(
|
||||
R.id.action_remove_file,
|
||||
R.id.action_rename_file,
|
||||
R.id.action_move_or_copy,
|
||||
R.id.action_lock_file,
|
||||
R.id.action_favorite
|
||||
)
|
||||
|
||||
private const val OFFICE_MIMETYPE =
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||
|
||||
private val ONLYOFFICE_DIRECT_EDITING_JSON =
|
||||
"""
|
||||
{
|
||||
"editors": {
|
||||
"onlyoffice": {
|
||||
"id": "onlyoffice",
|
||||
"name": "OnlyOffice",
|
||||
"mimetypes": [],
|
||||
"optionalMimetypes": ["$OFFICE_MIMETYPE"],
|
||||
"secure": false
|
||||
}
|
||||
},
|
||||
"creators": {}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
@@ -8,475 +9,136 @@
|
||||
*/
|
||||
package com.owncloud.android.files.services
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.client.device.BatteryStatus
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper
|
||||
import com.nextcloud.utils.PowerManagementFactory
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.lib.common.operations.OperationCancelledException
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertFalse
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
private var uploadsStorageManager: UploadsStorageManager? = null
|
||||
class FileUploaderIT : AbstractOnServerIT() {
|
||||
|
||||
private val powerManagementServiceMock: PowerManagementService = object : PowerManagementService {
|
||||
override val isIgnoringOptimization: Boolean
|
||||
get() = true
|
||||
private lateinit var uploadsStorageManager: UploadsStorageManager
|
||||
|
||||
override val isPowerSavingEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val battery: BatteryStatus
|
||||
get() = BatteryStatus()
|
||||
}
|
||||
private val powerManagementServiceMock = PowerManagementFactory.mock
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val contentResolver = targetContext.contentResolver
|
||||
val accountManager: UserAccountManager = UserAccountManagerImpl.fromContext(targetContext)
|
||||
uploadsStorageManager = UploadsStorageManager(accountManager, contentResolver)
|
||||
val accountManager = UserAccountManagerImpl.fromContext(targetContext)
|
||||
uploadsStorageManager = UploadsStorageManager(accountManager, targetContext.contentResolver)
|
||||
}
|
||||
|
||||
// /**
|
||||
// * uploads a file, overwrites it with an empty one, check if overwritten
|
||||
// */
|
||||
// disabled, flaky test
|
||||
// @Test
|
||||
// fun testKeepLocalAndOverwriteRemote() {
|
||||
// val file = getDummyFile("chunkedFile.txt")
|
||||
// val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
//
|
||||
// assertTrue(
|
||||
// UploadFileOperation(
|
||||
// uploadsStorageManager,
|
||||
// connectivityServiceMock,
|
||||
// powerManagementServiceMock,
|
||||
// user,
|
||||
// null,
|
||||
// ocUpload,
|
||||
// FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
// FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
// targetContext,
|
||||
// false,
|
||||
// false
|
||||
// )
|
||||
// .setRemoteFolderToBeCreated()
|
||||
// .execute(client, storageManager)
|
||||
// .isSuccess
|
||||
// )
|
||||
//
|
||||
// val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
// assertTrue(result.isSuccess)
|
||||
//
|
||||
// assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
//
|
||||
// val ocUpload2 = OCUpload(getDummyFile("empty.txt").absolutePath, "/testFile.txt", account.name)
|
||||
//
|
||||
// assertTrue(
|
||||
// UploadFileOperation(
|
||||
// uploadsStorageManager,
|
||||
// connectivityServiceMock,
|
||||
// powerManagementServiceMock,
|
||||
// user,
|
||||
// null,
|
||||
// ocUpload2,
|
||||
// FileUploader.NameCollisionPolicy.OVERWRITE,
|
||||
// FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
// targetContext,
|
||||
// false,
|
||||
// false
|
||||
// )
|
||||
// .execute(client, storageManager)
|
||||
// .isSuccess
|
||||
// )
|
||||
//
|
||||
// val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
// assertTrue(result2.isSuccess)
|
||||
//
|
||||
// assertEquals(0, (result2.data[0] as RemoteFile).length)
|
||||
// }
|
||||
|
||||
/**
|
||||
* uploads a file, overwrites it with an empty one, check if overwritten
|
||||
*/
|
||||
@Test
|
||||
fun testKeepLocalAndOverwriteRemoteStatic() {
|
||||
val file = getDummyFile("chunkedFile.txt")
|
||||
fun uploadWithOverwritePolicyReplacesRemoteFile() {
|
||||
val originalFile = getDummyFile(CHUNKED_FILE)
|
||||
uploadOriginalFile(originalFile)
|
||||
|
||||
FileUploadHelper().uploadNewFiles(
|
||||
user,
|
||||
arrayOf(file.absolutePath),
|
||||
arrayOf("/testFile.txt"),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
true,
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
val replacement = getDummyFile(EMPTY_FILE)
|
||||
assertTrue(uploadOperation(replacement, NameCollisionPolicy.OVERWRITE).execute(client).isSuccess)
|
||||
|
||||
longSleep()
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.storagePath = getDummyFile("empty.txt").absolutePath
|
||||
|
||||
FileUploadHelper().uploadUpdatedFile(
|
||||
user,
|
||||
arrayOf(ocFile2),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
NameCollisionPolicy.OVERWRITE
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(0, (result2.data[0] as RemoteFile).length)
|
||||
assertRemoteFileLength(REMOTE_PATH, EMPTY_LENGTH)
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads a file, uploads another one with automatically (2) added, check
|
||||
*/
|
||||
@Test
|
||||
fun testKeepBoth() {
|
||||
var renameListenerWasTriggered = false
|
||||
fun uploadWithRenamePolicyKeepsBothFiles() {
|
||||
val originalFile = getDummyFile(CHUNKED_FILE)
|
||||
uploadOriginalFile(originalFile)
|
||||
|
||||
val file = getDummyFile("chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
val renamedFile = getDummyFile(EMPTY_FILE)
|
||||
var renameListenerTriggered = false
|
||||
val operation = uploadOperation(renamedFile, NameCollisionPolicy.RENAME)
|
||||
.addRenameUploadListener { renameListenerTriggered = true }
|
||||
assertTrue(operation.execute(client).isSuccess)
|
||||
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
NameCollisionPolicy.DEFAULT,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val file2 = getDummyFile("empty.txt")
|
||||
val ocUpload2 = OCUpload(file2.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload2,
|
||||
NameCollisionPolicy.RENAME,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
.addRenameUploadListener {
|
||||
renameListenerWasTriggered = true
|
||||
}
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result2.data[0] as RemoteFile).length)
|
||||
|
||||
val result3 = ReadFileRemoteOperation("/testFile (2).txt").execute(client)
|
||||
assertTrue(result3.isSuccess)
|
||||
|
||||
assertEquals(file2.length(), (result3.data[0] as RemoteFile).length)
|
||||
assertTrue(renameListenerWasTriggered)
|
||||
assertRemoteFileLength(REMOTE_PATH, originalFile.length())
|
||||
assertRemoteFileLength(REMOTE_PATH_RENAMED, renamedFile.length())
|
||||
assertTrue(renameListenerTriggered)
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads a file, uploads another one with automatically (2) added, check
|
||||
*/
|
||||
@Test
|
||||
fun testKeepBothStatic() {
|
||||
val file = getDummyFile("nonEmpty.txt")
|
||||
fun uploadWithRenamePolicyKeepsBothFilesForNonEmptyOriginal() {
|
||||
val originalFile = getDummyFile(NON_EMPTY_FILE)
|
||||
uploadOriginalFile(originalFile)
|
||||
|
||||
FileUploadHelper().uploadNewFiles(
|
||||
user,
|
||||
arrayOf(file.absolutePath),
|
||||
arrayOf("/testFile.txt"),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
true,
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
val renamedFile = getDummyFile(EMPTY_FILE)
|
||||
assertTrue(uploadOperation(renamedFile, NameCollisionPolicy.RENAME).execute(client).isSuccess)
|
||||
|
||||
longSleep()
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.storagePath = getDummyFile("empty.txt").absolutePath
|
||||
|
||||
FileUploadHelper().uploadUpdatedFile(
|
||||
user,
|
||||
arrayOf(ocFile2),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
NameCollisionPolicy.RENAME
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result2.data[0] as RemoteFile).length)
|
||||
|
||||
val result3 = ReadFileRemoteOperation("/testFile (2).txt").execute(client)
|
||||
assertTrue(result3.isSuccess)
|
||||
|
||||
assertEquals(ocFile2.fileLength, (result3.data[0] as RemoteFile).length)
|
||||
assertRemoteFileLength(REMOTE_PATH, originalFile.length())
|
||||
assertRemoteFileLength(REMOTE_PATH_RENAMED, renamedFile.length())
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads a file with "keep server" option set, so do nothing
|
||||
*/
|
||||
@Test
|
||||
fun testKeepServer() {
|
||||
val file = getDummyFile("chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
fun uploadWithSkipPolicyKeepsRemoteFileUnchanged() {
|
||||
val originalFile = getDummyFile(CHUNKED_FILE)
|
||||
uploadOriginalFile(originalFile)
|
||||
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
NameCollisionPolicy.DEFAULT,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
val skippedFile = getDummyFile(EMPTY_FILE)
|
||||
val operation = uploadOperation(skippedFile, NameCollisionPolicy.SKIP)
|
||||
assertTrue(operation.execute(client).isSuccess)
|
||||
assertTrue(operation.wasSkipped())
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocUpload2 = OCUpload(getDummyFile("empty.txt").absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertFalse(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload2,
|
||||
NameCollisionPolicy.SKIP,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
.execute(client).isSuccess
|
||||
)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result2.data[0] as RemoteFile).length)
|
||||
assertRemoteFileLength(REMOTE_PATH, originalFile.length())
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads a file with "keep server" option set, so do nothing
|
||||
*/
|
||||
@Test
|
||||
fun testKeepServerStatic() {
|
||||
val file = getDummyFile("chunkedFile.txt")
|
||||
fun uploadWithSkipPolicyUploadsWhenNoRemoteFileExists() {
|
||||
val originalFile = getDummyFile(CHUNKED_FILE)
|
||||
val operation = uploadOperation(originalFile, NameCollisionPolicy.SKIP).setRemoteFolderToBeCreated()
|
||||
assertTrue(operation.execute(client).isSuccess)
|
||||
assertFalse(operation.wasSkipped())
|
||||
|
||||
FileUploadHelper().uploadNewFiles(
|
||||
user,
|
||||
arrayOf(file.absolutePath),
|
||||
arrayOf("/testFile.txt"),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
true,
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
assertRemoteFileLength(REMOTE_PATH, originalFile.length())
|
||||
|
||||
longSleep()
|
||||
val skippedFile = getDummyFile(EMPTY_FILE)
|
||||
val skippedOperation = uploadOperation(skippedFile, NameCollisionPolicy.SKIP)
|
||||
assertTrue(skippedOperation.execute(client).isSuccess)
|
||||
assertTrue(skippedOperation.wasSkipped())
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.storagePath = getDummyFile("empty.txt").absolutePath
|
||||
|
||||
FileUploadHelper().uploadUpdatedFile(
|
||||
user,
|
||||
arrayOf(ocFile2),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
NameCollisionPolicy.SKIP
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result2.data[0] as RemoteFile).length)
|
||||
assertRemoteFileLength(REMOTE_PATH, originalFile.length())
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads a file with "skip if exists" option set, so do nothing if file exists
|
||||
*/
|
||||
@Test
|
||||
fun testCancelServer() {
|
||||
val file = getDummyFile("chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
NameCollisionPolicy.SKIP,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
.setRemoteFolderToBeCreated()
|
||||
.execute(client)
|
||||
.isSuccess
|
||||
)
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocUpload2 = OCUpload(getDummyFile("empty.txt").absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
val uploadResult = UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload2,
|
||||
NameCollisionPolicy.SKIP,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
.execute(client)
|
||||
|
||||
assertFalse(uploadResult.isSuccess)
|
||||
assertTrue(uploadResult.exception is OperationCancelledException)
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result2.data[0] as RemoteFile).length)
|
||||
private fun uploadOriginalFile(originalFile: File) {
|
||||
val operation = uploadOperation(originalFile, NameCollisionPolicy.DEFAULT).setRemoteFolderToBeCreated()
|
||||
assertTrue(operation.execute(client).isSuccess)
|
||||
assertRemoteFileLength(REMOTE_PATH, originalFile.length())
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads a file with "skip if exists" option set, so do nothing if file exists
|
||||
*/
|
||||
@Test
|
||||
fun testKeepCancelStatic() {
|
||||
val file = getDummyFile("chunkedFile.txt")
|
||||
private fun uploadOperation(localFile: File, nameCollisionPolicy: NameCollisionPolicy) = UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
OCUpload(localFile.absolutePath, REMOTE_PATH, account.name),
|
||||
nameCollisionPolicy,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
)
|
||||
|
||||
FileUploadHelper().uploadNewFiles(
|
||||
user,
|
||||
arrayOf(file.absolutePath),
|
||||
arrayOf("/testFile.txt"),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
true,
|
||||
UploadFileOperation.CREATED_BY_USER,
|
||||
false,
|
||||
false,
|
||||
NameCollisionPolicy.DEFAULT
|
||||
)
|
||||
|
||||
longSleep()
|
||||
|
||||
val result = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
private fun assertRemoteFileLength(remotePath: String, expectedLength: Long) {
|
||||
val result = ReadFileRemoteOperation(remotePath).execute(client)
|
||||
assertTrue(result.isSuccess)
|
||||
assertEquals(expectedLength, (result.data[0] as RemoteFile).length)
|
||||
}
|
||||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.storagePath = getDummyFile("empty.txt").absolutePath
|
||||
|
||||
FileUploadHelper().uploadUpdatedFile(
|
||||
user,
|
||||
arrayOf(ocFile2),
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
NameCollisionPolicy.SKIP
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
val result2 = ReadFileRemoteOperation("/testFile.txt").execute(client)
|
||||
assertTrue(result2.isSuccess)
|
||||
|
||||
assertEquals(file.length(), (result2.data[0] as RemoteFile).length)
|
||||
companion object {
|
||||
private const val REMOTE_PATH = "/testFile.txt"
|
||||
private const val REMOTE_PATH_RENAMED = "/testFile (2).txt"
|
||||
private const val CHUNKED_FILE = "chunkedFile.txt"
|
||||
private const val NON_EMPTY_FILE = "nonEmpty.txt"
|
||||
private const val EMPTY_FILE = "empty.txt"
|
||||
private const val EMPTY_LENGTH = 0L
|
||||
}
|
||||
}
|
||||
-202
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.operations
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.client.device.BatteryStatus
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.network.ConnectivityManagerFactory
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ConcurrentFileOperationsIT : AbstractOnServerIT() {
|
||||
|
||||
companion object {
|
||||
private const val TIMEOUT_SECONDS = 120L
|
||||
private const val FILE_SIZE_ITERATIONS = 500
|
||||
private const val FILE_COUNT = 3
|
||||
}
|
||||
|
||||
private val connectivityServiceMock: ConnectivityService = ConnectivityManagerFactory.wifi
|
||||
|
||||
private val powerManagementServiceMock: PowerManagementService = object : PowerManagementService {
|
||||
override val isIgnoringOptimization: Boolean get() = true
|
||||
override val isPowerSavingEnabled: Boolean get() = false
|
||||
override val battery: BatteryStatus get() = BatteryStatus()
|
||||
}
|
||||
|
||||
private val uploadsStorageManager: UploadsStorageManager by lazy {
|
||||
UploadsStorageManager(
|
||||
UserAccountManagerImpl.fromContext(targetContext),
|
||||
targetContext.contentResolver
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uploadAndDownloadConcurrently() {
|
||||
val remoteFolder = "/concurrentUploadDownload/"
|
||||
val fileData = prepareFilesOnServer(remoteFolder, prefix = "ud")
|
||||
val ocFiles = resolveOCFiles(remoteFolder, fileData)
|
||||
|
||||
val errors = CopyOnWriteArrayList<String>()
|
||||
val latch = CountDownLatch(2)
|
||||
|
||||
startUploadThread(fileData, errors, latch)
|
||||
startDownloadThread(ocFiles, errors, latch)
|
||||
|
||||
assertTrue("Concurrent upload+download timed out", latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS))
|
||||
assertFalse("Unexpected errors during concurrent upload+download: $errors", errors.isNotEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uploadAndDeleteLocalOnlyConcurrently() {
|
||||
val remoteFolder = "/concurrentUploadDelete/"
|
||||
val fileData = prepareFilesOnServer(remoteFolder, prefix = "udel")
|
||||
val ocFiles = resolveOCFiles(remoteFolder, fileData)
|
||||
|
||||
val errors = CopyOnWriteArrayList<String>()
|
||||
val latch = CountDownLatch(2)
|
||||
|
||||
startUploadThread(fileData, errors, latch)
|
||||
startDeleteLocalThread(ocFiles, errors, latch, delayMs = 500L)
|
||||
|
||||
assertTrue("Concurrent upload+delete timed out", latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS))
|
||||
assertFalse("Unexpected errors during concurrent upload+delete: $errors", errors.isNotEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uploadDownloadAndDeleteLocalConcurrently() {
|
||||
val remoteFolder = "/concurrentAll/"
|
||||
val fileData = prepareFilesOnServer(remoteFolder, prefix = "all")
|
||||
val ocFiles = resolveOCFiles(remoteFolder, fileData)
|
||||
|
||||
val errors = CopyOnWriteArrayList<String>()
|
||||
val latch = CountDownLatch(3)
|
||||
|
||||
startUploadThread(fileData, errors, latch)
|
||||
startDownloadThread(ocFiles, errors, latch)
|
||||
startDeleteLocalThread(ocFiles, errors, latch, delayMs = 1000L)
|
||||
|
||||
assertTrue("Concurrent upload+download+delete timed out", latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS))
|
||||
assertFalse(
|
||||
"Unexpected errors during concurrent upload+download+delete: $errors",
|
||||
errors.isNotEmpty()
|
||||
)
|
||||
}
|
||||
|
||||
private fun prepareFilesOnServer(remoteFolder: String, prefix: String): List<Pair<File, String>> =
|
||||
(0 until FILE_COUNT).map { index ->
|
||||
val localFile = createFile("${prefix}_$index.txt", FILE_SIZE_ITERATIONS)
|
||||
val remotePath = "$remoteFolder${prefix}_$index.txt"
|
||||
uploadOCUpload(OCUpload(localFile.absolutePath, remotePath, account.name))
|
||||
localFile to remotePath
|
||||
}.also { refreshFolder(remoteFolder) }
|
||||
|
||||
private fun resolveOCFiles(remoteFolder: String, fileData: List<Pair<File, String>>): List<OCFile> {
|
||||
val ocFiles = fileData.mapNotNull { (_, remotePath) ->
|
||||
storageManager.getFileByDecryptedRemotePath(remotePath)
|
||||
}
|
||||
assertTrue(
|
||||
"Expected ${fileData.size} files in storage under $remoteFolder, got ${ocFiles.size}",
|
||||
ocFiles.size == fileData.size
|
||||
)
|
||||
return ocFiles
|
||||
}
|
||||
|
||||
private fun startUploadThread(
|
||||
fileData: List<Pair<File, String>>,
|
||||
errors: CopyOnWriteArrayList<String>,
|
||||
latch: CountDownLatch
|
||||
) {
|
||||
Thread {
|
||||
try {
|
||||
fileData.forEach { (localFile, remotePath) ->
|
||||
val upload = OCUpload(localFile.absolutePath, remotePath, account.name)
|
||||
val result = UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
upload,
|
||||
NameCollisionPolicy.OVERWRITE,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false,
|
||||
storageManager
|
||||
).execute(client)
|
||||
|
||||
if (!result.isSuccess) {
|
||||
errors.add("Upload ${result.code} for $remotePath")
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
latch.countDown()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun startDownloadThread(
|
||||
ocFiles: List<OCFile>,
|
||||
errors: CopyOnWriteArrayList<String>,
|
||||
latch: CountDownLatch
|
||||
) {
|
||||
Thread {
|
||||
try {
|
||||
ocFiles.forEach { ocFile ->
|
||||
val result = DownloadFileOperation(user, ocFile, targetContext).execute(client)
|
||||
if (!result.isSuccess) {
|
||||
errors.add("Download ${result.code} for ${ocFile.remotePath}")
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
latch.countDown()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun startDeleteLocalThread(
|
||||
ocFiles: List<OCFile>,
|
||||
errors: CopyOnWriteArrayList<String>,
|
||||
latch: CountDownLatch,
|
||||
delayMs: Long
|
||||
) {
|
||||
Thread {
|
||||
try {
|
||||
Thread.sleep(delayMs)
|
||||
ocFiles.forEach { ocFile ->
|
||||
val result = RemoveFileOperation(
|
||||
ocFile,
|
||||
true,
|
||||
user,
|
||||
true,
|
||||
targetContext,
|
||||
storageManager
|
||||
).execute(client)
|
||||
if (!result.isSuccess) {
|
||||
errors.add("DeleteLocalOnly ${result.code} for ${ocFile.remotePath}")
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
latch.countDown()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
+47
-10
@@ -8,10 +8,15 @@ package com.owncloud.android.providers
|
||||
|
||||
import android.provider.DocumentsContract
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper
|
||||
import com.nextcloud.test.RandomStringGenerator
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile.ROOT_PATH
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager.UploadStatus
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.providers.DocumentsProviderUtils.assertExistsOnServer
|
||||
import com.owncloud.android.providers.DocumentsProviderUtils.assertListFilesEquals
|
||||
@@ -31,12 +36,16 @@ import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.random.Random
|
||||
|
||||
private const val MAX_FILE_NAME_LENGTH = 225
|
||||
|
||||
// the provider can only enqueue the upload worker, so give it a generous budget before giving up
|
||||
private const val UPLOAD_POLL_ATTEMPTS = 45
|
||||
|
||||
class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
|
||||
private val context = targetContext
|
||||
@@ -48,8 +57,17 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
private val uri = DocumentsContract.buildTreeDocumentUri(authority, documentId)
|
||||
private val rootDir get() = DocumentFile.fromTreeUri(context, uri)!!
|
||||
|
||||
private val uploadsStorageManager = UploadsStorageManager(
|
||||
UserAccountManagerImpl.fromContext(context),
|
||||
contentResolver
|
||||
)
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
// an upload left over by a previous test fails once its local file is gone, and WorkManager
|
||||
// then drops everything appended behind it in the upload chain, including our own uploads
|
||||
FileUploadHelper.instance().cancel(user.accountName)
|
||||
|
||||
// DocumentsProvider#onCreate() is called when the application is started
|
||||
// which is *after* AbstractOnServerIT adds the accounts (when the app is freshly installed).
|
||||
// So we need to query our roots here to ensure that the internal storage map is initialized.
|
||||
@@ -211,11 +229,7 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
it!!.write(content1)
|
||||
}
|
||||
|
||||
// refresh
|
||||
while (file1.getOCFile(storageManager)!!.etagOnServer == createdETag) {
|
||||
shortSleep()
|
||||
rootDir.listFiles()
|
||||
}
|
||||
awaitUploadedToServer(file1, createdETag)
|
||||
|
||||
val remotePath = file1.getOCFile(storageManager)!!.remotePath
|
||||
|
||||
@@ -250,11 +264,7 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
it!!.write(content1)
|
||||
}
|
||||
|
||||
// refresh
|
||||
while (file1.getOCFile(storageManager)!!.etagOnServer == createdETag) {
|
||||
shortSleep()
|
||||
rootDir.listFiles()
|
||||
}
|
||||
awaitUploadedToServer(file1, createdETag)
|
||||
|
||||
val content2 = "new content".toByteArray()
|
||||
|
||||
@@ -266,4 +276,31 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
val bytes = contentResolver.openInputStream(file1.uri)?.readBytes() ?: ByteArray(0)
|
||||
assertEquals(String(content2), String(bytes))
|
||||
}
|
||||
|
||||
private fun awaitUploadedToServer(file: DocumentFile, etagBeforeUpload: String) {
|
||||
val remotePath = file.getOCFile(storageManager)!!.remotePath
|
||||
|
||||
repeat(UPLOAD_POLL_ATTEMPTS) {
|
||||
if (file.getOCFile(storageManager)!!.etagOnServer != etagBeforeUpload) {
|
||||
return
|
||||
}
|
||||
|
||||
failedUpload(remotePath)?.let {
|
||||
fail("upload of $remotePath failed with ${it.lastResult}")
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
rootDir.listFiles()
|
||||
}
|
||||
|
||||
fail("upload of $remotePath did not finish, stored uploads: ${describeUploads()}")
|
||||
}
|
||||
|
||||
private fun failedUpload(remotePath: String): OCUpload? = uploadsStorageManager
|
||||
.getUploadsForAccount(user.accountName)
|
||||
.firstOrNull { it.remotePath == remotePath && it.uploadStatus == UploadStatus.UPLOAD_FAILED }
|
||||
|
||||
private fun describeUploads(): String = uploadsStorageManager
|
||||
.getUploadsForAccount(user.accountName)
|
||||
.joinToString { "${it.remotePath} is ${it.uploadStatus} with ${it.lastResult}" }
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import androidx.test.filters.SdkSuppress
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.GrantStoragePermissionRule
|
||||
import com.nextcloud.test.RetryTestRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
@@ -53,6 +54,7 @@ class LoginIT : AbstractIT() {
|
||||
@Throws(InterruptedException::class)
|
||||
@Suppress("MagicNumber", "SwallowedException")
|
||||
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q)
|
||||
@Flaky("Login no longer uses an in-app WebView, so espresso-web (Espresso.onWebView) cannot drive it. ")
|
||||
fun login() {
|
||||
val arguments = InstrumentationRegistry.getArguments()
|
||||
val baseUrl = arguments.getString("TEST_SERVER_URL")!!
|
||||
|
||||
+5
-5
@@ -25,10 +25,10 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictsResolveDialog
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictsResolveDialog.Decision
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictsResolveDialog.OnConflictDecisionMadeListener
|
||||
import com.owncloud.android.ui.dialog.conflict.ConflictResolveDialogFactory
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
@@ -69,7 +69,7 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var dialog: ConflictsResolveDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
dialog = newInstance(
|
||||
dialog = ConflictResolveDialogFactory.forNormal(
|
||||
storageManager.getDecryptedPath(existingFile),
|
||||
targetContext,
|
||||
newFile,
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.Manifest
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.net.Uri
|
||||
@@ -21,6 +20,8 @@ import androidx.test.rule.GrantPermissionRule
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.GrantTestPermissionRule
|
||||
import com.nextcloud.test.RetryTestRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
@@ -39,36 +40,37 @@ class DrawerActivityIT : AbstractIT() {
|
||||
val retryTestRule = RetryTestRule()
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
val permissionRule: GrantPermissionRule = GrantTestPermissionRule.grantStorageAndNotification()
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Account switch relaunches FileDisplayActivity, which races with the drawer assertions")
|
||||
fun switchAccountViaAccountList() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
}
|
||||
|
||||
Assert.assertEquals(account1, sut!!.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
// Switching accounts finishes and relaunches FileDisplayActivity (see
|
||||
// FileDisplayActivity.handleRestartIntent). That self-relaunch is incompatible with
|
||||
// ActivityScenario#close(), which cannot drive its tracked instance to DESTROYED, so the
|
||||
// scenario is launched without auto-closing.
|
||||
val scenario = launchActivity<FileDisplayActivity>()
|
||||
lateinit var sut: FileDisplayActivity
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
}
|
||||
|
||||
Assert.assertEquals(account1, sut.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+19
-10
@@ -12,6 +12,7 @@ package com.owncloud.android.ui.activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
@@ -24,6 +25,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import com.facebook.testing.screenshot.internal.TestNameDetector
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.GrantStoragePermissionRule
|
||||
import com.nextcloud.test.withSelectedText
|
||||
import com.nextcloud.utils.extensions.removeFileExtension
|
||||
@@ -32,6 +34,8 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.hamcrest.Matchers.not
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -101,6 +105,7 @@ class ReceiveExternalFilesActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Rename dialog text selection is not settled when the assertions run")
|
||||
fun renameSingleFileUpload() {
|
||||
val imageFile = getDummyFile("image.jpg")
|
||||
val intent = createSendIntent(imageFile)
|
||||
@@ -229,18 +234,22 @@ class ReceiveExternalFilesActivityIT : AbstractIT() {
|
||||
val preferences = AppPreferencesImpl.fromContext(targetContext)
|
||||
preferences.setLastUploadPath(mainFolder.remotePath)
|
||||
|
||||
launchActivity<ReceiveExternalFilesActivity>(intent).use {
|
||||
val expectedMainFolderTitle = (getCurrentActivity() as ToolbarActivity).getActionBarTitle(mainFolder, false)
|
||||
// Verify that the test starts in the expected folder. If this fails, change the setup calls above
|
||||
onView(withId(R.id.toolbar))
|
||||
.check(matches(hasDescendant(withText(expectedMainFolderTitle))))
|
||||
// In the multi-upload case the rename field is hidden and no view requests focus, so the
|
||||
// activity window never gains focus on the CI emulator and Espresso's onView(...) fails with
|
||||
// RootViewWithoutFocusException. The view state is therefore asserted directly via
|
||||
// onActivity, which does not depend on window focus.
|
||||
launchActivity<ReceiveExternalFilesActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
// Verify that the test starts in the expected folder. If this fails, change the setup calls above
|
||||
val expectedMainFolderTitle = sut.getActionBarTitle(mainFolder, false)
|
||||
assertEquals(expectedMainFolderTitle, sut.supportActionBar?.title?.toString())
|
||||
|
||||
onView(withText(R.string.uploader_btn_upload_text))
|
||||
.check(matches(isDisplayed()))
|
||||
.check(matches(isEnabled()))
|
||||
val uploadButton = sut.findViewById<View>(R.id.uploader_choose_folder)
|
||||
assertEquals(View.VISIBLE, uploadButton.visibility)
|
||||
assertTrue(uploadButton.isEnabled)
|
||||
|
||||
onView(withId(R.id.user_input))
|
||||
.check(matches(not(isDisplayed())))
|
||||
assertEquals(View.GONE, sut.findViewById<View>(R.id.user_input).visibility)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-12
@@ -21,9 +21,13 @@ import com.owncloud.android.ui.interfaces.UnifiedSearchCurrentDirItemAction
|
||||
import com.owncloud.android.ui.interfaces.UnifiedSearchListInterface
|
||||
import com.owncloud.android.ui.unifiedsearch.ProviderID
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchSection
|
||||
import com.owncloud.android.ui.unifiedsearch.toUnifiedSearchEntry
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.overlay.OverlayManager
|
||||
import com.nextcloud.utils.thumbnail.FileThumbnailGenerator
|
||||
import com.nextcloud.utils.thumbnail.FolderThumbnailGenerator
|
||||
import com.nextcloud.utils.thumbnail.ThumbnailGenerator
|
||||
import javax.inject.Provider
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@@ -32,7 +36,7 @@ class UnifiedSearchListAdapterIT : AbstractIT() {
|
||||
|
||||
private val testClassName = "com.owncloud.android.ui.adapter.UnifiedSearchListAdapterIT"
|
||||
|
||||
private lateinit var overlayManager: OverlayManager
|
||||
private lateinit var thumbnailGenerator: ThumbnailGenerator
|
||||
private lateinit var preferences: AppPreferences
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -98,7 +102,7 @@ class UnifiedSearchListAdapterIT : AbstractIT() {
|
||||
UnifiedSearchSection(
|
||||
providerID = name.lowercase().replace(" ", "_"),
|
||||
name = name,
|
||||
entries = entries,
|
||||
entries = entries.map { it.toUnifiedSearchEntry(storageManager) },
|
||||
hasMoreResults = false
|
||||
)
|
||||
}
|
||||
@@ -108,7 +112,7 @@ class UnifiedSearchListAdapterIT : AbstractIT() {
|
||||
UnifiedSearchSection(
|
||||
providerID = name.lowercase().replace(" ", "_"),
|
||||
name = name,
|
||||
entries = entries,
|
||||
entries = entries.map { it.toUnifiedSearchEntry(storageManager) },
|
||||
hasMoreResults = true
|
||||
)
|
||||
}
|
||||
@@ -134,11 +138,20 @@ class UnifiedSearchListAdapterIT : AbstractIT() {
|
||||
): UnifiedSearchListAdapter {
|
||||
val accountManager = UserAccountManagerImpl.fromContext(targetContext)
|
||||
|
||||
overlayManager = OverlayManager(
|
||||
preferences = preferences,
|
||||
viewThemeUtils = sut.viewThemeUtils,
|
||||
context = targetContext,
|
||||
accountManager = accountManager
|
||||
thumbnailGenerator = ThumbnailGenerator(
|
||||
fileThumbnailGenerator = FileThumbnailGenerator(
|
||||
storageManager = Provider { sut.storageManager },
|
||||
preferences = preferences,
|
||||
viewThemeUtils = sut.viewThemeUtils,
|
||||
context = targetContext,
|
||||
accountManager = accountManager
|
||||
),
|
||||
folderThumbnailGenerator = FolderThumbnailGenerator(
|
||||
preferences = preferences,
|
||||
viewThemeUtils = sut.viewThemeUtils,
|
||||
context = targetContext,
|
||||
accountManager = accountManager
|
||||
)
|
||||
)
|
||||
|
||||
val adapter = UnifiedSearchListAdapter(
|
||||
@@ -152,12 +165,11 @@ class UnifiedSearchListAdapterIT : AbstractIT() {
|
||||
onClientReady: (com.nextcloud.common.NextcloudClient) -> Unit
|
||||
) = Unit
|
||||
},
|
||||
user = sut.user.get(),
|
||||
context = sut,
|
||||
viewThemeUtils = sut.viewThemeUtils,
|
||||
appPreferences = preferences,
|
||||
currentDirItemAction = noopCurrentDirAction,
|
||||
overlayManager = overlayManager
|
||||
thumbnailGenerator = thumbnailGenerator,
|
||||
user = sut.user.get()
|
||||
)
|
||||
|
||||
adapter.shouldShowFooters(true)
|
||||
|
||||
@@ -85,8 +85,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
|
||||
@After
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SetupEncryptionDialogFragment? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, null)
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, null, null)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
val keyWords = arrayListOf(
|
||||
"ability",
|
||||
@@ -64,7 +64,7 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SetupEncryptionDialogFragment? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, null)
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, null, null)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
sut.errorSavingKeys()
|
||||
}
|
||||
|
||||
+2
-5
@@ -6,13 +6,13 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.nextcloud.test.GrantTestPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
@@ -25,10 +25,7 @@ class SyncFileNotEnoughSpaceDialogFragmentTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest"
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
val permissionRule: GrantPermissionRule = GrantTestPermissionRule.grantStorageAndNotification()
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.extensions.getParcelableArgument
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Test
|
||||
|
||||
class FileDetailActivitiesFragmentIT : AbstractIT() {
|
||||
|
||||
@Test
|
||||
fun newInstanceStoresFileAndUserInArguments() {
|
||||
val file = OCFile("/test.txt").apply { fileId = 12 }
|
||||
|
||||
val fragment = FileDetailActivitiesFragment.newInstance(file, user)
|
||||
|
||||
val arguments = fragment.arguments
|
||||
assertNotNull(arguments)
|
||||
|
||||
val storedFile = arguments.getParcelableArgument("FILE", OCFile::class.java)
|
||||
val storedUser = arguments.getParcelableArgument("USER", User::class.java)
|
||||
|
||||
assertEquals(file.fileId, storedFile?.fileId)
|
||||
assertEquals(user.accountName, storedUser?.accountName)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -15,7 +15,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.nextcloud.ui.ImageDetailFragment
|
||||
import com.nextcloud.ui.fileInfo.FileInfoFragment
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -79,7 +79,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
activity = sut
|
||||
val fragment = ImageDetailFragment.newInstance(oCFile, user).apply {
|
||||
val fragment = FileInfoFragment.newInstance(oCFile, user).apply {
|
||||
hideMap()
|
||||
}
|
||||
sut.addFragment(fragment)
|
||||
|
||||
+159
-187
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2021 TSI-mc
|
||||
@@ -9,11 +10,13 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.accessibility.AccessibilityChecks
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
@@ -24,6 +27,7 @@ import com.google.android.apps.common.testing.accessibility.framework.Accessibil
|
||||
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.nextcloud.android.lib.resources.files.FileDownloadLimit
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.RetryTestRule
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
@@ -86,12 +90,14 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@Flaky("not stable")
|
||||
fun listSharesFileNone() {
|
||||
show(file)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@Flaky("not stable")
|
||||
fun listSharesFileResharingNotAllowed() {
|
||||
file.permissions = ""
|
||||
|
||||
@@ -100,6 +106,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@Flaky("not stable")
|
||||
fun listSharesDownloadLimit() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
@@ -153,6 +160,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun listSharesFileAllShareTypes() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
@@ -283,36 +291,30 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for advanced permissions
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun publicLinkOptionMenuFolderAdvancePermission() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
sut!!.refreshCapabilitiesFromDB()
|
||||
|
||||
val publicShare = OCShare().apply {
|
||||
isFolder = true
|
||||
shareType = ShareType.PUBLIC_LINK
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
activity!!.runOnUiThread { sut.showSharingMenuActionSheet(publicShare) }
|
||||
scenario.onActivity { sut.showSharingMenuActionSheet(publicShare) }
|
||||
|
||||
// check if items are visible
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_new_email).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_link).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_unshare).check(matches(isDisplayed()))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).perform(ViewActions.click())
|
||||
|
||||
// validate view shown on screen
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isDisplayed()))
|
||||
@@ -326,57 +328,57 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// upload and editing
|
||||
publicShare.permissions = MAXIMUM_PERMISSIONS_FOR_FOLDER
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// file request
|
||||
publicShare.permissions = 4
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// password protection
|
||||
publicShare.shareWith = "someValue"
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.shareWith = ""
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// hide download
|
||||
publicShare.isHideFileDownload = true
|
||||
publicShare.permissions = MAXIMUM_PERMISSIONS_FOR_FOLDER
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.isHideFileDownload = false
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(
|
||||
ViewMatchers.withId(R.id.share_process_hide_download_checkbox)
|
||||
).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.expirationDate = 1582019340000
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.expirationDate = 0
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))
|
||||
}
|
||||
@@ -386,76 +388,76 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for send new email
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun publicLinkOptionMenuFolderSendNewEmail() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val publicShare = OCShare().apply {
|
||||
isFolder = true
|
||||
shareType = ShareType.PUBLIC_LINK
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
verifySendNewEmail(sut!!, publicShare)
|
||||
verifySendNewEmail(scenario, sut, publicShare)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSecondaryFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
val parentFolder = OCFile("/")
|
||||
val secondary = FileDetailFragment.newInstance(file, parentFolder, user)
|
||||
activity.addSecondaryFragment(secondary, FileDisplayActivity.TAG_LIST_OF_FILES)
|
||||
activity.addView(
|
||||
FloatingActionButton(activity).apply {
|
||||
// needed for some reason
|
||||
visibility = View.GONE
|
||||
id = R.id.fab_main
|
||||
}
|
||||
)
|
||||
private fun addSharingFragment(activity: TestActivity): FileDetailSharingFragment {
|
||||
val fragment = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(fragment)
|
||||
fragment.refreshCapabilitiesFromDB()
|
||||
setupSecondaryFragment(activity)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
return fragment
|
||||
}
|
||||
|
||||
// the sharing action sheet is a BottomSheetDialog, so its items must be matched in the dialog window
|
||||
private fun onMenuItem(id: Int) = onView(ViewMatchers.withId(id)).inRoot(isDialog())
|
||||
|
||||
private fun setupSecondaryFragment(activity: TestActivity) {
|
||||
val parentFolder = OCFile("/")
|
||||
val secondary = FileDetailFragment.newInstance(file, parentFolder, user)
|
||||
activity.addSecondaryFragment(secondary, FileDisplayActivity.TAG_LIST_OF_FILES)
|
||||
activity.addView(
|
||||
FloatingActionButton(activity).apply {
|
||||
// needed for some reason
|
||||
visibility = View.GONE
|
||||
id = R.id.fab_main
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// public link and email are handled the same way
|
||||
// for advanced permissions
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun publicLinkOptionMenuFileAdvancePermission() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val publicShare = OCShare().apply {
|
||||
isFolder = false
|
||||
shareType = ShareType.PUBLIC_LINK
|
||||
permissions = 17
|
||||
}
|
||||
activity!!.handler.post { sut!!.showSharingMenuActionSheet(publicShare) }
|
||||
scenario.onActivity { sut.showSharingMenuActionSheet(publicShare) }
|
||||
|
||||
// check if items are visible
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_new_email).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_link).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_unshare).check(matches(isDisplayed()))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).perform(ViewActions.click())
|
||||
|
||||
// validate view shown on screen
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isDisplayed()))
|
||||
@@ -471,50 +473,50 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
publicShare.permissions = 17 // from server
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// editing
|
||||
publicShare.permissions = MAXIMUM_PERMISSIONS_FOR_FILE // from server
|
||||
openAdvancedPermissions(sut!!, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// hide download
|
||||
publicShare.isHideFileDownload = true
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.isHideFileDownload = false
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(
|
||||
ViewMatchers.withId(R.id.share_process_hide_download_checkbox)
|
||||
).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// password protection
|
||||
publicShare.isPasswordProtected = true
|
||||
publicShare.shareWith = "someValue"
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.isPasswordProtected = false
|
||||
publicShare.shareWith = ""
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// expires
|
||||
publicShare.expirationDate = 1582019340
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
publicShare.expirationDate = 0
|
||||
openAdvancedPermissions(sut, publicShare)
|
||||
openAdvancedPermissions(scenario, sut, publicShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))
|
||||
}
|
||||
@@ -524,25 +526,21 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for send new email
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun publicLinkOptionMenuFileSendNewEmail() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val publicShare = OCShare().apply {
|
||||
isFolder = false
|
||||
shareType = ShareType.PUBLIC_LINK
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
verifySendNewEmail(sut!!, publicShare)
|
||||
verifySendNewEmail(scenario, sut, publicShare)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,36 +552,31 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for advanced permissions
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun userOptionMenuFileAdvancePermission() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
suppressFDFAccessibilityChecks()
|
||||
activity.addFragment(sut)
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val userShare = OCShare().apply {
|
||||
isFolder = false
|
||||
shareType = ShareType.USER
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
activity!!.runOnUiThread { sut!!.showSharingMenuActionSheet(userShare) }
|
||||
scenario.onActivity { sut.showSharingMenuActionSheet(userShare) }
|
||||
|
||||
// check if items are visible
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(not(isDisplayed())))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_new_email).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_link).check(matches(not(isDisplayed())))
|
||||
onMenuItem(R.id.menu_share_unshare).check(matches(isDisplayed()))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).perform(ViewActions.click())
|
||||
|
||||
// validate view shown on screen
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isDisplayed()))
|
||||
@@ -605,24 +598,24 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
userShare.permissions = 17 // from server
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// editing
|
||||
userShare.permissions = MAXIMUM_PERMISSIONS_FOR_FILE // from server
|
||||
openAdvancedPermissions(sut!!, userShare)
|
||||
openAdvancedPermissions(scenario, sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// set expiration date
|
||||
userShare.expirationDate = 1582019340000
|
||||
openAdvancedPermissions(sut, userShare)
|
||||
openAdvancedPermissions(scenario, sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
userShare.expirationDate = 0
|
||||
openAdvancedPermissions(sut, userShare)
|
||||
openAdvancedPermissions(scenario, sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))
|
||||
}
|
||||
@@ -653,17 +646,14 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for send new email
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun userOptionMenuFileSendNewEmail() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val userShare = OCShare().apply {
|
||||
remoteId = 1001L
|
||||
isFolder = false
|
||||
@@ -671,7 +661,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
verifySendNewEmail(sut!!, userShare)
|
||||
verifySendNewEmail(scenario, sut, userShare)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,41 +673,37 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for advanced permissions
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky("not stable")
|
||||
fun userOptionMenuFolderAdvancePermission() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
suppressFDFAccessibilityChecks()
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val userShare = OCShare().apply {
|
||||
isFolder = true
|
||||
shareType = ShareType.USER
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
activity!!.runOnUiThread { sut!!.showSharingMenuActionSheet(userShare) }
|
||||
scenario.onActivity { sut.showSharingMenuActionSheet(userShare) }
|
||||
|
||||
// check if items are visible
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(not(isDisplayed())))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_new_email).check(matches(isDisplayed()))
|
||||
onMenuItem(R.id.menu_share_send_link).check(matches(not(isDisplayed())))
|
||||
onMenuItem(R.id.menu_share_unshare).check(matches(isDisplayed()))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).perform(ViewActions.click())
|
||||
|
||||
// validate view shown on screen
|
||||
// file request is only offered for public link and email shares, not for user shares
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(not(isDisplayed())))
|
||||
onView(
|
||||
ViewMatchers.withId(R.id.share_process_hide_download_checkbox)
|
||||
).check(matches(not(isDisplayed())))
|
||||
@@ -732,63 +718,46 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
userShare.permissions = 17 // from server
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// allow upload & editing
|
||||
userShare.permissions = MAXIMUM_PERMISSIONS_FOR_FOLDER // from server
|
||||
openAdvancedPermissions(sut!!, userShare)
|
||||
openAdvancedPermissions(scenario, sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isNotChecked()))
|
||||
goBack()
|
||||
|
||||
// file request
|
||||
userShare.permissions = 4
|
||||
openAdvancedPermissions(sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.can_edit_radio_button)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.file_request_radio_button)).check(matches(isChecked()))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
// set expiration date
|
||||
userShare.expirationDate = 1582019340000
|
||||
openAdvancedPermissions(sut, userShare)
|
||||
openAdvancedPermissions(scenario, sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))
|
||||
goBack()
|
||||
goBack(scenario)
|
||||
|
||||
userShare.expirationDate = 0
|
||||
openAdvancedPermissions(sut, userShare)
|
||||
openAdvancedPermissions(scenario, sut, userShare)
|
||||
onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))
|
||||
onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))
|
||||
}
|
||||
}
|
||||
|
||||
// open bottom sheet with actions
|
||||
private fun openAdvancedPermissions(sut: FileDetailSharingFragment, userShare: OCShare) {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
activity.handler.post {
|
||||
sut.showSharingMenuActionSheet(userShare)
|
||||
}
|
||||
}
|
||||
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
}
|
||||
private fun openAdvancedPermissions(
|
||||
scenario: ActivityScenario<TestActivity>,
|
||||
sut: FileDetailSharingFragment,
|
||||
userShare: OCShare
|
||||
) {
|
||||
scenario.onActivity { sut.showSharingMenuActionSheet(userShare) }
|
||||
onMenuItem(R.id.menu_share_advanced_permissions).perform(ViewActions.click())
|
||||
}
|
||||
|
||||
// remove the fragment shown
|
||||
private fun goBack() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
activity.handler.post {
|
||||
val processFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(FileDetailsSharingProcessFragment.TAG) as
|
||||
FileDetailsSharingProcessFragment
|
||||
processFragment.activity?.onBackPressedDispatcher?.onBackPressed()
|
||||
}
|
||||
}
|
||||
private fun goBack(scenario: ActivityScenario<TestActivity>) {
|
||||
scenario.onActivity { activity ->
|
||||
val processFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(FileDetailsSharingProcessFragment.TAG) as
|
||||
FileDetailsSharingProcessFragment
|
||||
processFragment.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,45 +769,43 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
// for send new email
|
||||
@Test
|
||||
@Suppress("MagicNumber")
|
||||
@Flaky(reason = "Share option menu occasionally does not open before the assertions run")
|
||||
fun userOptionMenuFolderSendNewEmail() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
lateinit var sut: FileDetailSharingFragment
|
||||
scenario.onActivity { activity ->
|
||||
sut = FileDetailSharingFragment.newInstance(file, user)
|
||||
activity.addFragment(sut)
|
||||
sut.refreshCapabilitiesFromDB()
|
||||
sut = addSharingFragment(activity)
|
||||
}
|
||||
|
||||
setupSecondaryFragment()
|
||||
|
||||
val userShare = OCShare().apply {
|
||||
isFolder = true
|
||||
shareType = ShareType.USER
|
||||
permissions = 17
|
||||
}
|
||||
|
||||
verifySendNewEmail(sut!!, userShare)
|
||||
verifySendNewEmail(scenario, sut, userShare)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verify send new email note text
|
||||
*/
|
||||
private fun verifySendNewEmail(sut: FileDetailSharingFragment, userShare: OCShare) {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
activity.runOnUiThread { sut.showSharingMenuActionSheet(userShare) }
|
||||
}
|
||||
private fun verifySendNewEmail(
|
||||
scenario: ActivityScenario<TestActivity>,
|
||||
sut: FileDetailSharingFragment,
|
||||
userShare: OCShare
|
||||
) {
|
||||
scenario.onActivity { sut.showSharingMenuActionSheet(userShare) }
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).perform(ViewActions.click())
|
||||
// click event
|
||||
onMenuItem(R.id.menu_share_send_new_email).perform(ViewActions.click())
|
||||
|
||||
// validate view shown on screen
|
||||
onView(ViewMatchers.withId(R.id.note_text)).check(matches(isDisplayed()))
|
||||
}
|
||||
// validate view shown on screen
|
||||
onView(ViewMatchers.withId(R.id.note_text)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky("not stable")
|
||||
fun testUploadAndEditingSharePermissions() {
|
||||
val testCases = mapOf(
|
||||
MAXIMUM_PERMISSIONS_FOR_FOLDER to true,
|
||||
@@ -857,6 +824,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky("not stable")
|
||||
fun testReadOnlySharePermissions() {
|
||||
val testCases = mapOf(
|
||||
READ_PERMISSION_FLAG to true,
|
||||
@@ -876,6 +844,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky("not stable")
|
||||
fun testFileRequestSharePermission() {
|
||||
val testCases = mapOf(
|
||||
CREATE_PERMISSION_FLAG to true,
|
||||
@@ -898,6 +867,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky("not stable")
|
||||
fun internalLinkUsesPrettyPathWhenModRewriteWorking() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
@@ -916,6 +886,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky("not stable")
|
||||
fun internalLinkUsesDefaultPathWhenModRewriteNotWorking() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
@@ -933,6 +904,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky("not stable")
|
||||
fun internalLinkFallsBackToDefaultPathWhenCapabilitiesNull() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: FileDetailSharingFragment? = null
|
||||
|
||||
@@ -27,12 +27,14 @@ import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.nextcloud.utils.extensions.getBigThumbnail
|
||||
import com.nextcloud.utils.extensions.getBigThumbnailKey
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension
|
||||
import com.owncloud.android.ui.adapter.GalleryRowHolder
|
||||
@@ -100,6 +102,7 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Gallery sections are occasionally not laid out before the multi select assertions run")
|
||||
fun multiSelect() {
|
||||
val imageCount = 100
|
||||
for (num in 1..imageCount) {
|
||||
@@ -219,9 +222,9 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
drawRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256))
|
||||
drawCircle(w / 2f, h / 2f, w.coerceAtMost(h) / 2f, Paint().apply { color = Color.BLACK })
|
||||
}
|
||||
ThumbnailsCacheManager.addBitmapToCache(PREFIX_RESIZED_IMAGE + file.remoteId, bitmap)
|
||||
ThumbnailsCacheManager.addBitmapToCache(file.getBigThumbnailKey(), bitmap)
|
||||
|
||||
assertNotNull(ThumbnailsCacheManager.getBitmapFromDiskCache(PREFIX_RESIZED_IMAGE + file.remoteId))
|
||||
assertNotNull(file.getBigThumbnail())
|
||||
|
||||
Log_OC.d("Gallery_thumbnail", "created $id with ${bitmap.width} x ${bitmap.height}")
|
||||
}
|
||||
|
||||
+8
@@ -22,6 +22,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
@@ -36,6 +37,7 @@ import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.hamcrest.Matchers.not
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -53,6 +55,11 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
Intents.init()
|
||||
}
|
||||
|
||||
@After
|
||||
fun releaseIntentRecording() {
|
||||
Intents.release()
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
@@ -417,6 +424,7 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Folder picker activity is occasionally not started before the intent assertions run")
|
||||
fun shouldStartMoveInParentFolder() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
+6
-1
@@ -13,11 +13,13 @@ import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.SearchResultEntry
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchSection
|
||||
import com.owncloud.android.ui.unifiedsearch.toUnifiedSearchEntry
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchViewModel
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
@@ -25,6 +27,7 @@ import java.io.File
|
||||
class UnifiedSearchFragmentIT : AbstractIT() {
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Search result list is occasionally not rendered before the assertions run")
|
||||
fun showSearchResult() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
|
||||
@@ -45,7 +48,7 @@ class UnifiedSearchFragmentIT : AbstractIT() {
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
).toUnifiedSearchEntry(storageManager)
|
||||
),
|
||||
hasMoreResults = false
|
||||
)
|
||||
@@ -58,11 +61,13 @@ class UnifiedSearchFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Search runs asynchronously and does not always complete before the assertions run")
|
||||
fun search() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setCurrentAccountProvider(activity.userAccountManager)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
|
||||
+12
-16
@@ -22,6 +22,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import com.nextcloud.test.FileRemovedIdlingResource
|
||||
import com.nextcloud.test.Flaky
|
||||
import com.nextcloud.test.LoopFailureHandler
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
@@ -29,6 +30,7 @@ import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertFalse
|
||||
@@ -49,29 +51,20 @@ class PreviewImageActivityIT : AbstractOnServerIT() {
|
||||
private fun createLocalMockedImageFiles(count: Int): List<OCFile> {
|
||||
val srcPngFile = getFile("imageFile.png")
|
||||
return (0 until count).map { i ->
|
||||
val pngFile = File(srcPngFile.parent ?: ".", "image$i.png")
|
||||
srcPngFile.copyTo(pngFile, overwrite = true)
|
||||
|
||||
OCFile("/${pngFile.name}").apply {
|
||||
storagePath = pngFile.absolutePath
|
||||
OCFile("/image$i.png").apply {
|
||||
mimeType = "image/png"
|
||||
modificationTimestamp = 1000000
|
||||
permissions = "D" // OCFile.PERMISSION_CAN_DELETE_OR_LEAVE_SHARE. Required for deletion button to show
|
||||
permissions = OCFile.PERMISSION_CAN_DELETE_OR_LEAVE_SHARE
|
||||
val localCopy = File(FileStorageUtils.getDefaultSavePathFor(user.accountName, this))
|
||||
localCopy.parentFile?.mkdirs()
|
||||
srcPngFile.copyTo(localCopy, overwrite = true)
|
||||
storagePath = localCopy.absolutePath
|
||||
}.also {
|
||||
storageManager.saveNewFile(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create image files and upload them to the connected server.
|
||||
*
|
||||
* This function relies on the images not existing beforehand, as AbstractOnServerIT#deleteAllFilesOnServer()
|
||||
* should clean up. If it does fail, likely because that clean up didn't work and there are leftovers from
|
||||
* a previous run
|
||||
* @param count Number of files to create
|
||||
* @param folder Parent folder to which to upload. Must start and end with a slash
|
||||
*/
|
||||
private fun createAndUploadImageFiles(count: Int, folder: String = REMOTE_FOLDER): List<OCFile> {
|
||||
val srcPngFile = getFile("imageFile.png")
|
||||
return (0 until count).map { i ->
|
||||
@@ -200,22 +193,25 @@ class PreviewImageActivityIT : AbstractOnServerIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Slideshow pager does not always settle on the next image before the assertions run")
|
||||
fun deleteFromSlideshow_localOnly_online() {
|
||||
testDeleteFromSlideshow_impl(localOnly = true, offline = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Slideshow pager does not always settle on the next image before the assertions run")
|
||||
fun deleteFromSlideshow_localOnly_offline() {
|
||||
testDeleteFromSlideshow_impl(localOnly = true, offline = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Flaky(reason = "Remote delete races with the slideshow pager update, so the assertions run too early")
|
||||
fun deleteFromSlideshow_remote_online() {
|
||||
testDeleteFromSlideshow_impl(localOnly = false, offline = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore(
|
||||
@Flaky(
|
||||
"Offline deletion is following a different UX and it is also brittle: Deletion might happen 10 minutes later"
|
||||
)
|
||||
fun deleteFromSlideshow_remote_offline() {
|
||||
|
||||
+2
-5
@@ -6,13 +6,13 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.nextcloud.test.GrantTestPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
@@ -26,10 +26,7 @@ class PreviewTextFileFragmentTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.preview.PreviewTextFileFragmentTest"
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
val permissionRule: GrantPermissionRule = GrantTestPermissionRule.grantStorageAndNotification()
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -27,6 +28,7 @@ import com.owncloud.android.operations.RefreshFolderOperation
|
||||
import com.owncloud.android.util.EncryptionTestIT
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Test
|
||||
|
||||
@@ -139,6 +141,13 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
2J9mW5WvAAaG+j28Q/GKSuE=
|
||||
""".trimIndent()
|
||||
|
||||
// Decryption derives the metadata version from the stored server capability, so align it with the fixture.
|
||||
private fun setE2EECapabilityVersion(version: E2EVersion) {
|
||||
val capability = storageManager.getCapability(account.name)
|
||||
capability.endToEndEncryptionApiVersion = version
|
||||
storageManager.saveCapabilities(capability)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEncryptDecryptMetadata() {
|
||||
val metadataKey = EncryptionUtils.generateKey()
|
||||
@@ -247,6 +256,7 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
}
|
||||
|
||||
val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert)
|
||||
setE2EECapabilityVersion(E2EVersion.fromValue(metadataFile.version))
|
||||
|
||||
val encrypted = encryptionUtilsV2.encryptFolderMetadataFile(
|
||||
metadataFile,
|
||||
@@ -300,8 +310,7 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
// random string, not real tag
|
||||
EncryptionUtils.generateUid(),
|
||||
EncryptionUtils.generateKey(),
|
||||
metadataFile,
|
||||
storageManager
|
||||
metadataFile
|
||||
)
|
||||
|
||||
assertEquals(3, updatedMetadata.metadata.files.size)
|
||||
@@ -341,7 +350,6 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
|
||||
@Test
|
||||
fun addFolder() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert)
|
||||
assertEquals(2, metadataFile.metadata.files.size)
|
||||
@@ -350,9 +358,7 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
val updatedMetadata = encryptionUtilsV2.addFolderToMetadata(
|
||||
EncryptionUtils.generateUid(),
|
||||
"new subfolder",
|
||||
metadataFile,
|
||||
folder,
|
||||
storageManager
|
||||
metadataFile
|
||||
)
|
||||
|
||||
assertEquals(2, updatedMetadata.metadata.files.size)
|
||||
@@ -361,7 +367,6 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
|
||||
@Test
|
||||
fun removeFolder() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert)
|
||||
assertEquals(2, metadataFile.metadata.files.size)
|
||||
@@ -371,9 +376,7 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
var updatedMetadata = encryptionUtilsV2.addFolderToMetadata(
|
||||
encryptedFileName,
|
||||
"new subfolder",
|
||||
metadataFile,
|
||||
folder,
|
||||
storageManager
|
||||
metadataFile
|
||||
)
|
||||
|
||||
assertEquals(2, updatedMetadata.metadata.files.size)
|
||||
@@ -643,76 +646,187 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
assertEquals("this is a test.\n", gunzip)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// fun validate() {
|
||||
// // ALEX
|
||||
// val metadata1 = """{
|
||||
// "metadata": {
|
||||
// "authenticationTag": "zMozev5R09UopLrq7Je1lw==",
|
||||
// "ciphertext": "j0OBtUrEt4IveGiexjmGK7eKEaWrY70ZkteA5KxHDaZT/t2wwGy9j2FPQGpqXnW6OO3iAYPNgwFikI1smnfNvqdxzVDvhavl/IXa9Kg2niWyqK3D9zpz0YD6mDvl0XsOgTNVyGXNVREdWgzGEERCQoyHI1xowt/swe3KCXw+lf+XPF/t1PfHv0DiDVk70AeWGpPPPu6yggAIxB4Az6PEZhaQWweTC0an48l2FHj2MtB2PiMHtW2v7RMuE8Al3PtE4gOA8CMFrB+Npy6rKcFCXOgTZm5bp7q+J1qkhBDbiBYtvdsYujJ52Xa5SifTpEhGeWWLFnLLgPAQ8o6bXcWOyCoYfLfp4Jpft/Y7H8qzHbPewNSyD6maEv+xljjfU7hxibbszz5A4JjMdQy2BDGoTmJx7Mas+g6l6ZuHLVbdmgQOvD3waJBy6rOg0euux0Cn4bB4bIFEF2KvbhdGbY1Uiq9DYa7kEmSEnlcAYaHyroTkDg4ew7ER0vIBBMzKM3r+UdPVKKS66uyXtZc=",
|
||||
// "nonce": "W+lxQJeGq7XAJiGfcDohkg=="
|
||||
// },
|
||||
// "users": [{
|
||||
// "certificate": "-----BEGIN CERTIFICATE-----\nMIIDkDCCAnigAwIBAgIBADANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJERTEb\nMBkGA1UECAwSQmFkZW4tV3VlcnR0ZW1iZXJnMRIwEAYDVQQHDAlTdHV0dGdhcnQx\nEjAQBgNVBAoMCU5leHRjbG91ZDENMAsGA1UEAwwEam9objAeFw0yMzA3MTQwNzM0\nNTZaFw00MzA3MDkwNzM0NTZaMGExCzAJBgNVBAYTAkRFMRswGQYDVQQIDBJCYWRl\nbi1XdWVydHRlbWJlcmcxEjAQBgNVBAcMCVN0dXR0Z2FydDESMBAGA1UECgwJTmV4\ndGNsb3VkMQ0wCwYDVQQDDARqb2huMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEA7j3Er5YahJT0LAnSRLhpqbRo+E1AVnt98rvp3DmEfBHNzNB+DS9IBDkS\nSXM/YtfAci6Tcw8ujVBjrZX/WEmrf8ynQHxYmSaJSnP8uAT306/MceZpdpruEc9/\nS10a7vp54Zbld4NYdmfS71oVFVKgM7c/Vthx+rgu48fuxzbWAvVYLFcx47hz0DJT\nnjz2Za/R68uXpxfz7J9uEXYiqsAs/FobDsLZluT3RyywVRwKBed1EZxUeLIJiyxp\nUthhGfIb8b3Vf9jZoUVi3m5gmc4spJQHvYAkfZYHzd9ras8jBu1abQRxcu2CYnVo\n6Y0mTxhKhQS/n5gjv3ExiQF3wp/XYwIDAQABo1MwUTAdBgNVHQ4EFgQUmTeILVuB\ntv70fTGkXWGAueDp5kAwHwYDVR0jBBgwFoAUmTeILVuBtv70fTGkXWGAueDp5kAw\nDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAyVtq9XAvW7nxSW/8\nhp30z6xbzGiuviXhy/Jo91VEa8IRsWCCn3OmDFiVduTEowx76tf8clJP0gk7Pozi\n6dg/7Fin+FqQGXfCk8bLAh9gXKAikQ2GK8yRN3slRFwYC2mm23HrLdKXZHUqJcpB\nMz2zsSrOGPj1YsYOl/U8FU6KA7Yj7U3q7kDMYTAgzUPZAH+d1DISGWpZsMa0RYid\nvigCCLByiccmS/Co4Sb1esF58H+YtV5+nFBRwx881U2g2TgDKF1lPMK/y3d8B8mh\nUtW+lFxRpvyNUDpsMjOErOrtNFEYbgoUJLtqwBMmyGR+nmmh6xna331QWcRAmw0P\nnDO4ew==\n-----END CERTIFICATE-----\n",
|
||||
// "encryptedMetadataKey": "HVT49bYmwXbGs/dJ2avgU9unrKnPf03MYUI5ZysSR1Bz5pqz64gzH2GBAuUJ+Q4VmHtEfcMaWW7VXgzfCQv5xLBrk+RSgcLOKnlIya8jaDlfttWxbe8jJK+/0+QVPOc6ycA/t5HNCPg09hzj+gnb2L89UHxL5accZD0iEzb5cQbGrc/N6GthjgGrgFKtFf0HhDVplUr+DL9aTyKuKLBPjrjuZbv8M6ZfXO93mOMwSZH3c3rwDUHb/KEaTR/Og4pWQmrqr1VxGLqeV/+GKWhzMYThrOZAUz+5gsbckU2M5V9i+ph0yBI5BjOZVhNuDwW8yP8WtyRJwQc+UBRei/RGBQ==",
|
||||
// "userId": "john"
|
||||
// }],
|
||||
// "version": "2"
|
||||
// }
|
||||
//
|
||||
// """
|
||||
//
|
||||
// val signature1 =
|
||||
// "ewogICAgIm1ldGFkYXRhIjogewogICAgICAgICJhdXRoZW50aWNhdGlvblRhZyI6ICJ6TW96ZXY1UjA5VW9wTHJxN0plMWx3PT0iLAogICAgICAgICJjaXBoZXJ0ZXh0IjogImowT0J0VXJFdDRJdmVHaWV4am1HSzdlS0VhV3JZNzBaa3RlQTVLeEhEYVpUL3Qyd3dHeTlqMkZQUUdwcVhuVzZPTzNpQVlQTmd3RmlrSTFzbW5mTnZxZHh6VkR2aGF2bC9JWGE5S2cybmlXeXFLM0Q5enB6MFlENm1EdmwwWHNPZ1ROVnlHWE5WUkVkV2d6R0VFUkNRb3lISTF4b3d0L3N3ZTNLQ1h3K2xmK1hQRi90MVBmSHYwRGlEVms3MEFlV0dwUFBQdTZ5Z2dBSXhCNEF6NlBFWmhhUVd3ZVRDMGFuNDhsMkZIajJNdEIyUGlNSHRXMnY3Uk11RThBbDNQdEU0Z09BOENNRnJCK05weTZyS2NGQ1hPZ1RabTVicDdxK0oxcWtoQkRiaUJZdHZkc1l1ako1MlhhNVNpZlRwRWhHZVdXTEZuTExnUEFROG82YlhjV095Q29ZZkxmcDRKcGZ0L1k3SDhxekhiUGV3TlN5RDZtYUV2K3hsampmVTdoeGliYnN6ejVBNEpqTWRReTJCREdvVG1KeDdNYXMrZzZsNlp1SExWYmRtZ1FPdkQzd2FKQnk2ck9nMGV1dXgwQ240YkI0YklGRUYyS3ZiaGRHYlkxVWlxOURZYTdrRW1TRW5sY0FZYUh5cm9Ua0RnNGV3N0VSMHZJQkJNektNM3IrVWRQVktLUzY2dXlYdFpjPSIsCiAgICAgICAgIm5vbmNlIjogIlcrbHhRSmVHcTdYQUppR2ZjRG9oa2c9PSIKICAgIH0sCiAgICAidXNlcnMiOiB7CiAgICAgICAgImNlcnRpZmljYXRlIjogIi0tLS0tQkVHSU4gQ0VSVElGSUNBVEUtLS0tLVxuTUlJRGtEQ0NBbmlnQXdJQkFnSUJBREFOQmdrcWhraUc5dzBCQVFVRkFEQmhNUXN3Q1FZRFZRUUdFd0pFUlRFYlxuTUJrR0ExVUVDQXdTUW1Ga1pXNHRWM1ZsY25SMFpXMWlaWEpuTVJJd0VBWURWUVFIREFsVGRIVjBkR2RoY25ReFxuRWpBUUJnTlZCQW9NQ1U1bGVIUmpiRzkxWkRFTk1Bc0dBMVVFQXd3RWFtOW9iakFlRncweU16QTNNVFF3TnpNMFxuTlRaYUZ3MDBNekEzTURrd056TTBOVFphTUdFeEN6QUpCZ05WQkFZVEFrUkZNUnN3R1FZRFZRUUlEQkpDWVdSbFxuYmkxWGRXVnlkSFJsYldKbGNtY3hFakFRQmdOVkJBY01DVk4wZFhSMFoyRnlkREVTTUJBR0ExVUVDZ3dKVG1WNFxuZEdOc2IzVmtNUTB3Q3dZRFZRUUREQVJxYjJodU1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQlxuQ2dLQ0FRRUE3ajNFcjVZYWhKVDBMQW5TUkxocHFiUm8rRTFBVm50OThydnAzRG1FZkJITnpOQitEUzlJQkRrU1xuU1hNL1l0ZkFjaTZUY3c4dWpWQmpyWlgvV0VtcmY4eW5RSHhZbVNhSlNuUDh1QVQzMDYvTWNlWnBkcHJ1RWM5L1xuUzEwYTd2cDU0WmJsZDROWWRtZlM3MW9WRlZLZ003Yy9WdGh4K3JndTQ4ZnV4emJXQXZWWUxGY3g0N2h6MERKVFxubmp6MlphL1I2OHVYcHhmejdKOXVFWFlpcXNBcy9Gb2JEc0xabHVUM1J5eXdWUndLQmVkMUVaeFVlTElKaXl4cFxuVXRoaEdmSWI4YjNWZjlqWm9VVmkzbTVnbWM0c3BKUUh2WUFrZlpZSHpkOXJhczhqQnUxYWJRUnhjdTJDWW5Wb1xuNlkwbVR4aEtoUVMvbjVnanYzRXhpUUYzd3AvWFl3SURBUUFCbzFNd1VUQWRCZ05WSFE0RUZnUVVtVGVJTFZ1QlxudHY3MGZUR2tYV0dBdWVEcDVrQXdId1lEVlIwakJCZ3dGb0FVbVRlSUxWdUJ0djcwZlRHa1hXR0F1ZURwNWtBd1xuRHdZRFZSMFRBUUgvQkFVd0F3RUIvekFOQmdrcWhraUc5dzBCQVFVRkFBT0NBUUVBeVZ0cTlYQXZXN254U1cvOFxuaHAzMHo2eGJ6R2l1dmlYaHkvSm85MVZFYThJUnNXQ0NuM09tREZpVmR1VEVvd3g3NnRmOGNsSlAwZ2s3UG96aVxuNmRnLzdGaW4rRnFRR1hmQ2s4YkxBaDlnWEtBaWtRMkdLOHlSTjNzbFJGd1lDMm1tMjNIckxkS1haSFVxSmNwQlxuTXoyenNTck9HUGoxWXNZT2wvVThGVTZLQTdZajdVM3E3a0RNWVRBZ3pVUFpBSCtkMURJU0dXcFpzTWEwUllpZFxudmlnQ0NMQnlpY2NtUy9DbzRTYjFlc0Y1OEgrWXRWNStuRkJSd3g4ODFVMmcyVGdES0YxbFBNSy95M2Q4QjhtaFxuVXRXK2xGeFJwdnlOVURwc01qT0VyT3J0TkZFWWJnb1VKTHRxd0JNbXlHUitubW1oNnhuYTMzMVFXY1JBbXcwUFxubkRPNGV3PT1cbi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS1cbiIsCiAgICAgICAgImVuY3J5cHRlZE1ldGFkYXRhS2V5IjogIkhWVDQ5Ylltd1hiR3MvZEoyYXZnVTl1bnJLblBmMDNNWVVJNVp5c1NSMUJ6NXBxejY0Z3pIMkdCQXVVSitRNFZtSHRFZmNNYVdXN1ZYZ3pmQ1F2NXhMQnJrK1JTZ2NMT0tubEl5YThqYURsZnR0V3hiZThqSksrLzArUVZQT2M2eWNBL3Q1SE5DUGcwOWh6aitnbmIyTDg5VUh4TDVhY2NaRDBpRXpiNWNRYkdyYy9ONkd0aGpnR3JnRkt0RmYwSGhEVnBsVXIrREw5YVR5S3VLTEJQanJqdVpidjhNNlpmWE85M21PTXdTWkgzYzNyd0RVSGIvS0VhVFIvT2c0cFdRbXJxcjFWeEdMcWVWLytHS1doek1ZVGhyT1pBVXorNWdzYmNrVTJNNVY5aStwaDB5Qkk1QmpPWlZoTnVEd1c4eVA4V3R5Ukp3UWMrVUJSZWkvUkdCUT09IiwKICAgICAgICAidXNlcklkIjogImpvaG4iCiAgICB9LAogICAgInZlcnNpb24iOiAiMiIKfQo="
|
||||
//
|
||||
// // TOBI
|
||||
// val metadata =
|
||||
// """{"metadata":{"authenticationTag":"qDcJnAAGtGDlHWiQMBfXgw\u003d\u003d","ciphertext":"3zUhwIgJWMB7DvrbsDaMvh8MbJdoTxL0OMPCCdYSfBt7gB+V/hwqelL1IOaLto3avhHGSebnrotF06iEP/jZwWg9hApIPTHc8B4XTOY0/kezqYyVqTyquTUZpDpqgVAheQskZZ8I4Ir0seajUkt4KtVRfzO6v8CePRrEg6uKwdYsqDcJnAAGtGDlHWiQMBfXgw\u003d\u003d|4hbOyn1ykQL+9D6SnPY3cQ\u003d\u003d","nonce":"4hbOyn1ykQL+9D6SnPY3cQ\u003d\u003d"},"users":[{"certificate":"-----BEGIN CERTIFICATE-----\nMIIC6DCCAdCgAwIBAgIBADANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDDAJ0MTAe\nFw0yMzA3MjUwNzU3MTJaFw00MzA3MjAwNzU3MTJaMA0xCzAJBgNVBAMMAnQxMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtafHmDBcBqIu4HmMxMDW3j0S\ny+S0YaKwHnBRt85KSwcEov0B5FOLuLknoBGx4Dn3u93ilThXXxacPMHeXL7WPuAs\n21/G7vsqwvrRRnCduf+FUO/AZeDCNErzpsQ8LmTa4PUloLPUcImpSjrHwhMs9Ekv\nEbLRjbeSmSp9XvM+1fV/3jkT5jkOSnCFx5TGwGN5uHqwUir4UWXasvg253NK2XmW\nipKCDCR9TmH1baP3pNdoiChdmErT1c6E4DbBXpTw8XgP5ZbYH+qg1UQ/hC8nRJ3D\nyCcHL+dg/GYraBMhDn4w2Vvq77xNNoNWQ9cT5Ay6cJbQLBQoJQirygQFrobYRQID\nAQABo1MwUTAdBgNVHQ4EFgQUE9zCeA9/QMAtVgLxD23X6ZcodhMwHwYDVR0jBBgw\nFoAUE9zCeA9/QMAtVgLxD23X6ZcodhMwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG\n9w0BAQUFAAOCAQEAZdy/YjJlvnz3FQwxp6oVtMJccpdxveEPfLzgaverhtd/vP8O\nAvDzOLgQJHmrDS91SG503eU4cYGyuNKwd77OyTnqMg+GUEmJhGfPpSVrEIdh65jv\nq61T4oqBdehevVmBq54rGiwL0DGv1DlXQlwiJZP4qni2KnOEFcnvL3gVtRnQjXQ+\nkHvlMshkK6w021EMV5NfjG2zg67wC65rLaej5f6Ssp2S7g2VtmE4aXq1bjAuEbqk\n4TiyZHLDdsJuqzyGyyOpMV7i9ucXDoaZt9cGS9hT2vRxTrSH63vKR8Xeig9+stLw\nt9ONcUqCKP7hd8rajtxM4JIIRExwD8OkgARWGg\u003d\u003d\n-----END CERTIFICATE-----\n","encryptedMetadataKey":"s4kDkkLpk1mSmXedP7huiCNC4DYmDAmA2VYGem5M8jIGPC6miVQoo4WXZrEBhdsLw7Msf5iT3A3fTaHhwsI8Jf4McsFyM9/FXT1mCEaGOEpNjbKOlJY1uPUFNOhLqUfFiBos6oBT53hWwoXWjytYvLBbXuXY5YLOysjgBh6URrgFUZAJAmcOJ6OFKgfIIthoqkQc7CQUY97VsRzAXzeYTANBc2yW1pSN51HqftvMzvewFRsJQLcu7a9NjpTdG9LiLhn5eLXOLymXEE/aaPHKXeprlXLzrdWU1xwZRJqV+to2FEiH6CQNsO4+9h5m0VjXekiNeAFrsXB5cJgUipGuzQ\u003d\u003d","userId":"t1"}],"version":"2.0"}"""
|
||||
//
|
||||
// val base = EncryptionUtils.encodeStringToBase64String(metadata)
|
||||
//
|
||||
// val signature =
|
||||
// "MIAGCSqGSIb3DQEHAqCAMIACAQExDTALBglghkgBZQMEAgEwCwYJKoZIhvcNAQcBoIAwggLoMIIB0KADAgECAgEAMA0GCSqGSIb3DQEBBQUAMA0xCzAJBgNVBAMMAnQxMB4XDTIzMDcyNTA3NTcxMloXDTQzMDcyMDA3NTcxMlowDTELMAkGA1UEAwwCdDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1p8eYMFwGoi7geYzEwNbePRLL5LRhorAecFG3zkpLBwSi/QHkU4u4uSegEbHgOfe73eKVOFdfFpw8wd5cvtY+4CzbX8bu+yrC+tFGcJ25/4VQ78Bl4MI0SvOmxDwuZNrg9SWgs9RwialKOsfCEyz0SS8RstGNt5KZKn1e8z7V9X/eORPmOQ5KcIXHlMbAY3m4erBSKvhRZdqy+Dbnc0rZeZaKkoIMJH1OYfVto/ek12iIKF2YStPVzoTgNsFelPDxeA/lltgf6qDVRD+ELydEncPIJwcv52D8ZitoEyEOfjDZW+rvvE02g1ZD1xPkDLpwltAsFCglCKvKBAWuhthFAgMBAAGjUzBRMB0GA1UdDgQWBBQT3MJ4D39AwC1WAvEPbdfplyh2EzAfBgNVHSMEGDAWgBQT3MJ4D39AwC1WAvEPbdfplyh2EzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQBl3L9iMmW+fPcVDDGnqhW0wlxyl3G94Q98vOBq96uG13+8/w4C8PM4uBAkeasNL3VIbnTd5ThxgbK40rB3vs7JOeoyD4ZQSYmEZ8+lJWsQh2HrmO+rrVPiioF16F69WYGrnisaLAvQMa/UOVdCXCIlk/iqeLYqc4QVye8veBW1GdCNdD6Qe+UyyGQrrDTbUQxXk1+MbbODrvALrmstp6Pl/pKynZLuDZW2YThperVuMC4RuqThOLJkcsN2wm6rPIbLI6kxXuL25xcOhpm31wZL2FPa9HFOtIfre8pHxd6KD36y0vC3041xSoIo/uF3ytqO3EzgkghETHAPw6SABFYaAAAxggHUMIIB0AIBATASMA0xCzAJBgNVBAMMAnQxAgEAMAsGCWCGSAFlAwQCAaCBljAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMzA3MjgwNzMwMTJaMCsGCSqGSIb3DQEJNDEeMBwwCwYJYIZIAWUDBAIBoQ0GCSqGSIb3DQEBCwUAMC8GCSqGSIb3DQEJBDEiBCAx7RTJg7hbY5Mkzjw3f6qhX7k/J0FdVz2cL3ow0AmyYjANBgkqhkiG9w0BAQsFAASCAQAbUmb9e7eoIcPNzDSmnzbrueBzgT8YszNGEI+1YCq8XdWN4kDztvP1ZNV21VCO6BvcbfUAnXXgcX5BPeLZNsgXPj3c8TbD59GQl3oT/tIchgMsA20RdAtIwvItlZKh+X6sp0OHkRPYSk/mEYKCKPqrKdJicRWex8ItCwpDR91KSOiKJrN/+DKOGG0sVI9gjzbtrHsN8HmVKxOoNV+wwipcLsWsEmuV+wvPCQ9HJidLX9Q17Bgfc+qJg19aB6iKLWPhjgnfpKGbK5VJuQTdDWPUJ2O4G3W/iwxJ0hAJ7tks4zIATmgGzhgTWYx5LVXbKcuL04xhIOjqwedHeCSBZSSaAAAAAAAA"
|
||||
//
|
||||
// val metadataFile = EncryptionUtils.deserializeJSON(
|
||||
// metadata,
|
||||
// object : TypeToken<EncryptedFolderMetadataFile>() {}
|
||||
// )
|
||||
// assertNotNull(metadataFile)
|
||||
//
|
||||
// val certJohnString = metadataFile.users[0].certificate
|
||||
// val certJohn = EncryptionUtils.convertCertFromString(certJohnString)
|
||||
//
|
||||
// val t1String = """-----BEGIN CERTIFICATE-----
|
||||
// MIIC6DCCAdCgAwIBAgIBADANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDDAJ0MTAe
|
||||
// Fw0yMzA3MjUwNzU3MTJaFw00MzA3MjAwNzU3MTJaMA0xCzAJBgNVBAMMAnQxMIIB
|
||||
// IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtafHmDBcBqIu4HmMxMDW3j0S
|
||||
// y+S0YaKwHnBRt85KSwcEov0B5FOLuLknoBGx4Dn3u93ilThXXxacPMHeXL7WPuAs
|
||||
// 21/G7vsqwvrRRnCduf+FUO/AZeDCNErzpsQ8LmTa4PUloLPUcImpSjrHwhMs9Ekv
|
||||
// EbLRjbeSmSp9XvM+1fV/3jkT5jkOSnCFx5TGwGN5uHqwUir4UWXasvg253NK2XmW
|
||||
// ipKCDCR9TmH1baP3pNdoiChdmErT1c6E4DbBXpTw8XgP5ZbYH+qg1UQ/hC8nRJ3D
|
||||
// yCcHL+dg/GYraBMhDn4w2Vvq77xNNoNWQ9cT5Ay6cJbQLBQoJQirygQFrobYRQID
|
||||
// AQABo1MwUTAdBgNVHQ4EFgQUE9zCeA9/QMAtVgLxD23X6ZcodhMwHwYDVR0jBBgw
|
||||
// FoAUE9zCeA9/QMAtVgLxD23X6ZcodhMwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG
|
||||
// 9w0BAQUFAAOCAQEAZdy/YjJlvnz3FQwxp6oVtMJccpdxveEPfLzgaverhtd/vP8O
|
||||
// AvDzOLgQJHmrDS91SG503eU4cYGyuNKwd77OyTnqMg+GUEmJhGfPpSVrEIdh65jv
|
||||
// q61T4oqBdehevVmBq54rGiwL0DGv1DlXQlwiJZP4qni2KnOEFcnvL3gVtRnQjXQ+
|
||||
// kHvlMshkK6w021EMV5NfjG2zg67wC65rLaej5f6Ssp2S7g2VtmE4aXq1bjAuEbqk
|
||||
// 4TiyZHLDdsJuqzyGyyOpMV7i9ucXDoaZt9cGS9hT2vRxTrSH63vKR8Xeig9+stLw
|
||||
// t9ONcUqCKP7hd8rajtxM4JIIRExwD8OkgARWGg==
|
||||
// -----END CERTIFICATE-----"""
|
||||
//
|
||||
// val t1cert = EncryptionUtils.convertCertFromString(t1String)
|
||||
// val t1PrivateKeyKey = EncryptionUtils.PEMtoPrivateKey(encryptionTestUtils.t1PrivateKey)
|
||||
//
|
||||
// // val signed = encryptionUtilsV2.getMessageSignature(
|
||||
// // t1cert,
|
||||
// // t1PrivateKeyKey,
|
||||
// // metadataFile
|
||||
// // )
|
||||
//
|
||||
// assertTrue(encryptionUtilsV2.verifySignedMessage(signature1, metadata1, listOf(certJohn, t1cert)))
|
||||
// }
|
||||
@Test
|
||||
fun verifyMetadataEmptyFolder() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
|
||||
val metadataKey = EncryptionUtils.generateKey()
|
||||
val metadata = DecryptedMetadata(
|
||||
mutableListOf(),
|
||||
false,
|
||||
0,
|
||||
mutableMapOf(),
|
||||
mutableMapOf(),
|
||||
metadataKey
|
||||
)
|
||||
// checksum must be present before encrypting, otherwise verifyMetadata returns false
|
||||
metadata.keyChecksums.add(encryptionUtilsV2.hashMetadataKey(metadataKey))
|
||||
|
||||
val metadataFile = DecryptedFolderMetadataFile(
|
||||
metadata,
|
||||
mutableListOf(DecryptedUser(enc1.accountName, enc1Cert, null)),
|
||||
mutableMapOf(),
|
||||
E2EVersion.V2_1.value
|
||||
)
|
||||
|
||||
val encrypted = encryptionUtilsV2.encryptFolderMetadataFile(
|
||||
metadataFile,
|
||||
enc1UserId,
|
||||
folder,
|
||||
storageManager,
|
||||
client,
|
||||
enc1PrivateKey,
|
||||
user,
|
||||
targetContext,
|
||||
arbitraryDataProvider
|
||||
)
|
||||
val signature = encryptionUtilsV2.getMessageSignature(enc1Cert, enc1PrivateKey, encrypted)
|
||||
|
||||
val result = encryptionUtilsV2.verifyMetadata(encrypted, metadataFile, 0, signature)
|
||||
|
||||
assertTrue(result)
|
||||
assertEquals(0, metadataFile.metadata.files.size)
|
||||
assertEquals(0, metadataFile.metadata.folders.size)
|
||||
assertEquals(0, metadataFile.metadata.counter)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyMetadataWithOneFile() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
|
||||
val metadata = DecryptedMetadata(
|
||||
mutableListOf(),
|
||||
false,
|
||||
1,
|
||||
mutableMapOf(),
|
||||
mutableMapOf(
|
||||
Pair(
|
||||
EncryptionUtils.generateUid(),
|
||||
DecryptedFile(
|
||||
"document.pdf",
|
||||
"application/pdf",
|
||||
"initializationVector",
|
||||
"authenticationTag",
|
||||
"key1"
|
||||
)
|
||||
)
|
||||
),
|
||||
EncryptionUtils.generateKey()
|
||||
)
|
||||
metadata.keyChecksums.add(encryptionUtilsV2.hashMetadataKey(metadata.metadataKey))
|
||||
|
||||
val metadataFile = DecryptedFolderMetadataFile(
|
||||
metadata,
|
||||
mutableListOf(DecryptedUser(enc1.accountName, enc1Cert, null)),
|
||||
mutableMapOf(),
|
||||
E2EVersion.V2_1.value
|
||||
)
|
||||
|
||||
val encrypted = encryptionUtilsV2.encryptFolderMetadataFile(
|
||||
metadataFile,
|
||||
enc1UserId,
|
||||
folder,
|
||||
storageManager,
|
||||
client,
|
||||
enc1PrivateKey,
|
||||
user,
|
||||
targetContext,
|
||||
arbitraryDataProvider
|
||||
)
|
||||
|
||||
val signature = encryptionUtilsV2.getMessageSignature(enc1Cert, enc1PrivateKey, encrypted)
|
||||
|
||||
val result = encryptionUtilsV2.verifyMetadata(encrypted, metadataFile, 0, signature)
|
||||
|
||||
assertTrue(result)
|
||||
assertEquals(1, metadataFile.metadata.files.size)
|
||||
assertEquals("document.pdf", metadataFile.metadata.files.values.first().filename)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyMetadataCounterTooOld() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert)
|
||||
|
||||
val encrypted = encryptionUtilsV2.encryptFolderMetadataFile(
|
||||
metadataFile,
|
||||
enc1UserId,
|
||||
folder,
|
||||
storageManager,
|
||||
client,
|
||||
enc1PrivateKey,
|
||||
user,
|
||||
targetContext,
|
||||
arbitraryDataProvider
|
||||
)
|
||||
|
||||
val signature = encryptionUtilsV2.getMessageSignature(enc1Cert, enc1PrivateKey, encrypted)
|
||||
|
||||
// counter in metadata is 1, passing oldCounter=2 should fail
|
||||
val result = encryptionUtilsV2.verifyMetadata(encrypted, metadataFile, 2, signature)
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyMetadataInvalidSignature() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert)
|
||||
|
||||
val encrypted = encryptionUtilsV2.encryptFolderMetadataFile(
|
||||
metadataFile,
|
||||
enc1UserId,
|
||||
folder,
|
||||
storageManager,
|
||||
client,
|
||||
enc1PrivateKey,
|
||||
user,
|
||||
targetContext,
|
||||
arbitraryDataProvider
|
||||
)
|
||||
|
||||
val signature = encryptionUtilsV2.getMessageSignature(enc1Cert, enc1PrivateKey, encrypted)
|
||||
|
||||
val tampered = encrypted.copy(
|
||||
metadata = encrypted.metadata.copy(ciphertext = encrypted.metadata.ciphertext.reversed())
|
||||
)
|
||||
|
||||
val result = encryptionUtilsV2.verifyMetadata(tampered, metadataFile, 0, signature)
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyMetadataChecksumMismatch() {
|
||||
val folder = OCFile("/e/")
|
||||
val enc1 = MockUser("enc1", "Nextcloud")
|
||||
val metadataFile = generateDecryptedFolderMetadataFile(enc1, enc1Cert)
|
||||
|
||||
val encrypted = encryptionUtilsV2.encryptFolderMetadataFile(
|
||||
metadataFile,
|
||||
enc1UserId,
|
||||
folder,
|
||||
storageManager,
|
||||
client,
|
||||
enc1PrivateKey,
|
||||
user,
|
||||
targetContext,
|
||||
arbitraryDataProvider
|
||||
)
|
||||
|
||||
// Replace the metadata key with a new one whose hash is NOT in keyChecksums
|
||||
metadataFile.metadata.metadataKey = EncryptionUtils.generateKey()
|
||||
|
||||
val signature = encryptionUtilsV2.getMessageSignature(enc1Cert, enc1PrivateKey, encrypted)
|
||||
|
||||
val result = encryptionUtilsV2.verifyMetadata(encrypted, metadataFile, 0, signature)
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
|
||||
@Throws(Throwable::class)
|
||||
@Test
|
||||
@@ -810,6 +924,7 @@ class EncryptionUtilsV2IT : EncryptionIT() {
|
||||
fun encryptionMetadataV2() {
|
||||
val decryptedFolderMetadata1: DecryptedFolderMetadataFile =
|
||||
EncryptionTestUtils().generateFolderMetadataV2(client.userId, EncryptionTestIT.publicKey)
|
||||
setE2EECapabilityVersion(E2EVersion.fromValue(decryptedFolderMetadata1.version))
|
||||
val root = OCFile("/")
|
||||
storageManager.saveFile(root)
|
||||
|
||||
|
||||
@@ -7,15 +7,32 @@
|
||||
*/
|
||||
package com.owncloud.android.utils
|
||||
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class FileExportUtilsIT : AbstractIT() {
|
||||
@Before
|
||||
fun clearExistingDownload() {
|
||||
val fileName = "export.txt"
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
targetContext.contentResolver.delete(
|
||||
MediaStore.Downloads.EXTERNAL_CONTENT_URI,
|
||||
"${MediaStore.MediaColumns.DISPLAY_NAME} = ?",
|
||||
arrayOf(fileName)
|
||||
)
|
||||
} else {
|
||||
File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), fileName).delete()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun exportFile() {
|
||||
val file = createFile("export.txt", 10)
|
||||
@@ -23,7 +40,7 @@ class FileExportUtilsIT : AbstractIT() {
|
||||
val sut = FileExportUtils()
|
||||
|
||||
val expectedFile = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
File("/sdcard/Downloads/export.txt")
|
||||
File("/sdcard/Download/export.txt")
|
||||
} else {
|
||||
File("/storage/emulated/0/Download/export.txt")
|
||||
}
|
||||
@@ -47,7 +64,7 @@ class FileExportUtilsIT : AbstractIT() {
|
||||
val sut = FileExportUtils()
|
||||
|
||||
val expectedFile = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
File("/sdcard/Downloads/export.txt")
|
||||
File("/sdcard/Download/export.txt")
|
||||
} else {
|
||||
File("/storage/emulated/0/Download/export.txt")
|
||||
}
|
||||
|
||||
@@ -19,8 +19,11 @@ import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkStatic
|
||||
import io.mockk.spyk
|
||||
import io.mockk.unmockkStatic
|
||||
import io.mockk.verify
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
@@ -43,9 +46,7 @@ class FileUploadHelperTest {
|
||||
val mockFileStorageManager = mockk<com.owncloud.android.datamodel.FileDataStorageManager>(relaxed = true)
|
||||
every { mockFileStorageManager.getCapability(any<com.nextcloud.client.account.User>()) } returns mockCapability
|
||||
|
||||
val field = FileUploadHelper::class.java.getDeclaredField("fileStorageManager")
|
||||
field.isAccessible = true
|
||||
field.set(fileUploadHelper, mockFileStorageManager)
|
||||
fileUploadHelper.fileStorageManager = mockFileStorageManager
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@@ -104,19 +105,25 @@ class FileUploadHelperTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockkStatic("com.nextcloud.utils.extensions.OCCapabilityExtensionsKt")
|
||||
|
||||
uploadDao = mockk(relaxed = true)
|
||||
fileUploadHelper = spyk(FileUploadHelper(), recordPrivateCalls = true)
|
||||
|
||||
val uploadsStorageManager = mockk<com.owncloud.android.datamodel.UploadsStorageManager>(relaxed = true)
|
||||
every { uploadsStorageManager.uploadDao } returns uploadDao
|
||||
|
||||
val daoField = com.owncloud.android.datamodel.UploadsStorageManager::class.java
|
||||
.declaredFields
|
||||
.first { it.type == UploadDao::class.java }
|
||||
daoField.isAccessible = true
|
||||
daoField.set(uploadsStorageManager, uploadDao)
|
||||
val accountManager = mockk<com.nextcloud.client.account.UserAccountManager>(relaxed = true)
|
||||
|
||||
val field = FileUploadHelper::class.java.getDeclaredField("uploadsStorageManager")
|
||||
field.isAccessible = true
|
||||
field.set(fileUploadHelper, uploadsStorageManager)
|
||||
fileUploadHelper = spyk(FileUploadHelper(), recordPrivateCalls = true)
|
||||
fileUploadHelper.uploadsStorageManager = uploadsStorageManager
|
||||
fileUploadHelper.accountManager = accountManager
|
||||
|
||||
toggleWCFRestrictions(false)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
unmockkStatic("com.nextcloud.utils.extensions.OCCapabilityExtensionsKt")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Instrumentation
|
||||
import android.content.Intent
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.espresso.intent.Intents.intending
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity
|
||||
import org.hamcrest.Matchers.anyOf
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SnackbarTests {
|
||||
|
||||
class NormalTestFragment : Fragment()
|
||||
class DialogTestFragment : DialogFragment()
|
||||
class BottomSheetTestFragment : BottomSheetDialogFragment()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
Intents.init()
|
||||
val cancelledResult = Instrumentation.ActivityResult(Activity.RESULT_CANCELED, Intent())
|
||||
intending(
|
||||
anyOf(
|
||||
hasComponent(AuthenticatorActivity::class.java.name),
|
||||
hasComponent(FirstRunActivity::class.java.name)
|
||||
)
|
||||
).respondWith(cancelledResult)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
|
||||
private fun assertSnackbarVisible(msg: String) {
|
||||
onView(withText(msg)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun assertSnackbarVisible(@StringRes msgRes: Int) {
|
||||
onView(withText(msgRes)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun testFragmentSnackbar(fragment: Fragment, @StringRes msgRes: Int) {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.addFragment(fragment)
|
||||
}
|
||||
scenario.onActivity {
|
||||
DisplayUtils.showSnackMessage(fragment, msgRes)
|
||||
}
|
||||
assertSnackbarVisible(msgRes)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNormalFragmentSnackbar() {
|
||||
testFragmentSnackbar(NormalTestFragment(), R.string.app_name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDialogFragmentSnackbar() {
|
||||
testFragmentSnackbar(DialogTestFragment(), R.string.app_name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBottomSheetFragmentSnackbar() {
|
||||
testFragmentSnackbar(BottomSheetTestFragment(), R.string.app_name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNullFragmentSnackbarShouldNotCrash() {
|
||||
DisplayUtils.showSnackMessage(null as Fragment?, R.string.app_name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testActivityStringResSnackbar() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
DisplayUtils.showSnackMessage(sut, R.string.app_name)
|
||||
}
|
||||
assertSnackbarVisible(R.string.app_name)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testActivityStringSnackbar() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var message = ""
|
||||
scenario.onActivity { sut ->
|
||||
message = sut.getString(R.string.app_name)
|
||||
DisplayUtils.showSnackMessage(sut, message)
|
||||
}
|
||||
assertSnackbarVisible(message)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewStringResSnackbar() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val contentView = sut.findViewById<android.view.View>(android.R.id.content)
|
||||
DisplayUtils.showSnackMessage(contentView, R.string.app_name)
|
||||
}
|
||||
assertSnackbarVisible(R.string.app_name)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewStringSnackbar() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var message = ""
|
||||
scenario.onActivity { sut ->
|
||||
message = sut.getString(R.string.app_name)
|
||||
val contentView = sut.findViewById<android.view.View>(android.R.id.content)
|
||||
DisplayUtils.showSnackMessage(contentView, message)
|
||||
}
|
||||
assertSnackbarVisible(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class CapabilityUtilsIT : AbstractIT() {
|
||||
@Test
|
||||
fun checkOutdatedWarning() {
|
||||
assertFalse(test(NextcloudVersion.nextcloud_31))
|
||||
assertFalse(test(NextcloudVersion.nextcloud_30))
|
||||
assertTrue(test(NextcloudVersion.nextcloud_30))
|
||||
|
||||
assertTrue(test(NextcloudVersion.nextcloud_29))
|
||||
assertTrue(test(NextcloudVersion.nextcloud_28))
|
||||
@@ -35,7 +35,7 @@ class CapabilityUtilsIT : AbstractIT() {
|
||||
@Test
|
||||
fun checkOutdatedWarningWithSubscription() {
|
||||
assertFalse(test(NextcloudVersion.nextcloud_31))
|
||||
assertFalse(test(NextcloudVersion.nextcloud_30))
|
||||
assertTrue(test(NextcloudVersion.nextcloud_30))
|
||||
|
||||
assertFalse(test(OwnCloudVersion.nextcloud_20, true))
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
||||
|
||||
<!-- Used for document scanning, but lib declares it as required, which it's not -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera2"
|
||||
android:required="false"
|
||||
tools:node="replace" />
|
||||
|
||||
<application
|
||||
android:name=".MainApp"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- Used for document scanning, but lib declares it as required, which it's not -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera2"
|
||||
android:required="false"
|
||||
tools:node="replace" />
|
||||
|
||||
<application
|
||||
android:name=".MainApp"
|
||||
android:fullBackupContent="@xml/backup_config"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2024 TSI-mc <surinder.kumar@t-systems.com>
|
||||
~ SPDX-FileCopyrightText: 2024-2025 TSI-mc <surinder.kumar@t-systems.com>
|
||||
~ SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
-->
|
||||
@@ -11,13 +11,9 @@
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" /> <!-- Used for document scanning, but lib declares it as required, which it's not -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera2"
|
||||
android:required="false"
|
||||
tools:node="replace" />
|
||||
<!--
|
||||
WRITE_EXTERNAL_STORAGE may be enabled or disabled by the user after installation in
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
||||
<!--
|
||||
WRITE_EXTERNAL_STORAGE may be enabled or disabled by the user after installation in
|
||||
API >= 23; the app needs to handle this
|
||||
-->
|
||||
<uses-permission
|
||||
@@ -53,9 +49,10 @@
|
||||
-->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Runtime permissions introduced in Android 13 (API level 33) -->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"
|
||||
tools:ignore="PhotoAndVideoPolicy,SelectedPhotoAccess" />
|
||||
tools:ignore="PhotoAndVideoPolicy" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"
|
||||
tools:ignore="PhotoAndVideoPolicy,SelectedPhotoAccess" /> <!-- Needed for Android 14 (API level 34) -->
|
||||
tools:ignore="PhotoAndVideoPolicy" /> <!-- Needed for Android 14 (API level 34) -->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<!--
|
||||
@@ -388,16 +385,20 @@
|
||||
android:theme="@style/PreferenceTheme" />
|
||||
<activity
|
||||
android:name=".ui.preview.PreviewImageActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:exported="false"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.ownCloud.Overlay" />
|
||||
<activity
|
||||
android:name=".ui.preview.PreviewMediaActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.ownCloud.Media" />
|
||||
android:name="com.nextcloud.client.player.ui.PlayerActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:launchMode="singleTask"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:theme="@style/Theme.ownCloud.NoActionBar" />
|
||||
|
||||
<service
|
||||
android:name="com.nextcloud.client.media.BackgroundPlayerService"
|
||||
android:name="com.nextcloud.client.player.media3.PlaybackService"
|
||||
android:exported="true"
|
||||
android:foregroundServiceType="mediaPlayback"
|
||||
tools:ignore="ExportedService">
|
||||
@@ -406,6 +407,13 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<receiver android:name="androidx.media3.session.MediaButtonReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".authentication.AccountAuthenticatorService"
|
||||
android:exported="false">
|
||||
@@ -559,11 +567,6 @@
|
||||
android:name="com.nextcloud.client.jobs.transfer.FileTransferService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name="com.nextcloud.client.media.PlayerService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="mediaPlayback" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.PassCodeActivity"
|
||||
android:exported="false"
|
||||
@@ -630,6 +633,9 @@
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".ui.activity.AlbumsPickerActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activity.ShareActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.nextcloud.client.account;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -30,6 +31,9 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
String ACCOUNT_USES_STANDARD_PASSWORD = "ACCOUNT_USES_STANDARD_PASSWORD";
|
||||
String PENDING_FOR_REMOVAL = "PENDING_FOR_REMOVAL";
|
||||
|
||||
@Nullable
|
||||
Context getContext();
|
||||
|
||||
@Nullable
|
||||
OwnCloudAccount getCurrentOwnCloudAccount();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
private static final String TAG = UserAccountManagerImpl.class.getSimpleName();
|
||||
private static final String PREF_SELECT_OC_ACCOUNT = "select_oc_account";
|
||||
|
||||
private Context context;
|
||||
private final Context context;
|
||||
private final AccountManager accountManager;
|
||||
|
||||
public static UserAccountManagerImpl fromContext(Context context) {
|
||||
@@ -305,6 +305,12 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
return AnonymousUser.fromContext(context);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public OwnCloudAccount getCurrentOwnCloudAccount() {
|
||||
|
||||
@@ -201,7 +201,6 @@ class ChatViewModel(private val remoteRepository: AssistantRemoteRepository) : V
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
stopPolling()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro@alvarobrey.com>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -99,7 +100,12 @@ import com.owncloud.android.db.ProviderMeta
|
||||
// manual migration used for 97 to 98
|
||||
AutoMigration(from = 98, to = 99),
|
||||
// manual migration used for 99 to 100
|
||||
AutoMigration(from = 100, to = 101, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class)
|
||||
AutoMigration(from = 100, to = 101, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
AutoMigration(from = 101, to = 102, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
AutoMigration(from = 102, to = 103, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
AutoMigration(from = 103, to = 104),
|
||||
AutoMigration(from = 104, to = 105),
|
||||
AutoMigration(from = 105, to = 106, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class)
|
||||
],
|
||||
exportSchema = true
|
||||
)
|
||||
|
||||
@@ -65,6 +65,23 @@ interface FileDao {
|
||||
)
|
||||
suspend fun getGalleryItemsSuspended(startDate: Long, endDate: Long, fileOwner: String): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM filelist" +
|
||||
" WHERE (content_type LIKE 'image/%' OR content_type LIKE 'video/%')" +
|
||||
" AND file_owner = :fileOwner" +
|
||||
" AND path LIKE :pathPrefix || '%'" +
|
||||
" AND (:mimeFilter IS NULL OR content_type LIKE :mimeFilter)" +
|
||||
" ORDER BY modified DESC, ${ProviderTableMeta._ID} DESC" +
|
||||
" LIMIT :limit OFFSET :offset"
|
||||
)
|
||||
suspend fun getGalleryItemsPageSuspended(
|
||||
fileOwner: String,
|
||||
pathPrefix: String,
|
||||
mimeFilter: String?,
|
||||
limit: Int,
|
||||
offset: Int
|
||||
): List<FileEntity>
|
||||
|
||||
@Query("SELECT * FROM filelist WHERE file_owner = :fileOwner ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}")
|
||||
fun getAllFiles(fileOwner: String): List<FileEntity>
|
||||
|
||||
@@ -152,6 +169,17 @@ interface FileDao {
|
||||
)
|
||||
suspend fun getFavoriteFiles(fileOwner: String): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM filelist
|
||||
WHERE file_owner = :fileOwner
|
||||
AND favorite = 1
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
fun getFavoriteFilesNonBlocking(fileOwner: String): List<FileEntity>
|
||||
|
||||
@Query("SELECT remote_id FROM filelist WHERE file_owner = :accountName AND remote_id IS NOT NULL")
|
||||
fun getAllRemoteIds(accountName: String): List<String>
|
||||
|
||||
@@ -171,4 +199,10 @@ interface FileDao {
|
||||
|
||||
@Query("DELETE FROM filelist WHERE file_owner = :fileOwner AND path = :remotePath")
|
||||
fun deleteFileByRemotePath(fileOwner: String, remotePath: String): Int
|
||||
|
||||
@Query("UPDATE filelist SET is_read_only = :readOnly WHERE file_owner = :fileOwner AND path = :path")
|
||||
fun setReadOnly(fileOwner: String, path: String, readOnly: Int): Int
|
||||
|
||||
@Update
|
||||
fun updateAll(entities: List<FileEntity>)
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.ShareEntity
|
||||
import com.nextcloud.client.database.entity.model.ShareeKey
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
|
||||
@Dao
|
||||
interface ShareDao {
|
||||
@@ -21,4 +23,12 @@ interface ShareDao {
|
||||
|
||||
@Query("DELETE FROM ocshares WHERE owner_share = :accountName")
|
||||
suspend fun clearSharesForAccount(accountName: String)
|
||||
|
||||
@Query(
|
||||
"SELECT path, ${ProviderTableMeta.OCSHARES_SHARE_WITH}, " +
|
||||
"${ProviderTableMeta.OCSHARES_SHARE_TYPE} FROM ${ProviderTableMeta.OCSHARES_TABLE_NAME} " +
|
||||
"WHERE path IN (:paths) AND owner_share = :accountName AND " +
|
||||
"${ProviderTableMeta.OCSHARES_SHARE_TYPE} IN (:shareTypes)"
|
||||
)
|
||||
fun getShareeKeys(paths: List<String>, accountName: String, shareTypes: List<Int>): List<ShareeKey>
|
||||
}
|
||||
@@ -95,9 +95,11 @@ interface UploadDao {
|
||||
SELECT * FROM ${ProviderTableMeta.UPLOADS_TABLE_NAME}
|
||||
WHERE ${ProviderTableMeta.UPLOADS_STATUS} = :status
|
||||
AND (:nameCollisionPolicy IS NULL OR ${ProviderTableMeta.UPLOADS_NAME_COLLISION_POLICY} = :nameCollisionPolicy)
|
||||
ORDER BY ${ProviderTableMeta._ID} DESC
|
||||
LIMIT :limit
|
||||
"""
|
||||
)
|
||||
suspend fun getUploadsByStatus(status: Int, nameCollisionPolicy: Int? = null): List<UploadEntity>
|
||||
suspend fun getUploadsByStatus(status: Int, nameCollisionPolicy: Int? = null, limit: Int): List<UploadEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
@@ -105,11 +107,14 @@ interface UploadDao {
|
||||
WHERE ${ProviderTableMeta.UPLOADS_ACCOUNT_NAME} = :accountName
|
||||
AND ${ProviderTableMeta.UPLOADS_STATUS} = :status
|
||||
AND (:nameCollisionPolicy IS NULL OR ${ProviderTableMeta.UPLOADS_NAME_COLLISION_POLICY} = :nameCollisionPolicy)
|
||||
ORDER BY ${ProviderTableMeta._ID} DESC
|
||||
LIMIT :limit
|
||||
"""
|
||||
)
|
||||
suspend fun getUploadsByAccountNameAndStatus(
|
||||
accountName: String,
|
||||
status: Int,
|
||||
nameCollisionPolicy: Int? = null
|
||||
nameCollisionPolicy: Int? = null,
|
||||
limit: Int
|
||||
): List<UploadEntity>
|
||||
}
|
||||
@@ -126,6 +126,8 @@ data class CapabilityEntity(
|
||||
val dropAccount: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_SECURITY_GUARD)
|
||||
val securityGuard: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_GOVERNANCE)
|
||||
val governance: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAME_CHARACTERS)
|
||||
val forbiddenFileNameCharacters: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAMES)
|
||||
@@ -153,7 +155,11 @@ data class CapabilityEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON)
|
||||
val clientIntegrationJson: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_MOD_REWRITE_WORKING)
|
||||
val modRewriteWorking: Int?
|
||||
val modRewriteWorking: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_CHUNKED_UPLOAD_MAX_SIZE)
|
||||
val chunkedUploadMaxSize: Long?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_SHARING_JSON)
|
||||
val sharingJson: String?
|
||||
)
|
||||
|
||||
@Suppress("LongMethod", "ReturnCount")
|
||||
@@ -222,6 +228,7 @@ fun CapabilityEntity?.toOCCapability(): OCCapability {
|
||||
capability.groupfolders = intToBoolean(this.groupfolders)
|
||||
capability.dropAccount = intToBoolean(this.dropAccount)
|
||||
capability.securityGuard = intToBoolean(this.securityGuard)
|
||||
capability.governance = intToBoolean(this.governance)
|
||||
capability.forbiddenFilenameCharactersJson = this.forbiddenFileNameCharacters
|
||||
capability.forbiddenFilenamesJson = this.forbiddenFileNames
|
||||
capability.forbiddenFilenameExtensionJson = this.forbiddenFileNameExtensions
|
||||
@@ -235,6 +242,7 @@ fun CapabilityEntity?.toOCCapability(): OCCapability {
|
||||
capability.hasValidSubscription = intToBoolean(this.hasValidSubscription)
|
||||
capability.clientIntegrationJson = this.clientIntegrationJson
|
||||
capability.modRewriteWorking = intToBoolean(this.modRewriteWorking)
|
||||
capability.chunkedUploadMaxSize = this.chunkedUploadMaxSize ?: OCCapability.CHUNKED_UPLOAD_MAX_SIZE_UNKNOWN
|
||||
|
||||
return capability
|
||||
}
|
||||
@@ -121,5 +121,7 @@ data class FileEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_INTERNAL_TWO_WAY_SYNC_RESULT)
|
||||
val internalTwoWaySyncResult: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_UPLOADED)
|
||||
val uploaded: Long?
|
||||
val uploaded: Long?,
|
||||
@ColumnInfo(name = ProviderTableMeta.FILE_IS_READ_ONLY)
|
||||
val isReadOnly: Int?
|
||||
)
|
||||
@@ -9,10 +9,28 @@ package com.nextcloud.client.database.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
|
||||
@Entity(tableName = ProviderTableMeta.FILESYSTEM_TABLE_NAME)
|
||||
@Entity(
|
||||
tableName = ProviderTableMeta.FILESYSTEM_TABLE_NAME,
|
||||
indices = [
|
||||
Index(
|
||||
value = [
|
||||
ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH,
|
||||
ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID
|
||||
]
|
||||
),
|
||||
Index(
|
||||
value = [
|
||||
ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID,
|
||||
ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD,
|
||||
ProviderTableMeta.FILESYSTEM_FILE_IS_FOLDER
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
data class FilesystemEntity(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = ProviderTableMeta._ID)
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.nextcloud.client.database.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import com.nextcloud.utils.autoRename.AutoRename
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
@@ -21,7 +22,14 @@ import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
@Entity(tableName = ProviderTableMeta.UPLOADS_TABLE_NAME)
|
||||
@Entity(
|
||||
tableName = ProviderTableMeta.UPLOADS_TABLE_NAME,
|
||||
indices = [
|
||||
Index(value = [ProviderTableMeta.UPLOADS_ACCOUNT_NAME, ProviderTableMeta.UPLOADS_STATUS]),
|
||||
Index(value = [ProviderTableMeta.UPLOADS_REMOTE_PATH, ProviderTableMeta.UPLOADS_ACCOUNT_NAME]),
|
||||
Index(value = [ProviderTableMeta.UPLOADS_ACCOUNT_NAME, ProviderTableMeta.UPLOADS_LOCAL_PATH])
|
||||
]
|
||||
)
|
||||
data class UploadEntity(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = ProviderTableMeta._ID)
|
||||
|
||||
Loaded 100 of 705 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user