Compare commits
924
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f852195ac | ||
|
|
90ebd53227 | ||
|
|
04bd74ac09 | ||
|
|
104d1e6663 | ||
|
|
04aec3f7c8 | ||
|
|
f5814b9822 | ||
|
|
0710c82101 | ||
|
|
e8b0d378f3 | ||
|
|
cd4c43ce82 | ||
|
|
d384dc5a43 | ||
|
|
f7c1f921bb | ||
|
|
d31db26d00 | ||
|
|
dff8ee60a3 | ||
|
|
9be50ef142 | ||
|
|
3a8bbd0ebb | ||
|
|
0dbaf81dbb | ||
|
|
d9d0f88bce | ||
|
|
0f7ce1e33f | ||
|
|
4c80d1c5c3 | ||
|
|
ed4b7addff | ||
|
|
300b499a10 | ||
|
|
6fa1ed5c3d | ||
|
|
dfddbf0e07 | ||
|
|
24053b5bd9 | ||
|
|
bc3b4218a1 | ||
|
|
9a2a313b8f | ||
|
|
b5a3e6be29 | ||
|
|
a5c7b87bf1 | ||
|
|
e89141a714 | ||
|
|
dc3b8c6918 | ||
|
|
54dd53c6ff | ||
|
|
96f6cc3a43 | ||
|
|
9d0740294c | ||
|
|
4fe9328b4c | ||
|
|
349c1bc919 | ||
|
|
e69f2976a0 | ||
|
|
dd87b213d7 | ||
|
|
96debdd3a5 | ||
|
|
bdc9bb1829 | ||
|
|
07c09e1e99 | ||
|
|
5fd2e2942c | ||
|
|
2bb71c8b89 | ||
|
|
64f79d8462 | ||
|
|
ac7d82a7f0 | ||
|
|
27340def2c | ||
|
|
e8a8a82671 | ||
|
|
7a1ac3b3bf | ||
|
|
416e2b80f8 | ||
|
|
176577aae8 | ||
|
|
2500a692a7 | ||
|
|
076972789e | ||
|
|
0c737e04c5 | ||
|
|
46d1253210 | ||
|
|
2719530f7a | ||
|
|
72ff3a5f26 | ||
|
|
0028b6f0fd | ||
|
|
e77b10ebdc | ||
|
|
88fc3f362b | ||
|
|
1d19cc6992 | ||
|
|
d831a8b96d | ||
|
|
3453a7a1f3 | ||
|
|
2f58e63b45 | ||
|
|
cbe2e9e433 | ||
|
|
17e6e553e5 | ||
|
|
4453eaf5d3 | ||
|
|
21e0c82e65 | ||
|
|
7a5f707e9a | ||
|
|
cbe4932b85 | ||
|
|
be2b8416da | ||
|
|
57acd7d046 | ||
|
|
622e22f801 | ||
|
|
8bc660e9b0 | ||
|
|
b431522ceb | ||
|
|
aa5d00dc85 | ||
|
|
675017c0b7 | ||
|
|
79f3938a10 | ||
|
|
55ee6af50c | ||
|
|
02684cb212 | ||
|
|
8169857a28 | ||
|
|
145b79633e | ||
|
|
eb6282f885 | ||
|
|
a66095eead | ||
|
|
5cc8c43531 | ||
|
|
1036b44975 | ||
|
|
8510970467 | ||
|
|
782adad8a5 | ||
|
|
f3df1dd4f5 | ||
|
|
94fed2aa62 | ||
|
|
bca8dae206 | ||
|
|
a7f42e8caa | ||
|
|
8a315b9f9f | ||
|
|
bcbc089094 | ||
|
|
2fbf25e765 | ||
|
|
4e0c1083bb | ||
|
|
1ae05df898 | ||
|
|
699cbc525b | ||
|
|
e1a80b64f4 | ||
|
|
52bb721afc | ||
|
|
bb1782e7cc | ||
|
|
004f14ea7f | ||
|
|
b1d842c6f6 | ||
|
|
f5acb815b3 | ||
|
|
feed19eea4 | ||
|
|
7dbfa0d551 | ||
|
|
a222d55b0c | ||
|
|
16996c7601 | ||
|
|
3a3072612d | ||
|
|
f7dee5449f | ||
|
|
f1434d833d | ||
|
|
195c398ca4 | ||
|
|
5a86c0f00a | ||
|
|
a9a00f0619 | ||
|
|
db0d113b52 | ||
|
|
8fac856d87 | ||
|
|
083c393c0b | ||
|
|
07e81c2c87 | ||
|
|
5b9a7d291b | ||
|
|
3bb1c7f4d8 | ||
|
|
7e9c8ccbfc | ||
|
|
3686edd55c | ||
|
|
62a51e4063 | ||
|
|
5b11ed7b20 | ||
|
|
4e9247a130 | ||
|
|
81296dcf8b | ||
|
|
a704326574 | ||
|
|
3cab716a97 | ||
|
|
596264d5cd | ||
|
|
50d4b8d187 | ||
|
|
cf5cbb1635 | ||
|
|
a71c7fd1d9 | ||
|
|
ea3d6407c5 | ||
|
|
b4bba97efc | ||
|
|
84be18b5fb | ||
|
|
2a64e26c10 | ||
|
|
67a638ad4e | ||
|
|
8f4096e6dc | ||
|
|
a26beacc40 | ||
|
|
1a40920dd7 | ||
|
|
6de9b48fd3 | ||
|
|
1000c82d5e | ||
|
|
f03f517593 | ||
|
|
3155c65a74 | ||
|
|
7e1880c3de | ||
|
|
794d48e665 | ||
|
|
5d033e7986 | ||
|
|
279b5fa209 | ||
|
|
d562e5feb3 | ||
|
|
18481f45d7 | ||
|
|
683ed9b0b8 | ||
|
|
d4e131e81f | ||
|
|
484fe04245 | ||
|
|
b0f429b477 | ||
|
|
13f40c4026 | ||
|
|
2ea35f2f0b | ||
|
|
9e4197e4b9 | ||
|
|
7a021f4be9 | ||
|
|
03c22ee4a0 | ||
|
|
4fbaaa307d | ||
|
|
7275d8b14e | ||
|
|
199e754e9b | ||
|
|
db028503d9 | ||
|
|
8a028567d1 | ||
|
|
7a97e558c3 | ||
|
|
b83ac7d6a4 | ||
|
|
6bdbbcb0d7 | ||
|
|
45a5e6bd26 | ||
|
|
8d2182a29e | ||
|
|
5479c135eb | ||
|
|
3c5aaad6d6 | ||
|
|
eb13420f35 | ||
|
|
26158aba2c | ||
|
|
c89832b1ff | ||
|
|
6e3f63d4d4 | ||
|
|
eedd3473f5 | ||
|
|
5ebb4cfad2 | ||
|
|
8baa0a6988 | ||
|
|
1f900b7a55 | ||
|
|
c18278b973 | ||
|
|
7fe00834ed | ||
|
|
83d3cfba1d | ||
|
|
30e67b530f | ||
|
|
a4eb0c9275 | ||
|
|
39a7aff33c | ||
|
|
07e7484c5a | ||
|
|
a1ce48da06 | ||
|
|
8dd522d600 | ||
|
|
b489ddae99 | ||
|
|
80552ca895 | ||
|
|
e6aa4471b8 | ||
|
|
79d2ed8889 | ||
|
|
2a6ba436aa | ||
|
|
4e9f63873c | ||
|
|
895fd68e84 | ||
|
|
614bacc074 | ||
|
|
e7d0c1d0ec | ||
|
|
fc927e7bac | ||
|
|
d52dbb705c | ||
|
|
ea07d3c5ee | ||
|
|
50fc0d3d7f | ||
|
|
1587631797 | ||
|
|
3f9ed092df | ||
|
|
63f6edc1d4 | ||
|
|
0f237fc3dc | ||
|
|
0776265f6d | ||
|
|
312be7b171 | ||
|
|
3b26d54de5 | ||
|
|
1ba667e925 | ||
|
|
1bc0e70453 | ||
|
|
1be313a21c | ||
|
|
37e936b19a | ||
|
|
3aaf7603f9 | ||
|
|
f6c790f13c | ||
|
|
f0ebd7d2c7 | ||
|
|
e307143074 | ||
|
|
f5b288b59f | ||
|
|
bef0cfa885 | ||
|
|
5e895ec306 | ||
|
|
9122d0a261 | ||
|
|
98c4ea9c77 | ||
|
|
a1aa3a5455 | ||
|
|
20ea984885 | ||
|
|
5dbe8d5eab | ||
|
|
d267d4cb2c | ||
|
|
24a11c5e5e | ||
|
|
f639788ebc | ||
|
|
b622174c95 | ||
|
|
31fa1c4413 | ||
|
|
2f6b724540 | ||
|
|
0814e10937 | ||
|
|
18e9019a14 | ||
|
|
86e35bc871 | ||
|
|
a85379bafb | ||
|
|
d1d06c144f | ||
|
|
7352fa05e4 | ||
|
|
fad3ed061f | ||
|
|
b90110b605 | ||
|
|
5d5e5106d1 | ||
|
|
032e906778 | ||
|
|
84de8e64c4 | ||
|
|
4f873754f8 | ||
|
|
7531426c0b | ||
|
|
65e93d8500 | ||
|
|
f065874a96 | ||
|
|
1956e0e582 | ||
|
|
e1877d0cb4 | ||
|
|
505d6b72ac | ||
|
|
74a5282dbb | ||
|
|
94a1a7e34d | ||
|
|
2cbda4ed42 | ||
|
|
9c80a480f4 | ||
|
|
af76c5c9b6 | ||
|
|
4503d4431e | ||
|
|
29a0956614 | ||
|
|
2aeb912938 | ||
|
|
a92e11967c | ||
|
|
b6e7310e39 | ||
|
|
1c7749bcb4 | ||
|
|
3242b07782 | ||
|
|
361d9fa69e | ||
|
|
ede66e8fa4 | ||
|
|
7f200295b3 | ||
|
|
83d6ed4f6a | ||
|
|
949282e638 | ||
|
|
239f33f44c | ||
|
|
7f4f85200e | ||
|
|
02a3a9e0a5 | ||
|
|
b83c773cec | ||
|
|
22f3ee5fc5 | ||
|
|
9722e882e8 | ||
|
|
677d855a4c | ||
|
|
0c427262fd | ||
|
|
05ee6abd95 | ||
|
|
93d4244859 | ||
|
|
40ec339c3e | ||
|
|
3df4e98916 | ||
|
|
be8d6b3d95 | ||
|
|
21b28d3429 | ||
|
|
fc034019e3 | ||
|
|
9c4322f3cf | ||
|
|
3e811defc5 | ||
|
|
18c7759040 | ||
|
|
726fcbc8e4 | ||
|
|
aab2051f5f | ||
|
|
39c7dcf6ce | ||
|
|
18133fc98b | ||
|
|
7a80da65cb | ||
|
|
975150c93a | ||
|
|
5795a91119 | ||
|
|
7386cae700 | ||
|
|
68257e6eb9 | ||
|
|
244719e80e | ||
|
|
94aa44b0c5 | ||
|
|
03dc62a840 | ||
|
|
63c16c729e | ||
|
|
afad33e363 | ||
|
|
f48d05d8a6 | ||
|
|
679b8ef364 | ||
|
|
288f5a2d99 | ||
|
|
c3e12ccb22 | ||
|
|
b7e6c92f4b | ||
|
|
525f8f19f4 | ||
|
|
1ecf6fa3e6 | ||
|
|
e3b03034a4 | ||
|
|
ff7f278079 | ||
|
|
ecf9c94d92 | ||
|
|
ab7a295a46 | ||
|
|
9769568b27 | ||
|
|
c703e6f640 | ||
|
|
c6a34b9e4d | ||
|
|
7e473ceed6 | ||
|
|
fe1a90a15e | ||
|
|
d6ab287416 | ||
|
|
d01134d095 | ||
|
|
f1cbb3595f | ||
|
|
e597d04fbe | ||
|
|
abff643d2a | ||
|
|
741f7441e4 | ||
|
|
8a9a5d60b1 | ||
|
|
f2643692a2 | ||
|
|
654fb6f08c | ||
|
|
77af02b5ba | ||
|
|
155a353871 | ||
|
|
37ed66906a | ||
|
|
e93c8f3ff0 | ||
|
|
b5696ae9f3 | ||
|
|
f7f6246a55 | ||
|
|
b765998bb8 | ||
|
|
beae24ac6d | ||
|
|
1810de536a | ||
|
|
e970fe0ab1 | ||
|
|
7bd657784a | ||
|
|
980b199933 | ||
|
|
e28e6e3c31 | ||
|
|
86e43a57b2 | ||
|
|
f22a9642ee | ||
|
|
a68f18b78f | ||
|
|
9730b78492 | ||
|
|
98c9912dd6 | ||
|
|
69c647126e | ||
|
|
6f93f301bc | ||
|
|
d27622480d | ||
|
|
8d041af4ba | ||
|
|
3438ec12a6 | ||
|
|
5d79759e40 | ||
|
|
7480a7bafa | ||
|
|
5e523f9a47 | ||
|
|
7a64807645 | ||
|
|
70bbf2860b | ||
|
|
a332ee0abf | ||
|
|
28e176f22d | ||
|
|
6236ebf049 | ||
|
|
d81acbf96e | ||
|
|
ce9217a4e5 | ||
|
|
0376033c44 | ||
|
|
5dc101e3f3 | ||
|
|
9c4bc28bd0 | ||
|
|
753e2a932f | ||
|
|
383d7e050b | ||
|
|
65eed51ead | ||
|
|
bd5ba98f29 | ||
|
|
3f4da24b17 | ||
|
|
f2efe8bcda | ||
|
|
2eeddd3efe | ||
|
|
688de64360 | ||
|
|
b7b250bb2f | ||
|
|
c9e9dab8fe | ||
|
|
e4c7ee0c77 | ||
|
|
8ed3b16e15 | ||
|
|
9f5a72cf96 | ||
|
|
3a0d8a9411 | ||
|
|
a5dbe2a46a | ||
|
|
dfc8fb9791 | ||
|
|
51d42575a7 | ||
|
|
f2643d2f97 | ||
|
|
a5f2a634b3 | ||
|
|
4a7105d502 | ||
|
|
cff3cfcdb6 | ||
|
|
dbb49e107a | ||
|
|
17b758ed27 | ||
|
|
82cb46643d | ||
|
|
59efb5ed2f | ||
|
|
c9a12d8c34 | ||
|
|
daad4b58ef | ||
|
|
432743e00b | ||
|
|
057b9a2846 | ||
|
|
749d8d779a | ||
|
|
c9bfd3dacd | ||
|
|
bc935f9d32 | ||
|
|
4dc4f0a505 | ||
|
|
1e7ed9d5c0 | ||
|
|
1083997359 | ||
|
|
1ccc351cdb | ||
|
|
728401ee63 | ||
|
|
4a1940ac94 | ||
|
|
835a82bf2f | ||
|
|
017df65d8b | ||
|
|
097a56b66a | ||
|
|
64ac912f92 | ||
|
|
8901f564b0 | ||
|
|
d2296a0fb6 | ||
|
|
8fb887daf5 | ||
|
|
636314ed49 | ||
|
|
e5bbd98738 | ||
|
|
559df47acf | ||
|
|
c31cba30f5 | ||
|
|
b5818fd0b5 | ||
|
|
f2cf44166f | ||
|
|
5d71b9a05c | ||
|
|
4727b8ae44 | ||
|
|
cdf29a20d7 | ||
|
|
71c84b8803 | ||
|
|
a9a53215c0 | ||
|
|
87ac2c5c2b | ||
|
|
e9cd78d0f8 | ||
|
|
2e85fedc91 | ||
|
|
9fb3f5fcad | ||
|
|
6daeb80aa1 | ||
|
|
726e0b44d6 | ||
|
|
88369d8fbd | ||
|
|
8ab2235f9c | ||
|
|
72f3d82cda | ||
|
|
8d5783900b | ||
|
|
29a8ec164a | ||
|
|
b1013ad3a6 | ||
|
|
b5220141f8 | ||
|
|
c47e51a130 | ||
|
|
26f2a09c9a | ||
|
|
bd3d77a4e5 | ||
|
|
38413ffc09 | ||
|
|
dd6b62cf13 | ||
|
|
68d580cdb3 | ||
|
|
530361cd4c | ||
|
|
6a8cdd6376 | ||
|
|
7e1706b55f | ||
|
|
bc7a1916c8 | ||
|
|
f5695051e7 | ||
|
|
73e3cf48c6 | ||
|
|
2f56f04fc9 | ||
|
|
abd48a4f8c | ||
|
|
5e0bc0eabd | ||
|
|
cfcf6e6b18 | ||
|
|
95fd955841 | ||
|
|
dc0b720a2b | ||
|
|
8371f2816a | ||
|
|
7a020a93b0 | ||
|
|
19e44f0990 | ||
|
|
f19b598f51 | ||
|
|
a33bf852ca | ||
|
|
f78ddf501b | ||
|
|
d449731f9d | ||
|
|
beccd79b29 | ||
|
|
12b8ed756d | ||
|
|
eba9f99d02 | ||
|
|
c0d776a7ce | ||
|
|
9933671937 | ||
|
|
9183fcb9e4 | ||
|
|
5f645b6cf2 | ||
|
|
cd394c906d | ||
|
|
eee4f10a21 | ||
|
|
8862924874 | ||
|
|
34f295d3e3 | ||
|
|
3bda3337aa | ||
|
|
db3e868b1d | ||
|
|
2983d87407 | ||
|
|
30be0af6a2 | ||
|
|
6610b63223 | ||
|
|
7c82fd84f8 | ||
|
|
f15308f18a | ||
|
|
f54c11e321 | ||
|
|
d5bb3634f9 | ||
|
|
7d0c268340 | ||
|
|
89e0def4f7 | ||
|
|
caf7be5bea | ||
|
|
0ce0653d64 | ||
|
|
bd94526ce2 | ||
|
|
37df0dca9d | ||
|
|
05e83cb275 | ||
|
|
c06be56a54 | ||
|
|
196a1937e1 | ||
|
|
3ff3226f43 | ||
|
|
ff0e98610d | ||
|
|
08a431ad6f | ||
|
|
1b8922fc8c | ||
|
|
159ed52397 | ||
|
|
2088049bf6 | ||
|
|
3a1ff78ab4 | ||
|
|
7a93e41f09 | ||
|
|
25efa940f2 | ||
|
|
84f184a1f0 | ||
|
|
b83c36cf9e | ||
|
|
bab32993e3 | ||
|
|
6137573286 | ||
|
|
c6d5ab94c7 | ||
|
|
3b50aeb33d | ||
|
|
b309a3268a | ||
|
|
68d22b8748 | ||
|
|
ad79ed3daa | ||
|
|
6bed9e6791 | ||
|
|
57810705ab | ||
|
|
644e48f8ad | ||
|
|
ba31ccffc3 | ||
|
|
b4aff053ba | ||
|
|
b846aa56c2 | ||
|
|
a7f50c1450 | ||
|
|
1e1d64c041 | ||
|
|
6ca492a11d | ||
|
|
b9405370ea | ||
|
|
170b223561 | ||
|
|
e7b137368e | ||
|
|
25a4ee37d4 | ||
|
|
737a489a0d | ||
|
|
a859cf1639 | ||
|
|
48ce57e631 | ||
|
|
6b0eed42af | ||
|
|
26680fc9c5 | ||
|
|
b880273e52 | ||
|
|
b0b9c41c50 | ||
|
|
a398bb964c | ||
|
|
d0cc3a858b | ||
|
|
63ed7704c6 | ||
|
|
6bd8269083 | ||
|
|
16ac534ca9 | ||
|
|
1f42252bb2 | ||
|
|
9a0447d8e7 | ||
|
|
a71209a8e3 | ||
|
|
a7135c46a7 | ||
|
|
49ca25ca7f | ||
|
|
a393f6f3d0 | ||
|
|
c34a8cdd0c | ||
|
|
715db982b7 | ||
|
|
693e0404c7 | ||
|
|
1a3dd76e44 | ||
|
|
b7c495b7ec | ||
|
|
b79e6371bb | ||
|
|
af08563a22 | ||
|
|
aa88901c54 | ||
|
|
0e0707a745 | ||
|
|
f21edf0676 | ||
|
|
a534e51c5b | ||
|
|
ec3557fd5c | ||
|
|
5c68528f66 | ||
|
|
0a79fbc0da | ||
|
|
42195c2e94 | ||
|
|
529785d9dc | ||
|
|
3b4eee4308 | ||
|
|
a4b5712e5c | ||
|
|
b80d726fd0 | ||
|
|
f4ddbf5c33 | ||
|
|
ea5bfa4be0 | ||
|
|
2102e689f8 | ||
|
|
dec952328a | ||
|
|
f4a098bbd6 | ||
|
|
1c77c7d896 | ||
|
|
14dbf15b4f | ||
|
|
d37d844513 | ||
|
|
ca57da7683 | ||
|
|
c618521bd7 | ||
|
|
50c2ffac49 | ||
|
|
c8847d66b6 | ||
|
|
c6a7b09056 | ||
|
|
8903f65547 | ||
|
|
1aeaa69747 | ||
|
|
19a3e4ced1 | ||
|
|
99262748d0 | ||
|
|
a61b242444 | ||
|
|
eea9580f54 | ||
|
|
a5b988cd4b | ||
|
|
448a5f817f | ||
|
|
9969e146a3 | ||
|
|
4f7c5a7f99 | ||
|
|
d73545928a | ||
|
|
89c3e20e43 | ||
|
|
fa71fd145e | ||
|
|
30a02e5ea0 | ||
|
|
02f5686aa5 | ||
|
|
0d3cbf9983 | ||
|
|
8e4253dcaf | ||
|
|
98f2e883c8 | ||
|
|
5c3dae18af | ||
|
|
fc55795967 | ||
|
|
8845986198 | ||
|
|
c283c0e9f3 | ||
|
|
0d430ab61e | ||
|
|
eee561f79d | ||
|
|
2899c21bc0 | ||
|
|
63036905a4 | ||
|
|
846b832695 | ||
|
|
4c3ca044c2 | ||
|
|
0b1e1885bc | ||
|
|
b16ce04487 | ||
|
|
d4a2ef98b2 | ||
|
|
8d2096ac96 | ||
|
|
f1ba224b4d | ||
|
|
568026c325 | ||
|
|
f77044b48a | ||
|
|
2b0655447e | ||
|
|
d48d3fb2c5 | ||
|
|
5d74deda1b | ||
|
|
5aef9077bc | ||
|
|
6e4bb2bde7 | ||
|
|
6c2996253d | ||
|
|
75d6becf23 | ||
|
|
1c47a34e21 | ||
|
|
8583b560d7 | ||
|
|
f2be557682 | ||
|
|
04fc3eb489 | ||
|
|
2bb557611f | ||
|
|
fa3bdf3095 | ||
|
|
6baa4b1513 | ||
|
|
0c094743c4 | ||
|
|
bdc42311b9 | ||
|
|
5571bcbab1 | ||
|
|
b56fe51346 | ||
|
|
aa26ff24da | ||
|
|
295e79f2d9 | ||
|
|
ce685646ed | ||
|
|
2ec0896945 | ||
|
|
1157919a64 | ||
|
|
7a9ccf113d | ||
|
|
75e8727b0a | ||
|
|
f2ccc6f82f | ||
|
|
760b05436e | ||
|
|
0a1aec1969 | ||
|
|
3291d5bd21 | ||
|
|
48e692718d | ||
|
|
fe18db0b9b | ||
|
|
3258c51ad9 | ||
|
|
37f5cf0a51 | ||
|
|
b42f88eea3 | ||
|
|
b29a9072b4 | ||
|
|
402075dab1 | ||
|
|
284addaeb5 | ||
|
|
9a5def6c91 | ||
|
|
18851098a8 | ||
|
|
6d1830be74 | ||
|
|
c2a7ad454c | ||
|
|
1463c2502d | ||
|
|
21c2cfee90 | ||
|
|
f77d913d3e | ||
|
|
0928eba4db | ||
|
|
bf34e2b483 | ||
|
|
660a508d0a | ||
|
|
63f237c7d6 | ||
|
|
e3c32f5355 | ||
|
|
b9b546411c | ||
|
|
5e0b95a6f5 | ||
|
|
a442571c3a | ||
|
|
e35b8ae3b0 | ||
|
|
e3114f29c6 | ||
|
|
105b98f0ee | ||
|
|
eea5a27196 | ||
|
|
0fc66177e0 | ||
|
|
67e73b6165 | ||
|
|
42e966f7bc | ||
|
|
4a6c006741 | ||
|
|
81acf16099 | ||
|
|
b11093eace | ||
|
|
09f2615e26 | ||
|
|
30f217ef6e | ||
|
|
aa11388cbe | ||
|
|
a251356d2e | ||
|
|
e5b9849e36 | ||
|
|
2e337af091 | ||
|
|
e21ed79d3f | ||
|
|
db193872b2 | ||
|
|
d3cc4d8454 | ||
|
|
e22ed33ee1 | ||
|
|
c72abc8d69 | ||
|
|
74a6356f92 | ||
|
|
df57012a84 | ||
|
|
013caa14c9 | ||
|
|
618330cacb | ||
|
|
b4451ec013 | ||
|
|
2f9da59fd5 | ||
|
|
b8fe4e3c8f | ||
|
|
e31d94af95 | ||
|
|
1dfb02b8f5 | ||
|
|
2a7f54f694 | ||
|
|
2aab5de022 | ||
|
|
82e8de22cb | ||
|
|
c713db1328 | ||
|
|
6a5791785c | ||
|
|
d863a8b90d | ||
|
|
a7c0f2e755 | ||
|
|
f3cfd576c2 | ||
|
|
27194f2617 | ||
|
|
4f38a4f4d8 | ||
|
|
1e2b1ea8e1 | ||
|
|
345367f8e0 | ||
|
|
600ca3cfd0 | ||
|
|
e256b29d60 | ||
|
|
54d468bdbc | ||
|
|
739f21aca6 | ||
|
|
3872e0ec36 | ||
|
|
632b54e665 | ||
|
|
0eb2b07a1e | ||
|
|
73692d0c4b | ||
|
|
9a7a8e2681 | ||
|
|
00cfdaa170 | ||
|
|
2ce7fa6c3f | ||
|
|
acc424672a | ||
|
|
e3a0d9e6cc | ||
|
|
60b190b8f5 | ||
|
|
55487a4b0a | ||
|
|
f9e8000928 | ||
|
|
9706c451b3 | ||
|
|
26de62b0f1 | ||
|
|
5bef6b6161 | ||
|
|
b18bafba99 | ||
|
|
c3187eed04 | ||
|
|
94d64aaa73 | ||
|
|
3efb7dc1b1 | ||
|
|
fe3ece4bd6 | ||
|
|
ffe6da3b03 | ||
|
|
cb74de9ea1 | ||
|
|
2ba9064186 | ||
|
|
fe019fe8a1 | ||
|
|
ed9ea6a619 | ||
|
|
ebf770fd0c | ||
|
|
8ca9a6bf21 | ||
|
|
89308e8358 | ||
|
|
d9b8637fde | ||
|
|
96451c0d03 | ||
|
|
8d2baa17a8 | ||
|
|
f24ef3a4f2 | ||
|
|
6979ce88ca | ||
|
|
bd67ee4aed | ||
|
|
34e62bf3af | ||
|
|
7c8ef33957 | ||
|
|
4a7eb53ecc | ||
|
|
970aba2ebc | ||
|
|
729d7a4d35 | ||
|
|
c3230d1e40 | ||
|
|
33060c85e6 | ||
|
|
1d03bbea38 | ||
|
|
91b6d78bf9 | ||
|
|
43125e461e | ||
|
|
6aa2e9ad06 | ||
|
|
f034dba42b | ||
|
|
5d185f91e6 | ||
|
|
2745352940 | ||
|
|
4af230007f | ||
|
|
5b77729006 | ||
|
|
f663a4d9a2 | ||
|
|
4c297865db | ||
|
|
7febaa084f | ||
|
|
7407708025 | ||
|
|
0181865985 | ||
|
|
cb8ade66a5 | ||
|
|
c2f4b8aaa6 | ||
|
|
df099a6587 | ||
|
|
294a1f2bdb | ||
|
|
6791e830fa | ||
|
|
dbf34dfd03 | ||
|
|
4e13a133ea | ||
|
|
74d6ad3ed0 | ||
|
|
bbe2db3e87 | ||
|
|
6a5e37d9d6 | ||
|
|
a46c8eac31 | ||
|
|
4178971111 | ||
|
|
4d30751614 | ||
|
|
d1949adc9e | ||
|
|
84b08ca168 | ||
|
|
a740bf3c3b | ||
|
|
01bf6eb912 | ||
|
|
68808cfd0c | ||
|
|
17154f2819 | ||
|
|
eae5ec5706 | ||
|
|
e3d56940db | ||
|
|
0c7d95d6d3 | ||
|
|
935a4b2ecb | ||
|
|
00dec45b55 | ||
|
|
bc164ee2ad | ||
|
|
8638e736da | ||
|
|
5cc39843fd | ||
|
|
44e48ee939 | ||
|
|
9021f3476e | ||
|
|
13213f8656 | ||
|
|
54fbf38afa | ||
|
|
522b554897 | ||
|
|
62f7cd833a | ||
|
|
862d5979e7 | ||
|
|
8be6367956 | ||
|
|
ad288c772f | ||
|
|
50c01bf69b | ||
|
|
a97ee4145e | ||
|
|
aefea6bfc8 | ||
|
|
fce01302f5 | ||
|
|
8fd60081eb | ||
|
|
ab1734835d | ||
|
|
4ccded750d | ||
|
|
722ca7c27c | ||
|
|
684a44068c | ||
|
|
a266871335 | ||
|
|
c010a0b14a | ||
|
|
05f8f5552b | ||
|
|
2e03b45de9 | ||
|
|
bf5a465b98 | ||
|
|
f75e8f187c | ||
|
|
fdfaa45629 | ||
|
|
45be6e8ee4 | ||
|
|
07478d898d | ||
|
|
0efe9ae6a4 | ||
|
|
4aa0f4cc79 | ||
|
|
cedc14f60f | ||
|
|
35e581613a | ||
|
|
2e2d7530db | ||
|
|
ff86174c92 | ||
|
|
af7212f28e | ||
|
|
ffba359e78 | ||
|
|
d8aeb35a82 | ||
|
|
aa44132a56 | ||
|
|
6b950395bd | ||
|
|
9079813c8d | ||
|
|
bbaa241ec0 | ||
|
|
6fbaf2fb82 | ||
|
|
95375f8de8 | ||
|
|
1c775ce373 | ||
|
|
6e4dbcf59b | ||
|
|
58c43024cd | ||
|
|
988c8b580a | ||
|
|
90ed06b783 | ||
|
|
7a80c50ab3 | ||
|
|
e15de852fa | ||
|
|
d620623abe | ||
|
|
805eb6963f | ||
|
|
f3a738b8da | ||
|
|
d5656c255f | ||
|
|
9d0f7a491f | ||
|
|
1ec49dd2da | ||
|
|
09950c6a67 | ||
|
|
5457679954 | ||
|
|
58c762062a | ||
|
|
a754c0f934 | ||
|
|
e12bb3e533 | ||
|
|
2e078f85c6 | ||
|
|
b19258ab77 | ||
|
|
f1d005b241 | ||
|
|
a5db5d2557 | ||
|
|
2044ceb8c0 | ||
|
|
3b9d06a6b3 | ||
|
|
0c63b65c1e | ||
|
|
ef58c25d3f | ||
|
|
a7f2fd22b6 | ||
|
|
86a057f17e | ||
|
|
ecdcbdbfdf | ||
|
|
a3aaea4c9c | ||
|
|
b4560afed5 | ||
|
|
cfb9e5e0c6 | ||
|
|
1da4a1acb8 | ||
|
|
81c1254c29 | ||
|
|
ab92098d09 | ||
|
|
6f87fbc8c1 | ||
|
|
0b33e4fa25 | ||
|
|
3146122771 | ||
|
|
d513f1e7ab | ||
|
|
2cf4942e54 | ||
|
|
6e808eef58 | ||
|
|
13e19e7b85 | ||
|
|
b21c5ecc11 | ||
|
|
b6e84319a4 | ||
|
|
30ff136cac | ||
|
|
b103dd4583 | ||
|
|
69c5beaa15 | ||
|
|
6a1fbf0637 | ||
|
|
e30feffa2b | ||
|
|
de61b461ca | ||
|
|
b2bde1c080 | ||
|
|
76a3781990 | ||
|
|
456622067a | ||
|
|
af30d7a749 | ||
|
|
828d0a30a1 | ||
|
|
a73b5578de | ||
|
|
a95a5f7140 | ||
|
|
84e45db213 | ||
|
|
ad08fe6178 | ||
|
|
9fa48229a5 | ||
|
|
82241eb162 | ||
|
|
919ac0c1ea | ||
|
|
4616ecd18f | ||
|
|
500db0c5ff | ||
|
|
fa53e32c9a | ||
|
|
47d889615e | ||
|
|
c5b311ccb0 | ||
|
|
294dea3e6a | ||
|
|
92f0c91d2d | ||
|
|
dcfbe8e752 | ||
|
|
878d2be5bb | ||
|
|
f04265ee6b | ||
|
|
3c307190a8 | ||
|
|
4c222760bc | ||
|
|
c2b83e39f3 | ||
|
|
b7a025ff15 | ||
|
|
f56cdc2cab | ||
|
|
4e390e0432 | ||
|
|
b25fff7dac | ||
|
|
8162084251 | ||
|
|
d3d94046e6 | ||
|
|
af044ceeff | ||
|
|
4b4da4cdab | ||
|
|
689a5a65c8 | ||
|
|
6366a00e54 | ||
|
|
4b019c6ab1 | ||
|
|
1a73aa6478 | ||
|
|
7c94affc93 | ||
|
|
4077517ac6 | ||
|
|
a83959df53 | ||
|
|
4e449bf576 | ||
|
|
57746486d4 | ||
|
|
cd1adb7575 | ||
|
|
aeb5a50a07 | ||
|
|
567e5fb3c0 | ||
|
|
29ddaa0120 | ||
|
|
9214fc4074 | ||
|
|
6399f836fd | ||
|
|
a3ec7a7aef | ||
|
|
247a211559 | ||
|
|
d54f418555 | ||
|
|
21601766e6 | ||
|
|
57c3ce69ec | ||
|
|
f72bbcb999 | ||
|
|
3a11bec690 | ||
|
|
bf3e39bc7c | ||
|
|
fe40dac890 |
No files matched your search
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:noble@sha256:a08e551cb33850e4740772b38217fc1796a66da2506d312abe51acda354ff061
|
||||
FROM ubuntu:noble@sha256:66460d557b25769b102175144d538d88219c077c678a49af4afca6fbfc1b5252
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ steps:
|
||||
commands:
|
||||
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
|
||||
- sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle
|
||||
- sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle.kts
|
||||
- scripts/wait_for_emulator.sh
|
||||
- scripts/runAllScreenshotCombinations noCI false
|
||||
- scripts/screenshotSummary.sh
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -27,6 +27,7 @@ concurrency:
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Disabled on forks
|
||||
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
|
||||
@@ -51,13 +52,13 @@ jobs:
|
||||
echo "repo=${{ github.event.pull_request.head.repo.full_name }}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -70,10 +71,9 @@ jobs:
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.caching=true"
|
||||
echo "org.gradle.parallel=true"
|
||||
echo "org.gradle.jvmargs=-Xmx5g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.configureondemand=true"
|
||||
echo "org.gradle.configuration-cache=false"
|
||||
echo "kapt.incremental.apt=true"
|
||||
} > "$HOME/.gradle/gradle.properties"
|
||||
scripts/analysis/analysis-wrapper.sh "${{ steps.get-vars.outputs.branch }}" "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" "$GITHUB_RUN_NUMBER" "${{ steps.get-vars.outputs.pr }}"
|
||||
@@ -22,13 +22,13 @@ jobs:
|
||||
matrix:
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
- uses: gradle/actions/wrapper-validation@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
|
||||
- uses: gradle/actions/wrapper-validation@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
|
||||
|
||||
@@ -22,9 +22,9 @@ jobs:
|
||||
matrix:
|
||||
task: [ detekt, spotlessKotlinCheck ]
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set Swap Space
|
||||
@@ -43,11 +43,11 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
|
||||
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -57,4 +57,4 @@ jobs:
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
|
||||
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||
@@ -20,9 +20,9 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
#
|
||||
|
||||
## This file is intended to be sourced by other scripts
|
||||
|
||||
|
||||
function err() {
|
||||
echo >&2 "$@"
|
||||
}
|
||||
|
||||
|
||||
function curl_gh() {
|
||||
if [[ -n "$GITHUB_TOKEN" ]]
|
||||
then
|
||||
curl \
|
||||
--silent \
|
||||
--header "Authorization: token $GITHUB_TOKEN" \
|
||||
"$@"
|
||||
else
|
||||
err "WARNING: No GITHUB_TOKEN found. Skipping API call"
|
||||
fi
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
SPDX-FileCopyrightText: 2019-2025 Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
+46
-44
@@ -1,53 +1,55 @@
|
||||
# SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]e>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
|
||||
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]e>
|
||||
# SPDX-License-Identifier: MIT
|
||||
name: "QA"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
pull_request:
|
||||
branches: [ main, master, stable-* ]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: qa-build-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
group: qa-build-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
qa:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check if secrets are available
|
||||
run: echo "ok=${{ secrets.KS_PASS != '' }}" >> "$GITHUB_OUTPUT"
|
||||
id: check-secrets
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
- name: Build QA
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
KS_PASS: ${{ secrets.KS_PASS }}
|
||||
KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
|
||||
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
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
|
||||
echo "kapt.incremental.apt=true" >> $HOME/.gradle/gradle.properties
|
||||
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" app/build.gradle
|
||||
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" app/build.gradle
|
||||
./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 scripts/QA_keystore.jks app/build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD ${{github.event.number}} ${{github.event.number}} $GITHUB_TOKEN
|
||||
qa:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check if secrets are available
|
||||
run: echo "ok=${{ secrets.KS_PASS != '' }}" >> "$GITHUB_OUTPUT"
|
||||
id: check-secrets
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
- name: Build QA
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
KS_PASS: ${{ secrets.KS_PASS }}
|
||||
KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
|
||||
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
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; org.gradle.parallel=true; org.gradle.configureondemand=true; kapt.incremental.apt=true" >> "$HOME/.gradle/gradle.properties"
|
||||
sed -i "/qa/,/\}/ s/versionCode.*/versionCode = ${{ github.event.number }}/" 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
|
||||
.github/workflows/uploadArtifact.sh "$LOG_USERNAME" "$LOG_PASSWORD" "${{github.event.number}}" "${{github.event.number}}" "$GITHUB_TOKEN"
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: REUSE Compliance Check
|
||||
uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5.0.0
|
||||
uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 # v6.0.0
|
||||
@@ -29,12 +29,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
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@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
|
||||
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -25,17 +25,17 @@ jobs:
|
||||
color: [ blue ]
|
||||
api-level: [ 27 ]
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.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@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -102,7 +102,7 @@ jobs:
|
||||
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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
|
||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
|
||||
with:
|
||||
days-before-stale: 28
|
||||
days-before-close: 14
|
||||
|
||||
@@ -21,9 +21,9 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
|
||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
||||
- name: Run unit tests with coverage
|
||||
run: ./gradlew jacocoTestGplayDebugUnitTest
|
||||
- name: Upload failing results
|
||||
@@ -42,14 +42,14 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
|
||||
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
fail_ci_if_error: true
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/tests/testGplayDebugUnitTest/
|
||||
@@ -20,24 +20,25 @@ PR=$4
|
||||
GITHUB_TOKEN=$5
|
||||
DAV_URL=https://nextcloud.kaminsky.me/remote.php/dav/files/$USER/android-artifacts/
|
||||
|
||||
source scripts/lib.sh
|
||||
source .github/workflows/lib.sh
|
||||
REPO=$(cat scripts/repo)
|
||||
|
||||
if ! test -e app/build/outputs/apk/qa/debug/qa-debug-*.apk ; then
|
||||
if ! test -e app/build/outputs/apk/qa/debug/*qa-debug*.apk ; then
|
||||
exit 1
|
||||
fi
|
||||
echo "Uploaded artifact to $DAV_URL/$BUILD.apk"
|
||||
|
||||
# delete all old comments, starting with "APK file:"
|
||||
oldComments=$(curl_gh -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
oldComments=$(curl_gh -X GET https://api.github.com/repos/nextcloud/$REPO/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
curl_gh -X DELETE https://api.github.com/repos/nextcloud/$REPO/issues/comments/$comment
|
||||
done
|
||||
|
||||
sudo apt-get -y install qrencode
|
||||
|
||||
qrencode -o $PR.png "$PUBLIC_URL/$BUILD.apk"
|
||||
|
||||
curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file app/build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.png --upload-file $PR.png
|
||||
curl_gh -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD.apk <br/><br/>  <br/><br/>To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app. \" }"
|
||||
curl_gh -X POST https://api.github.com/repos/nextcloud/$REPO/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD.apk <br/><br/>  <br/><br/>To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app. \" }"
|
||||
@@ -1,3 +1,95 @@
|
||||
## 3.33.0 (September 10, 2025)
|
||||
|
||||
- Migrate to Glide 4
|
||||
- Performance improvements
|
||||
- Fix gallery image scaling
|
||||
- Bugfixes
|
||||
|
||||
Minimum: NC 18 Server, Android 8.1 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/112
|
||||
|
||||
## 3.32.3 (August 21, 2025)
|
||||
|
||||
- Bugfixes
|
||||
|
||||
Minimum: NC 18 Server, Android 8.0 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/114
|
||||
|
||||
## 3.32.2 (July 18, 2025)
|
||||
|
||||
- Resolved image blurriness issue.
|
||||
- Fixed crash occurring in the conflict resolution dialog.
|
||||
- Addressed crash in the upload finish receiver event handler.
|
||||
|
||||
Minimum: NC 18 Server, Android 8.0 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/115
|
||||
|
||||
## 3.32.1 (July 14, 2025)
|
||||
|
||||
- Bug fixes.
|
||||
|
||||
Minimum: NC 18 Server, Android 8.0 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/113
|
||||
|
||||
## 3.32.0 (July 2, 2025)
|
||||
|
||||
- Minimum supported Android version is 8.0.
|
||||
- Scrolling performance has been increased in the media tab.
|
||||
- Multi-select feature added to the media tab.
|
||||
- Custom share permissions have been added.
|
||||
- Bug fixes.
|
||||
|
||||
Minimum: NC 18 Server, Android 8.0 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/107
|
||||
|
||||
## 3.31.4 (June 3, 2025)
|
||||
|
||||
- Add missing auto migration
|
||||
|
||||
Minimum: NC 18 Server, Android 7.1 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/110
|
||||
|
||||
## 3.31.3 (May 28, 2025)
|
||||
|
||||
- fix simple sign up
|
||||
- bugfixes
|
||||
- update translations
|
||||
|
||||
Minimum: NC 18 Server, Android 7.1 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/110
|
||||
|
||||
## 3.31.2 (May 20, 2025)
|
||||
|
||||
- bring back MANAGE_EXTERNAL_STORAGE permission
|
||||
|
||||
Minimum: NC 18 Server, Android 7.1 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/108
|
||||
|
||||
## 3.31.1 (April 3, 2025)
|
||||
|
||||
- Various bug fixes and performance enhancements
|
||||
|
||||
Minimum: NC 18 Server, Android 7.1 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/108
|
||||
|
||||
## 3.31.0 (February 25, 2025)
|
||||
|
||||
- New share layout
|
||||
- Various bug fixes and performance enhancements
|
||||
|
||||
Minimum: NC 18 Server, Android 7.1 Nougat
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/100
|
||||
|
||||
## 3.30.7 (January 6, 2025)
|
||||
|
||||
- Fix crash of auto upload settings
|
||||
|
||||
@@ -12,6 +12,9 @@ height="80">](https://play.google.com/store/apps/details?id=com.nextcloud.client
|
||||
[<img src="https://f-droid.org/badge/get-it-on.png"
|
||||
alt="Get it on F-Droid"
|
||||
height="80">](https://f-droid.org/packages/com.nextcloud.client/)
|
||||
[<img src="https://github.com/user-attachments/assets/713d71c5-3dec-4ec4-a3f2-8d28d025a9c6"
|
||||
alt="Get it with Obtainium"
|
||||
height="80">](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22com.nextcloud.client%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fnextcloud%2Fandroid%22%2C%22author%22%3A%22nextcloud%22%2C%22name%22%3A%22Nextcloud%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22includePrereleases%5C%22%3Afalse%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22filterReleaseNotesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22sortMethodChoice%5C%22%3A%5C%22date%5C%22%2C%5C%22useLatestAssetDateAsReleaseDate%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%2C%5C%22trackOnly%5C%22%3Afalse%2C%5C%22versionExtractionRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22matchGroupToUse%5C%22%3A%5C%22%5C%22%2C%5C%22versionDetection%5C%22%3Atrue%2C%5C%22releaseDateAsVersion%5C%22%3Afalse%2C%5C%22useVersionCodeAsOSVersion%5C%22%3Afalse%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Enextcloud.*%5C%22%2C%5C%22invertAPKFilter%5C%22%3Afalse%2C%5C%22autoApkFilterByArch%5C%22%3Atrue%2C%5C%22appName%5C%22%3A%5C%22%5C%22%2C%5C%22appAuthor%5C%22%3A%5C%22%5C%22%2C%5C%22shizukuPretendToBeGooglePlay%5C%22%3Afalse%2C%5C%22allowInsecure%5C%22%3Afalse%2C%5C%22exemptFromBackgroundUpdates%5C%22%3Afalse%2C%5C%22skipUpdateNotifications%5C%22%3Afalse%2C%5C%22about%5C%22%3A%5C%22Nextcloud%20ist%20eine%20Cloudanwendung%2C%20die%20selbst%20gehostet%20werden%20kann.%5C%22%2C%5C%22refreshBeforeDownload%5C%22%3Atrue%7D%22%2C%22overrideSource%22%3Anull%7D)
|
||||
|
||||
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK:
|
||||
- APK with "gplay" name, found [here](https://github.com/nextcloud/android/releases) or distributed via Google Play Store
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<!--
|
||||
~ SPDX-FileCopyrightText: 2025 Saeed <[email protected]>
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
-->
|
||||
# تطبيق [Nextcloud](https://nextcloud.com)لأجهزة أندرويد 📱
|
||||
|
||||
[](https://api.reuse.software/info/github.com/nextcloud/android)
|
||||
[](https://drone.nextcloud.com/nextcloud/android)
|
||||
[](https://app.codacy.com/gh/nextcloud/android/dashboard)
|
||||
[](https://github.com/nextcloud/android/releases/latest)
|
||||
|
||||
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" alt="تحميل من Google Play" height="80">](https://play.google.com/store/apps/details?id=com.nextcloud.client)
|
||||
[<img src="https://f-droid.org/badge/get-it-on.png" alt="احصل عليه من F-Droid" height="80">](https://f-droid.org/packages/com.nextcloud.client/)
|
||||
|
||||
## التحقق من توقيع التطبيق 🔐
|
||||
|
||||
للتأكد من صحة ملف APK:
|
||||
|
||||
- ملف APK باسم "gplay" متوفر [هنا](https://github.com/nextcloud/android/releases) أو عبر متجر Google Play
|
||||
- ملف APK باسم "nextcloud" متوفر [هنا](https://github.com/nextcloud/android/releases)
|
||||
- غير مناسب لتحميلات F-Droid، لأن F-Droid يقوم بتوقيعه بنفسه
|
||||
|
||||
```plaintext
|
||||
SHA-256: fb009522f65e25802261b67b10a45fd70e610031976f40b28a649e152ded0373
|
||||
SHA-1: 74aa1702e714941be481e1f7ce4a8f779c19dcea
|
||||
```
|
||||
|
||||
**تطبيق Nextcloud لأندرويد يتيح لك إدارة بياناتك بسهولة على خادم Nextcloud الخاص بك.**
|
||||
|
||||
## الحصول على الدعم 🆘
|
||||
|
||||
إذا واجهت مشكلة أو لديك سؤال، يمكنك زيارة [منتدى الدعم](https://help.nextcloud.com/c/clients/android).
|
||||
إذا اكتشفت خطأ أو لديك اقتراح لتحسين التطبيق، يمكنك [فتح قضية جديدة على GitHub](https://github.com/nextcloud/android/issues).
|
||||
|
||||
إذا لم تكن متأكدًا ما إذا كانت المشكلة ناتجة عن التطبيق أو الإعدادات أو الخادم، فابدأ بالسؤال في المنتدى، ثم عد إلى GitHub إذا لزم الأمر.
|
||||
|
||||
> ملاحظة: هذا المستودع خاص بتطبيق أندرويد فقط. إذا كانت المشكلة في الخادم، يرجى التواصل مع [فريق خادم Nextcloud](https://github.com/nextcloud/server).
|
||||
|
||||
## كيف تساهم في المشروع 🚀
|
||||
|
||||
هناك العديد من الطرق للمساهمة، سواء كنت مبرمجًا أو لا:
|
||||
|
||||
- مساعدة المستخدمين في المنتدى: https://help.nextcloud.com
|
||||
- ترجمة التطبيق عبر [Transifex](https://app.transifex.com/nextcloud/nextcloud/android/)
|
||||
- الإبلاغ عن المشاكل أو تقديم اقتراحات عبر [GitHub Issues](https://github.com/nextcloud/android/issues/new/choose)
|
||||
- تنفيذ إصلاحات أو تحسينات عبر Pull Requests
|
||||
- مراجعة [طلبات الدمج](https://github.com/nextcloud/android/pulls)
|
||||
- اختبار النسخ التجريبية أو اليومية أو المرشحة للإصدار
|
||||
- تحسين [التوثيق](https://github.com/nextcloud/documentation/)
|
||||
- اختبار الميزات الأساسية في آخر إصدار مستقر
|
||||
- تعلم كيفية جمع سجلات الأخطاء (logcat) لتقديم تقارير دقيقة
|
||||
|
||||
## إرشادات المساهمة والترخيص 📜
|
||||
|
||||
- الترخيص: [GPLv2](https://github.com/nextcloud/android/blob/master/LICENSE.txt)
|
||||
- جميع المساهمات بعد 16 يونيو 2016 تعتبر مرخصة تحت AGPLv3 أو أي إصدار لاحق
|
||||
- لا حاجة لتوقيع اتفاقية مساهم (CLA)
|
||||
- يُفضل إضافة السطر التالي في رأس الملف عند إجراء تغييرات كبيرة:
|
||||
|
||||
```plaintext
|
||||
SPDX-FileCopyrightText: <السنة> <اسمك> <بريدك الإلكتروني>
|
||||
```
|
||||
|
||||
يرجى قراءة [مدونة السلوك](https://nextcloud.com/community/code-of-conduct/) لضمان بيئة تعاون إيجابية.
|
||||
راجع أيضًا [إرشادات المساهمة](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## ابدأ بالمساهمة 🔧
|
||||
|
||||
- اقرأ [SETUP.md](https://github.com/nextcloud/android/blob/master/SETUP.md) و[CONTRIBUTING.md](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md)
|
||||
- قم بعمل fork للمستودع وابدأ بإرسال Pull Requests إلى فرع master
|
||||
- يمكنك البدء بمراجعة [طلبات الدمج](https://github.com/nextcloud/android/pulls) أو العمل على [القضايا المبتدئة](https://github.com/nextcloud/android/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
|
||||
|
||||
## جمع سجلات الأخطاء (logcat) 🔍
|
||||
|
||||
### على لينكس:
|
||||
|
||||
- فعّل USB-Debugging على هاتفك
|
||||
- افتح الطرفية وأدخل:
|
||||
|
||||
```bash
|
||||
adb logcat --pid=$(adb shell pidof -s 'com.nextcloud.client') > logcatOutput.txt
|
||||
```
|
||||
|
||||
> تأكد من تثبيت [adb](https://developer.android.com/studio/releases/platform-tools.html)
|
||||
|
||||
### على ويندوز:
|
||||
|
||||
- حمّل [Minimal ADB and Fastboot](https://forum.xda-developers.com/t/tool-minimal-adb-and-fastboot-2-9-18.2317790/#post-42407269)
|
||||
- فعّل USB-Debugging
|
||||
- افتح البرنامج وأدخل:
|
||||
|
||||
```bash
|
||||
adb shell pidof -s 'com.nextcloud.client'
|
||||
```
|
||||
|
||||
- استخدم الناتج كـ `<processID>` في الأمر التالي:
|
||||
|
||||
```bash
|
||||
adb logcat --pid=<processID> > "%USERPROFILE%\Downloads\logcatOutput.txt"
|
||||
```
|
||||
|
||||
### على الجهاز (مع صلاحيات root):
|
||||
|
||||
```bash
|
||||
su
|
||||
logcat -d --pid $(pidof -s com.nextcloud.client) -f /sdcard/logcatOutput.txt
|
||||
```
|
||||
|
||||
أو استخدم تطبيقات مثل [CatLog](https://play.google.com/store/apps/details?id=com.nolanlawson.logcat) أو [aLogcat](https://play.google.com/store/apps/details?id=org.jtb.alogcat)
|
||||
|
||||
## النسخة التطويرية 🛠️
|
||||
|
||||
- [تحميل مباشر للـ APK](https://download.nextcloud.com/android/dev/latest.apk)
|
||||
- [F-Droid النسخة التجريبية](https://f-droid.org/en/packages/com.nextcloud.android.beta/)
|
||||
|
||||
## المشاكل المعروفة والأسئلة الشائعة
|
||||
|
||||
### الإشعارات الفورية لا تعمل في نسخ F-Droid
|
||||
|
||||
بسبب اعتمادها على خدمات Google Play، لا تعمل الإشعارات الفورية في نسخ F-Droid حاليًا.
|
||||
@@ -1,535 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2024 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2024 Andy Scherzinger <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
import com.github.spotbugs.snom.Confidence
|
||||
import com.github.spotbugs.snom.Effort
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:$androidPluginVersion"
|
||||
classpath libs.spotbugs.gradle.plugin
|
||||
classpath libs.kotlin.gradle.plugin
|
||||
classpath libs.detekt.gradle.plugin
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath "com.karumi:shot:6.1.0"
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.spotless)
|
||||
alias(libs.plugins.kapt)
|
||||
alias(libs.plugins.ksp) apply false
|
||||
}
|
||||
|
||||
apply plugin: "com.android.application"
|
||||
|
||||
apply plugin: "kotlin-android"
|
||||
apply plugin: "kotlin-parcelize"
|
||||
apply plugin: "checkstyle"
|
||||
apply plugin: "pmd"
|
||||
apply from: "$rootProject.projectDir/jacoco.gradle"
|
||||
apply plugin: "com.github.spotbugs"
|
||||
apply plugin: "io.gitlab.arturbosch.detekt"
|
||||
|
||||
// needed to make renovate run without shot, as shot requires Android SDK
|
||||
// https://github.com/pedrovgs/Shot/issues/300
|
||||
if (shotTest) {
|
||||
apply plugin: "shot"
|
||||
}
|
||||
apply plugin: "com.google.devtools.ksp"
|
||||
|
||||
|
||||
println "Gradle uses Java ${Jvm.current()}"
|
||||
|
||||
configurations {
|
||||
configureEach {
|
||||
exclude group: "org.jetbrains", module: "annotations-java5" // via prism4j, already using annotations explicitly
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy.eachDependency {
|
||||
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
|
||||
useVersion(checkerVersion)
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 33
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
|
||||
def ndkEnv = new HashMap<String, String>()
|
||||
file("$project.rootDir/ndk.env").readLines().each() {
|
||||
def (key, value) = it.tokenize("=")
|
||||
ndkEnv.put(key, value)
|
||||
}
|
||||
|
||||
def perfAnalysis = project.hasProperty("perfAnalysis")
|
||||
|
||||
def getConfigProperties() {
|
||||
def props = new Properties()
|
||||
def file = rootProject.file(".gradle/config.properties")
|
||||
if (file.exists()) {
|
||||
props.load(new FileInputStream(file))
|
||||
}
|
||||
return props
|
||||
}
|
||||
|
||||
def configProps = getConfigProperties()
|
||||
|
||||
android {
|
||||
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
|
||||
ndkVersion = "${ndkEnv.get("NDK_VERSION")}"
|
||||
|
||||
|
||||
namespace = "com.owncloud.android"
|
||||
testNamespace = "${namespace}.test"
|
||||
|
||||
androidResources {
|
||||
generateLocaleConfig = true
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.nextcloud.client"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
compileSdk = 35
|
||||
|
||||
buildConfigField "boolean", "CI", ciBuild.toString()
|
||||
buildConfigField "boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString()
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
if (shotTest) {
|
||||
testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
|
||||
} else {
|
||||
testInstrumentationRunner "com.nextcloud.client.TestRunner"
|
||||
}
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
|
||||
testInstrumentationRunnerArguments disableAnalytics: "true"
|
||||
|
||||
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
|
||||
if (versionBuild > 89) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
} else if (versionBuild > 50) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
|
||||
} else {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
flavorDimensions += "default"
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
buildConfigField "String", "NC_TEST_SERVER_DATA_STRING", "\"\""
|
||||
}
|
||||
|
||||
debug {
|
||||
testCoverageEnabled = project.hasProperty("coverage")
|
||||
resConfigs "xxxhdpi"
|
||||
|
||||
buildConfigField "String", "NC_TEST_SERVER_DATA_STRING", "\"nc://login/user:${configProps['NC_TEST_SERVER_USERNAME']}&password:${configProps['NC_TEST_SERVER_PASSWORD']}&server:${configProps['NC_TEST_SERVER_BASEURL']}\""
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
generic {
|
||||
applicationId "com.nextcloud.client"
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
gplay {
|
||||
applicationId "com.nextcloud.client"
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
huawei {
|
||||
applicationId "com.nextcloud.client"
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20220322
|
||||
versionName "20220322"
|
||||
}
|
||||
|
||||
qa {
|
||||
applicationId "com.nextcloud.android.qa"
|
||||
dimension "default"
|
||||
versionCode 1
|
||||
versionName "1"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
animationsDisabled = true
|
||||
}
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += "META-INF/LICENSE*"
|
||||
excludes += "META-INF/versions/9/OSGI-INF/MANIFEST*"
|
||||
pickFirst "MANIFEST.MF" // workaround for duplicated manifest on some dependencies
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkstyle", Checkstyle) {
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
|
||||
source "src"
|
||||
include "**/*.java"
|
||||
exclude "**/gen/**"
|
||||
classpath = files()
|
||||
}
|
||||
|
||||
tasks.register("pmd", Pmd) {
|
||||
ruleSetFiles = files("${project.rootDir}/ruleset.xml")
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = []
|
||||
|
||||
source "src"
|
||||
include "**/*.java"
|
||||
exclude "**/gen/**"
|
||||
|
||||
reports {
|
||||
xml {
|
||||
destination = layout.buildDirectory.file("reports/pmd/pmd.xml").get().asFile
|
||||
}
|
||||
html {
|
||||
destination = layout.buildDirectory.file("reports/pmd/pmd.html").get().asFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn "checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt"
|
||||
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
aidl = true
|
||||
compose = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError = false
|
||||
checkGeneratedSources = true
|
||||
disable "MissingTranslation", "GradleDependency", "VectorPath", "IconMissingDensityFolder", "IconDensities", "GoogleAppIndexingWarning", "MissingDefaultResource", "InvalidPeriodicWorkRequestInterval", "StringFormatInvalid", "MissingQuantity"
|
||||
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
|
||||
htmlReport = true
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
// Adds exported schema location as test app assets.
|
||||
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
||||
}
|
||||
|
||||
kapt {
|
||||
useBuildCache = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: "org.ogce", module: "xpp3" // unused in Android and brings wrong Junit version
|
||||
}
|
||||
|
||||
// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
|
||||
implementation libs.splashscreen
|
||||
|
||||
// Jetpack Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.graphics)
|
||||
implementation(libs.compose.material3)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
|
||||
// Media3
|
||||
implementation libs.media3.ui
|
||||
implementation libs.media3.session
|
||||
implementation libs.media3.exoplayer
|
||||
implementation libs.media3.datasource
|
||||
|
||||
// Room
|
||||
implementation libs.room.runtime
|
||||
ksp "androidx.room:room-compiler:$roomVersion"
|
||||
androidTestImplementation libs.room.testing
|
||||
|
||||
// Espresso
|
||||
androidTestImplementation libs.espresso.core
|
||||
androidTestImplementation libs.espresso.contrib
|
||||
androidTestImplementation libs.espresso.web
|
||||
androidTestImplementation libs.espresso.accessibility
|
||||
androidTestImplementation libs.espresso.intents
|
||||
androidTestImplementation libs.espresso.idling.resource
|
||||
|
||||
// Glide
|
||||
implementation libs.glide
|
||||
ksp libs.ksp
|
||||
|
||||
compileOnly "org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2"
|
||||
// remove after entire switch to lib v2
|
||||
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
implementation "org.apache.jackrabbit:jackrabbit-webdav:2.13.5" // remove after entire switch to lib v2
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.2.1"
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
implementation "com.google.android.material:material:1.12.0"
|
||||
implementation "com.jakewharton:disklrucache:2.0.2"
|
||||
implementation "androidx.appcompat:appcompat:$appCompatVersion"
|
||||
implementation "androidx.webkit:webkit:1.14.0"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation "androidx.exifinterface:exifinterface:1.4.1"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.2"
|
||||
implementation "androidx.lifecycle:lifecycle-service:2.9.2"
|
||||
implementation "androidx.work:work-runtime:$workRuntime"
|
||||
implementation "androidx.work:work-runtime-ktx:$workRuntime"
|
||||
implementation "androidx.fragment:fragment-ktx:1.8.8"
|
||||
implementation "com.github.albfernandez:juniversalchardet:2.5.0" // need this version for Android <7
|
||||
compileOnly "com.google.code.findbugs:annotations:3.0.1u2"
|
||||
implementation "commons-io:commons-io:2.20.0"
|
||||
implementation "org.greenrobot:eventbus:3.3.1"
|
||||
implementation "com.googlecode.ez-vcard:ez-vcard:0.12.1"
|
||||
implementation "org.lukhnos:nnio:0.3.1"
|
||||
implementation "org.bouncycastle:bcpkix-jdk18on:1.81"
|
||||
implementation "com.google.code.gson:gson:2.13.1"
|
||||
implementation "com.github.nextcloud-deps:sectioned-recyclerview:0.6.1"
|
||||
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.29"
|
||||
implementation "com.github.nextcloud-deps:qrcodescanner:0.1.2.4" // "com.github.blikoon:QRCodeScanner:0.1.2"
|
||||
implementation "com.google.android.flexbox:flexbox:3.0.0"
|
||||
|
||||
implementation "com.caverock:androidsvg:1.4"
|
||||
implementation "androidx.annotation:annotation:1.9.1"
|
||||
implementation "com.vanniktech:emoji-google:0.21.0"
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.2")
|
||||
|
||||
// document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
gplayImplementation project(":appscan")
|
||||
huaweiImplementation project(":appscan")
|
||||
qaImplementation project(":appscan")
|
||||
|
||||
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0"
|
||||
spotbugsPlugins "com.mebigfatguy.fb-contrib:fb-contrib:7.6.12"
|
||||
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
implementation "com.google.dagger:dagger-android:$daggerVersion"
|
||||
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
implementation "org.conscrypt:conscrypt-android:2.5.3"
|
||||
|
||||
implementation "me.zhanghai.android.fastscroll:library:1.3.0"
|
||||
|
||||
// Shimmer animation
|
||||
implementation "io.github.elye:loaderviewlibrary:3.0.0"
|
||||
|
||||
// dependencies for markdown rendering
|
||||
implementation "io.noties.markwon:core:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-tables:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-tasklist:$markwonVersion"
|
||||
implementation "io.noties.markwon:html:$markwonVersion"
|
||||
|
||||
implementation "io.noties.markwon:syntax-highlight:$markwonVersion"
|
||||
implementation "io.noties:prism4j:$prismVersion"
|
||||
kapt "io.noties:prism4j-bundler:$prismVersion"
|
||||
|
||||
// dependencies for image cropping and rotation
|
||||
implementation "com.vanniktech:android-image-cropper:4.6.0"
|
||||
|
||||
implementation "org.osmdroid:osmdroid-android:6.1.20"
|
||||
|
||||
implementation("org.mnode.ical4j:ical4j:3.0.0") {
|
||||
["org.apache.commons", "commons-logging"].each {
|
||||
exclude group: "$it"
|
||||
}
|
||||
}
|
||||
|
||||
if (perfAnalysis) {
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:2.14"
|
||||
}
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation "junit:junit:4.13.2"
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
testImplementation "androidx.test:core:$androidxTestVersion"
|
||||
testImplementation "org.json:json:20250517"
|
||||
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
testImplementation "io.mockk:mockk:$mockkVersion"
|
||||
testImplementation "io.mockk:mockk-android:$mockkVersion"
|
||||
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation "androidx.test.ext:junit:1.2.1"
|
||||
androidTestImplementation "androidx.test:rules:$androidxTestVersion"
|
||||
// Android JUnit Runner
|
||||
androidTestImplementation "androidx.test:runner:1.6.2"
|
||||
androidTestUtil "androidx.test:orchestrator:1.5.1"
|
||||
androidTestImplementation "androidx.test:core-ktx:$androidxTestVersion"
|
||||
|
||||
// Mocking support
|
||||
androidTestImplementation "com.github.tmurakami:dexopener:2.0.5" // required to allow mocking on API 27 and older
|
||||
androidTestImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
androidTestImplementation("org.mockito:mockito-android:$mockitoVersion")
|
||||
androidTestImplementation "io.mockk:mockk-android:$mockkVersion"
|
||||
androidTestImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
androidTestImplementation "com.facebook.testing.screenshot:core:0.15.0"
|
||||
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
// androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation "tools.fastlane:screengrab:2.1.1"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
|
||||
// upon each update first test: new registration, receive push
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:24.1.2"
|
||||
gplayImplementation "com.google.android.gms:play-services-base:18.5.0"
|
||||
gplayImplementation "com.google.android.play:review-ktx:2.0.2"
|
||||
|
||||
implementation "com.github.nextcloud.android-common:ui:$androidCommonLibraryVersion"
|
||||
|
||||
implementation "io.coil-kt:coil:2.7.0"
|
||||
}
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy {
|
||||
force "org.objenesis:objenesis:3.4"
|
||||
eachDependency { details ->
|
||||
if ("org.jacoco" == details.requested.group) {
|
||||
details.useVersion "$jacoco_version"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run the compiler as a separate process
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.fork = true
|
||||
|
||||
// Enable Incremental Compilation
|
||||
options.incremental = true
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
// Run tests in parallel
|
||||
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
|
||||
|
||||
// increased logging for tests
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.configureEach { variant ->
|
||||
variant.outputs.configureEach { output -> outputFileName = "${output.baseName}-${variant.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
spotless {
|
||||
kotlin {
|
||||
target "**/*.kt"
|
||||
ktlint()
|
||||
}
|
||||
}
|
||||
|
||||
detekt {
|
||||
config.setFrom("detekt.yml")
|
||||
}
|
||||
|
||||
if (shotTest) {
|
||||
shot {
|
||||
showOnlyFailingTestsInReports = ciBuild
|
||||
// CI environment renders some shadows slightly different from local VMs
|
||||
// Add a 0.5% tolerance to account for that
|
||||
tolerance = ciBuild ? 0.1 : 0
|
||||
}
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "$jacoco_version"
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = Effort.MAX
|
||||
reportLevel = Confidence.valueOf("MEDIUM")
|
||||
}
|
||||
|
||||
tasks.withType(SpotBugsTask){task ->
|
||||
String variantNameCap = task.name.replace("spotbugs", "")
|
||||
String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
|
||||
dependsOn "compile${variantNameCap}Sources"
|
||||
|
||||
classes = fileTree(layout.buildDirectory.get().asFile.toString()+"/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/")
|
||||
excludeFilter = file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml")
|
||||
reports {
|
||||
xml {
|
||||
required = true
|
||||
}
|
||||
html {
|
||||
required = true
|
||||
outputLocation = layout.buildDirectory.file("reports/spotbugs/spotbugs.html").get().asFile
|
||||
stylesheet = "fancy.xsl"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksp {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
}
|
||||
@@ -0,0 +1,518 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Jimly Asshiddiqy <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
@file:Suppress("UnstableApiUsage", "DEPRECATION")
|
||||
|
||||
import com.android.build.gradle.internal.api.ApkVariantOutputImpl
|
||||
import com.github.spotbugs.snom.Confidence
|
||||
import com.github.spotbugs.snom.Effort
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
import com.karumi.shot.ShotExtension
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import java.io.FileInputStream
|
||||
import java.util.Properties
|
||||
|
||||
val shotTest = System.getenv("SHOT_TEST") == "true"
|
||||
val ciBuild = System.getenv("CI") == "true"
|
||||
val perfAnalysis = project.hasProperty("perfAnalysis")
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.spotless)
|
||||
alias(libs.plugins.kapt)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.kotlin.parcelize)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
alias(libs.plugins.spotbugs)
|
||||
alias(libs.plugins.detekt)
|
||||
// needed to make renovate run without shot, as shot requires Android SDK
|
||||
// https://github.com/pedrovgs/Shot/issues/300
|
||||
if (System.getenv("SHOT_TEST") == "true") alias(libs.plugins.shot)
|
||||
id("checkstyle")
|
||||
id("pmd")
|
||||
}
|
||||
apply(from = "${rootProject.projectDir}/jacoco.gradle.kts")
|
||||
|
||||
println("Gradle uses Java ${Jvm.current()}")
|
||||
|
||||
configurations.configureEach {
|
||||
// via prism4j, already using annotations explicitly
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
val versionMajor = 3
|
||||
val versionMinor = 35
|
||||
val versionPatch = 0
|
||||
val versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
val ndkEnv = buildMap {
|
||||
file("${project.rootDir}/ndk.env").readLines().forEach {
|
||||
val (key, value) = it.split("=")
|
||||
put(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
val configProps = Properties().apply {
|
||||
val file = rootProject.file(".gradle/config.properties")
|
||||
if (file.exists()) load(FileInputStream(file))
|
||||
}
|
||||
|
||||
val ncTestServerUsername = configProps["NC_TEST_SERVER_USERNAME"]
|
||||
val ncTestServerPassword = configProps["NC_TEST_SERVER_PASSWORD"]
|
||||
val ncTestServerBaseUrl = configProps["NC_TEST_SERVER_BASEURL"]
|
||||
|
||||
android {
|
||||
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
|
||||
ndkVersion = "${ndkEnv["NDK_VERSION"]}"
|
||||
|
||||
namespace = "com.owncloud.android"
|
||||
testNamespace = "${namespace}.test"
|
||||
|
||||
androidResources.generateLocaleConfig = true
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.nextcloud.client"
|
||||
minSdk = 27
|
||||
targetSdk = 36
|
||||
compileSdk = 36
|
||||
|
||||
buildConfigField("boolean", "CI", ciBuild.toString())
|
||||
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
|
||||
|
||||
javaCompileOptions.annotationProcessorOptions {
|
||||
arguments += mapOf("room.schemaLocation" to "$projectDir/schemas")
|
||||
}
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunner = if (shotTest) "com.karumi.shot.ShotTestRunner"
|
||||
else "com.nextcloud.client.TestRunner"
|
||||
|
||||
testInstrumentationRunnerArguments += mapOf(
|
||||
"TEST_SERVER_URL" to ncTestServerBaseUrl.toString(),
|
||||
"TEST_SERVER_USERNAME" to ncTestServerUsername.toString(),
|
||||
"TEST_SERVER_PASSWORD" to ncTestServerPassword.toString()
|
||||
)
|
||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||
|
||||
versionCode = versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
versionName = when {
|
||||
versionBuild > 89 -> "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
versionBuild > 50 -> "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
|
||||
else -> "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
flavorDimensions += "default"
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"")
|
||||
}
|
||||
|
||||
debug {
|
||||
enableUnitTestCoverage = project.hasProperty("coverage")
|
||||
resConfigs("xxxhdpi")
|
||||
|
||||
buildConfigField(
|
||||
"String",
|
||||
"NC_TEST_SERVER_DATA_STRING",
|
||||
"\"nc://login/user:${ncTestServerUsername}&password:${ncTestServerPassword}&server:${ncTestServerBaseUrl}\""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
register("generic") {
|
||||
applicationId = "com.nextcloud.client"
|
||||
dimension = "default"
|
||||
}
|
||||
|
||||
register("gplay") {
|
||||
applicationId = "com.nextcloud.client"
|
||||
dimension = "default"
|
||||
}
|
||||
|
||||
register("huawei") {
|
||||
applicationId = "com.nextcloud.client"
|
||||
dimension = "default"
|
||||
}
|
||||
|
||||
register("versionDev") {
|
||||
applicationId = "com.nextcloud.android.beta"
|
||||
dimension = "default"
|
||||
versionCode = 20220322
|
||||
versionName = "20220322"
|
||||
}
|
||||
|
||||
register("qa") {
|
||||
applicationId = "com.nextcloud.android.qa"
|
||||
dimension = "default"
|
||||
versionCode = 1
|
||||
versionName = "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applicationVariants.configureEach {
|
||||
outputs.configureEach {
|
||||
if (this is ApkVariantOutputImpl) this.outputFileName = "${this.baseName}-${this.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.isReturnDefaultValues = true
|
||||
animationsDisabled = true
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
packaging.resources {
|
||||
excludes.addAll(listOf("META-INF/LICENSE*", "META-INF/versions/9/OSGI-INF/MANIFEST*"))
|
||||
pickFirsts.add("MANIFEST.MF") // workaround for duplicated manifest on some dependencies
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
aidl = true
|
||||
compose = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError = false
|
||||
checkGeneratedSources = true
|
||||
disable.addAll(
|
||||
listOf(
|
||||
"MissingTranslation",
|
||||
"GradleDependency",
|
||||
"VectorPath",
|
||||
"IconMissingDensityFolder",
|
||||
"IconDensities",
|
||||
"GoogleAppIndexingWarning",
|
||||
"MissingDefaultResource",
|
||||
"InvalidPeriodicWorkRequestInterval",
|
||||
"StringFormatInvalid",
|
||||
"MissingQuantity"
|
||||
)
|
||||
)
|
||||
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
|
||||
htmlReport = true
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
// Adds exported schema location as test app assets.
|
||||
getByName("androidTest") {
|
||||
assets.srcDirs(files("$projectDir/schemas"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
kapt.useBuildCache = true
|
||||
|
||||
ksp.arg("room.schemaLocation", "$projectDir/schemas")
|
||||
|
||||
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
|
||||
|
||||
spotless.kotlin {
|
||||
target("**/*.kt")
|
||||
ktlint()
|
||||
}
|
||||
|
||||
detekt.config.setFrom("detekt.yml")
|
||||
|
||||
if (shotTest) configure<ShotExtension> {
|
||||
showOnlyFailingTestsInReports = ciBuild
|
||||
// CI environment renders some shadows slightly different from local VMs
|
||||
// Add a 0.5% tolerance to account for that
|
||||
tolerance = if (ciBuild) 0.1 else 0.0
|
||||
}
|
||||
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = Effort.MAX
|
||||
reportLevel = Confidence.valueOf("MEDIUM")
|
||||
}
|
||||
|
||||
tasks.register<Checkstyle>("checkstyle") {
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
setConfigProperties(
|
||||
"checkstyleSuppressionsPath" to file("${rootProject.rootDir}/suppressions.xml").absolutePath
|
||||
)
|
||||
source("src")
|
||||
include("**/*.java")
|
||||
exclude("**/gen/**")
|
||||
classpath = files()
|
||||
}
|
||||
|
||||
tasks.register<Pmd>("pmd") {
|
||||
ruleSetFiles = files("${rootProject.rootDir}/ruleset.xml")
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = emptyList()
|
||||
|
||||
source("src")
|
||||
include("**/*.java")
|
||||
exclude("**/gen/**")
|
||||
|
||||
reports {
|
||||
xml.outputLocation.set(layout.buildDirectory.file("reports/pmd/pmd.xml").get().asFile)
|
||||
html.outputLocation.set(layout.buildDirectory.file("reports/pmd/pmd.html").get().asFile)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<SpotBugsTask>().configureEach {
|
||||
val variantNameCap = name.replace("spotbugs", "")
|
||||
val variantName = variantNameCap.substring(0, 1).lowercase() + variantNameCap.substring(1)
|
||||
dependsOn("compile${variantNameCap}Sources")
|
||||
|
||||
classes = fileTree(
|
||||
layout.buildDirectory.get().asFile.toString() +
|
||||
"/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/"
|
||||
)
|
||||
excludeFilter.set(file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml"))
|
||||
|
||||
reports.create("xml") {
|
||||
required.set(true)
|
||||
}
|
||||
reports.create("html") {
|
||||
required.set(true)
|
||||
outputLocation.set(layout.buildDirectory.file("reports/spotbugs/spotbugs.html"))
|
||||
setStylesheet("fancy.xsl")
|
||||
}
|
||||
}
|
||||
|
||||
// Run the compiler as a separate process
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.isFork = true
|
||||
|
||||
// Enable Incremental Compilation
|
||||
options.isIncremental = true
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
// Run tests in parallel
|
||||
maxParallelForks = Runtime.getRuntime().availableProcessors().div(2)
|
||||
|
||||
// increased logging for tests
|
||||
testLogging.events("passed", "skipped", "failed")
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn("checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// region Nextcloud library
|
||||
implementation(libs.android.library) {
|
||||
exclude(group = "org.ogce", module = "xpp3") // unused in Android and brings wrong Junit version
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Splash Screen
|
||||
implementation(libs.splashscreen)
|
||||
// endregion
|
||||
|
||||
// region Jetpack Compose
|
||||
implementation(platform(libs.compose.bom))
|
||||
implementation(libs.material.icons.core)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.graphics)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
// endregion
|
||||
|
||||
// region Media3
|
||||
implementation(libs.bundles.media3)
|
||||
// endregion
|
||||
|
||||
// region Room
|
||||
implementation(libs.room.runtime)
|
||||
ksp(libs.room.compiler)
|
||||
androidTestImplementation(libs.room.testing)
|
||||
// endregion
|
||||
|
||||
// region Espresso
|
||||
androidTestImplementation(libs.bundles.espresso)
|
||||
// endregion
|
||||
|
||||
// region Glide
|
||||
implementation(libs.glide)
|
||||
ksp(libs.ksp)
|
||||
// endregion
|
||||
|
||||
// region UI
|
||||
implementation(libs.bundles.ui)
|
||||
// endregion
|
||||
|
||||
// region Worker
|
||||
implementation(libs.work.runtime)
|
||||
implementation(libs.work.runtime.ktx)
|
||||
// endregion
|
||||
|
||||
// region Lifecycle
|
||||
implementation(libs.lifecycle.viewmodel.ktx)
|
||||
implementation(libs.lifecycle.service)
|
||||
implementation(libs.lifecycle.runtime.ktx)
|
||||
// endregion
|
||||
|
||||
// region JUnit
|
||||
androidTestImplementation(libs.junit)
|
||||
androidTestImplementation(libs.rules)
|
||||
androidTestImplementation(libs.runner)
|
||||
androidTestUtil(libs.orchestrator)
|
||||
androidTestImplementation(libs.core.ktx)
|
||||
androidTestImplementation(libs.core.testing)
|
||||
// endregion
|
||||
|
||||
// region other libraries
|
||||
compileOnly(libs.org.jbundle.util.osgi.wrapped.org.apache.http.client)
|
||||
implementation(libs.commons.httpclient.commons.httpclient) // remove after entire switch to lib v2
|
||||
implementation(libs.jackrabbit.webdav) // remove after entire switch to lib v2
|
||||
implementation(libs.constraintlayout)
|
||||
implementation(libs.legacy.support.v4)
|
||||
implementation(libs.material)
|
||||
implementation(libs.disklrucache)
|
||||
implementation(libs.juniversalchardet) // need this version for Android <7
|
||||
compileOnly(libs.annotations)
|
||||
implementation(libs.commons.io)
|
||||
implementation(libs.eventbus)
|
||||
implementation(libs.ez.vcard)
|
||||
implementation(libs.nnio)
|
||||
implementation(libs.bcpkix.jdk18on)
|
||||
implementation(libs.gson)
|
||||
implementation(libs.sectioned.recyclerview)
|
||||
implementation(libs.photoview)
|
||||
implementation(libs.android.gif.drawable)
|
||||
implementation(libs.qrcodescanner) // "com.github.blikoon:QRCodeScanner:0.1.2"
|
||||
implementation(libs.flexbox)
|
||||
implementation(libs.androidsvg)
|
||||
implementation(libs.annotation)
|
||||
implementation(libs.emoji.google)
|
||||
// endregion
|
||||
|
||||
// region AppScan, document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
"gplayImplementation"(project(":appscan"))
|
||||
"huaweiImplementation"(project(":appscan"))
|
||||
"qaImplementation"(project(":appscan"))
|
||||
// endregion
|
||||
|
||||
// region SpotBugs
|
||||
spotbugsPlugins(libs.findsecbugs.plugin)
|
||||
spotbugsPlugins(libs.fb.contrib)
|
||||
// endregion
|
||||
|
||||
// region Dagger
|
||||
implementation(libs.dagger)
|
||||
implementation(libs.dagger.android)
|
||||
implementation(libs.dagger.android.support)
|
||||
ksp(libs.dagger.compiler)
|
||||
ksp(libs.dagger.processor)
|
||||
// endregion
|
||||
|
||||
// region Crypto
|
||||
implementation(libs.conscrypt.android)
|
||||
// endregion
|
||||
|
||||
// region Library
|
||||
implementation(libs.library)
|
||||
// endregion
|
||||
|
||||
// region Shimmer
|
||||
implementation(libs.loaderviewlibrary)
|
||||
// endregion
|
||||
|
||||
// region Markdown rendering
|
||||
implementation(libs.bundles.markdown.rendering)
|
||||
kapt(libs.prism4j.bundler)
|
||||
// endregion
|
||||
|
||||
// region Image cropping / rotation
|
||||
implementation(libs.android.image.cropper)
|
||||
// endregion
|
||||
|
||||
// region Maps
|
||||
implementation(libs.osmdroid.android)
|
||||
// endregion
|
||||
|
||||
// region iCal4j
|
||||
implementation(libs.ical4j) {
|
||||
listOf("org.apache.commons", "commons-logging").forEach { groupName -> exclude(group = groupName) }
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region LeakCanary
|
||||
if (perfAnalysis) debugImplementation(libs.leakcanary)
|
||||
// endregion
|
||||
|
||||
// region Local Unit Test
|
||||
testImplementation(libs.bundles.unit.test)
|
||||
// endregion
|
||||
|
||||
// region Mocking support
|
||||
androidTestImplementation(libs.bundles.mocking)
|
||||
// endregion
|
||||
|
||||
// region UIAutomator
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
// androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0"
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
// androidTestImplementation("com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation(libs.screengrab)
|
||||
// endregion
|
||||
|
||||
// region Kotlin
|
||||
implementation(libs.kotlin.stdlib)
|
||||
// endregion
|
||||
|
||||
// region Stateless
|
||||
implementation(libs.stateless4j)
|
||||
// endregion
|
||||
|
||||
// region Google Play dependencies, upon each update first test: new registration, receive push
|
||||
"gplayImplementation"(libs.bundles.gplay)
|
||||
// endregion
|
||||
|
||||
// region UI
|
||||
implementation(libs.ui)
|
||||
// endregion
|
||||
|
||||
// region Image loading
|
||||
implementation(libs.coil)
|
||||
// endregion
|
||||
|
||||
// kotlinx.serialization
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
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
@@ -24,6 +24,7 @@ import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.fragment.EmptyListState
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
@@ -68,7 +69,7 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
resetScrolling(true)
|
||||
it.setEmptyListLoadingMessage()
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
val fragment = sut.listOfFilesFragment
|
||||
Assert.assertNotNull(fragment)
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListLoadingMessage()
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
@@ -113,7 +114,7 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
fragment.setFabEnabled(false)
|
||||
fragment.setEmptyListLoadingMessage()
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
@@ -146,7 +147,7 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
it.setEmptyListLoadingMessage()
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
public class FirstRunActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FirstRunActivity> activityRule = new IntentsTestRule<>(FirstRunActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class FirstRunActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.FirstRunActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<FirstRunActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,8 @@ class SyncedFoldersActivityIT : AbstractIT() {
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val dialog = sut.buildPowerCheckDialog()
|
||||
dialog.show()
|
||||
sut.showPowerCheckDialog()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPowerCheckDialog", "")
|
||||
|
||||
@@ -12,7 +12,7 @@ import android.net.Uri
|
||||
import android.os.Parcel
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
import com.owncloud.android.lib.common.OwnCloudBasicCredentials
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotSame
|
||||
@@ -31,7 +31,7 @@ class RegisteredUserTest {
|
||||
val ownCloudAccount = OwnCloudAccount(uri, credentials)
|
||||
val server = Server(
|
||||
uri = URI(uri.toString()),
|
||||
version = OwnCloudVersion.nextcloud_18
|
||||
version = NextcloudVersion.nextcloud_31
|
||||
)
|
||||
return RegisteredUser(
|
||||
account = account,
|
||||
|
||||
@@ -107,7 +107,7 @@ class DeepLinkHandlerTest {
|
||||
fun createMockUser(serverBaseUrl: String): User {
|
||||
val user = mock<User>()
|
||||
val uri = URI.create(serverBaseUrl)
|
||||
val server = Server(uri = uri, version = OwnCloudVersion.nextcloud_19)
|
||||
val server = Server(uri = uri, version = OwnCloudVersion.nextcloud_20)
|
||||
whenever(user.server).thenReturn(server)
|
||||
return user
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.extensions
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.nextcloud.utils.rotateBitmapViaExif
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class BitmapRotationTests {
|
||||
|
||||
private fun createTestBitmap(): Bitmap = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888).apply {
|
||||
setPixel(0, 0, Color.RED)
|
||||
setPixel(1, 0, Color.GREEN)
|
||||
setPixel(0, 1, Color.BLUE)
|
||||
setPixel(1, 1, Color.YELLOW)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateBitmapViaExifWhenGivenNullBitmapShouldReturnNull() {
|
||||
val rotated = null.rotateBitmapViaExif(ExifInterface.ORIENTATION_ROTATE_90)
|
||||
assertEquals(null, rotated)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateBitmapViaExifWhenGivenNormalOrientationShouldReturnSameBitmap() {
|
||||
val bmp = createTestBitmap()
|
||||
val rotated = bmp.rotateBitmapViaExif(ExifInterface.ORIENTATION_NORMAL)
|
||||
assertEquals(bmp, rotated)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateBitmapViaExifWhenGivenRotate90ShouldReturnRotatedBitmap() {
|
||||
val bmp = createTestBitmap()
|
||||
val rotated = bmp.rotateBitmapViaExif(ExifInterface.ORIENTATION_ROTATE_90)!!
|
||||
assertEquals(bmp.width, rotated.height)
|
||||
assertEquals(bmp.height, rotated.width)
|
||||
|
||||
assertEquals(Color.BLUE, rotated.getPixel(0, 0))
|
||||
assertEquals(Color.RED, rotated.getPixel(1, 0))
|
||||
assertEquals(Color.YELLOW, rotated.getPixel(0, 1))
|
||||
assertEquals(Color.GREEN, rotated.getPixel(1, 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateBitmapViaExifWhenGivenRotate180ShouldReturnRotatedBitmap() {
|
||||
val bmp = createTestBitmap()
|
||||
val rotated = bmp.rotateBitmapViaExif(ExifInterface.ORIENTATION_ROTATE_180)!!
|
||||
assertEquals(bmp.width, rotated.width)
|
||||
assertEquals(bmp.height, rotated.height)
|
||||
|
||||
assertEquals(Color.YELLOW, rotated.getPixel(0, 0))
|
||||
assertEquals(Color.BLUE, rotated.getPixel(1, 0))
|
||||
assertEquals(Color.GREEN, rotated.getPixel(0, 1))
|
||||
assertEquals(Color.RED, rotated.getPixel(1, 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateBitmapViaExifWhenGivenFlipHorizontalShouldReturnFlippedBitmap() {
|
||||
val bmp = createTestBitmap()
|
||||
val rotated = bmp.rotateBitmapViaExif(ExifInterface.ORIENTATION_FLIP_HORIZONTAL)!!
|
||||
assertEquals(bmp.width, rotated.width)
|
||||
assertEquals(bmp.height, rotated.height)
|
||||
|
||||
assertEquals(Color.GREEN, rotated.getPixel(0, 0))
|
||||
assertEquals(Color.RED, rotated.getPixel(1, 0))
|
||||
assertEquals(Color.YELLOW, rotated.getPixel(0, 1))
|
||||
assertEquals(Color.BLUE, rotated.getPixel(1, 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateBitmapViaExifWhenGivenFlipVerticalShouldReturnFlippedBitmap() {
|
||||
val bmp = createTestBitmap()
|
||||
val rotated = bmp.rotateBitmapViaExif(ExifInterface.ORIENTATION_FLIP_VERTICAL)!!
|
||||
assertEquals(bmp.width, rotated.width)
|
||||
assertEquals(bmp.height, rotated.height)
|
||||
|
||||
assertEquals(Color.BLUE, rotated.getPixel(0, 0))
|
||||
assertEquals(Color.YELLOW, rotated.getPixel(1, 0))
|
||||
assertEquals(Color.RED, rotated.getPixel(0, 1))
|
||||
assertEquals(Color.GREEN, rotated.getPixel(1, 1))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.extensions
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.nextcloud.utils.extensions.getExifOrientation
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class GetExifOrientationTests {
|
||||
|
||||
private val tempFiles = mutableListOf<File>()
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun createTempImageFile(): File {
|
||||
val file = File.createTempFile("test_image", ".jpg")
|
||||
tempFiles.add(file)
|
||||
|
||||
val bmp = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888).apply {
|
||||
setPixel(0, 0, Color.RED)
|
||||
setPixel(1, 0, Color.GREEN)
|
||||
setPixel(0, 1, Color.BLUE)
|
||||
setPixel(1, 1, Color.YELLOW)
|
||||
}
|
||||
|
||||
file.outputStream().use { out ->
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
||||
}
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
@After
|
||||
fun cleanup() {
|
||||
tempFiles.forEach { it.delete() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetExifOrientationWhenExifIsRotate90ShouldReturnRotate90() {
|
||||
val file = createTempImageFile()
|
||||
|
||||
val exif = ExifInterface(file.absolutePath)
|
||||
exif.setAttribute(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_ROTATE_90.toString())
|
||||
exif.saveAttributes()
|
||||
|
||||
val orientation = getExifOrientation(file.absolutePath)
|
||||
|
||||
assertEquals(ExifInterface.ORIENTATION_ROTATE_90, orientation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetExifOrientationWhenExifIsRotate180ShouldReturnRotate180() {
|
||||
val file = createTempImageFile()
|
||||
|
||||
val exif = ExifInterface(file.absolutePath)
|
||||
exif.setAttribute(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_ROTATE_180.toString())
|
||||
exif.saveAttributes()
|
||||
|
||||
val orientation = getExifOrientation(file.absolutePath)
|
||||
assertEquals(ExifInterface.ORIENTATION_ROTATE_180, orientation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetExifOrientationWhenExifIsUndefinedShouldReturnUndefined() {
|
||||
val file = createTempImageFile()
|
||||
|
||||
val orientation = getExifOrientation(file.absolutePath)
|
||||
assertEquals(ExifInterface.ORIENTATION_UNDEFINED, orientation)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.extensions
|
||||
import com.nextcloud.utils.extensions.isNotBlankAndEquals
|
||||
import junit.framework.TestCase.assertFalse
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class StringExtensionTests {
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreNull() {
|
||||
val str1: String? = null
|
||||
val str2: String? = null
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsNull() {
|
||||
val str1: String? = null
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsNull() {
|
||||
val str1 = "hello"
|
||||
val str2: String? = null
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreEmpty() {
|
||||
val str1 = ""
|
||||
val str2 = ""
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsEmpty() {
|
||||
val str1 = ""
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsEmpty() {
|
||||
val str1 = "hello"
|
||||
val str2 = ""
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreWhitespaceOnly() {
|
||||
val str1 = " "
|
||||
val str2 = " \t "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsWhitespaceOnly() {
|
||||
val str1 = " "
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsWhitespaceOnly() {
|
||||
val str1 = "hello"
|
||||
val str2 = " "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenStringsAreDifferentButBothValid() {
|
||||
val str1 = "hello"
|
||||
val str2 = "world"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenStringsHaveDifferentCase() {
|
||||
val str1 = "Hello"
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenMixedCaseStrings() {
|
||||
val str1 = "HeLLo WoRLd"
|
||||
val str2 = "hello world"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenUppercaseStrings() {
|
||||
val str1 = "HELLO"
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalAndValid() {
|
||||
val str1 = "hello"
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalWithSpaces() {
|
||||
val str1 = "hello world"
|
||||
val str2 = "hello world"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalSingleCharacter() {
|
||||
val str1 = "a"
|
||||
val str2 = "A"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalWithSpecialCharacters() {
|
||||
val str1 = "hello@world!123"
|
||||
val str2 = "HELLO@WORLD!123"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneHasLeadingWhitespaceAndOtherDoesNot() {
|
||||
val str1 = " hello"
|
||||
val str2 = "HELLO"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneHasTrailingWhitespaceAndOtherDoesNot() {
|
||||
val str1 = "hello"
|
||||
val str2 = "HELLO "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothHaveIdenticalWhitespacePaddingDifferentCase() {
|
||||
val str1 = " hello "
|
||||
val str2 = " HELLO "
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenMixedWhitespaceCharacters() {
|
||||
val str1 = "\t"
|
||||
val str2 = "\n"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneIsNullAndOtherIsEmpty() {
|
||||
val str1: String? = null
|
||||
val str2 = ""
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneIsNullAndOtherIsWhitespace() {
|
||||
val str1: String? = null
|
||||
val str2 = " "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -10,115 +11,70 @@ package com.nextcloud.ui
|
||||
import android.graphics.BitmapFactory
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
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.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class BitmapIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
private val testClassName = "com.nextcloud.ui.BitmapIT"
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun roundBitmap() {
|
||||
val file = getFile("christine.jpg")
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
val imageView = ImageView(activity).apply {
|
||||
setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
val bitmap2 = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val imageView2 = ImageView(activity).apply {
|
||||
setImageBitmap(BitmapUtils.roundBitmap(bitmap2))
|
||||
}
|
||||
|
||||
val linearLayout = LinearLayout(activity).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
}
|
||||
linearLayout.addView(imageView, 200, 200)
|
||||
linearLayout.addView(imageView2, 200, 200)
|
||||
activity.addView(linearLayout)
|
||||
|
||||
screenshot(activity)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @ScreenshotTest
|
||||
// fun glideSVG() {
|
||||
// val activity = testActivityRule.launchActivity(null)
|
||||
// val accountProvider = UserAccountManagerImpl.fromContext(activity)
|
||||
// val clientFactory = ClientFactoryImpl(activity)
|
||||
//
|
||||
// val linearLayout = LinearLayout(activity).apply {
|
||||
// orientation = LinearLayout.VERTICAL
|
||||
// setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
// }
|
||||
//
|
||||
// val file = getFile("christine.jpg")
|
||||
// val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
//
|
||||
// ImageView(activity).apply {
|
||||
// setImageBitmap(bitmap)
|
||||
// linearLayout.addView(this, 50, 50)
|
||||
// }
|
||||
//
|
||||
// downloadIcon(
|
||||
// client.baseUri.toString() + "/apps/files/img/app.svg",
|
||||
// activity,
|
||||
// linearLayout,
|
||||
// accountProvider,
|
||||
// clientFactory
|
||||
// )
|
||||
//
|
||||
// downloadIcon(
|
||||
// client.baseUri.toString() + "/core/img/actions/group.svg",
|
||||
// activity,
|
||||
// linearLayout,
|
||||
// accountProvider,
|
||||
// clientFactory
|
||||
// )
|
||||
//
|
||||
// activity.addView(linearLayout)
|
||||
//
|
||||
// longSleep()
|
||||
//
|
||||
// screenshot(activity)
|
||||
// }
|
||||
//
|
||||
// private fun downloadIcon(
|
||||
// url: String,
|
||||
// activity: TestActivity,
|
||||
// linearLayout: LinearLayout,
|
||||
// accountProvider: UserAccountManager,
|
||||
// clientFactory: ClientFactory
|
||||
// ) {
|
||||
// val view = ImageView(activity).apply {
|
||||
// linearLayout.addView(this, 50, 50)
|
||||
// }
|
||||
// val target = object : SimpleTarget<Drawable>() {
|
||||
// override fun onResourceReady(resource: Drawable?, glideAnimation: GlideAnimation<in Drawable>?) {
|
||||
// view.setColorFilter(targetContext.getColor(R.color.dark), PorterDuff.Mode.SRC_ATOP)
|
||||
// view.setImageDrawable(resource)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// testActivityRule.runOnUiThread {
|
||||
// DisplayUtils.downloadIcon(
|
||||
// accountProvider,
|
||||
// clientFactory,
|
||||
// activity,
|
||||
// url,
|
||||
// target,
|
||||
// R.drawable.ic_user
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun roundBitmap() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val file = getFile("christine.jpg")
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
|
||||
val imageView = ImageView(activity).apply {
|
||||
setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
val bitmap2 = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val imageView2 = ImageView(activity).apply {
|
||||
setImageBitmap(BitmapUtils.roundBitmap(bitmap2))
|
||||
}
|
||||
|
||||
val linearLayout = LinearLayout(activity).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
}
|
||||
linearLayout.addView(imageView, 200, 200)
|
||||
linearLayout.addView(imageView2, 200, 200)
|
||||
activity.addView(linearLayout)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "roundBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SetOnlineStatusBottomSheetIT : AbstractIT() {
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.users.ClearAt
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SetStatusDialogFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
var activityRule = IntentsTestRule(FileDisplayActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
fun open() {
|
||||
val sut = SetStatusDialogFragment.newInstance(user, Status(StatusType.DND, "Working hard…", "🤖", -1))
|
||||
val activity = activityRule.launchActivity(null)
|
||||
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
|
||||
activity.runOnUiThread { sut.setPredefinedStatus(predefinedStatus) }
|
||||
|
||||
longSleep()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.users.ClearAt
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SetStatusMessageBottomSheetIT : AbstractIT() {
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetStatusMessageBottomSheet(
|
||||
user,
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("be-right-back", "⏳", "Be right back", ClearAt("period", "900")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
sut.setPredefinedStatus(predefinedStatus)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,4 +230,12 @@ class AutoRenameTests : AbstractOnServerIT() {
|
||||
val expectedFilename = "readme.txt"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFolderNameLowercase() {
|
||||
val filename = "Foo.Bar.Baz"
|
||||
val result = AutoRename.rename(filename, capability, isFolderPath = true)
|
||||
val expectedFilename = "Foo.Bar.Baz"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.utils
|
||||
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class FileHelperTest {
|
||||
|
||||
private lateinit var testDirectory: File
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
testDirectory = Files.createTempDirectory("test").toFile()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
testDirectory.deleteRecursively()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenNullDirectoryShouldReturnEmptyList() {
|
||||
val result = FileHelper.listDirectoryEntries(null, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenNonExistentDirectoryShouldReturnEmptyList() {
|
||||
val nonExistent = File(testDirectory, "does_not_exist")
|
||||
val result = FileHelper.listDirectoryEntries(nonExistent, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenFileInsteadOfDirectoryShouldReturnEmptyList() {
|
||||
val file = File(testDirectory, "test.txt")
|
||||
file.createNewFile()
|
||||
val result = FileHelper.listDirectoryEntries(file, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenEmptyDirectoryShouldReturnEmptyList() {
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFoldersShouldReturnOnlyFolders() {
|
||||
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)
|
||||
|
||||
assertEquals(2, result.size)
|
||||
assertTrue(result.all { it.isDirectory })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFilesShouldReturnOnlyFiles() {
|
||||
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)
|
||||
|
||||
assertEquals(2, result.size)
|
||||
assertTrue(result.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() {
|
||||
for (i in 1..5) File(testDirectory, "folder$i").mkdir()
|
||||
for (i in 1..3) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 2, 10, true)
|
||||
|
||||
assertEquals(3, result.size)
|
||||
assertTrue(result.all { it.isDirectory })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenFetchingFilesWithOffsetShouldSkipCorrectly() {
|
||||
for (i in 1..3) File(testDirectory, "folder$i").mkdir()
|
||||
for (i in 1..5) File(testDirectory, "file$i.txt").createNewFile()
|
||||
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 2, 10, false)
|
||||
|
||||
assertEquals(3, result.size)
|
||||
assertTrue(result.all { it.isFile })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testListDirectoryEntriesWhenGivenOnlyFoldersAndFetchingFilesShouldReturnEmptyList() {
|
||||
for (i in 1..5) File(testDirectory, "folder$i").mkdir()
|
||||
val result = FileHelper.listDirectoryEntries(testDirectory, 0, 10, false)
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@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() {
|
||||
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)
|
||||
|
||||
assertEquals(3, folders.size)
|
||||
assertEquals(7, files.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)
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,12 @@ class FileNameValidatorTests : AbstractOnServerIT() {
|
||||
assertEquals(targetContext.getString(R.string.filename_empty), result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBlankFileName() {
|
||||
val result = FileNameValidator.checkFileName(" ", capability, targetContext)
|
||||
assertEquals(targetContext.getString(R.string.filename_empty), result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFileAlreadyExists() {
|
||||
val existingFiles = setOf("existingFile")
|
||||
|
||||
@@ -22,6 +22,8 @@ import android.view.View;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.facebook.testing.screenshot.internal.TestNameDetector;
|
||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes;
|
||||
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;
|
||||
@@ -53,6 +55,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.theme.MaterialSchemesProvider;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.After;
|
||||
@@ -293,7 +296,7 @@ public abstract class AbstractIT {
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
|
||||
protected void onIdleSync(Runnable recipient) {
|
||||
public void onIdleSync(Runnable recipient) {
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdle(recipient);
|
||||
}
|
||||
|
||||
@@ -397,11 +400,6 @@ public abstract class AbstractIT {
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingExclusionAvailable() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
@@ -452,7 +450,7 @@ public abstract class AbstractIT {
|
||||
screenshot(view, "");
|
||||
}
|
||||
|
||||
protected void screenshotViaName(Activity activity, String name) {
|
||||
public void screenshotViaName(Activity activity, String name) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
Screenshot.snapActivity(activity).setName(name).record();
|
||||
}
|
||||
@@ -542,4 +540,38 @@ public abstract class AbstractIT {
|
||||
protected static boolean removeAccount(Account account) {
|
||||
return AccountManager.get(targetContext).removeAccountExplicitly(account);
|
||||
}
|
||||
|
||||
protected MaterialSchemesProvider getMaterialSchemesProvider() {
|
||||
return new MaterialSchemesProvider() {
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForUser(@NonNull User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCapability(@NonNull OCCapability capability) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCurrentUser() {
|
||||
return new MaterialSchemesImpl(R.color.primary, false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getDefaultMaterialSchemes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForPrimaryBackground() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -173,9 +173,7 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
Assert.fail("Server not ready!");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -218,11 +216,6 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingExclusionAvailable() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
|
||||
@@ -82,12 +82,6 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingExclusionAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
@@ -237,11 +231,6 @@ public class UploadIT extends AbstractOnServerIT {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingExclusionAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
|
||||
@@ -43,7 +43,6 @@ class ContentResolverHelperIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
|
||||
fun contentResolver_onAndroid26_usesNewAPI() {
|
||||
ContentResolverHelper
|
||||
.queryResolver(resolver, URI, PROJECTION, SELECTION, null, SORT_COLUMN, SORT_DIRECTION, LIMIT)
|
||||
|
||||
+5
-7
@@ -18,6 +18,7 @@ import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.database.entity.UploadEntityKt;
|
||||
import com.nextcloud.test.RandomStringGenerator;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.MainApp;
|
||||
@@ -108,7 +109,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
OCUpload upload = createUpload(account);
|
||||
|
||||
uploads.add(upload);
|
||||
uploadsStorageManager.storeUpload(upload);
|
||||
uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(upload));
|
||||
}
|
||||
|
||||
OCUpload[] storedUploads = uploadsStorageManager.getAllStoredUploads();
|
||||
@@ -151,17 +152,14 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
account.name);
|
||||
|
||||
corruptUpload.setLocalPath(null);
|
||||
|
||||
uploadsStorageManager.storeUpload(corruptUpload);
|
||||
|
||||
uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(corruptUpload));
|
||||
uploadsStorageManager.getAllStoredUploads();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getById() {
|
||||
OCUpload upload = createUpload(account);
|
||||
long id = uploadsStorageManager.storeUpload(upload);
|
||||
|
||||
long id = uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(upload));
|
||||
OCUpload newUpload = uploadsStorageManager.getUploadById(id);
|
||||
|
||||
assertNotNull(newUpload);
|
||||
@@ -178,7 +176,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
|
||||
private void insertUploads(Account account, int rowsToInsert) {
|
||||
for (int i = 0; i < rowsToInsert; i++) {
|
||||
uploadsStorageManager.storeUpload(createUpload(account));
|
||||
uploadsStorageManager.uploadDao.insertOrReplace(UploadEntityKt.toUploadEntity(createUpload(account)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
|
||||
inline fun <reified T : Activity> AbstractIT.launchAndCapture(
|
||||
testClassName: String,
|
||||
actionName: String,
|
||||
intent: Intent? = null,
|
||||
crossinline before: (T) -> Unit
|
||||
) {
|
||||
launchActivity<T>(intent).use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
before(activity)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenshotName = createName(testClassName + "_" + actionName, "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenshotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,6 @@ abstract class FileUploaderIT : AbstractOnServerIT() {
|
||||
override val isPowerSavingEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val isPowerSavingExclusionAvailable: Boolean
|
||||
get() = false
|
||||
|
||||
override val battery: BatteryStatus
|
||||
get() = BatteryStatus()
|
||||
}
|
||||
|
||||
@@ -178,10 +178,10 @@ object DocumentsProviderUtils {
|
||||
@Suppress("EXPERIMENTAL_API_USAGE")
|
||||
@VisibleForTesting
|
||||
internal suspend fun getLoadedCursor(timeout: Long = 15_000, query: () -> Cursor?) = withTimeout(timeout) {
|
||||
suspendCancellableCoroutine<Cursor> { cont ->
|
||||
suspendCancellableCoroutine { cont ->
|
||||
val cursor = query() ?: throw IOException("Initial query returned no results")
|
||||
cont.invokeOnCancellation { cursor.close() }
|
||||
val loading = cursor.extras.getBoolean(EXTRA_LOADING, false)
|
||||
val loading = cursor.extras?.getBoolean(EXTRA_LOADING, false) ?: false
|
||||
if (loading) {
|
||||
Log_OC.e("TEST", "Cursor was loading, wait for update...")
|
||||
cursor.registerContentObserver(
|
||||
|
||||
@@ -53,6 +53,14 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
// 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.
|
||||
storageManager.run {
|
||||
val updatedRootPath = getFileByEncryptedRemotePath(ROOT_PATH).apply {
|
||||
permissions = "RSMCKGWDNV"
|
||||
}
|
||||
|
||||
saveFile(updatedRootPath)
|
||||
}
|
||||
|
||||
contentResolver.query(DocumentsContract.buildRootsUri(authority), null, null, null)
|
||||
assertTrue("Storage root does not exist", rootDir.exists())
|
||||
assertTrue(rootDir.isDirectory)
|
||||
|
||||
+14
-14
@@ -1,32 +1,32 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.providers
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.annotation.UiThread
|
||||
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 com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class UsersAndGroupsSearchProviderIT : AbstractOnServerIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun searchUser() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
|
||||
shortSleep()
|
||||
|
||||
activity.runOnUiThread {
|
||||
// fragment.search("Admin")
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
longSleep()
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.net.Uri;
|
||||
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.test.RetryTestRule;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DrawerActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final RetryTestRule retryTestRule = new RetryTestRule();
|
||||
|
||||
private static Account account1;
|
||||
private static User user1;
|
||||
private static Account account2;
|
||||
private static String account2Name;
|
||||
private static String account2DisplayName;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
|
||||
Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
|
||||
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
|
||||
for (Account account : platformAccountManager.getAccounts()) {
|
||||
platformAccountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
|
||||
String loginName = "user1";
|
||||
String password = "user1";
|
||||
|
||||
Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(UserAccountManager.ACCOUNT_VERSION));
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
|
||||
account1 = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
user1 = userAccountManager.getUser(account1.name).orElseThrow(IllegalAccessError::new);
|
||||
|
||||
loginName = "user2";
|
||||
password = "user2";
|
||||
|
||||
temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(UserAccountManager.ACCOUNT_VERSION));
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
|
||||
account2 = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
account2Name = loginName + "@" + baseUrl;
|
||||
account2DisplayName = "User Two@" + baseUrl;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void switchAccountViaAccountList() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
sut.setUser(user1);
|
||||
|
||||
assertEquals(account1, sut.getUser().get().toPlatformAccount());
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
|
||||
onView(anyOf(withText(account2Name), withText(account2DisplayName))).perform(click());
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
assertEquals(account2, sut.getUser().get().toPlatformAccount());
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
onView(withText(account1.name)).perform(click());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.net.Uri
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.test.RetryTestRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.hamcrest.Matchers
|
||||
import org.junit.Assert
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.function.Supplier
|
||||
|
||||
class DrawerActivityIT : AbstractIT() {
|
||||
@Rule
|
||||
@JvmField
|
||||
val retryTestRule = RetryTestRule()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun switchAccountViaAccountList() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.setUser(user1)
|
||||
|
||||
Assert.assertEquals(account1, sut.user.get().toPlatformAccount())
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf<View?>(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var account1: Account? = null
|
||||
private var user1: User? = null
|
||||
private var account2: Account? = null
|
||||
private var account2Name: String? = null
|
||||
private var account2DisplayName: String? = null
|
||||
|
||||
@JvmStatic
|
||||
@BeforeClass
|
||||
fun beforeClass() {
|
||||
val arguments = InstrumentationRegistry.getArguments()
|
||||
val baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"))
|
||||
|
||||
val platformAccountManager = AccountManager.get(targetContext)
|
||||
val userAccountManager: UserAccountManager = UserAccountManagerImpl.fromContext(targetContext)
|
||||
|
||||
for (account in platformAccountManager.accounts) {
|
||||
platformAccountManager.removeAccountExplicitly(account)
|
||||
}
|
||||
|
||||
var loginName = "user1"
|
||||
var password = "user1"
|
||||
|
||||
var temp = Account("$loginName@$baseUrl", MainApp.getAccountType(targetContext))
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null)
|
||||
platformAccountManager.setUserData(
|
||||
temp,
|
||||
AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
UserAccountManager.ACCOUNT_VERSION.toString()
|
||||
)
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0")
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString())
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName) // same as userId
|
||||
|
||||
account1 = userAccountManager.getAccountByName("$loginName@$baseUrl")
|
||||
user1 = userAccountManager.getUser(account1!!.name)
|
||||
.orElseThrow<IllegalAccessError?>(Supplier { IllegalAccessError() })
|
||||
|
||||
loginName = "user2"
|
||||
password = "user2"
|
||||
|
||||
temp = Account("$loginName@$baseUrl", MainApp.getAccountType(targetContext))
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null)
|
||||
platformAccountManager.setUserData(
|
||||
temp,
|
||||
AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
UserAccountManager.ACCOUNT_VERSION.toString()
|
||||
)
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0")
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString())
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName) // same as userId
|
||||
|
||||
account2 = userAccountManager.getAccountByName("$loginName@$baseUrl")
|
||||
account2Name = "$loginName@$baseUrl"
|
||||
account2DisplayName = "User Two@$baseUrl"
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -27,8 +27,8 @@ public class FileDisplayActivityTest extends AbstractIT {
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
Activity activity =
|
||||
ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED).iterator().next();
|
||||
if (activity instanceof WhatsNewActivity) {
|
||||
activity.onBackPressed();
|
||||
if (activity instanceof WhatsNewActivity whatsNewActivity) {
|
||||
whatsNewActivity.getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
});
|
||||
scenario.recreate();
|
||||
|
||||
@@ -1,650 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Intent;
|
||||
import android.net.http.SslCertificate;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nextcloud.android.common.ui.color.ColorUtil;
|
||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes;
|
||||
import com.nextcloud.android.common.ui.theme.MaterialSchemesImpl;
|
||||
import com.nextcloud.android.lib.resources.profile.Action;
|
||||
import com.nextcloud.android.lib.resources.profile.HoverCard;
|
||||
import com.nextcloud.client.account.RegisteredUser;
|
||||
import com.nextcloud.client.account.Server;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.device.DeviceInfo;
|
||||
import com.nextcloud.client.documentscan.AppScanOptionalFeature;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
|
||||
import com.nextcloud.utils.EditorUtils;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.EnforcedServer;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.Creator;
|
||||
import com.owncloud.android.lib.common.DirectEditing;
|
||||
import com.owncloud.android.lib.common.Editor;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.Status;
|
||||
import com.owncloud.android.lib.resources.users.StatusType;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog;
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
import com.owncloud.android.utils.theme.MaterialSchemesProvider;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.activity.result.contract.ActivityResultContract;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import kotlin.Unit;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
public class DialogFragmentIT extends AbstractIT {
|
||||
|
||||
private final String SERVER_URL = "https://nextcloud.localhost";
|
||||
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule =
|
||||
new IntentsTestRule<>(FileDisplayActivity.class, true, false);
|
||||
|
||||
private FileDisplayActivity getFileDisplayActivity() {
|
||||
Intent intent = new Intent(targetContext, FileDisplayActivity.class);
|
||||
return activityRule.launchActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void quitLooperIfNeeded() {
|
||||
if (Looper.myLooper() != null) {
|
||||
Looper.myLooper().quitSafely();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRenameFileDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(new OCFile("/Test/"),
|
||||
new OCFile("/"));
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testLoadingDialog() {
|
||||
LoadingDialog dialog = LoadingDialog.newInstance("Wait…");
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithOneAction() {
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[]{}, R.string.filedetails_sync_file, R.string.common_ok, -1, -1);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithTwoAction() {
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[]{}, R.string.filedetails_sync_file, R.string.common_ok, R.string.common_cancel, -1);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithThreeAction() {
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[]{}, R.string.filedetails_sync_file, R.string.common_ok, R.string.common_cancel, R.string.common_confirm);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testConfirmationDialogWithThreeActionRTL() {
|
||||
enableRTL();
|
||||
|
||||
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_list_empty_text_auto_upload, new String[] { }, -1, R.string.common_ok, R.string.common_cancel, R.string.common_confirm);
|
||||
showDialog(dialog);
|
||||
|
||||
resetLocale();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRemoveFileDialog() {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(new OCFile("/Test.md"));
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRemoveFilesDialog() {
|
||||
ArrayList<OCFile> toDelete = new ArrayList<>();
|
||||
toDelete.add(new OCFile("/Test.md"));
|
||||
toDelete.add(new OCFile("/Document.odt"));
|
||||
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(toDelete);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRemoveFolderDialog() {
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(new OCFile("/Folder/"));
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testRemoveFoldersDialog() {
|
||||
ArrayList<OCFile> toDelete = new ArrayList<>();
|
||||
toDelete.add(new OCFile("/Folder/"));
|
||||
toDelete.add(new OCFile("/Documents/"));
|
||||
|
||||
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(toDelete);
|
||||
showDialog(dialog);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testNewFolderDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
CreateFolderDialogFragment sut = CreateFolderDialogFragment.newInstance(new OCFile("/"));
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testEnforcedPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, false);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testOptionalPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, true);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testAccountChooserDialog() throws AccountUtils.AccountNotFoundException {
|
||||
FileDisplayActivity activity = getFileDisplayActivity();
|
||||
UserAccountManager userAccountManager = activity.getUserAccountManager();
|
||||
AccountManager accountManager = AccountManager.get(targetContext);
|
||||
for (Account account : accountManager.getAccountsByType(MainApp.getAccountType(targetContext))) {
|
||||
accountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
|
||||
Account newAccount = new Account("test@https://nextcloud.localhost", MainApp.getAccountType(targetContext));
|
||||
accountManager.addAccountExplicitly(newAccount, "password", null);
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, SERVER_URL);
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test");
|
||||
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
|
||||
User newUser = userAccountManager.getUser(newAccount.name).orElseThrow(RuntimeException::new);
|
||||
userAccountManager.setCurrentOwnCloudAccount(newAccount.name);
|
||||
|
||||
Account newAccount2 = new Account("[email protected]", MainApp.getAccountType(targetContext));
|
||||
accountManager.addAccountExplicitly(newAccount2, "password", null);
|
||||
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_OC_BASE_URL, SERVER_URL);
|
||||
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_USER_ID, "user1");
|
||||
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_OC_VERSION, "20.0.0");
|
||||
accountManager.setAuthToken(newAccount2, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
|
||||
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
OCCapability capability = new OCCapability();
|
||||
capability.setUserStatus(CapabilityBooleanType.TRUE);
|
||||
capability.setUserStatusSupportsEmoji(CapabilityBooleanType.TRUE);
|
||||
fileDataStorageManager.saveCapabilities(capability);
|
||||
|
||||
ChooseAccountDialogFragment sut =
|
||||
ChooseAccountDialogFragment.newInstance(new RegisteredUser(newAccount,
|
||||
new OwnCloudAccount(newAccount, targetContext),
|
||||
new Server(URI.create(SERVER_URL),
|
||||
OwnCloudVersion.nextcloud_20)));
|
||||
showDialog(activity, sut);
|
||||
|
||||
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.DND,
|
||||
"Busy fixing 🐛…",
|
||||
"",
|
||||
-1),
|
||||
targetContext));
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
screenshot(sut, "dnd");
|
||||
|
||||
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.ONLINE,
|
||||
"",
|
||||
"",
|
||||
-1),
|
||||
targetContext));
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
screenshot(sut, "online");
|
||||
|
||||
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.ONLINE,
|
||||
"Let's have some fun",
|
||||
"🎉",
|
||||
-1),
|
||||
targetContext));
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
screenshot(sut, "fun");
|
||||
|
||||
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.OFFLINE, "", "", -1), targetContext));
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
screenshot(sut, "offline");
|
||||
|
||||
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.AWAY, "Vacation", "🌴", -1), targetContext));
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
screenshot(sut, "away");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testAccountChooserDialogWithStatusDisabled() throws AccountUtils.AccountNotFoundException {
|
||||
AccountManager accountManager = AccountManager.get(targetContext);
|
||||
for (Account account : accountManager.getAccounts()) {
|
||||
accountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
|
||||
Account newAccount = new Account("test@https://nextcloud.localhost", MainApp.getAccountType(targetContext));
|
||||
accountManager.addAccountExplicitly(newAccount, "password", null);
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, SERVER_URL);
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test");
|
||||
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
|
||||
|
||||
FileDisplayActivity fda = getFileDisplayActivity();
|
||||
UserAccountManager userAccountManager = fda.getUserAccountManager();
|
||||
User newUser = userAccountManager.getUser(newAccount.name).get();
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
OCCapability capability = new OCCapability();
|
||||
capability.setUserStatus(CapabilityBooleanType.FALSE);
|
||||
|
||||
fileDataStorageManager.saveCapabilities(capability);
|
||||
|
||||
ChooseAccountDialogFragment sut =
|
||||
ChooseAccountDialogFragment.newInstance(new RegisteredUser(newAccount,
|
||||
new OwnCloudAccount(newAccount, targetContext),
|
||||
new Server(URI.create(SERVER_URL),
|
||||
OwnCloudVersion.nextcloud_20)));
|
||||
showDialog(fda, sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
OCFileListBottomSheetActions action = new OCFileListBottomSheetActions() {
|
||||
|
||||
@Override
|
||||
public void createFolder() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFromApp() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFiles() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newDocument() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newSpreadsheet() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newPresentation() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void directCameraUpload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanDocUpload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTemplate(Creator creator, String headline) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRichWorkspace() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
DeviceInfo info = new DeviceInfo();
|
||||
OCFile ocFile = new OCFile("/test.md");
|
||||
ocFile.setRemoteId("00000001");
|
||||
|
||||
Intent intent = new Intent(targetContext, FileDisplayActivity.class);
|
||||
FileDisplayActivity fda = activityRule.launchActivity(intent);
|
||||
|
||||
// add direct editing info
|
||||
DirectEditing directEditing = new DirectEditing();
|
||||
directEditing.getCreators().put("1", new Creator("1",
|
||||
"text",
|
||||
"text file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false));
|
||||
|
||||
directEditing.getCreators().put("2", new Creator("2",
|
||||
"md",
|
||||
"markdown file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false));
|
||||
|
||||
directEditing.getEditors().put("text",
|
||||
new Editor("1",
|
||||
"Text",
|
||||
new ArrayList<>(Collections.singletonList(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)),
|
||||
new ArrayList<>(),
|
||||
false));
|
||||
|
||||
String json = new Gson().toJson(directEditing);
|
||||
|
||||
new ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue(user.getAccountName(),
|
||||
ArbitraryDataProvider.DIRECT_EDITING,
|
||||
json);
|
||||
|
||||
// activate templates
|
||||
OCCapability capability = fda.getCapabilities();
|
||||
capability.setRichDocuments(CapabilityBooleanType.TRUE);
|
||||
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
|
||||
capability.setRichDocumentsTemplatesAvailable(CapabilityBooleanType.TRUE);
|
||||
capability.setAccountName(user.getAccountName());
|
||||
|
||||
CapabilityUtils.updateCapability(capability);
|
||||
|
||||
AppScanOptionalFeature appScanOptionalFeature = new AppScanOptionalFeature() {
|
||||
@NonNull
|
||||
@Override
|
||||
public ActivityResultContract<Unit, String> getScanContract() {
|
||||
throw new UnsupportedOperationException("Document scan is not available");
|
||||
}
|
||||
};
|
||||
|
||||
MaterialSchemesProvider materialSchemesProvider = new MaterialSchemesProvider() {
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForUser(@NonNull User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCapability(@NonNull OCCapability capability) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForCurrentUser() {
|
||||
return new MaterialSchemesImpl(R.color.primary, false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getDefaultMaterialSchemes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialSchemes getMaterialSchemesForPrimaryBackground() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
ViewThemeUtils viewThemeUtils = new ViewThemeUtils(materialSchemesProvider.getMaterialSchemesForCurrentUser(),
|
||||
new ColorUtil(targetContext));
|
||||
|
||||
EditorUtils editorUtils = new EditorUtils(new ArbitraryDataProviderImpl(targetContext));
|
||||
|
||||
|
||||
OCFileListBottomSheetDialog sut = new OCFileListBottomSheetDialog(fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature);
|
||||
|
||||
fda.runOnUiThread(sut::show);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
sut.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
ViewGroup viewGroup = sut.getWindow().findViewById(android.R.id.content);
|
||||
hideCursors(viewGroup);
|
||||
|
||||
screenshot(Objects.requireNonNull(sut.getWindow()).getDecorView());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testProfileBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
// Fixed values for HoverCard
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(new Action("profile",
|
||||
"View profile",
|
||||
"https://dev.nextcloud.com/core/img/actions/profile.svg",
|
||||
"https://dev.nextcloud.com/index.php/u/christine"));
|
||||
actions.add(new Action("core",
|
||||
"[email protected]",
|
||||
"https://dev.nextcloud.com/core/img/actions/mail.svg",
|
||||
"mailto:[email protected]"));
|
||||
|
||||
actions.add(new Action("spreed",
|
||||
"Talk to Christine",
|
||||
"https://dev.nextcloud.com/apps/spreed/img/app-dark.svg",
|
||||
"https://dev.nextcloud.com/apps/spreed/?callUser=christine"
|
||||
));
|
||||
|
||||
HoverCard hoverCard = new HoverCard("christine", "Christine Scott", actions);
|
||||
|
||||
// show dialog
|
||||
Intent intent = new Intent(targetContext, FileDisplayActivity.class);
|
||||
FileDisplayActivity fda = activityRule.launchActivity(intent);
|
||||
|
||||
ProfileBottomSheetDialog sut = new ProfileBottomSheetDialog(fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils);
|
||||
|
||||
fda.runOnUiThread(sut::show);
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut.getWindow().getDecorView());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testSslUntrustedCertDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
final SslCertificate certificate = new SslCertificate("foo", "bar", "2022/01/10", "2022/01/30");
|
||||
final SslError sslError = new SslError(SslError.SSL_UNTRUSTED, certificate);
|
||||
|
||||
final SslErrorHandler handler = Mockito.mock(SslErrorHandler.class);
|
||||
|
||||
SslUntrustedCertDialog sut = SslUntrustedCertDialog.newInstanceForEmptySslError(sslError, handler);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testStoragePermissionDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
StoragePermissionDialogFragment sut = StoragePermissionDialogFragment.Companion.newInstance(false);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testFileActionsBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
OCFile ocFile = new OCFile("/test.md");
|
||||
ocFile.setRemoteId("0001");
|
||||
final FileActionsBottomSheet sut = FileActionsBottomSheet.newInstance(ocFile, false);
|
||||
showDialog(sut);
|
||||
}
|
||||
|
||||
private void showDialog(DialogFragment dialog) {
|
||||
Intent intent = new Intent(targetContext, FileDisplayActivity.class);
|
||||
|
||||
FileDisplayActivity sut = activityRule.getActivity();
|
||||
|
||||
if (sut == null) {
|
||||
sut = activityRule.launchActivity(intent);
|
||||
}
|
||||
|
||||
showDialog(sut, dialog);
|
||||
}
|
||||
|
||||
private void showDialog(FileDisplayActivity sut, DialogFragment dialog) {
|
||||
dialog.show(sut.getSupportFragmentManager(), "");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
ViewGroup viewGroup = dialog.requireDialog().getWindow().findViewById(android.R.id.content);
|
||||
hideCursors(viewGroup);
|
||||
|
||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
||||
|
||||
}
|
||||
|
||||
private void hideCursors(ViewGroup viewGroup) {
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
View child = viewGroup.getChildAt(i);
|
||||
|
||||
if (child instanceof ViewGroup) {
|
||||
hideCursors((ViewGroup) child);
|
||||
}
|
||||
|
||||
if (child instanceof TextView) {
|
||||
((TextView) child).setCursorVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGson() {
|
||||
ArrayList<EnforcedServer> t = new ArrayList<>();
|
||||
t.add(new EnforcedServer("name", "url"));
|
||||
t.add(new EnforcedServer("name2", "url1"));
|
||||
|
||||
String s = new Gson().toJson(t);
|
||||
|
||||
ArrayList<EnforcedServer> t2 = new Gson().fromJson(s, new TypeToken<ArrayList<EnforcedServer>>() {
|
||||
}.getType());
|
||||
|
||||
ArrayList<String> temp = new ArrayList<>();
|
||||
for (EnforcedServer p : t2) {
|
||||
temp.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,777 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.net.http.SslCertificate
|
||||
import android.net.http.SslError
|
||||
import android.os.Looper
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.SslErrorHandler
|
||||
import android.widget.TextView
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.nextcloud.android.common.ui.color.ColorUtil
|
||||
import com.nextcloud.android.lib.resources.profile.Action
|
||||
import com.nextcloud.android.lib.resources.profile.HoverCard
|
||||
import com.nextcloud.client.account.RegisteredUser
|
||||
import com.nextcloud.client.account.Server
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.client.documentscan.AppScanOptionalFeature
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment.Companion.newInstance
|
||||
import com.nextcloud.ui.SetOnlineStatusBottomSheet
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet.Companion.newInstance
|
||||
import com.nextcloud.utils.EditorUtils
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.authentication.EnforcedServer
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.Creator
|
||||
import com.owncloud.android.lib.common.DirectEditing
|
||||
import com.owncloud.android.lib.common.Editor
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
import com.owncloud.android.lib.common.accounts.AccountTypeUtils
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.dialog.LoadingDialog.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.Companion.newInstanceForEmptySslError
|
||||
import com.owncloud.android.ui.dialog.StoragePermissionDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import io.mockk.mockk
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.net.URI
|
||||
import java.util.function.Supplier
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class DialogFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.DialogFragmentIT"
|
||||
private val serverUrl = "https://nextcloud.localhost"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun quitLooperIfNeeded() {
|
||||
Looper.myLooper()?.quitSafely()
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRenameFileDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
newInstance(
|
||||
OCFile("/Test/"),
|
||||
OCFile("/")
|
||||
).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testLoadingDialog() {
|
||||
newInstance("Wait…").run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithOneAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.string.common_ok,
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithTwoAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.string.common_ok,
|
||||
R.string.common_cancel,
|
||||
-1,
|
||||
-1
|
||||
).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithThreeAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.string.common_ok,
|
||||
R.string.common_cancel,
|
||||
R.string.common_confirm,
|
||||
-1
|
||||
).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithThreeActionRTL() {
|
||||
enableRTL()
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
-1,
|
||||
R.string.common_ok,
|
||||
R.string.common_cancel,
|
||||
R.string.common_confirm,
|
||||
-1
|
||||
).run {
|
||||
showDialog(this)
|
||||
resetLocale()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFileDialog() {
|
||||
RemoveFilesDialogFragment.newInstance(OCFile("/Test.md")).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFilesDialog() {
|
||||
val toDelete = ArrayList<OCFile>().apply {
|
||||
add(OCFile("/Test.md"))
|
||||
add(OCFile("/Document.odt"))
|
||||
}
|
||||
|
||||
val dialog: RemoveFilesDialogFragment = RemoveFilesDialogFragment.newInstance(toDelete)
|
||||
showDialog(dialog)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFolderDialog() {
|
||||
val dialog = RemoveFilesDialogFragment.newInstance(OCFile("/Folder/"))
|
||||
showDialog(dialog)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFoldersDialog() {
|
||||
val toDelete = ArrayList<OCFile>()
|
||||
toDelete.add(OCFile("/Folder/"))
|
||||
toDelete.add(OCFile("/Documents/"))
|
||||
|
||||
val dialog: RemoveFilesDialogFragment = RemoveFilesDialogFragment.newInstance(toDelete)
|
||||
showDialog(dialog)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testNewFolderDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val sut = CreateFolderDialogFragment.newInstance(OCFile("/"))
|
||||
showDialog(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testEnforcedPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val sut = newInstance(OCFile("/"), true, false)
|
||||
showDialog(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testOptionalPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val sut = newInstance(OCFile("/"), true, true)
|
||||
showDialog(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testAccountChooserDialog() {
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
ActivityScenario.launch<FileDisplayActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { activity: FileDisplayActivity ->
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val userAccountManager = activity.userAccountManager
|
||||
val accountManager = AccountManager.get(targetContext)
|
||||
for (account in accountManager.getAccountsByType(MainApp.getAccountType(targetContext))) {
|
||||
accountManager.removeAccountExplicitly(account)
|
||||
}
|
||||
|
||||
val newAccount = Account("test@https://nextcloud.localhost", MainApp.getAccountType(targetContext))
|
||||
accountManager.addAccountExplicitly(newAccount, "password", null)
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, serverUrl)
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test")
|
||||
accountManager.setAuthToken(
|
||||
newAccount,
|
||||
AccountTypeUtils.getAuthTokenTypePass(newAccount.type),
|
||||
"password"
|
||||
)
|
||||
val newUser = userAccountManager.getUser(newAccount.name)
|
||||
.orElseThrow(Supplier { RuntimeException() })
|
||||
userAccountManager.setCurrentOwnCloudAccount(newAccount.name)
|
||||
|
||||
val newAccount2 = Account("[email protected]", MainApp.getAccountType(targetContext))
|
||||
accountManager.addAccountExplicitly(newAccount2, "password", null)
|
||||
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_OC_BASE_URL, serverUrl)
|
||||
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_USER_ID, "user1")
|
||||
accountManager.setUserData(newAccount2, AccountUtils.Constants.KEY_OC_VERSION, "20.0.0")
|
||||
accountManager.setAuthToken(
|
||||
newAccount2,
|
||||
AccountTypeUtils.getAuthTokenTypePass(newAccount.type),
|
||||
"password"
|
||||
)
|
||||
|
||||
val fileDataStorageManager = FileDataStorageManager(
|
||||
newUser,
|
||||
targetContext.contentResolver
|
||||
)
|
||||
|
||||
val capability = OCCapability().apply {
|
||||
userStatus = CapabilityBooleanType.TRUE
|
||||
userStatusSupportsEmoji = CapabilityBooleanType.TRUE
|
||||
}
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
try {
|
||||
onIdleSync {
|
||||
val sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(URI.create(serverUrl), OwnCloudVersion.nextcloud_20)
|
||||
)
|
||||
)
|
||||
showDialog(activity, sut)
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.DND,
|
||||
"Busy fixing 🐛…",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "dnd")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "online")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"Let's have some fun",
|
||||
"🎉",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "fun")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.OFFLINE, "", "", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "offline")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.AWAY, "Vacation", "🌴", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "away")
|
||||
}
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
throw java.lang.RuntimeException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Throws(AccountUtils.AccountNotFoundException::class)
|
||||
fun testAccountChooserDialogWithStatusDisabled() {
|
||||
val accountManager = AccountManager.get(targetContext)
|
||||
for (account in accountManager.accounts) {
|
||||
accountManager.removeAccountExplicitly(account)
|
||||
}
|
||||
|
||||
val newAccount = Account("test@https://nextcloud.localhost", MainApp.getAccountType(targetContext))
|
||||
accountManager.addAccountExplicitly(newAccount, "password", null)
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, serverUrl)
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test")
|
||||
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password")
|
||||
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val userAccountManager = fda.userAccountManager
|
||||
val newUser = userAccountManager.getUser(newAccount.name).get()
|
||||
val fileDataStorageManager = FileDataStorageManager(
|
||||
newUser,
|
||||
targetContext.contentResolver
|
||||
)
|
||||
|
||||
val capability = OCCapability().apply {
|
||||
userStatus = CapabilityBooleanType.FALSE
|
||||
}
|
||||
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val sut =
|
||||
newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(
|
||||
URI.create(serverUrl),
|
||||
OwnCloudVersion.nextcloud_20
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
showDialog(fda, sut)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val action: OCFileListBottomSheetActions = object : OCFileListBottomSheetActions {
|
||||
override fun createFolder() = Unit
|
||||
override fun uploadFromApp() = Unit
|
||||
override fun uploadFiles() = Unit
|
||||
override fun newDocument() = Unit
|
||||
override fun newSpreadsheet() = Unit
|
||||
override fun newPresentation() = Unit
|
||||
override fun directCameraUpload() = Unit
|
||||
override fun scanDocUpload() = Unit
|
||||
override fun showTemplate(creator: Creator?, headline: String?) = Unit
|
||||
override fun createRichWorkspace() = Unit
|
||||
}
|
||||
|
||||
val info = DeviceInfo()
|
||||
val ocFile = OCFile("/test.md").apply {
|
||||
remoteId = "00000001"
|
||||
}
|
||||
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
// add direct editing info
|
||||
var directEditing = DirectEditing()
|
||||
val creators = directEditing.creators.toMutableMap()
|
||||
val editors = directEditing.editors.toMutableMap()
|
||||
|
||||
creators.put(
|
||||
"1",
|
||||
Creator(
|
||||
"1",
|
||||
"text",
|
||||
"text file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
)
|
||||
creators.put(
|
||||
"2",
|
||||
Creator(
|
||||
"2",
|
||||
"md",
|
||||
"markdown file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
)
|
||||
editors.put(
|
||||
"text",
|
||||
Editor(
|
||||
"1",
|
||||
"Text",
|
||||
ArrayList(mutableListOf(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)),
|
||||
ArrayList(),
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
directEditing = DirectEditing(editors, creators)
|
||||
val json = Gson().toJson(directEditing)
|
||||
|
||||
ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue(
|
||||
user.accountName,
|
||||
ArbitraryDataProvider.DIRECT_EDITING,
|
||||
json
|
||||
)
|
||||
|
||||
// activate templates
|
||||
val capability = fda.capabilities.apply {
|
||||
richDocuments = CapabilityBooleanType.TRUE
|
||||
richDocumentsDirectEditing = CapabilityBooleanType.TRUE
|
||||
richDocumentsTemplatesAvailable = CapabilityBooleanType.TRUE
|
||||
accountName = user.accountName
|
||||
}
|
||||
CapabilityUtils.updateCapability(capability)
|
||||
|
||||
val appScanOptionalFeature: AppScanOptionalFeature = object : AppScanOptionalFeature() {
|
||||
override fun getScanContract(): ActivityResultContract<Unit, String?> =
|
||||
throw UnsupportedOperationException("Document scan is not available")
|
||||
}
|
||||
|
||||
val materialSchemesProvider = getMaterialSchemesProvider()
|
||||
val viewThemeUtils = ViewThemeUtils(
|
||||
materialSchemesProvider.getMaterialSchemesForCurrentUser(),
|
||||
ColorUtil(targetContext)
|
||||
)
|
||||
|
||||
val editorUtils = EditorUtils(ArbitraryDataProviderImpl(targetContext))
|
||||
|
||||
val sut = OCFileListBottomSheetDialog(
|
||||
fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
sut.show()
|
||||
sut.behavior.setState(BottomSheetBehavior.STATE_EXPANDED)
|
||||
val viewGroup = sut.window?.findViewById<ViewGroup>(android.R.id.content) ?: return@onIdleSync
|
||||
hideCursors(viewGroup)
|
||||
val screenShotName = createName(testClassName + "_" + "testBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testOnlineStatusBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
// show dialog
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Focus time", "\uD83E\uDD13", -1)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.show(fda.supportFragmentManager, "set_online_status")
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testOnlineStatusBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.view, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testProfileBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
// Fixed values for HoverCard
|
||||
val actions: MutableList<Action> = ArrayList()
|
||||
actions.add(
|
||||
Action(
|
||||
"profile",
|
||||
"View profile",
|
||||
"https://dev.nextcloud.com/core/img/actions/profile.svg",
|
||||
"https://dev.nextcloud.com/index.php/u/christine"
|
||||
)
|
||||
)
|
||||
actions.add(
|
||||
Action(
|
||||
"core",
|
||||
"[email protected]",
|
||||
"https://dev.nextcloud.com/core/img/actions/mail.svg",
|
||||
"mailto:[email protected]"
|
||||
)
|
||||
)
|
||||
|
||||
actions.add(
|
||||
Action(
|
||||
"spreed",
|
||||
"Talk to Christine",
|
||||
"https://dev.nextcloud.com/apps/spreed/img/app-dark.svg",
|
||||
"https://dev.nextcloud.com/apps/spreed/?callUser=christine"
|
||||
)
|
||||
)
|
||||
|
||||
val hoverCard = HoverCard("christine", "Christine Scott", actions)
|
||||
|
||||
// show dialog
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = ProfileBottomSheetDialog(
|
||||
fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.show()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testProfileBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testSslUntrustedCertDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val certificate = SslCertificate("foo", "bar", "2022/01/10", "2022/01/30")
|
||||
val sslError = SslError(SslError.SSL_UNTRUSTED, certificate)
|
||||
|
||||
val handler = mockk<SslErrorHandler>(relaxed = true)
|
||||
|
||||
newInstanceForEmptySslError(sslError, handler).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testStoragePermissionDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
newInstance(false).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testFileActionsBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val ocFile = OCFile("/test.md").apply {
|
||||
remoteId = "0001"
|
||||
}
|
||||
|
||||
newInstance(ocFile, false).run {
|
||||
showDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialog(dialog: DialogFragment) {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
showDialog(sut, dialog)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialog(sut: FileDisplayActivity, dialog: DialogFragment) {
|
||||
dialog.show(sut.supportFragmentManager, null)
|
||||
onIdleSync {
|
||||
val dialogInstance = waitForDialog(dialog)
|
||||
?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content) ?: return@onIdleSync
|
||||
hideCursors(viewGroup)
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialogInstance.window?.decorView)
|
||||
}
|
||||
}
|
||||
|
||||
private fun waitForDialog(dialogFragment: DialogFragment, timeoutMs: Long = 5000): Dialog? {
|
||||
val start = System.currentTimeMillis()
|
||||
while (System.currentTimeMillis() - start < timeoutMs) {
|
||||
val dialog = dialogFragment.dialog
|
||||
if (dialog != null) return dialog
|
||||
Thread.sleep(100)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun hideCursors(viewGroup: ViewGroup) {
|
||||
for (i in 0..<viewGroup.childCount) {
|
||||
val child = viewGroup.getChildAt(i)
|
||||
|
||||
if (child is ViewGroup) {
|
||||
hideCursors(child)
|
||||
}
|
||||
|
||||
if (child is TextView) {
|
||||
child.isCursorVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGson() {
|
||||
val t = ArrayList<EnforcedServer?>().apply {
|
||||
add(EnforcedServer("name", "url"))
|
||||
add(EnforcedServer("name2", "url1"))
|
||||
}
|
||||
|
||||
val s = Gson().toJson(t)
|
||||
val t2 = Gson().fromJson<ArrayList<EnforcedServer>>(
|
||||
s,
|
||||
object : TypeToken<ArrayList<EnforcedServer?>?>() {
|
||||
}.type
|
||||
)
|
||||
|
||||
val temp = ArrayList<String?>()
|
||||
for (p in t2) {
|
||||
temp.add(p.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,55 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
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 com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SendShareDialogTest : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SendShareDialogTest"
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fm: FragmentManager = activity.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
|
||||
val fm: FragmentManager = activity.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
val file = OCFile("/1.jpg").apply {
|
||||
mimeType = "image/jpg"
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val file = OCFile("/1.jpg").apply {
|
||||
mimeType = "image/jpg"
|
||||
val sut = SendShareDialog.newInstance(file, false, OCCapability())
|
||||
sut.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val sut = SendShareDialog.newInstance(file, false, OCCapability())
|
||||
sut.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
shortSleep()
|
||||
shortSleep()
|
||||
sut.requireDialog().window?.decorView.let { screenshot(it) }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -8,8 +9,13 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
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.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
@@ -17,155 +23,171 @@ import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.TextDrawable
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class AvatarIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.AvatarIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showAvatars() {
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val fragment = AvatarTestFragment()
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = AvatarTestFragment()
|
||||
|
||||
runOnUiThread {
|
||||
fragment.addAvatar("Admin", avatarRadius, width, targetContext)
|
||||
fragment.addAvatar("Test Server Admin", avatarRadius, width, targetContext)
|
||||
fragment.addAvatar("Cormier Paulette", avatarRadius, width, targetContext)
|
||||
fragment.addAvatar("winston brent", avatarRadius, width, targetContext)
|
||||
fragment.addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
fragment.addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
fragment.addAvatar("[email protected]", avatarRadius, width, targetContext)
|
||||
sut.addFragment(fragment)
|
||||
fragment.run {
|
||||
addAvatar("Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Test Server Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Cormier Paulette", avatarRadius, width, targetContext)
|
||||
addAvatar("winston brent", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("[email protected]", avatarRadius, width, targetContext)
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatars", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showAvatarsWithStatus() {
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val sut = testActivityRule.launchActivity(null)
|
||||
val fragment = AvatarTestFragment()
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val paulette = BitmapFactory.decodeFile(getFile("paulette.jpg").absolutePath)
|
||||
val christine = BitmapFactory.decodeFile(getFile("christine.jpg").absolutePath)
|
||||
val textBitmap = BitmapUtils.drawableToBitmap(TextDrawable.createNamedAvatar("Admin", avatarRadius))
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = AvatarTestFragment()
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val paulette = BitmapFactory.decodeFile(getFile("paulette.jpg").absolutePath)
|
||||
val christine = BitmapFactory.decodeFile(getFile("christine.jpg").absolutePath)
|
||||
val textBitmap = BitmapUtils.drawableToBitmap(TextDrawable.createNamedAvatar("Admin", avatarRadius))
|
||||
|
||||
runOnUiThread {
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.ONLINE, "😘", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
sut.addFragment(fragment)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "☁️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
fragment.run {
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.ONLINE, "😘", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "☁️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.DND, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.AWAY, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.OFFLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "😘", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "☁️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.DND, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.AWAY, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.OFFLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.DND, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.AWAY, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.OFFLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "😘", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "☁️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.DND, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.AWAY, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
|
||||
fragment.addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.OFFLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatarsWithStatus", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -471,7 +471,6 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
permissions = 17
|
||||
}
|
||||
activity.handler.post { sut.showSharingMenuActionSheet(publicShare) }
|
||||
waitForIdleSync()
|
||||
|
||||
// check if items are visible
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))
|
||||
@@ -611,8 +610,6 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
// validate view shown on screen
|
||||
onView(ViewMatchers.withId(R.id.view_only_radio_button)).check(matches(isDisplayed()))
|
||||
@@ -825,7 +822,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
val processFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(FileDetailsSharingProcessFragment.TAG) as
|
||||
FileDetailsSharingProcessFragment
|
||||
processFragment.onBackPressed()
|
||||
processFragment.activity?.onBackPressedDispatcher?.onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -231,6 +231,13 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/Foo%e2%80%aedm.exe").apply {
|
||||
remoteId = "000000011"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
|
||||
+80
-57
@@ -1,86 +1,109 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
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.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.UnifiedSearchViewModel
|
||||
import org.junit.Rule
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class UnifiedSearchFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
fun showSearchResult() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
activity.addFragment(sut)
|
||||
|
||||
shortSleep()
|
||||
|
||||
UiThreadStatement.runOnUiThread {
|
||||
sut.onSearchResultChanged(
|
||||
listOf(
|
||||
UnifiedSearchSection(
|
||||
providerID = "files",
|
||||
name = "Files",
|
||||
entries = listOf(
|
||||
SearchResultEntry(
|
||||
"thumbnailUrl",
|
||||
"Test",
|
||||
"in Files",
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
),
|
||||
hasMoreResults = false
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
shortSleep()
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun showSearchResult() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.onSearchResultChanged(
|
||||
listOf(
|
||||
UnifiedSearchSection(
|
||||
providerID = "files",
|
||||
name = "Files",
|
||||
entries = listOf(
|
||||
SearchResultEntry(
|
||||
"thumbnailUrl",
|
||||
"Test",
|
||||
"in Files",
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
),
|
||||
hasMoreResults = false
|
||||
)
|
||||
)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun search() {
|
||||
val activity = testActivityRule.launchActivity(null) as TestActivity
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null)
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val ocFile = OCFile("/folder/test1.txt").apply {
|
||||
storagePath = "/sdcard/1.txt"
|
||||
storageManager.saveFile(this)
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
val ocFile = OCFile("/folder/test1.txt").apply {
|
||||
storagePath = "/sdcard/1.txt"
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
File(ocFile.storagePath).createNewFile()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setViewModel(testViewModel)
|
||||
sut.vm.setQuery("test")
|
||||
sut.vm.initialQuery()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File(ocFile.storagePath).createNewFile()
|
||||
|
||||
activity.addFragment(sut)
|
||||
|
||||
shortSleep()
|
||||
|
||||
UiThreadStatement.runOnUiThread {
|
||||
sut.setViewModel(testViewModel)
|
||||
sut.vm.setQuery("test")
|
||||
sut.vm.initialQuery()
|
||||
}
|
||||
shortSleep()
|
||||
}
|
||||
}
|
||||
+34
-14
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -8,36 +9,55 @@
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.preview.PreviewBitmapScreenshotIT"
|
||||
|
||||
companion object {
|
||||
private const val PNG_FILE_ASSET = "imageFile.png"
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(PreviewBitmapActivity::class.java, true, false)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showBitmap() {
|
||||
val pngFile = getFile(PNG_FILE_ASSET)
|
||||
|
||||
val activity = testActivityRule.launchActivity(
|
||||
Intent().putExtra(
|
||||
PreviewBitmapActivity.EXTRA_BITMAP_PATH,
|
||||
pngFile.absolutePath
|
||||
)
|
||||
val intent = Intent(targetContext, PreviewBitmapActivity::class.java).putExtra(
|
||||
PreviewBitmapActivity.EXTRA_BITMAP_PATH,
|
||||
pngFile.absolutePath
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(activity)
|
||||
launchActivity<PreviewBitmapActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "showBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import org.junit.Rule
|
||||
|
||||
class PreviewImageFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
// Disabled for now due to strange failing when using entire test suite
|
||||
// Findings so far:
|
||||
// PreviewImageFragmentIT runs fine when only running this
|
||||
// running it in whole test suite fails
|
||||
// manually tried to execute LoadBitmapTask, but this does not start "doInBackground", but only creates class
|
||||
|
||||
// @Test
|
||||
// @ScreenshotTest
|
||||
// fun corruptImage() {
|
||||
// val activity = testActivityRule.launchActivity(null)
|
||||
//
|
||||
// val ocFile = OCFile("/test.png")
|
||||
// val sut = PreviewImageFragment.newInstance(ocFile, true, false)
|
||||
//
|
||||
// activity.addFragment(sut)
|
||||
//
|
||||
// while (!sut.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
// shortSleep()
|
||||
// }
|
||||
//
|
||||
// screenshot(activity)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @ScreenshotTest
|
||||
// fun validImage() {
|
||||
// val activity = testActivityRule.launchActivity(null)
|
||||
//
|
||||
// val ocFile = OCFile("/test.png")
|
||||
// ocFile.storagePath = getFile("imageFile.png").absolutePath
|
||||
//
|
||||
// val sut = PreviewImageFragment.newInstance(ocFile, true, false)
|
||||
//
|
||||
// activity.addFragment(sut)
|
||||
//
|
||||
// while (!sut.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
// shortSleep()
|
||||
// }
|
||||
//
|
||||
// screenshot(activity)
|
||||
// }
|
||||
}
|
||||
+41
-25
@@ -1,54 +1,70 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.preview.pdf
|
||||
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
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.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewPdfFragmentScreenshotIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.preview.pdf.PreviewPdfFragmentScreenshotIT"
|
||||
|
||||
companion object {
|
||||
private const val PDF_FILE_ASSET = "test.pdf"
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showPdf() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
}
|
||||
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
sut.dismissSnack()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPdf", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
|
||||
while (!sut.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
shortSleep()
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
sut.dismissSnack()
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(activity)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.extensions.launchAndCapture
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
@@ -71,84 +72,50 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun files() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
val screenShotName = createName(testClassName + "_" + "files", "")
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "files", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "empty", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showInitialLoading()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "loading", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showInitialLoading()
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun normalUser() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showUser()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "normalUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "normalUser", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,19 +134,10 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
putExtra(Intent.EXTRA_USER, "differentUser@https://nextcloud.localhost")
|
||||
}
|
||||
|
||||
launchActivity<TrashbinActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showUser()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "differentUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "differentUser", intent = intent, before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.owncloud.android.datamodel.e2e.v1.decrypted.Encrypted;
|
||||
import com.owncloud.android.datamodel.e2e.v1.encrypted.EncryptedFolderMetadataFileV1;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.CsrHelper;
|
||||
import com.owncloud.android.utils.crypto.CryptoHelper;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -44,7 +45,6 @@ import java.security.PrivateKey;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.interfaces.RSAPrivateCrtKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -57,7 +57,6 @@ import javax.crypto.Cipher;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decodeStringToBase64Bytes;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptFile;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptFolderMetaData;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptPrivateKey;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptStringAsymmetric;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.decryptStringSymmetric;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.deserializeJSON;
|
||||
@@ -262,13 +261,8 @@ public class EncryptionTestIT extends AbstractIT {
|
||||
byte[] privateKeyBytes = privateKey.getEncoded();
|
||||
String privateKeyString = encodeBytesToBase64String(privateKeyBytes);
|
||||
|
||||
String encryptedString;
|
||||
if (new Random().nextBoolean()) {
|
||||
encryptedString = EncryptionUtils.encryptPrivateKey(privateKeyString, keyPhrase);
|
||||
} else {
|
||||
encryptedString = EncryptionUtils.encryptPrivateKeyOld(privateKeyString, keyPhrase);
|
||||
}
|
||||
String decryptedString = decryptPrivateKey(encryptedString, keyPhrase);
|
||||
String encryptedString = CryptoHelper.INSTANCE.encryptPrivateKey(privateKeyString, keyPhrase);
|
||||
String decryptedString = CryptoHelper.INSTANCE.decryptPrivateKey(encryptedString, keyPhrase);
|
||||
|
||||
assertEquals(privateKeyString, decryptedString);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ class CapabilityUtilsIT : AbstractIT() {
|
||||
assertTrue(test(NextcloudVersion.nextcloud_22))
|
||||
assertTrue(test(NextcloudVersion.nextcloud_21))
|
||||
assertTrue(test(OwnCloudVersion.nextcloud_20))
|
||||
assertTrue(test(OwnCloudVersion.nextcloud_19))
|
||||
assertTrue(test(OwnCloudVersion.nextcloud_18))
|
||||
}
|
||||
|
||||
private fun test(version: OwnCloudVersion): Boolean =
|
||||
|
||||
@@ -44,6 +44,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.KeyFactory;
|
||||
@@ -96,7 +97,11 @@ public final class PushUtils {
|
||||
if (!new File(privateKeyPath).exists() && !new File(publicKeyPath).exists()) {
|
||||
try {
|
||||
if (!keyPathFile.exists()) {
|
||||
keyPathFile.mkdir();
|
||||
try {
|
||||
Files.createDirectory(keyPathFile.toPath());
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Could not create directory: " + keyPathFile.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
|
||||
keyGen.initialize(2048);
|
||||
@@ -304,8 +309,12 @@ public final class PushUtils {
|
||||
try {
|
||||
if (!new File(path).exists()) {
|
||||
File newFile = new File(path);
|
||||
newFile.getParentFile().mkdirs();
|
||||
newFile.createNewFile();
|
||||
try {
|
||||
Files.createDirectories(newFile.getParentFile().toPath());
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Could not create directory: " + newFile.getParentFile(), e);
|
||||
}
|
||||
Files.createFile(newFile.toPath());
|
||||
}
|
||||
keyFileOutputStream = new FileOutputStream(path);
|
||||
keyFileOutputStream.write(encoded);
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:theme="@style/Theme.ownCloud.Toolbar"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="UnusedAttribute"
|
||||
@@ -269,6 +269,12 @@
|
||||
android:exported="false"
|
||||
tools:replace="android:exported" />
|
||||
|
||||
<receiver
|
||||
android:name="com.nextcloud.client.jobs.offlineOperations.receiver.OfflineOperationReceiver"
|
||||
android:exported="false" />
|
||||
<receiver
|
||||
android:name=".operations.upload.UploadFileBroadcastReceiver"
|
||||
android:exported="false" />
|
||||
<receiver
|
||||
android:name="com.nextcloud.client.jobs.MediaFoldersDetectionWork$NotificationReceiver"
|
||||
android:exported="false" />
|
||||
@@ -347,6 +353,7 @@
|
||||
<activity
|
||||
android:name=".ui.activity.SettingsActivity"
|
||||
android:exported="false"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:theme="@style/PreferenceTheme" />
|
||||
<activity
|
||||
android:name=".ui.preview.PreviewImageActivity"
|
||||
@@ -578,6 +585,8 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name="com.nextcloud.client.jobs.folderDownload.FolderDownloadWorkerReceiver" android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.CopyToClipboardActivity"
|
||||
android:exported="false"
|
||||
@@ -610,8 +619,7 @@
|
||||
<activity
|
||||
android:name=".ui.activity.ManageSpaceActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/manage_space_title"
|
||||
android:theme="@style/Theme.ownCloud" />
|
||||
android:label="@string/manage_space_title" />
|
||||
|
||||
<service
|
||||
android:name=".services.AccountManagerService"
|
||||
|
||||
@@ -17,7 +17,10 @@ import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.core.ClockImpl
|
||||
import com.nextcloud.client.database.dao.ArbitraryDataDao
|
||||
import com.nextcloud.client.database.dao.FileDao
|
||||
import com.nextcloud.client.database.dao.FileSystemDao
|
||||
import com.nextcloud.client.database.dao.OfflineOperationDao
|
||||
import com.nextcloud.client.database.dao.RecommendedFileDao
|
||||
import com.nextcloud.client.database.dao.SyncedFolderDao
|
||||
import com.nextcloud.client.database.dao.UploadDao
|
||||
import com.nextcloud.client.database.entity.ArbitraryDataEntity
|
||||
import com.nextcloud.client.database.entity.CapabilityEntity
|
||||
@@ -25,6 +28,7 @@ import com.nextcloud.client.database.entity.ExternalLinkEntity
|
||||
import com.nextcloud.client.database.entity.FileEntity
|
||||
import com.nextcloud.client.database.entity.FilesystemEntity
|
||||
import com.nextcloud.client.database.entity.OfflineOperationEntity
|
||||
import com.nextcloud.client.database.entity.RecommendedFileEntity
|
||||
import com.nextcloud.client.database.entity.ShareEntity
|
||||
import com.nextcloud.client.database.entity.SyncedFolderEntity
|
||||
import com.nextcloud.client.database.entity.UploadEntity
|
||||
@@ -48,7 +52,8 @@ import com.owncloud.android.db.ProviderMeta
|
||||
SyncedFolderEntity::class,
|
||||
UploadEntity::class,
|
||||
VirtualEntity::class,
|
||||
OfflineOperationEntity::class
|
||||
OfflineOperationEntity::class,
|
||||
RecommendedFileEntity::class
|
||||
],
|
||||
version = ProviderMeta.DB_VERSION,
|
||||
autoMigrations = [
|
||||
@@ -75,7 +80,10 @@ import com.owncloud.android.db.ProviderMeta
|
||||
AutoMigration(from = 86, to = 87, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
AutoMigration(from = 87, to = 88, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
// manual migration used for 88 to 89
|
||||
AutoMigration(from = 89, to = 90)
|
||||
AutoMigration(from = 89, to = 90),
|
||||
AutoMigration(from = 90, to = 91),
|
||||
AutoMigration(from = 91, to = 92),
|
||||
AutoMigration(from = 92, to = 93, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class)
|
||||
],
|
||||
exportSchema = true
|
||||
)
|
||||
@@ -87,6 +95,9 @@ abstract class NextcloudDatabase : RoomDatabase() {
|
||||
abstract fun fileDao(): FileDao
|
||||
abstract fun offlineOperationDao(): OfflineOperationDao
|
||||
abstract fun uploadDao(): UploadDao
|
||||
abstract fun recommendedFileDao(): RecommendedFileDao
|
||||
abstract fun fileSystemDao(): FileSystemDao
|
||||
abstract fun syncedFolderDao(): SyncedFolderDao
|
||||
|
||||
companion object {
|
||||
const val FIRST_ROOM_DB_VERSION = 65
|
||||
|
||||
@@ -12,7 +12,9 @@ import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import com.nextcloud.client.database.entity.FileEntity
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
import com.owncloud.android.utils.MimeType
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@Dao
|
||||
interface FileDao {
|
||||
@Update
|
||||
@@ -62,4 +64,51 @@ interface FileDao {
|
||||
"ORDER BY internal_two_way_sync_timestamp DESC"
|
||||
)
|
||||
fun getInternalTwoWaySyncFolders(fileOwner: String): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM filelist
|
||||
WHERE parent = :parentId
|
||||
AND file_owner = :accountName
|
||||
AND is_encrypted = 0
|
||||
AND (content_type = :dirType OR content_type = :webdavType)
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
fun getNonEncryptedSubfolders(
|
||||
parentId: Long,
|
||||
accountName: String,
|
||||
dirType: String = MimeType.DIRECTORY,
|
||||
webdavType: String = MimeType.WEBDAV_FOLDER
|
||||
): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM filelist
|
||||
WHERE parent = :parentId
|
||||
AND file_owner = :accountName
|
||||
AND (content_type != :dirType AND content_type != :webdavType)
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
fun getSubfiles(
|
||||
parentId: Long,
|
||||
accountName: String,
|
||||
dirType: String = MimeType.DIRECTORY,
|
||||
webdavType: String = MimeType.WEBDAV_FOLDER
|
||||
): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM filelist
|
||||
WHERE file_owner = :fileOwner
|
||||
AND parent = :parentId
|
||||
AND ${ProviderTableMeta.FILE_NAME} LIKE '%' || :query || '%'
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
fun searchFilesInFolder(parentId: Long, fileOwner: String, query: String): List<FileEntity>
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.FilesystemEntity
|
||||
import com.owncloud.android.db.ProviderMeta
|
||||
|
||||
@Dao
|
||||
interface FileSystemDao {
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM ${ProviderMeta.ProviderTableMeta.FILESYSTEM_TABLE_NAME}
|
||||
WHERE ${ProviderMeta.ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID} = :syncedFolderId
|
||||
AND ${ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD} = 0
|
||||
AND ${ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_IS_FOLDER} = 0
|
||||
AND ${ProviderMeta.ProviderTableMeta._ID} > :lastId
|
||||
ORDER BY ${ProviderMeta.ProviderTableMeta._ID}
|
||||
LIMIT :limit
|
||||
"""
|
||||
)
|
||||
suspend fun getAutoUploadFilesEntities(syncedFolderId: String, limit: Int, lastId: Int): List<FilesystemEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
UPDATE ${ProviderMeta.ProviderTableMeta.FILESYSTEM_TABLE_NAME}
|
||||
SET ${ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_SENT_FOR_UPLOAD} = 1
|
||||
WHERE ${ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH} = :localPath
|
||||
AND ${ProviderMeta.ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID} = :syncedFolderId
|
||||
"""
|
||||
)
|
||||
suspend fun markFileAsUploaded(localPath: String, syncedFolderId: String)
|
||||
}
|
||||
@@ -40,4 +40,7 @@ interface OfflineOperationDao {
|
||||
|
||||
@Query("DELETE FROM offline_operations")
|
||||
fun clearTable()
|
||||
|
||||
@Query("DELETE FROM offline_operations WHERE _id = :id")
|
||||
fun deleteById(id: Int)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.RecommendedFileEntity
|
||||
import com.owncloud.android.db.ProviderMeta
|
||||
|
||||
@Dao
|
||||
interface RecommendedFileDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertAll(recommendedFiles: List<RecommendedFileEntity>)
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM ${ProviderMeta.ProviderTableMeta.RECOMMENDED_FILE_TABLE_NAME} WHERE account_name = :accountName"
|
||||
)
|
||||
suspend fun getAll(accountName: String): List<RecommendedFileEntity>
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.SyncedFolderEntity
|
||||
import com.owncloud.android.db.ProviderMeta
|
||||
|
||||
@Dao
|
||||
interface SyncedFolderDao {
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM ${ProviderMeta.ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME}
|
||||
WHERE ${ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH} = :localPath
|
||||
AND ${ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT} = :account
|
||||
LIMIT 1
|
||||
"""
|
||||
)
|
||||
fun findByLocalPathAndAccount(localPath: String, account: String): SyncedFolderEntity?
|
||||
}
|
||||
@@ -8,7 +8,10 @@
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.UploadEntity
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
|
||||
@Dao
|
||||
@@ -19,4 +22,59 @@ interface UploadDao {
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " = :accountName AND _id IS NOT NULL"
|
||||
)
|
||||
fun getAllIds(status: Int, accountName: String): List<Int>
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM " + ProviderTableMeta.UPLOADS_TABLE_NAME +
|
||||
" WHERE " + ProviderTableMeta._ID + " IN (:ids) AND " +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " = :accountName"
|
||||
)
|
||||
fun getUploadsByIds(ids: LongArray, accountName: String): List<UploadEntity>
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM ${ProviderTableMeta.UPLOADS_TABLE_NAME} " +
|
||||
"WHERE ${ProviderTableMeta.UPLOADS_REMOTE_PATH} = :remotePath LIMIT 1"
|
||||
)
|
||||
fun getByRemotePath(remotePath: String): UploadEntity?
|
||||
|
||||
@Query(
|
||||
"DELETE FROM ${ProviderTableMeta.UPLOADS_TABLE_NAME} " +
|
||||
"WHERE ${ProviderTableMeta.UPLOADS_ACCOUNT_NAME} = :accountName " +
|
||||
"AND ${ProviderTableMeta.UPLOADS_REMOTE_PATH} = :remotePath"
|
||||
)
|
||||
fun deleteByAccountAndRemotePath(accountName: String, remotePath: String)
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM " + ProviderTableMeta.UPLOADS_TABLE_NAME +
|
||||
" WHERE " + ProviderTableMeta._ID + " = :id AND " +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " = :accountName " +
|
||||
"LIMIT 1"
|
||||
)
|
||||
fun getUploadById(id: Long, accountName: String): UploadEntity?
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.Companion.REPLACE)
|
||||
fun insertOrReplace(entity: UploadEntity): Long
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM " + ProviderTableMeta.UPLOADS_TABLE_NAME +
|
||||
" WHERE " + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " = :accountName AND " +
|
||||
ProviderTableMeta.UPLOADS_LOCAL_PATH + " = :localPath AND " +
|
||||
ProviderTableMeta.UPLOADS_REMOTE_PATH + " = :remotePath " +
|
||||
"LIMIT 1"
|
||||
)
|
||||
fun getUploadByAccountAndPaths(accountName: String, localPath: String, remotePath: String): UploadEntity?
|
||||
|
||||
@Query(
|
||||
"UPDATE ${ProviderTableMeta.UPLOADS_TABLE_NAME} " +
|
||||
"SET ${ProviderTableMeta.UPLOADS_STATUS} = :status " +
|
||||
"WHERE ${ProviderTableMeta.UPLOADS_REMOTE_PATH} = :remotePath " +
|
||||
"AND ${ProviderTableMeta.UPLOADS_ACCOUNT_NAME} = :accountName"
|
||||
)
|
||||
suspend fun updateStatus(remotePath: String, accountName: String, status: Int): Int
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM ${ProviderTableMeta.UPLOADS_TABLE_NAME} " +
|
||||
"WHERE ${ProviderTableMeta.UPLOADS_ACCOUNT_NAME} = :accountName " +
|
||||
"AND ${ProviderTableMeta.UPLOADS_STATUS} = :status"
|
||||
)
|
||||
suspend fun getUploadsByStatus(accountName: String, status: Int): List<UploadEntity>
|
||||
}
|
||||
@@ -140,5 +140,7 @@ data class CapabilityEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_NOTES_FOLDER_PATH)
|
||||
val notesFolderPath: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_DEFAULT_PERMISSIONS)
|
||||
val defaultPermissions: Int?
|
||||
val defaultPermissions: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_BUSY)
|
||||
val userStatusSupportsBusy: Int?
|
||||
)
|
||||
@@ -42,13 +42,27 @@ data class OfflineOperationEntity(
|
||||
fun isRenameOrRemove(): Boolean =
|
||||
(type is OfflineOperationType.RenameFile || type is OfflineOperationType.RemoveFile)
|
||||
|
||||
fun getConflictText(context: Context): String = if (type is OfflineOperationType.RemoveFile) {
|
||||
context.getString(R.string.offline_operations_worker_notification_remove_conflict_text, filename)
|
||||
} else if (type is OfflineOperationType.RenameFile) {
|
||||
context.getString(R.string.offline_operations_worker_notification_rename_conflict_text, filename)
|
||||
} else if (type is OfflineOperationType.CreateFile) {
|
||||
context.getString(R.string.offline_operations_worker_notification_create_file_conflict_text, filename)
|
||||
} else {
|
||||
context.getString(R.string.offline_operations_worker_notification_create_folder_conflict_text, filename)
|
||||
fun isCreate(): Boolean = (type is OfflineOperationType.CreateFile || type is OfflineOperationType.CreateFolder)
|
||||
|
||||
fun getConflictText(context: Context): String {
|
||||
val resId = when (type) {
|
||||
is OfflineOperationType.RemoveFile -> {
|
||||
R.string.offline_operations_worker_notification_remove_conflict_text
|
||||
}
|
||||
|
||||
is OfflineOperationType.RenameFile -> {
|
||||
R.string.offline_operations_worker_notification_rename_conflict_text
|
||||
}
|
||||
|
||||
is OfflineOperationType.CreateFile -> {
|
||||
R.string.offline_operations_worker_notification_create_file_conflict_text
|
||||
}
|
||||
|
||||
else -> {
|
||||
R.string.offline_operations_worker_notification_create_folder_conflict_text
|
||||
}
|
||||
}
|
||||
|
||||
return context.getString(resId, filename)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.nextcloud.android.lib.resources.recommendations.Recommendation
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
|
||||
@Entity(tableName = ProviderTableMeta.RECOMMENDED_FILE_TABLE_NAME)
|
||||
data class RecommendedFileEntity(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = ProviderTableMeta._ID)
|
||||
val id: Long,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_NAME)
|
||||
val name: String,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_DIRECTORY)
|
||||
val directory: String,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_EXTENSIONS)
|
||||
val extension: String,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_MIME_TYPE)
|
||||
val mimeType: String,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_HAS_PREVIEW)
|
||||
val hasPreview: Boolean,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_REASON)
|
||||
val reason: String,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_TIMESTAMP)
|
||||
val timestamp: Long,
|
||||
|
||||
@ColumnInfo(name = ProviderTableMeta.RECOMMENDED_FILE_ACCOUNT_NAME)
|
||||
val accountName: String?
|
||||
)
|
||||
|
||||
fun ArrayList<Recommendation>.toEntity(accountName: String): List<RecommendedFileEntity> = this.map { recommendation ->
|
||||
RecommendedFileEntity(
|
||||
id = recommendation.id,
|
||||
name = recommendation.name,
|
||||
directory = recommendation.directory,
|
||||
extension = recommendation.extension,
|
||||
mimeType = recommendation.mimeType,
|
||||
hasPreview = recommendation.hasPreview,
|
||||
reason = recommendation.reason,
|
||||
timestamp = recommendation.timestamp,
|
||||
accountName = accountName
|
||||
)
|
||||
}
|
||||
|
||||
fun List<RecommendedFileEntity>.toOCFile(storageManager: FileDataStorageManager): ArrayList<OCFile> =
|
||||
mapNotNull { entity ->
|
||||
entity.id.let {
|
||||
storageManager.getFileByLocalId(it).apply {
|
||||
this?.reason = entity.reason
|
||||
this?.setIsRecommendedFile(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
.toCollection(ArrayList())
|
||||
@@ -10,6 +10,9 @@ package com.nextcloud.client.database.entity
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.nextcloud.client.preferences.SubFolderRule
|
||||
import com.owncloud.android.datamodel.MediaFolderType
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
|
||||
@Entity(tableName = ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME)
|
||||
@@ -50,3 +53,40 @@ data class SyncedFolderEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.SYNCED_FOLDER_LAST_SCAN_TIMESTAMP_MS)
|
||||
val lastScanTimestampMs: Long?
|
||||
)
|
||||
|
||||
fun SyncedFolderEntity.toSyncedFolder(): SyncedFolder = SyncedFolder(
|
||||
// id
|
||||
(this.id ?: SyncedFolder.UNPERSISTED_ID).toLong(),
|
||||
// localPath
|
||||
this.localPath ?: "",
|
||||
// remotePath
|
||||
this.remotePath ?: "",
|
||||
// wifiOnly
|
||||
this.wifiOnly == 1,
|
||||
// chargingOnly
|
||||
this.chargingOnly == 1,
|
||||
// existing
|
||||
this.existing == 1,
|
||||
// subfolderByDate
|
||||
this.subfolderByDate == 1,
|
||||
// account
|
||||
this.account ?: "",
|
||||
// uploadAction
|
||||
this.uploadAction ?: 0,
|
||||
// nameCollisionPolicy
|
||||
this.nameCollisionPolicy ?: 0,
|
||||
// enabled
|
||||
this.enabled == 1,
|
||||
// timestampMs
|
||||
(this.enabledTimestampMs ?: SyncedFolder.EMPTY_ENABLED_TIMESTAMP_MS).toLong(),
|
||||
// type
|
||||
MediaFolderType.getById(this.type ?: MediaFolderType.CUSTOM.id),
|
||||
// hidden
|
||||
this.hidden == 1,
|
||||
// subFolderRule
|
||||
this.subFolderRule?.let { SubFolderRule.entries[it] },
|
||||
// excludeHidden
|
||||
this.excludeHidden == 1,
|
||||
// lastScanTimestampMs
|
||||
this.lastScanTimestampMs ?: SyncedFolder.NOT_SCANNED_YET
|
||||
)
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -10,7 +11,13 @@ package com.nextcloud.client.database.entity
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.nextcloud.utils.autoRename.AutoRename
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
import com.owncloud.android.db.UploadResult
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
|
||||
@Entity(tableName = ProviderTableMeta.UPLOADS_TABLE_NAME)
|
||||
data class UploadEntity(
|
||||
@@ -48,3 +55,57 @@ data class UploadEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.UPLOADS_FOLDER_UNLOCK_TOKEN)
|
||||
val folderUnlockToken: String?
|
||||
)
|
||||
|
||||
fun UploadEntity.toOCUpload(capability: OCCapability? = null): OCUpload {
|
||||
val localPath = localPath
|
||||
var remotePath = remotePath
|
||||
if (capability != null && remotePath != null) {
|
||||
remotePath = AutoRename.rename(remotePath, capability)
|
||||
}
|
||||
val upload = OCUpload(localPath, remotePath, accountName)
|
||||
|
||||
fileSize?.let { upload.fileSize = it }
|
||||
id?.let { upload.uploadId = it.toLong() }
|
||||
status?.let { upload.uploadStatus = UploadsStorageManager.UploadStatus.fromValue(it) }
|
||||
localBehaviour?.let { upload.localAction = it }
|
||||
nameCollisionPolicy?.let { upload.nameCollisionPolicy = NameCollisionPolicy.deserialize(it) }
|
||||
isCreateRemoteFolder?.let { upload.isCreateRemoteFolder = it == 1 }
|
||||
uploadEndTimestamp?.let { upload.uploadEndTimestamp = it.toLong() }
|
||||
lastResult?.let { upload.lastResult = UploadResult.fromValue(it) }
|
||||
createdBy?.let { upload.createdBy = it }
|
||||
isWifiOnly?.let { upload.isUseWifiOnly = it == 1 }
|
||||
isWhileChargingOnly?.let { upload.isWhileChargingOnly = it == 1 }
|
||||
folderUnlockToken?.let { upload.folderUnlockToken = it }
|
||||
|
||||
return upload
|
||||
}
|
||||
|
||||
fun OCUpload.toUploadEntity(): UploadEntity {
|
||||
val id = if (uploadId == -1L) {
|
||||
// needed for the insert new records to the db so that insert DAO function returns new generated id
|
||||
null
|
||||
} else {
|
||||
uploadId
|
||||
}
|
||||
|
||||
return UploadEntity(
|
||||
id = id?.toInt(),
|
||||
localPath = localPath,
|
||||
remotePath = remotePath,
|
||||
accountName = accountName,
|
||||
fileSize = fileSize,
|
||||
status = uploadStatus?.value,
|
||||
localBehaviour = localAction,
|
||||
nameCollisionPolicy = nameCollisionPolicy?.serialize(),
|
||||
isCreateRemoteFolder = if (isCreateRemoteFolder) 1 else 0,
|
||||
|
||||
// uploadEndTimestamp may overflow max int capacity since it is conversion from long to int. coerceAtMost needed
|
||||
uploadEndTimestamp = uploadEndTimestamp.coerceAtMost(Int.MAX_VALUE.toLong()).toInt(),
|
||||
lastResult = lastResult?.value,
|
||||
createdBy = createdBy,
|
||||
isWifiOnly = if (isUseWifiOnly) 1 else 0,
|
||||
isWhileChargingOnly = if (isWhileChargingOnly) 1 else 0,
|
||||
folderUnlockToken = folderUnlockToken,
|
||||
uploadTime = null
|
||||
)
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.nextcloud.client.database.migrations.model.SQLiteColumnType
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
val MIGRATION_88_89 = object : Migration(88, 89) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
DatabaseMigrationUtil.addColumnIfNotExists(
|
||||
|
||||
@@ -10,7 +10,6 @@ package com.nextcloud.client.device
|
||||
|
||||
import android.content.Context
|
||||
import android.os.PowerManager
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@@ -18,13 +17,11 @@ import dagger.Provides
|
||||
class DeviceModule {
|
||||
|
||||
@Provides
|
||||
fun powerManagementService(context: Context, preferences: AppPreferences): PowerManagementService {
|
||||
fun powerManagementService(context: Context): PowerManagementService {
|
||||
val platformPowerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
return PowerManagementServiceImpl(
|
||||
context = context,
|
||||
platformPowerManager = platformPowerManager,
|
||||
deviceInfo = DeviceInfo(),
|
||||
preferences = preferences
|
||||
platformPowerManager = platformPowerManager
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,6 @@ interface PowerManagementService {
|
||||
*/
|
||||
val isPowerSavingEnabled: Boolean
|
||||
|
||||
/**
|
||||
* Checks if the device vendor requires power saving
|
||||
* exclusion workaround.
|
||||
*
|
||||
* @return true if workaround is required, false otherwise
|
||||
*/
|
||||
val isPowerSavingExclusionAvailable: Boolean
|
||||
|
||||
/**
|
||||
* Checks current battery status using platform [android.os.BatteryManager]
|
||||
*/
|
||||
|
||||
@@ -11,46 +11,27 @@ import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.BatteryManager
|
||||
import android.os.PowerManager
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl
|
||||
import com.nextcloud.utils.extensions.registerBroadcastReceiver
|
||||
import com.owncloud.android.datamodel.ReceiverFlag
|
||||
|
||||
internal class PowerManagementServiceImpl(
|
||||
private val context: Context,
|
||||
private val platformPowerManager: PowerManager,
|
||||
private val preferences: AppPreferences,
|
||||
private val deviceInfo: DeviceInfo = DeviceInfo()
|
||||
private val platformPowerManager: PowerManager
|
||||
) : PowerManagementService {
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Vendors on this list use aggressive power saving methods that might
|
||||
* break application experience.
|
||||
*/
|
||||
val OVERLY_AGGRESSIVE_POWER_SAVING_VENDORS = setOf("samsung", "huawei", "xiaomi")
|
||||
|
||||
@JvmStatic
|
||||
fun fromContext(context: Context): PowerManagementServiceImpl {
|
||||
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
val preferences = AppPreferencesImpl.fromContext(context)
|
||||
|
||||
return PowerManagementServiceImpl(context, powerManager, preferences, DeviceInfo())
|
||||
return PowerManagementServiceImpl(context, powerManager)
|
||||
}
|
||||
}
|
||||
|
||||
override val isPowerSavingEnabled: Boolean
|
||||
get() {
|
||||
if (preferences.isPowerCheckDisabled) {
|
||||
return false
|
||||
}
|
||||
|
||||
return platformPowerManager.isPowerSaveMode
|
||||
}
|
||||
|
||||
override val isPowerSavingExclusionAvailable: Boolean
|
||||
get() = deviceInfo.vendor in OVERLY_AGGRESSIVE_POWER_SAVING_VENDORS
|
||||
|
||||
@Suppress("MagicNumber") // 100% is 100, we're not doing Cobol
|
||||
override val battery: BatteryStatus
|
||||
get() {
|
||||
|
||||
@@ -16,6 +16,8 @@ import com.nextcloud.client.device.DeviceModule;
|
||||
import com.nextcloud.client.integrations.IntegrationsModule;
|
||||
import com.nextcloud.client.jobs.JobsModule;
|
||||
import com.nextcloud.client.jobs.download.FileDownloadHelper;
|
||||
import com.nextcloud.client.jobs.offlineOperations.receiver.OfflineOperationReceiver;
|
||||
import com.nextcloud.client.jobs.folderDownload.FolderDownloadWorkerReceiver;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadBroadcastReceiver;
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper;
|
||||
import com.nextcloud.client.media.BackgroundPlayerService;
|
||||
@@ -72,6 +74,10 @@ public interface AppComponent {
|
||||
|
||||
void inject(FileUploadBroadcastReceiver fileUploadBroadcastReceiver);
|
||||
|
||||
void inject(OfflineOperationReceiver offlineOperationReceiver);
|
||||
|
||||
void inject(FolderDownloadWorkerReceiver folderDownloadWorkerReceiver);
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
|
||||
@@ -30,7 +30,8 @@ import com.nextcloud.receiver.NetworkChangeReceiver;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.nextcloud.ui.ChooseStorageLocationDialogFragment;
|
||||
import com.nextcloud.ui.ImageDetailFragment;
|
||||
import com.nextcloud.ui.SetStatusDialogFragment;
|
||||
import com.nextcloud.ui.SetOnlineStatusBottomSheet;
|
||||
import com.nextcloud.ui.SetStatusMessageBottomSheet;
|
||||
import com.nextcloud.ui.composeActivity.ComposeActivity;
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
|
||||
import com.nextcloud.ui.trashbinFileActions.TrashbinFileActionsBottomSheet;
|
||||
@@ -89,7 +90,6 @@ import com.owncloud.android.ui.dialog.LocalStoragePathPickerDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.MultipleAccountsDialog;
|
||||
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenamePublicShareDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SendFilesDialog;
|
||||
import com.owncloud.android.ui.dialog.SendShareDialog;
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
|
||||
@@ -301,7 +301,7 @@ abstract class ComponentsModule {
|
||||
abstract ChooseAccountDialogFragment chooseAccountDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SetStatusDialogFragment setStatusDialogFragment();
|
||||
abstract SetOnlineStatusBottomSheet setOnlineStatusBottomSheet();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewTextFileFragment previewTextFileFragment();
|
||||
@@ -414,9 +414,6 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract RemoveFilesDialogFragment removeFilesDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract RenamePublicShareDialogFragment renamePublicShareDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SendShareDialog sendShareDialog();
|
||||
|
||||
@@ -505,4 +502,7 @@ abstract class ComponentsModule {
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract TermsOfServiceDialog termsOfServiceDialog();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SetStatusMessageBottomSheet setStatusMessageBottomSheet();
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class DocumentScanActivity :
|
||||
true
|
||||
}
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.nextcloud.client.di.Injectable
|
||||
@@ -46,6 +47,7 @@ class EtmActivity :
|
||||
onPageChanged(it)
|
||||
}
|
||||
)
|
||||
handleOnBackPressed()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
||||
@@ -58,11 +60,17 @@ class EtmActivity :
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onBackPressed() {
|
||||
if (!vm.onBackPressed()) {
|
||||
super.onBackPressed()
|
||||
}
|
||||
private fun handleOnBackPressed() {
|
||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
val handledByVm = vm.onBackPressed()
|
||||
|
||||
if (!handledByVm) {
|
||||
isEnabled = false
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun onPageChanged(page: EtmMenuEntry?) {
|
||||
|
||||
@@ -17,13 +17,17 @@ import androidx.work.WorkerFactory
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.client.database.NextcloudDatabase
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.documentscan.GeneratePDFUseCase
|
||||
import com.nextcloud.client.documentscan.GeneratePdfFromImagesWork
|
||||
import com.nextcloud.client.integrations.deck.DeckApi
|
||||
import com.nextcloud.client.jobs.autoUpload.AutoUploadWorker
|
||||
import com.nextcloud.client.jobs.autoUpload.FileSystemRepository
|
||||
import com.nextcloud.client.jobs.download.FileDownloadWorker
|
||||
import com.nextcloud.client.jobs.metadata.MetadataWorker
|
||||
import com.nextcloud.client.jobs.offlineOperations.OfflineOperationsWorker
|
||||
import com.nextcloud.client.jobs.folderDownload.FolderDownloadWorker
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.logger.Logger
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
@@ -49,7 +53,6 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private val clock: Clock,
|
||||
private val powerManagementService: PowerManagementService,
|
||||
private val backgroundJobManager: Provider<BackgroundJobManager>,
|
||||
private val deviceInfo: DeviceInfo,
|
||||
private val accountManager: UserAccountManager,
|
||||
private val resources: Resources,
|
||||
private val arbitraryDataProvider: ArbitraryDataProvider,
|
||||
@@ -61,7 +64,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private val viewThemeUtils: Provider<ViewThemeUtils>,
|
||||
private val localBroadcastManager: Provider<LocalBroadcastManager>,
|
||||
private val generatePdfUseCase: GeneratePDFUseCase,
|
||||
private val syncedFolderProvider: SyncedFolderProvider
|
||||
private val syncedFolderProvider: SyncedFolderProvider,
|
||||
private val database: NextcloudDatabase
|
||||
) : WorkerFactory() {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@@ -83,7 +87,7 @@ class BackgroundJobFactory @Inject constructor(
|
||||
when (workerClass) {
|
||||
ContactsBackupWork::class -> createContactsBackupWork(context, workerParameters)
|
||||
ContactsImportWork::class -> createContactsImportWork(context, workerParameters)
|
||||
FilesSyncWork::class -> createFilesSyncWork(context, workerParameters)
|
||||
AutoUploadWorker::class -> createFilesSyncWork(context, workerParameters)
|
||||
OfflineSyncWork::class -> createOfflineSyncWork(context, workerParameters)
|
||||
MediaFoldersDetectionWork::class -> createMediaFoldersDetectionWork(context, workerParameters)
|
||||
NotificationWork::class -> createNotificationWork(context, workerParameters)
|
||||
@@ -98,6 +102,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
TestJob::class -> createTestJob(context, workerParameters)
|
||||
OfflineOperationsWorker::class -> createOfflineOperationsWorker(context, workerParameters)
|
||||
InternalTwoWaySyncWork::class -> createInternalTwoWaySyncWork(context, workerParameters)
|
||||
MetadataWorker::class -> createMetadataWorker(context, workerParameters)
|
||||
FolderDownloadWorker::class -> createFolderDownloadWorker(context, workerParameters)
|
||||
else -> null // caller falls back to default factory
|
||||
}
|
||||
}
|
||||
@@ -164,16 +170,16 @@ class BackgroundJobFactory @Inject constructor(
|
||||
contentResolver
|
||||
)
|
||||
|
||||
private fun createFilesSyncWork(context: Context, params: WorkerParameters): FilesSyncWork = FilesSyncWork(
|
||||
private fun createFilesSyncWork(context: Context, params: WorkerParameters): AutoUploadWorker = AutoUploadWorker(
|
||||
context = context,
|
||||
params = params,
|
||||
contentResolver = contentResolver,
|
||||
userAccountManager = accountManager,
|
||||
uploadsStorageManager = uploadsStorageManager,
|
||||
connectivityService = connectivityService,
|
||||
powerManagementService = powerManagementService,
|
||||
syncedFolderProvider = syncedFolderProvider,
|
||||
backgroundJobManager = backgroundJobManager.get()
|
||||
backgroundJobManager = backgroundJobManager.get(),
|
||||
repository = FileSystemRepository(dao = database.fileSystemDao())
|
||||
)
|
||||
|
||||
private fun createOfflineSyncWork(context: Context, params: WorkerParameters): OfflineSyncWork = OfflineSyncWork(
|
||||
@@ -277,4 +283,18 @@ class BackgroundJobFactory @Inject constructor(
|
||||
connectivityService,
|
||||
preferences
|
||||
)
|
||||
|
||||
private fun createMetadataWorker(context: Context, params: WorkerParameters): MetadataWorker = MetadataWorker(
|
||||
context,
|
||||
params,
|
||||
accountManager.user
|
||||
)
|
||||
|
||||
private fun createFolderDownloadWorker(context: Context, params: WorkerParameters): FolderDownloadWorker =
|
||||
FolderDownloadWorker(
|
||||
accountManager,
|
||||
context,
|
||||
viewThemeUtils.get(),
|
||||
params
|
||||
)
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.work.ListenableWorker
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.operations.DownloadType
|
||||
|
||||
/**
|
||||
@@ -119,15 +120,12 @@ interface BackgroundJobManager {
|
||||
|
||||
fun startImmediateFilesExportJob(files: Collection<OCFile>): LiveData<JobInfo?>
|
||||
|
||||
fun schedulePeriodicFilesSyncJob(syncedFolderID: Long)
|
||||
fun schedulePeriodicFilesSyncJob(syncedFolder: SyncedFolder)
|
||||
|
||||
/**
|
||||
* Immediately start File Sync job for given syncFolderID.
|
||||
*/
|
||||
fun startImmediateFilesSyncJob(
|
||||
syncedFolderID: Long,
|
||||
fun startAutoUploadImmediately(
|
||||
syncedFolder: SyncedFolder,
|
||||
overridePowerSaving: Boolean = false,
|
||||
changedFiles: Array<String?> = arrayOf<String?>()
|
||||
contentUris: Array<String?> = arrayOf()
|
||||
)
|
||||
|
||||
fun cancelTwoWaySyncJob()
|
||||
@@ -139,15 +137,13 @@ interface BackgroundJobManager {
|
||||
|
||||
fun startNotificationJob(subject: String, signature: String)
|
||||
fun startAccountRemovalJob(accountName: String, remoteWipe: Boolean)
|
||||
fun startFilesUploadJob(user: User, uploadIds: LongArray)
|
||||
fun startFilesUploadJob(user: User, uploadIds: LongArray, showSameFileAlreadyExistsNotification: Boolean)
|
||||
fun getFileUploads(user: User): LiveData<List<JobInfo>>
|
||||
fun cancelFilesUploadJob(user: User)
|
||||
fun isStartFileUploadJobScheduled(user: User): Boolean
|
||||
fun isStartFileUploadJobScheduled(accountName: String): Boolean
|
||||
|
||||
fun cancelFilesDownloadJob(user: User, fileId: Long)
|
||||
|
||||
fun isStartFileDownloadJobScheduled(user: User, fileId: Long): Boolean
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
fun startFileDownloadJob(
|
||||
user: User,
|
||||
@@ -174,4 +170,7 @@ interface BackgroundJobManager {
|
||||
fun startPeriodicallyOfflineOperation()
|
||||
fun scheduleInternal2WaySync(intervalMinutes: Long)
|
||||
fun cancelAllFilesDownloadJobs()
|
||||
fun startMetadataSyncJob(currentDirPath: String)
|
||||
fun downloadFolder(folder: OCFile, accountName: String)
|
||||
fun cancelFolderDownload()
|
||||
}
|
||||
@@ -26,14 +26,22 @@ import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.documentscan.GeneratePdfFromImagesWork
|
||||
import com.nextcloud.client.jobs.autoUpload.AutoUploadWorker
|
||||
import com.nextcloud.client.jobs.download.FileDownloadWorker
|
||||
import com.nextcloud.client.jobs.folderDownload.FolderDownloadWorker
|
||||
import com.nextcloud.client.jobs.metadata.MetadataWorker
|
||||
import com.nextcloud.client.jobs.offlineOperations.OfflineOperationsWorker
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.utils.extensions.isWorkRunning
|
||||
import com.nextcloud.utils.extensions.isWorkScheduled
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.operations.DownloadType
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Date
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -62,7 +70,6 @@ internal class BackgroundJobManagerImpl(
|
||||
Injectable {
|
||||
|
||||
companion object {
|
||||
|
||||
const val TAG_ALL = "*" // This tag allows us to retrieve list of all jobs run by Nextcloud client
|
||||
const val JOB_CONTENT_OBSERVER = "content_observer"
|
||||
const val JOB_PERIODIC_CONTACTS_BACKUP = "periodic_contacts_backup"
|
||||
@@ -87,7 +94,8 @@ internal class BackgroundJobManagerImpl(
|
||||
const val JOB_PERIODIC_OFFLINE_OPERATIONS = "periodic_offline_operations"
|
||||
const val JOB_PERIODIC_HEALTH_STATUS = "periodic_health_status"
|
||||
const val JOB_IMMEDIATE_HEALTH_STATUS = "immediate_health_status"
|
||||
|
||||
const val JOB_DOWNLOAD_FOLDER = "download_folder"
|
||||
const val JOB_METADATA_SYNC = "metadata_sync"
|
||||
const val JOB_INTERNAL_TWO_WAY_SYNC = "internal_two_way_sync"
|
||||
|
||||
const val JOB_TEST = "test_job"
|
||||
@@ -171,6 +179,8 @@ internal class BackgroundJobManagerImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private val defaultDispatcherScope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
override fun logStartOfWorker(workerName: String?) {
|
||||
val logs = deleteOldLogs(preferences.readLogEntry().toMutableList())
|
||||
|
||||
@@ -461,46 +471,73 @@ internal class BackgroundJobManagerImpl(
|
||||
|
||||
workManager.enqueueUniqueWork(
|
||||
JOB_OFFLINE_OPERATIONS,
|
||||
ExistingWorkPolicy.REPLACE,
|
||||
ExistingWorkPolicy.KEEP,
|
||||
request
|
||||
)
|
||||
}
|
||||
|
||||
override fun schedulePeriodicFilesSyncJob(syncedFolderID: Long) {
|
||||
override fun schedulePeriodicFilesSyncJob(syncedFolder: SyncedFolder) {
|
||||
val syncedFolderID = syncedFolder.id
|
||||
|
||||
val arguments = Data.Builder()
|
||||
.putLong(FilesSyncWork.SYNCED_FOLDER_ID, syncedFolderID)
|
||||
.putLong(AutoUploadWorker.SYNCED_FOLDER_ID, syncedFolderID)
|
||||
.build()
|
||||
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.setRequiresCharging(syncedFolder.isChargingOnly)
|
||||
.build()
|
||||
|
||||
val request = periodicRequestBuilder(
|
||||
jobClass = FilesSyncWork::class,
|
||||
jobClass = AutoUploadWorker::class,
|
||||
jobName = JOB_PERIODIC_FILES_SYNC + "_" + syncedFolderID,
|
||||
intervalMins = DEFAULT_PERIODIC_JOB_INTERVAL_MINUTES
|
||||
intervalMins = DEFAULT_PERIODIC_JOB_INTERVAL_MINUTES,
|
||||
constraints = constraints
|
||||
)
|
||||
.setBackoffCriteria(
|
||||
BackoffPolicy.LINEAR,
|
||||
DEFAULT_BACKOFF_CRITERIA_DELAY_SEC,
|
||||
TimeUnit.SECONDS
|
||||
)
|
||||
.setInputData(arguments)
|
||||
.build()
|
||||
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
JOB_PERIODIC_FILES_SYNC + "_" + syncedFolderID,
|
||||
ExistingPeriodicWorkPolicy.REPLACE,
|
||||
ExistingPeriodicWorkPolicy.KEEP,
|
||||
request
|
||||
)
|
||||
}
|
||||
|
||||
override fun startImmediateFilesSyncJob(
|
||||
syncedFolderID: Long,
|
||||
override fun startAutoUploadImmediately(
|
||||
syncedFolder: SyncedFolder,
|
||||
overridePowerSaving: Boolean,
|
||||
changedFiles: Array<String?>
|
||||
contentUris: Array<String?>
|
||||
) {
|
||||
val syncedFolderID = syncedFolder.id
|
||||
|
||||
val arguments = Data.Builder()
|
||||
.putBoolean(FilesSyncWork.OVERRIDE_POWER_SAVING, overridePowerSaving)
|
||||
.putStringArray(FilesSyncWork.CHANGED_FILES, changedFiles)
|
||||
.putLong(FilesSyncWork.SYNCED_FOLDER_ID, syncedFolderID)
|
||||
.putBoolean(AutoUploadWorker.OVERRIDE_POWER_SAVING, overridePowerSaving)
|
||||
.putStringArray(AutoUploadWorker.CONTENT_URIS, contentUris)
|
||||
.putLong(AutoUploadWorker.SYNCED_FOLDER_ID, syncedFolderID)
|
||||
.build()
|
||||
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.setRequiresCharging(syncedFolder.isChargingOnly)
|
||||
.build()
|
||||
|
||||
val request = oneTimeRequestBuilder(
|
||||
jobClass = FilesSyncWork::class,
|
||||
jobClass = AutoUploadWorker::class,
|
||||
jobName = JOB_IMMEDIATE_FILES_SYNC + "_" + syncedFolderID
|
||||
)
|
||||
.setInputData(arguments)
|
||||
.setConstraints(constraints)
|
||||
.setBackoffCriteria(
|
||||
BackoffPolicy.LINEAR,
|
||||
DEFAULT_BACKOFF_CRITERIA_DELAY_SEC,
|
||||
TimeUnit.SECONDS
|
||||
)
|
||||
.build()
|
||||
|
||||
workManager.enqueueUniqueWork(
|
||||
@@ -518,6 +555,28 @@ internal class BackgroundJobManagerImpl(
|
||||
workManager.cancelAllWorkByTag(formatClassTag(FileDownloadWorker::class))
|
||||
}
|
||||
|
||||
override fun startMetadataSyncJob(currentDirPath: String) {
|
||||
val inputData = Data.Builder()
|
||||
.putString(MetadataWorker.FILE_PATH, currentDirPath)
|
||||
.build()
|
||||
|
||||
val constrains = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.setRequiresBatteryNotLow(true)
|
||||
.build()
|
||||
|
||||
val request = oneTimeRequestBuilder(MetadataWorker::class, JOB_METADATA_SYNC)
|
||||
.setConstraints(constrains)
|
||||
.setInputData(inputData)
|
||||
.build()
|
||||
|
||||
workManager.enqueueUniqueWork(
|
||||
JOB_METADATA_SYNC,
|
||||
ExistingWorkPolicy.REPLACE,
|
||||
request
|
||||
)
|
||||
}
|
||||
|
||||
override fun scheduleOfflineSync() {
|
||||
val constrains = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.UNMETERED)
|
||||
@@ -578,10 +637,10 @@ internal class BackgroundJobManagerImpl(
|
||||
workManager.enqueue(request)
|
||||
}
|
||||
|
||||
private fun startFileUploadJobTag(user: User): String = JOB_FILES_UPLOAD + user.accountName
|
||||
private fun startFileUploadJobTag(accountName: String): String = JOB_FILES_UPLOAD + accountName
|
||||
|
||||
override fun isStartFileUploadJobScheduled(user: User): Boolean =
|
||||
workManager.isWorkScheduled(startFileUploadJobTag(user))
|
||||
override fun isStartFileUploadJobScheduled(accountName: String): Boolean =
|
||||
workManager.isWorkScheduled(startFileUploadJobTag(accountName))
|
||||
|
||||
/**
|
||||
* This method supports initiating uploads for various scenarios, including:
|
||||
@@ -595,31 +654,56 @@ internal class BackgroundJobManagerImpl(
|
||||
* and cannot be determined directly from the account name or a single function
|
||||
* within the worker.
|
||||
*/
|
||||
override fun startFilesUploadJob(user: User, uploadIds: LongArray) {
|
||||
val tag = startFileUploadJobTag(user)
|
||||
val dataBuilder = Data.Builder()
|
||||
.putString(FileUploadWorker.ACCOUNT, user.accountName)
|
||||
.putLongArray(FileUploadWorker.UPLOAD_IDS, uploadIds)
|
||||
override fun startFilesUploadJob(user: User, uploadIds: LongArray, showSameFileAlreadyExistsNotification: Boolean) {
|
||||
defaultDispatcherScope.launch {
|
||||
val batchSize = FileUploadHelper.MAX_FILE_COUNT
|
||||
val batches = uploadIds.toList().chunked(batchSize)
|
||||
val tag = startFileUploadJobTag(user.accountName)
|
||||
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
|
||||
val request = oneTimeRequestBuilder(FileUploadWorker::class, JOB_FILES_UPLOAD, user)
|
||||
.addTag(tag)
|
||||
.setInputData(dataBuilder.build())
|
||||
.setConstraints(constraints)
|
||||
.build()
|
||||
val dataBuilder = Data.Builder()
|
||||
.putBoolean(
|
||||
FileUploadWorker.SHOW_SAME_FILE_ALREADY_EXISTS_NOTIFICATION,
|
||||
showSameFileAlreadyExistsNotification
|
||||
)
|
||||
.putString(FileUploadWorker.ACCOUNT, user.accountName)
|
||||
.putInt(FileUploadWorker.TOTAL_UPLOAD_SIZE, uploadIds.size)
|
||||
|
||||
workManager.enqueueUniqueWork(tag, ExistingWorkPolicy.APPEND_OR_REPLACE, request)
|
||||
val workRequests = batches.mapIndexed { index, batch ->
|
||||
dataBuilder
|
||||
.putLongArray(FileUploadWorker.UPLOAD_IDS, batch.toLongArray())
|
||||
.putInt(FileUploadWorker.CURRENT_BATCH_INDEX, index)
|
||||
|
||||
oneTimeRequestBuilder(FileUploadWorker::class, JOB_FILES_UPLOAD, user)
|
||||
.addTag(tag)
|
||||
.setInputData(dataBuilder.build())
|
||||
.setConstraints(constraints)
|
||||
.build()
|
||||
}
|
||||
|
||||
// Chain the work requests sequentially
|
||||
if (workRequests.isNotEmpty()) {
|
||||
var workChain = workManager.beginUniqueWork(
|
||||
tag,
|
||||
ExistingWorkPolicy.APPEND_OR_REPLACE,
|
||||
workRequests.first()
|
||||
)
|
||||
|
||||
workRequests.drop(1).forEach { request ->
|
||||
workChain = workChain.then(request)
|
||||
}
|
||||
|
||||
workChain.enqueue()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startFileDownloadJobTag(user: User, fileId: Long): String =
|
||||
JOB_FOLDER_DOWNLOAD + user.accountName + fileId
|
||||
|
||||
override fun isStartFileDownloadJobScheduled(user: User, fileId: Long): Boolean =
|
||||
workManager.isWorkScheduled(startFileDownloadJobTag(user, fileId))
|
||||
|
||||
override fun startFileDownloadJob(
|
||||
user: User,
|
||||
file: OCFile,
|
||||
@@ -739,4 +823,28 @@ internal class BackgroundJobManagerImpl(
|
||||
|
||||
workManager.enqueueUniquePeriodicWork(JOB_INTERNAL_TWO_WAY_SYNC, ExistingPeriodicWorkPolicy.UPDATE, request)
|
||||
}
|
||||
|
||||
override fun downloadFolder(folder: OCFile, accountName: String) {
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.setRequiresStorageNotLow(true)
|
||||
.build()
|
||||
|
||||
val data = Data.Builder()
|
||||
.putLong(FolderDownloadWorker.FOLDER_ID, folder.fileId)
|
||||
.putString(FolderDownloadWorker.ACCOUNT_NAME, accountName)
|
||||
.build()
|
||||
|
||||
val request = oneTimeRequestBuilder(FolderDownloadWorker::class, JOB_DOWNLOAD_FOLDER)
|
||||
.addTag(JOB_DOWNLOAD_FOLDER)
|
||||
.setInputData(data)
|
||||
.setConstraints(constraints)
|
||||
.build()
|
||||
|
||||
workManager.enqueueUniqueWork(JOB_DOWNLOAD_FOLDER, ExistingWorkPolicy.APPEND_OR_REPLACE, request)
|
||||
}
|
||||
|
||||
override fun cancelFolderDownload() {
|
||||
workManager.cancelAllWorkByTag(JOB_DOWNLOAD_FOLDER)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,27 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019 Chris Narkiewicz <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.app.Notification
|
||||
import android.content.Context
|
||||
import androidx.work.Worker
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.utils.ForegroundServiceHelper
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.ForegroundServiceType
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.FilesSyncHelper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
* This work is triggered when OS detects change in media folders.
|
||||
@@ -21,53 +30,113 @@ import com.owncloud.android.utils.FilesSyncHelper
|
||||
*
|
||||
* This job must not be started on API < 24.
|
||||
*/
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
class ContentObserverWork(
|
||||
appContext: Context,
|
||||
private val context: Context,
|
||||
private val params: WorkerParameters,
|
||||
private val syncedFolderProvider: SyncedFolderProvider,
|
||||
private val powerManagementService: PowerManagementService,
|
||||
private val backgroundJobManager: BackgroundJobManager
|
||||
) : Worker(appContext, params) {
|
||||
) : CoroutineWorker(context, params) {
|
||||
|
||||
override fun doWork(): Result {
|
||||
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class))
|
||||
|
||||
if (params.triggeredContentUris.isNotEmpty()) {
|
||||
Log_OC.d(TAG, "File-sync Content Observer detected files change")
|
||||
checkAndStartFileSyncJob()
|
||||
backgroundJobManager.startMediaFoldersDetectionJob()
|
||||
} else {
|
||||
Log_OC.d(TAG, "triggeredContentUris empty")
|
||||
}
|
||||
recheduleSelf()
|
||||
|
||||
val result = Result.success()
|
||||
backgroundJobManager.logEndOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class), result)
|
||||
return result
|
||||
companion object {
|
||||
private const val TAG = "🔍" + "ContentObserverWork"
|
||||
private const val CHANNEL_ID = NotificationUtils.NOTIFICATION_CHANNEL_CONTENT_OBSERVER
|
||||
private const val NOTIFICATION_ID = 774
|
||||
}
|
||||
|
||||
private fun recheduleSelf() {
|
||||
override suspend fun doWork(): Result = withContext(Dispatchers.IO) {
|
||||
val workerName = BackgroundJobManagerImpl.formatClassTag(this@ContentObserverWork::class)
|
||||
backgroundJobManager.logStartOfWorker(workerName)
|
||||
Log_OC.d(TAG, "started")
|
||||
|
||||
try {
|
||||
if (params.triggeredContentUris.isNotEmpty()) {
|
||||
Log_OC.d(TAG, "📸 content observer detected file changes.")
|
||||
|
||||
val notificationTitle = context.getString(R.string.content_observer_work_notification_title)
|
||||
val notification = createNotification(notificationTitle)
|
||||
updateForegroundInfo(notification)
|
||||
checkAndTriggerAutoUpload()
|
||||
|
||||
// prevent worker fail because of another worker
|
||||
try {
|
||||
backgroundJobManager.startMediaFoldersDetectionJob()
|
||||
} catch (e: Exception) {
|
||||
Log_OC.d(TAG, "⚠️ media folder detection job failed :$e")
|
||||
}
|
||||
} else {
|
||||
Log_OC.d(TAG, "⚠️ triggeredContentUris is empty — nothing to sync.")
|
||||
}
|
||||
|
||||
rescheduleSelf()
|
||||
|
||||
val result = Result.success()
|
||||
backgroundJobManager.logEndOfWorker(workerName, result)
|
||||
Log_OC.d(TAG, "finished")
|
||||
result
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "❌ Exception in ContentObserverWork: ${e.message}", e)
|
||||
Result.retry()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateForegroundInfo(notification: Notification) {
|
||||
val foregroundInfo = ForegroundServiceHelper.createWorkerForegroundInfo(
|
||||
NOTIFICATION_ID,
|
||||
notification,
|
||||
ForegroundServiceType.DataSync
|
||||
)
|
||||
setForeground(foregroundInfo)
|
||||
}
|
||||
|
||||
private fun createNotification(title: String): Notification = NotificationCompat.Builder(context, CHANNEL_ID)
|
||||
.setContentTitle(title)
|
||||
.setSmallIcon(R.drawable.ic_find_in_page)
|
||||
.setOngoing(true)
|
||||
.setSound(null)
|
||||
.setVibrate(null)
|
||||
.setOnlyAlertOnce(true)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setSilent(true)
|
||||
.build()
|
||||
|
||||
/**
|
||||
* Re-schedules this observer to ensure continuous monitoring of media changes.
|
||||
*/
|
||||
private fun rescheduleSelf() {
|
||||
Log_OC.d(TAG, "🔁 Rescheduling ContentObserverWork for continued observation.")
|
||||
backgroundJobManager.scheduleContentObserverJob()
|
||||
}
|
||||
|
||||
private fun checkAndStartFileSyncJob() {
|
||||
if (!powerManagementService.isPowerSavingEnabled && syncedFolderProvider.countEnabledSyncedFolders() > 0) {
|
||||
val changedFiles = mutableListOf<String>()
|
||||
for (uri in params.triggeredContentUris) {
|
||||
changedFiles.add(uri.toString())
|
||||
}
|
||||
FilesSyncHelper.startFilesSyncForAllFolders(
|
||||
private suspend fun checkAndTriggerAutoUpload() = withContext(Dispatchers.IO) {
|
||||
if (powerManagementService.isPowerSavingEnabled) {
|
||||
Log_OC.w(TAG, "⚡ Power saving mode active — skipping file sync.")
|
||||
return@withContext
|
||||
}
|
||||
|
||||
val enabledFoldersCount = syncedFolderProvider.countEnabledSyncedFolders()
|
||||
if (enabledFoldersCount <= 0) {
|
||||
Log_OC.w(TAG, "🚫 No enabled synced folders found — skipping file sync.")
|
||||
return@withContext
|
||||
}
|
||||
|
||||
val contentUris = params.triggeredContentUris.map { uri ->
|
||||
// adds uri strings e.g. content://media/external/images/media/2281
|
||||
uri.toString()
|
||||
}.toTypedArray()
|
||||
Log_OC.d(TAG, "📄 Content uris detected")
|
||||
|
||||
try {
|
||||
FilesSyncHelper.startAutoUploadImmediatelyWithContentUris(
|
||||
syncedFolderProvider,
|
||||
backgroundJobManager,
|
||||
false,
|
||||
changedFiles.toTypedArray()
|
||||
contentUris
|
||||
)
|
||||
} else {
|
||||
Log_OC.w(TAG, "cant startFilesSyncForAllFolders")
|
||||
Log_OC.d(TAG, "✅ auto upload triggered successfully for ${contentUris.size} file(s).")
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "❌ Failed to start auto upload for changed files: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG: String = ContentObserverWork::class.java.simpleName
|
||||
}
|
||||
}
|
||||
@@ -1,404 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Jonas Mayer <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2017 Mario Danic <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.text.TextUtils
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.jobs.upload.FileUploadHelper
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.client.preferences.SubFolderRule
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
|
||||
import com.owncloud.android.datamodel.FilesystemDataProvider
|
||||
import com.owncloud.android.datamodel.MediaFolderType
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.FilesSyncHelper
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import java.io.File
|
||||
import java.text.ParsePosition
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
@Suppress("LongParameterList") // legacy code
|
||||
class FilesSyncWork(
|
||||
private val context: Context,
|
||||
params: WorkerParameters,
|
||||
private val contentResolver: ContentResolver,
|
||||
private val userAccountManager: UserAccountManager,
|
||||
private val uploadsStorageManager: UploadsStorageManager,
|
||||
private val connectivityService: ConnectivityService,
|
||||
private val powerManagementService: PowerManagementService,
|
||||
private val syncedFolderProvider: SyncedFolderProvider,
|
||||
private val backgroundJobManager: BackgroundJobManager
|
||||
) : Worker(context, params) {
|
||||
|
||||
companion object {
|
||||
const val TAG = "FilesSyncJob"
|
||||
const val OVERRIDE_POWER_SAVING = "overridePowerSaving"
|
||||
const val CHANGED_FILES = "changedFiles"
|
||||
const val SYNCED_FOLDER_ID = "syncedFolderId"
|
||||
}
|
||||
|
||||
private lateinit var syncedFolder: SyncedFolder
|
||||
|
||||
@Suppress("MagicNumber", "ReturnCount")
|
||||
override fun doWork(): Result {
|
||||
val syncFolderId = inputData.getLong(SYNCED_FOLDER_ID, -1)
|
||||
val changedFiles = inputData.getStringArray(CHANGED_FILES)
|
||||
|
||||
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class) + "_" + syncFolderId)
|
||||
Log_OC.d(TAG, "AutoUpload started folder ID: $syncFolderId")
|
||||
|
||||
// Create all the providers we'll need
|
||||
val resources = context.resources
|
||||
val lightVersion = resources.getBoolean(R.bool.syncedFolder_light)
|
||||
val filesystemDataProvider = FilesystemDataProvider(contentResolver)
|
||||
val currentLocale = resources.configuration.locale
|
||||
val dateFormat = SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale)
|
||||
dateFormat.timeZone = TimeZone.getTimeZone(TimeZone.getDefault().id)
|
||||
|
||||
if (!setSyncedFolder(syncFolderId)) {
|
||||
Log_OC.w(TAG, "AutoUpload skipped since syncedFolder ($syncFolderId) is not enabled!")
|
||||
return logEndOfWorker(syncFolderId)
|
||||
}
|
||||
|
||||
// Always first try to schedule uploads to make sure files are uploaded even if worker was killed to early
|
||||
uploadFilesFromFolder(
|
||||
context,
|
||||
resources,
|
||||
lightVersion,
|
||||
filesystemDataProvider,
|
||||
currentLocale,
|
||||
dateFormat,
|
||||
syncedFolder
|
||||
)
|
||||
|
||||
if (canExitEarly(changedFiles, syncFolderId)) {
|
||||
Log_OC.w(TAG, "AutoUpload skipped canExit conditions are met")
|
||||
return logEndOfWorker(syncFolderId)
|
||||
}
|
||||
|
||||
val user = userAccountManager.getUser(syncedFolder.account)
|
||||
if (user.isPresent) {
|
||||
var uploadIds = uploadsStorageManager.getCurrentUploadIds(user.get().accountName)
|
||||
backgroundJobManager.startFilesUploadJob(user.get(), uploadIds)
|
||||
}
|
||||
|
||||
// Get changed files from ContentObserverWork (only images and videos) or by scanning filesystem
|
||||
Log_OC.d(
|
||||
TAG,
|
||||
"AutoUpload (${syncedFolder.remotePath}) changed files from observer: " +
|
||||
changedFiles.contentToString()
|
||||
)
|
||||
collectChangedFiles(changedFiles)
|
||||
Log_OC.d(TAG, "AutoUpload (${syncedFolder.remotePath}) finished checking files.")
|
||||
|
||||
uploadFilesFromFolder(
|
||||
context,
|
||||
resources,
|
||||
lightVersion,
|
||||
filesystemDataProvider,
|
||||
currentLocale,
|
||||
dateFormat,
|
||||
syncedFolder
|
||||
)
|
||||
|
||||
FilesSyncHelper.restartUploadsIfNeeded(
|
||||
uploadsStorageManager,
|
||||
userAccountManager,
|
||||
connectivityService,
|
||||
powerManagementService
|
||||
)
|
||||
|
||||
return logEndOfWorker(syncFolderId)
|
||||
}
|
||||
|
||||
private fun logEndOfWorker(syncFolderId: Long): Result {
|
||||
Log_OC.d(TAG, "AutoUpload worker (${syncedFolder.remotePath}) finished")
|
||||
val result = Result.success()
|
||||
backgroundJobManager.logEndOfWorker(
|
||||
BackgroundJobManagerImpl.formatClassTag(this::class) +
|
||||
"_" + syncFolderId,
|
||||
result
|
||||
)
|
||||
return result
|
||||
}
|
||||
|
||||
private fun setSyncedFolder(syncedFolderID: Long): Boolean {
|
||||
val syncedFolderTmp = syncedFolderProvider.getSyncedFolderByID(syncedFolderID)
|
||||
if (syncedFolderTmp == null || !syncedFolderTmp.isEnabled) {
|
||||
return false
|
||||
}
|
||||
syncedFolder = syncedFolderTmp
|
||||
return true
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun canExitEarly(changedFiles: Array<String>?, syncedFolderID: Long): Boolean {
|
||||
// If we are in power save mode better to postpone scan and upload
|
||||
val overridePowerSaving = inputData.getBoolean(OVERRIDE_POWER_SAVING, false)
|
||||
if ((powerManagementService.isPowerSavingEnabled && !overridePowerSaving)) {
|
||||
Log_OC.w(TAG, "AutoUpload skipped powerSaving is enabled!")
|
||||
return true
|
||||
}
|
||||
|
||||
if (syncedFolderID < 0) {
|
||||
Log_OC.w(TAG, "AutoUpload skipped no valid syncedFolderID provided")
|
||||
return true
|
||||
}
|
||||
|
||||
// or sync worker already running
|
||||
if (backgroundJobManager.bothFilesSyncJobsRunning(syncedFolderID)) {
|
||||
Log_OC.w(TAG, "AutoUpload skipped another worker instance is running for $syncedFolderID")
|
||||
return true
|
||||
}
|
||||
|
||||
val calculatedScanInterval =
|
||||
FilesSyncHelper.calculateScanInterval(syncedFolder, connectivityService, powerManagementService)
|
||||
val totalScanInterval = (syncedFolder.lastScanTimestampMs + calculatedScanInterval)
|
||||
val currentTime = System.currentTimeMillis()
|
||||
val passedScanInterval = totalScanInterval <= currentTime
|
||||
|
||||
Log_OC.d(TAG, "AutoUpload lastScanTimestampMs: " + syncedFolder.lastScanTimestampMs)
|
||||
Log_OC.d(TAG, "AutoUpload calculatedScanInterval: $calculatedScanInterval")
|
||||
Log_OC.d(TAG, "AutoUpload totalScanInterval: $totalScanInterval")
|
||||
Log_OC.d(TAG, "AutoUpload currentTime: $currentTime")
|
||||
Log_OC.d(TAG, "AutoUpload passedScanInterval: $passedScanInterval")
|
||||
|
||||
if (!passedScanInterval && changedFiles.isNullOrEmpty() && !overridePowerSaving) {
|
||||
Log_OC.w(
|
||||
TAG,
|
||||
"AutoUpload skipped since started before scan interval and nothing todo: " + syncedFolder.localPath
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
if (syncedFolder.isChargingOnly &&
|
||||
!powerManagementService.battery.isCharging &&
|
||||
!powerManagementService.battery.isFull
|
||||
) {
|
||||
Log_OC.w(
|
||||
TAG,
|
||||
"AutoUpload skipped since phone is not charging: " + syncedFolder.localPath
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun collectChangedFiles(changedFiles: Array<String>?) {
|
||||
if (!changedFiles.isNullOrEmpty()) {
|
||||
FilesSyncHelper.insertChangedEntries(syncedFolder, changedFiles)
|
||||
} else {
|
||||
// Check every file in synced folder for changes and update
|
||||
// filesystemDataProvider database (potentially needs a long time)
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolder)
|
||||
}
|
||||
syncedFolder.lastScanTimestampMs = System.currentTimeMillis()
|
||||
syncedFolderProvider.updateSyncFolder(syncedFolder)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod") // legacy code
|
||||
private fun uploadFilesFromFolder(
|
||||
context: Context,
|
||||
resources: Resources,
|
||||
lightVersion: Boolean,
|
||||
filesystemDataProvider: FilesystemDataProvider,
|
||||
currentLocale: Locale,
|
||||
sFormatter: SimpleDateFormat,
|
||||
syncedFolder: SyncedFolder
|
||||
) {
|
||||
val uploadAction: Int?
|
||||
val needsCharging: Boolean
|
||||
val needsWifi: Boolean
|
||||
val accountName = syncedFolder.account
|
||||
|
||||
val optionalUser = userAccountManager.getUser(accountName)
|
||||
if (!optionalUser.isPresent) {
|
||||
Log_OC.w(TAG, "AutoUpload:uploadFilesFromFolder skipped user not present")
|
||||
return
|
||||
}
|
||||
|
||||
val user = optionalUser.get()
|
||||
val arbitraryDataProvider = if (lightVersion) {
|
||||
ArbitraryDataProviderImpl(context)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
// Ensure only new files are processed for upload.
|
||||
// Files that have been previously uploaded cannot be re-uploaded,
|
||||
// even if they have been deleted or moved from the target folder,
|
||||
// as they are already marked as uploaded in the database.
|
||||
val paths = filesystemDataProvider.getFilesForUpload(
|
||||
syncedFolder.localPath,
|
||||
syncedFolder.id.toString()
|
||||
)
|
||||
if (paths.isEmpty()) {
|
||||
Log_OC.w(TAG, "AutoUpload:uploadFilesFromFolder skipped paths is empty")
|
||||
return
|
||||
}
|
||||
|
||||
val pathsAndMimes = paths.map { path ->
|
||||
val file = File(path)
|
||||
val localPath = file.absolutePath
|
||||
val remotePath = getRemotePath(file, syncedFolder, sFormatter, lightVersion, resources, currentLocale)
|
||||
val mimeType = MimeTypeUtil.getBestMimeTypeByFilename(localPath)
|
||||
|
||||
Log_OC.d(TAG, "AutoUpload:pathsAndMimes file.path: ${file.path}")
|
||||
Log_OC.d(TAG, "AutoUpload:pathsAndMimes localPath: $localPath")
|
||||
Log_OC.d(TAG, "AutoUpload:pathsAndMimes remotePath: $remotePath")
|
||||
Log_OC.d(TAG, "AutoUpload:pathsAndMimes mimeType: $mimeType")
|
||||
|
||||
Triple(
|
||||
localPath,
|
||||
remotePath,
|
||||
mimeType
|
||||
)
|
||||
}
|
||||
|
||||
val localPaths = pathsAndMimes.map { it.first }.toTypedArray()
|
||||
val remotePaths = pathsAndMimes.map { it.second }.toTypedArray()
|
||||
|
||||
if (lightVersion) {
|
||||
Log_OC.d(TAG, "AutoUpload:uploadFilesFromFolder light version is used")
|
||||
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging)
|
||||
needsWifi = arbitraryDataProvider?.getBooleanValue(
|
||||
accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI
|
||||
) ?: true
|
||||
|
||||
val uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour)
|
||||
uploadAction = getUploadAction(uploadActionString)
|
||||
Log_OC.d(TAG, "AutoUpload upload action is: $uploadAction")
|
||||
} else {
|
||||
Log_OC.d(TAG, "AutoUpload:uploadFilesFromFolder not light version is used")
|
||||
|
||||
needsCharging = syncedFolder.isChargingOnly
|
||||
needsWifi = syncedFolder.isWifiOnly
|
||||
uploadAction = syncedFolder.uploadAction
|
||||
}
|
||||
|
||||
FileUploadHelper.instance().uploadNewFiles(
|
||||
user,
|
||||
localPaths,
|
||||
remotePaths,
|
||||
uploadAction,
|
||||
// create parent folder if not existent
|
||||
true,
|
||||
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
|
||||
needsWifi,
|
||||
needsCharging,
|
||||
syncedFolder.nameCollisionPolicy
|
||||
)
|
||||
|
||||
for (path in paths) {
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(
|
||||
path,
|
||||
syncedFolder.id.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRemotePath(
|
||||
file: File,
|
||||
syncedFolder: SyncedFolder,
|
||||
sFormatter: SimpleDateFormat,
|
||||
lightVersion: Boolean,
|
||||
resources: Resources,
|
||||
currentLocale: Locale
|
||||
): String {
|
||||
val lastModificationTime = calculateLastModificationTime(file, syncedFolder, sFormatter)
|
||||
val remoteFolder: String
|
||||
val useSubfolders: Boolean
|
||||
val subFolderRule: SubFolderRule
|
||||
if (lightVersion) {
|
||||
Log_OC.d(TAG, "AutoUpload:getRemotePath light version is used")
|
||||
|
||||
useSubfolders = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders)
|
||||
remoteFolder = resources.getString(R.string.syncedFolder_remote_folder)
|
||||
subFolderRule = SubFolderRule.YEAR_MONTH
|
||||
} else {
|
||||
Log_OC.d(TAG, "AutoUpload:getRemotePath not light version is used")
|
||||
|
||||
useSubfolders = syncedFolder.isSubfolderByDate
|
||||
remoteFolder = syncedFolder.remotePath
|
||||
subFolderRule = syncedFolder.subfolderRule
|
||||
}
|
||||
return FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
currentLocale,
|
||||
remoteFolder,
|
||||
syncedFolder.localPath,
|
||||
lastModificationTime,
|
||||
useSubfolders,
|
||||
subFolderRule
|
||||
)
|
||||
}
|
||||
|
||||
private fun hasExif(file: File): Boolean {
|
||||
val mimeType = FileStorageUtils.getMimeTypeFromName(file.absolutePath)
|
||||
return MimeType.JPEG.equals(mimeType, ignoreCase = true) || MimeType.TIFF.equals(mimeType, ignoreCase = true)
|
||||
}
|
||||
|
||||
private fun calculateLastModificationTime(
|
||||
file: File,
|
||||
syncedFolder: SyncedFolder,
|
||||
formatter: SimpleDateFormat
|
||||
): Long {
|
||||
var lastModificationTime = file.lastModified()
|
||||
if (MediaFolderType.IMAGE == syncedFolder.type && hasExif(file)) {
|
||||
Log_OC.d(TAG, "AutoUpload:calculateLastModificationTime exif found")
|
||||
|
||||
@Suppress("TooGenericExceptionCaught") // legacy code
|
||||
try {
|
||||
val exifInterface = ExifInterface(file.absolutePath)
|
||||
val exifDate = exifInterface.getAttribute(ExifInterface.TAG_DATETIME)
|
||||
if (!TextUtils.isEmpty(exifDate)) {
|
||||
val pos = ParsePosition(0)
|
||||
val dateTime = formatter.parse(exifDate, pos)
|
||||
lastModificationTime = dateTime.time
|
||||
Log_OC.w(TAG, "AutoUpload:calculateLastModificationTime calculatedTime is: $lastModificationTime")
|
||||
} else {
|
||||
Log_OC.w(TAG, "AutoUpload:calculateLastModificationTime exifDate is empty")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log_OC.d(TAG, "Failed to get the proper time " + e.localizedMessage)
|
||||
}
|
||||
}
|
||||
return lastModificationTime
|
||||
}
|
||||
|
||||
private fun getUploadAction(action: String): Int = when (action) {
|
||||
"LOCAL_BEHAVIOUR_FORGET" -> FileUploadWorker.LOCAL_BEHAVIOUR_FORGET
|
||||
"LOCAL_BEHAVIOUR_MOVE" -> FileUploadWorker.LOCAL_BEHAVIOUR_MOVE
|
||||
"LOCAL_BEHAVIOUR_DELETE" -> FileUploadWorker.LOCAL_BEHAVIOUR_DELETE
|
||||
else -> FileUploadWorker.LOCAL_BEHAVIOUR_FORGET
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,8 @@ class OfflineSyncWork(
|
||||
true,
|
||||
context,
|
||||
storageManager,
|
||||
true
|
||||
true,
|
||||
false
|
||||
)
|
||||
synchronizeFileOperation.execute(context)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.jobs.autoUpload
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.database.entity.UploadEntity
|
||||
import com.nextcloud.client.database.entity.toOCUpload
|
||||
import com.nextcloud.client.database.entity.toUploadEntity
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager
|
||||
import com.nextcloud.client.jobs.upload.FileUploadWorker
|
||||
import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.client.preferences.SubFolderRule
|
||||
import com.nextcloud.utils.ForegroundServiceHelper
|
||||
import com.nextcloud.utils.extensions.updateStatus
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.ForegroundServiceType
|
||||
import com.owncloud.android.datamodel.MediaFolderType
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.FilesSyncHelper
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.text.ParsePosition
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
@Suppress("LongParameterList", "TooManyFunctions")
|
||||
class AutoUploadWorker(
|
||||
private val context: Context,
|
||||
params: WorkerParameters,
|
||||
private val userAccountManager: UserAccountManager,
|
||||
private val uploadsStorageManager: UploadsStorageManager,
|
||||
private val connectivityService: ConnectivityService,
|
||||
private val powerManagementService: PowerManagementService,
|
||||
private val syncedFolderProvider: SyncedFolderProvider,
|
||||
private val backgroundJobManager: BackgroundJobManager,
|
||||
private val repository: FileSystemRepository
|
||||
) : CoroutineWorker(context, params) {
|
||||
|
||||
companion object {
|
||||
const val TAG = "🔄📤" + "AutoUpload"
|
||||
const val OVERRIDE_POWER_SAVING = "overridePowerSaving"
|
||||
const val CONTENT_URIS = "content_uris"
|
||||
const val SYNCED_FOLDER_ID = "syncedFolderId"
|
||||
private const val CHANNEL_ID = NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD
|
||||
|
||||
private const val NOTIFICATION_ID = 266
|
||||
}
|
||||
|
||||
private lateinit var syncedFolder: SyncedFolder
|
||||
private val notificationManager by lazy {
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught", "ReturnCount")
|
||||
override suspend fun doWork(): Result {
|
||||
return try {
|
||||
val syncFolderId = inputData.getLong(SYNCED_FOLDER_ID, -1)
|
||||
syncedFolder = syncedFolderProvider.getSyncedFolderByID(syncFolderId)
|
||||
?.takeIf { it.isEnabled } ?: return Result.failure()
|
||||
|
||||
// initial notification
|
||||
val notification = createNotification(context.getString(R.string.upload_files))
|
||||
updateForegroundInfo(notification)
|
||||
|
||||
/**
|
||||
* Receives from [com.nextcloud.client.jobs.ContentObserverWork.checkAndTriggerAutoUpload]
|
||||
*/
|
||||
val contentUris = inputData.getStringArray(CONTENT_URIS)
|
||||
|
||||
if (canExitEarly(contentUris, syncFolderId)) {
|
||||
return Result.retry()
|
||||
}
|
||||
|
||||
collectFileChangesFromContentObserverWork(contentUris)
|
||||
updateNotification()
|
||||
uploadFiles(syncedFolder)
|
||||
|
||||
Log_OC.d(TAG, "✅ ${syncedFolder.remotePath} finished checking files.")
|
||||
Result.success()
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "❌ failed: ${e.message}")
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateNotification() {
|
||||
getStartNotificationTitle()?.let { (localFolderName, remoteFolderName) ->
|
||||
val startNotification = createNotification(
|
||||
context.getString(
|
||||
R.string.auto_upload_worker_start_text,
|
||||
localFolderName,
|
||||
remoteFolderName
|
||||
)
|
||||
)
|
||||
|
||||
notificationManager.notify(NOTIFICATION_ID, startNotification)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateForegroundInfo(notification: Notification) {
|
||||
val foregroundInfo = ForegroundServiceHelper.createWorkerForegroundInfo(
|
||||
NOTIFICATION_ID,
|
||||
notification,
|
||||
ForegroundServiceType.DataSync
|
||||
)
|
||||
setForeground(foregroundInfo)
|
||||
}
|
||||
|
||||
private fun createNotification(title: String): Notification = NotificationCompat.Builder(context, CHANNEL_ID)
|
||||
.setContentTitle(title)
|
||||
.setSmallIcon(R.drawable.uploads)
|
||||
.setOngoing(true)
|
||||
.setSound(null)
|
||||
.setVibrate(null)
|
||||
.setOnlyAlertOnce(true)
|
||||
.setSilent(true)
|
||||
.build()
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
private fun getStartNotificationTitle(): Pair<String, String>? = try {
|
||||
val localPath = syncedFolder.localPath
|
||||
val remotePath = syncedFolder.remotePath
|
||||
if (localPath.isBlank() || remotePath.isBlank()) {
|
||||
null
|
||||
} else {
|
||||
try {
|
||||
File(localPath).name to File(remotePath).name
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun canExitEarly(contentUris: Array<String>?, syncedFolderID: Long): Boolean {
|
||||
val overridePowerSaving = inputData.getBoolean(OVERRIDE_POWER_SAVING, false)
|
||||
if ((powerManagementService.isPowerSavingEnabled && !overridePowerSaving)) {
|
||||
Log_OC.w(TAG, "⚡ Skipping: device is in power saving mode")
|
||||
return true
|
||||
}
|
||||
|
||||
if (syncedFolderID < 0) {
|
||||
Log_OC.e(TAG, "invalid sync folder id")
|
||||
return true
|
||||
}
|
||||
|
||||
if (backgroundJobManager.bothFilesSyncJobsRunning(syncedFolderID)) {
|
||||
Log_OC.w(TAG, "🚧 another worker is already running for $syncedFolderID")
|
||||
return true
|
||||
}
|
||||
|
||||
val totalScanInterval = syncedFolder.getTotalScanInterval(connectivityService, powerManagementService)
|
||||
val currentTime = System.currentTimeMillis()
|
||||
val passedScanInterval = totalScanInterval <= currentTime
|
||||
|
||||
Log_OC.d(TAG, "lastScanTimestampMs: " + syncedFolder.lastScanTimestampMs)
|
||||
Log_OC.d(TAG, "totalScanInterval: $totalScanInterval")
|
||||
Log_OC.d(TAG, "currentTime: $currentTime")
|
||||
Log_OC.d(TAG, "passedScanInterval: $passedScanInterval")
|
||||
|
||||
if (!passedScanInterval && contentUris.isNullOrEmpty() && !overridePowerSaving) {
|
||||
Log_OC.w(
|
||||
TAG,
|
||||
"skipped since started before scan interval and nothing todo: " + syncedFolder.localPath
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of scanning the entire local folder, optional content URIs can be passed to the worker
|
||||
* to detect only the relevant changes.
|
||||
*/
|
||||
@Suppress("MagicNumber", "TooGenericExceptionCaught")
|
||||
private suspend fun collectFileChangesFromContentObserverWork(contentUris: Array<String>?) = try {
|
||||
withContext(Dispatchers.IO) {
|
||||
if (contentUris.isNullOrEmpty()) {
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolder)
|
||||
} else {
|
||||
val isContentUrisStored = FilesSyncHelper.insertChangedEntries(syncedFolder, contentUris)
|
||||
if (!isContentUrisStored) {
|
||||
Log_OC.w(
|
||||
TAG,
|
||||
"changed content uris not stored, fallback to insert all db entries to not lose files"
|
||||
)
|
||||
|
||||
FilesSyncHelper.insertAllDBEntriesForSyncedFolder(syncedFolder)
|
||||
}
|
||||
}
|
||||
syncedFolder.lastScanTimestampMs = System.currentTimeMillis()
|
||||
syncedFolderProvider.updateSyncFolder(syncedFolder)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log_OC.d(TAG, "Exception collectFileChangesFromContentObserverWork: $e")
|
||||
}
|
||||
|
||||
private fun prepareDateFormat(): SimpleDateFormat {
|
||||
val currentLocale = context.resources.configuration.locales[0]
|
||||
return SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale).apply {
|
||||
timeZone = TimeZone.getTimeZone(TimeZone.getDefault().id)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getUserOrReturn(syncedFolder: SyncedFolder): User? {
|
||||
val optionalUser = userAccountManager.getUser(syncedFolder.account)
|
||||
if (!optionalUser.isPresent) {
|
||||
Log_OC.w(TAG, "user not present")
|
||||
return null
|
||||
}
|
||||
return optionalUser.get()
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun getUploadSettings(syncedFolder: SyncedFolder): Triple<Boolean, Boolean, Int> {
|
||||
val lightVersion = context.resources.getBoolean(R.bool.syncedFolder_light)
|
||||
val accountName = syncedFolder.account
|
||||
|
||||
return if (lightVersion) {
|
||||
Log_OC.d(TAG, "light version is used")
|
||||
val arbitraryDataProvider = ArbitraryDataProviderImpl(context)
|
||||
val needsCharging = context.resources.getBoolean(R.bool.syncedFolder_light_on_charging)
|
||||
val needsWifi = arbitraryDataProvider.getBooleanValue(
|
||||
accountName,
|
||||
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI
|
||||
)
|
||||
val uploadActionString = context.resources.getString(R.string.syncedFolder_light_upload_behaviour)
|
||||
val uploadAction = getUploadAction(uploadActionString)
|
||||
Log_OC.d(TAG, "upload action is: $uploadAction")
|
||||
Triple(needsCharging, needsWifi, uploadAction)
|
||||
} else {
|
||||
Log_OC.d(TAG, "not light version is used")
|
||||
Triple(syncedFolder.isChargingOnly, syncedFolder.isWifiOnly, syncedFolder.uploadAction)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod", "DEPRECATION", "TooGenericExceptionCaught")
|
||||
private suspend fun uploadFiles(syncedFolder: SyncedFolder) = withContext(Dispatchers.IO) {
|
||||
val dateFormat = prepareDateFormat()
|
||||
val user = getUserOrReturn(syncedFolder) ?: return@withContext
|
||||
val ocAccount = OwnCloudAccount(user.toPlatformAccount(), context)
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(ocAccount, context)
|
||||
val lightVersion = context.resources.getBoolean(R.bool.syncedFolder_light)
|
||||
val currentLocale = context.resources.configuration.locales[0]
|
||||
|
||||
var lastId = 0
|
||||
while (true) {
|
||||
val filePathsWithIds = repository.getFilePathsWithIds(syncedFolder, lastId)
|
||||
|
||||
if (filePathsWithIds.isEmpty()) {
|
||||
Log_OC.w(TAG, "no more files to upload at lastId: $lastId")
|
||||
break
|
||||
}
|
||||
Log_OC.d(TAG, "Processing batch: lastId=$lastId, count=${filePathsWithIds.size}")
|
||||
|
||||
filePathsWithIds.forEach { (path, id) ->
|
||||
val file = File(path)
|
||||
val localPath = file.absolutePath
|
||||
val remotePath = getRemotePath(
|
||||
file,
|
||||
syncedFolder,
|
||||
dateFormat,
|
||||
lightVersion,
|
||||
context.resources,
|
||||
currentLocale
|
||||
)
|
||||
|
||||
try {
|
||||
var (uploadEntity, upload) = createEntityAndUpload(user, localPath, remotePath)
|
||||
try {
|
||||
// Insert/update to IN_PROGRESS state before starting upload
|
||||
val generatedId = uploadsStorageManager.uploadDao.insertOrReplace(uploadEntity)
|
||||
uploadEntity = uploadEntity.copy(id = generatedId.toInt())
|
||||
upload.uploadId = generatedId
|
||||
|
||||
val operation = createUploadFileOperation(upload, user)
|
||||
Log_OC.d(TAG, "🕒 uploading: $localPath, id: $generatedId")
|
||||
|
||||
val result = operation.execute(client)
|
||||
uploadsStorageManager.updateStatus(uploadEntity, result.isSuccess)
|
||||
|
||||
if (result.isSuccess) {
|
||||
repository.markFileAsUploaded(localPath, syncedFolder)
|
||||
Log_OC.d(TAG, "✅ upload completed: $localPath")
|
||||
} else {
|
||||
Log_OC.e(
|
||||
TAG,
|
||||
"❌ upload failed $localPath (${upload.accountName}): ${result.logMessage}"
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
uploadsStorageManager.updateStatus(
|
||||
uploadEntity,
|
||||
UploadsStorageManager.UploadStatus.UPLOAD_FAILED
|
||||
)
|
||||
Log_OC.e(
|
||||
TAG,
|
||||
"Exception during upload file, localPath: $localPath, remotePath: $remotePath," +
|
||||
" exception: $e"
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(
|
||||
TAG,
|
||||
"Exception uploadFiles during creating entity and upload, localPath: $localPath, " +
|
||||
"remotePath: $remotePath, exception: $e"
|
||||
)
|
||||
}
|
||||
|
||||
// update last id so upload can continue where it left
|
||||
lastId = id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createEntityAndUpload(user: User, localPath: String, remotePath: String): Pair<UploadEntity, OCUpload> {
|
||||
val (needsCharging, needsWifi, uploadAction) = getUploadSettings(syncedFolder)
|
||||
Log_OC.d(TAG, "creating oc upload for ${user.accountName}")
|
||||
|
||||
// Get or create upload entity
|
||||
var uploadEntity = uploadsStorageManager.uploadDao.getUploadByAccountAndPaths(
|
||||
localPath = localPath,
|
||||
remotePath = remotePath,
|
||||
accountName = user.accountName
|
||||
)
|
||||
|
||||
val upload: OCUpload
|
||||
if (uploadEntity != null) {
|
||||
// Existing upload - convert and update status
|
||||
|
||||
upload = uploadEntity.toOCUpload(null)
|
||||
upload.uploadStatus = UploadsStorageManager.UploadStatus.UPLOAD_IN_PROGRESS
|
||||
uploadEntity = upload.toUploadEntity()
|
||||
} else {
|
||||
// New upload - create with all settings
|
||||
|
||||
upload = OCUpload(localPath, remotePath, user.accountName).apply {
|
||||
nameCollisionPolicy = syncedFolder.nameCollisionPolicy
|
||||
isUseWifiOnly = needsWifi
|
||||
isWhileChargingOnly = needsCharging
|
||||
uploadStatus = UploadsStorageManager.UploadStatus.UPLOAD_IN_PROGRESS
|
||||
createdBy = UploadFileOperation.CREATED_AS_INSTANT_PICTURE
|
||||
isCreateRemoteFolder = true
|
||||
localAction = uploadAction
|
||||
}
|
||||
uploadEntity = upload.toUploadEntity()
|
||||
}
|
||||
|
||||
return uploadEntity to upload
|
||||
}
|
||||
|
||||
private fun createUploadFileOperation(upload: OCUpload, user: User): UploadFileOperation = UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
user,
|
||||
null,
|
||||
upload,
|
||||
upload.nameCollisionPolicy,
|
||||
upload.localAction,
|
||||
context,
|
||||
upload.isUseWifiOnly,
|
||||
upload.isWhileChargingOnly,
|
||||
true,
|
||||
FileDataStorageManager(user, context.contentResolver)
|
||||
)
|
||||
|
||||
private fun getRemotePath(
|
||||
file: File,
|
||||
syncedFolder: SyncedFolder,
|
||||
sFormatter: SimpleDateFormat,
|
||||
lightVersion: Boolean,
|
||||
resources: Resources,
|
||||
currentLocale: Locale
|
||||
): String {
|
||||
val lastModificationTime = calculateLastModificationTime(file, syncedFolder, sFormatter)
|
||||
|
||||
val (remoteFolder, useSubfolders, subFolderRule) = if (lightVersion) {
|
||||
Triple(
|
||||
resources.getString(R.string.syncedFolder_remote_folder),
|
||||
resources.getBoolean(R.bool.syncedFolder_light_use_subfolders),
|
||||
SubFolderRule.YEAR_MONTH
|
||||
)
|
||||
} else {
|
||||
Triple(
|
||||
syncedFolder.remotePath,
|
||||
syncedFolder.isSubfolderByDate,
|
||||
syncedFolder.subfolderRule
|
||||
)
|
||||
}
|
||||
|
||||
return FileStorageUtils.getInstantUploadFilePath(
|
||||
file,
|
||||
currentLocale,
|
||||
remoteFolder,
|
||||
syncedFolder.localPath,
|
||||
lastModificationTime,
|
||||
useSubfolders,
|
||||
subFolderRule
|
||||
)
|
||||
}
|
||||
|
||||
private fun hasExif(file: File): Boolean {
|
||||
val mimeType = FileStorageUtils.getMimeTypeFromName(file.absolutePath)
|
||||
return MimeType.JPEG.equals(mimeType, ignoreCase = true) || MimeType.TIFF.equals(mimeType, ignoreCase = true)
|
||||
}
|
||||
|
||||
@Suppress("NestedBlockDepth")
|
||||
private fun calculateLastModificationTime(
|
||||
file: File,
|
||||
syncedFolder: SyncedFolder,
|
||||
formatter: SimpleDateFormat
|
||||
): Long {
|
||||
var lastModificationTime = file.lastModified()
|
||||
if (MediaFolderType.IMAGE == syncedFolder.type && hasExif(file)) {
|
||||
Log_OC.d(TAG, "calculateLastModificationTime exif found")
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
try {
|
||||
val exifInterface = ExifInterface(file.absolutePath)
|
||||
val exifDate = exifInterface.getAttribute(ExifInterface.TAG_DATETIME)
|
||||
if (!exifDate.isNullOrBlank()) {
|
||||
val pos = ParsePosition(0)
|
||||
val dateTime = formatter.parse(exifDate, pos)
|
||||
if (dateTime != null) {
|
||||
lastModificationTime = dateTime.time
|
||||
Log_OC.w(TAG, "calculateLastModificationTime calculatedTime is: $lastModificationTime")
|
||||
} else {
|
||||
Log_OC.w(TAG, "calculateLastModificationTime dateTime is empty")
|
||||
}
|
||||
} else {
|
||||
Log_OC.w(TAG, "calculateLastModificationTime exifDate is empty")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log_OC.d(TAG, "Failed to get the proper time " + e.localizedMessage)
|
||||
}
|
||||
}
|
||||
return lastModificationTime
|
||||
}
|
||||
|
||||
private fun getUploadAction(action: String): Int = when (action) {
|
||||
"LOCAL_BEHAVIOUR_FORGET" -> FileUploadWorker.Companion.LOCAL_BEHAVIOUR_FORGET
|
||||
"LOCAL_BEHAVIOUR_MOVE" -> FileUploadWorker.Companion.LOCAL_BEHAVIOUR_MOVE
|
||||
"LOCAL_BEHAVIOUR_DELETE" -> FileUploadWorker.Companion.LOCAL_BEHAVIOUR_DELETE
|
||||
else -> FileUploadWorker.Companion.LOCAL_BEHAVIOUR_FORGET
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.jobs.autoUpload
|
||||
|
||||
import com.nextcloud.client.database.dao.FileSystemDao
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.utils.SyncedFolderUtils
|
||||
import java.io.File
|
||||
|
||||
class FileSystemRepository(private val dao: FileSystemDao) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "FilesystemRepository"
|
||||
const val BATCH_SIZE = 50
|
||||
}
|
||||
|
||||
@Suppress("NestedBlockDepth")
|
||||
suspend fun getFilePathsWithIds(syncedFolder: SyncedFolder, lastId: Int): List<Pair<String, Int>> {
|
||||
val syncedFolderId = syncedFolder.id.toString()
|
||||
Log_OC.d(TAG, "Fetching candidate files for syncedFolderId = $syncedFolderId")
|
||||
|
||||
val entities = dao.getAutoUploadFilesEntities(syncedFolderId, BATCH_SIZE, lastId)
|
||||
val filtered = mutableListOf<Pair<String, Int>>()
|
||||
|
||||
entities.forEach {
|
||||
it.localPath?.let { path ->
|
||||
val file = File(path)
|
||||
if (!file.exists()) {
|
||||
Log_OC.w(TAG, "Ignoring file for upload (doesn't exist): $path")
|
||||
} else if (!SyncedFolderUtils.isQualifiedFolder(file.parent)) {
|
||||
Log_OC.w(TAG, "Ignoring file for upload (unqualified folder): $path")
|
||||
} else if (!SyncedFolderUtils.isFileNameQualifiedForAutoUpload(file.name)) {
|
||||
Log_OC.w(TAG, "Ignoring file for upload (unqualified file): $path")
|
||||
} else {
|
||||
Log_OC.d(TAG, "Adding path to upload: $path")
|
||||
|
||||
if (it.id != null) {
|
||||
filtered.add(path to it.id)
|
||||
} else {
|
||||
Log_OC.w(TAG, "cant adding path to upload, id is null")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filtered
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
suspend fun markFileAsUploaded(localPath: String, syncedFolder: SyncedFolder) {
|
||||
val syncedFolderIdStr = syncedFolder.id.toString()
|
||||
|
||||
try {
|
||||
dao.markFileAsUploaded(localPath, syncedFolderIdStr)
|
||||
Log_OC.d(TAG, "Marked file as uploaded: $localPath for syncedFolderId=$syncedFolderIdStr")
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Error marking file as uploaded: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -14,13 +14,22 @@ import com.nextcloud.client.jobs.notification.WorkerNotificationManager
|
||||
import com.nextcloud.utils.numberFormatter.NumberFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.io.File
|
||||
import java.security.SecureRandom
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class DownloadNotificationManager(id: Int, private val context: Context, viewThemeUtils: ViewThemeUtils) :
|
||||
WorkerNotificationManager(id, context, viewThemeUtils, R.string.downloader_download_in_progress_ticker) {
|
||||
WorkerNotificationManager(
|
||||
id,
|
||||
context,
|
||||
viewThemeUtils,
|
||||
tickerId = R.string.downloader_download_in_progress_ticker,
|
||||
channelId = NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD
|
||||
) {
|
||||
|
||||
private var lastPercent = -1
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun prepareForStart(operation: DownloadFileOperation) {
|
||||
@@ -44,6 +53,12 @@ class DownloadNotificationManager(id: Int, private val context: Context, viewThe
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun updateDownloadProgress(percent: Int, totalToTransfer: Long) {
|
||||
// If downloads are so fast, no need to notify again.
|
||||
if (percent == lastPercent) {
|
||||
return
|
||||
}
|
||||
lastPercent = percent
|
||||
|
||||
val progressText = NumberFormatter.getPercentageText(percent)
|
||||
setProgress(percent, progressText, totalToTransfer < 0)
|
||||
showNotification()
|
||||
|
||||
Loaded 100 of 461 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user