Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
565bbd55bf | ||
|
|
2b697501e9 | ||
|
|
5d790f1e05 | ||
|
|
64ecefa305 | ||
|
|
ec302fd42d | ||
|
|
12ff1d5235 | ||
|
|
8cf0aa1a4f | ||
|
|
9de4faa4d6 | ||
|
|
2e2b519ba2 | ||
|
|
ae87f6eb28 | ||
|
|
cea7d7f2d6 | ||
|
|
8ff1a76cd5 | ||
|
|
52ff08c02e | ||
|
|
9dc14a2588 | ||
|
|
80630cb8fa | ||
|
|
efc07945f3 | ||
|
|
28c5d85ea0 | ||
|
|
a2d3014e71 | ||
|
|
3c0ef18505 | ||
|
|
8104883d62 | ||
|
|
68e28f4d32 | ||
|
|
1a60516706 | ||
|
|
11f5ee22cf | ||
|
|
e270ba89db | ||
|
|
95b54c4a93 | ||
|
|
2c118c7b7a | ||
|
|
204f9e23b1 | ||
|
|
be77b87304 | ||
|
|
d575173a0d | ||
|
|
535993571b | ||
|
|
07841f297a | ||
|
|
65143c3e51 | ||
|
|
1995d9e425 | ||
|
|
d98ed21691 | ||
|
|
bbff6d2b6a | ||
|
|
eeb5692d4f | ||
|
|
542ce2e641 | ||
|
|
0f24168711 | ||
|
|
42a4bc290a | ||
|
|
43bbc46bd7 | ||
|
|
4c05872f2f | ||
|
|
f48455af66 | ||
|
|
38fdc7a99e | ||
|
|
abaf4975f8 | ||
|
|
2f2fc1015a | ||
|
|
f2437c35e5 | ||
|
|
c830f06212 | ||
|
|
e377d52077 | ||
|
|
8121c9e6e6 | ||
|
|
e22b4a41d0 | ||
|
|
3b5e2b90e0 | ||
|
|
c1f26f28d2 | ||
|
|
9d07282403 | ||
|
|
704cc79cc3 | ||
|
|
b7f8234832 | ||
|
|
5d423fcdab | ||
|
|
ce29f3d227 | ||
|
|
9a3f72871f | ||
|
|
6f0315759e | ||
|
|
1fc7bf16da | ||
|
|
831f1b4842 | ||
|
|
9131291bdb | ||
|
|
703f6238c8 | ||
|
|
0d5f7fe6ad | ||
|
|
278319c39d | ||
|
|
5028977cc8 | ||
|
|
b2974669b0 | ||
|
|
3a997b480e | ||
|
|
5cc53050ea | ||
|
|
16bbdca67e | ||
|
|
045429fd38 | ||
|
|
370d3c2b79 | ||
|
|
d48b8418fc | ||
|
|
7aa5ac583f | ||
|
|
b4332c7cc7 | ||
|
|
c85e7a63dc | ||
|
|
82634b52d6 | ||
|
|
f0a250beeb | ||
|
|
d307ab5b2a | ||
|
|
ec55b04c5a | ||
|
|
be88ad96e1 | ||
|
|
4c4be4f57e | ||
|
|
2f8f20297f | ||
|
|
0ddc684537 | ||
|
|
dc9db57529 | ||
|
|
a7fa2a3097 | ||
|
|
5da3a1c527 | ||
|
|
c7bdc4d4aa | ||
|
|
caff81156d | ||
|
|
12c76849b8 | ||
|
|
eb2711a569 | ||
|
|
d34c02a5f4 | ||
|
|
2e47a09845 | ||
|
|
933b7ec44c | ||
|
|
f92fd7e521 | ||
|
|
fe710979d9 | ||
|
|
12e0e52d7b | ||
|
|
a05730a547 | ||
|
|
bd6f12cfad | ||
|
|
63172442b5 | ||
|
|
f384e2961a | ||
|
|
2b7e64a861 | ||
|
|
e8e2b43af0 | ||
|
|
5342b2f871 | ||
|
|
4d544a59a3 | ||
|
|
fa7ca6b719 | ||
|
|
653c5b97e5 | ||
|
|
d17d2d2a3e | ||
|
|
5e0f19171b | ||
|
|
2d20a14026 | ||
|
|
ecf0fd92ad | ||
|
|
8c665a4fbd | ||
|
|
0a82d58279 | ||
|
|
309f2c511d | ||
|
|
641b82cbc2 | ||
|
|
0798a10d66 | ||
|
|
159dd3b074 | ||
|
|
5013aa0587 | ||
|
|
1e74f7a8b1 | ||
|
|
be8621ca27 | ||
|
|
271999ec08 | ||
|
|
7e53fffff2 | ||
|
|
a44c07004e | ||
|
|
c009702ced | ||
|
|
abeaa0bea2 | ||
|
|
aaae403c46 | ||
|
|
07e68c0cb4 | ||
|
|
9246e70820 | ||
|
|
9ca02722ef | ||
|
|
be626864b1 | ||
|
|
1a42c12abc | ||
|
|
26d517e0cb | ||
|
|
96676a00cb | ||
|
|
ab96482dca | ||
|
|
b159dd9aff | ||
|
|
8bf4f70481 | ||
|
|
e7aac49d4b | ||
|
|
963ba65aaa | ||
|
|
7bcd4d2e8c | ||
|
|
d53569bea3 | ||
|
|
0933747068 | ||
|
|
9304f1b1f4 | ||
|
|
e770287f8a | ||
|
|
892fe1de6d | ||
|
|
ca4cc0a308 | ||
|
|
4b35496fcf | ||
|
|
7955f412e1 | ||
|
|
303a431118 | ||
|
|
7fe29ea822 | ||
|
|
3e54ebbcb0 | ||
|
|
821f1b6c5a | ||
|
|
b93034677e | ||
|
|
b58cc428cf | ||
|
|
28b35ed556 | ||
|
|
1a958730df | ||
|
|
53682a6d81 | ||
|
|
ec5bf46318 | ||
|
|
f2c3986498 | ||
|
|
00c3dc0ab7 | ||
|
|
6f36ce7737 | ||
|
|
4a040f9e03 | ||
|
|
fdd93ca520 | ||
|
|
e99bb65703 | ||
|
|
774be28b22 | ||
|
|
f1a1481351 | ||
|
|
53e0adea34 | ||
|
|
4dafa55cb6 | ||
|
|
4d55f77f5e | ||
|
|
2af165bed1 | ||
|
|
198a2f0b32 | ||
|
|
0800900271 | ||
|
|
e7477225c1 | ||
|
|
96337feb27 | ||
|
|
fc2642a432 | ||
|
|
f4aec3c690 | ||
|
|
c71874eb30 | ||
|
|
73cb67a763 | ||
|
|
e9103a1b3b | ||
|
|
f5cc60a22d | ||
|
|
c31f400a49 | ||
|
|
6bc597dbbf | ||
|
|
ba55ce8e4e | ||
|
|
0cce33aedd | ||
|
|
857a75d4af | ||
|
|
d1df066ff3 | ||
|
|
641ef49407 | ||
|
|
3fe3a8d143 | ||
|
|
fb01b1e74b | ||
|
|
dba02f5db9 | ||
|
|
0f98682f46 | ||
|
|
19c1c03c2c | ||
|
|
91dd8753af | ||
|
|
78cb027065 | ||
|
|
2b30f0bbd6 | ||
|
|
bde1361e0d | ||
|
|
2588450000 | ||
|
|
fea04392ef | ||
|
|
416dda67b0 | ||
|
|
674aa2afb8 | ||
|
|
2dc375c71c | ||
|
|
5c715fe263 | ||
|
|
c03755b672 | ||
|
|
47d168dc9a | ||
|
|
5079c17d56 | ||
|
|
94638b6e4a | ||
|
|
6ad9fb0655 | ||
|
|
53bc4a7baf | ||
|
|
ac069c0002 | ||
|
|
22dea5430a | ||
|
|
e9358fba93 | ||
|
|
913084ac91 | ||
|
|
3b3fb17f18 | ||
|
|
07ba37f008 | ||
|
|
9c64a7e976 | ||
|
|
3bffab5448 | ||
|
|
cad7e79a5f | ||
|
|
da5da2713c | ||
|
|
8c0689bfa9 | ||
|
|
a751848f7e | ||
|
|
1b043dca33 | ||
|
|
eeac608cfc | ||
|
|
105667b1b2 | ||
|
|
86157201af | ||
|
|
1f1ba2efc5 | ||
|
|
647525919b | ||
|
|
48c8db13dc | ||
|
|
fa73f5d521 | ||
|
|
dbeda64e38 | ||
|
|
390d898806 | ||
|
|
fef419abac | ||
|
|
03caa6211f | ||
|
|
cb7e4b95dc | ||
|
|
bcac98a989 | ||
|
|
1407ecec9e | ||
|
|
7b7f1d6650 | ||
|
|
87e67db2ac | ||
|
|
397f4f73da | ||
|
|
9e1a450e20 | ||
|
|
d1c8ab07ea | ||
|
|
0a5c5a234c | ||
|
|
abf4353d0c | ||
|
|
274954334e | ||
|
|
5f298c5c13 | ||
|
|
ccbbe2257e | ||
|
|
03e5f5f516 | ||
|
|
5213ea092e | ||
|
|
e3147733dd | ||
|
|
18e8fac47f | ||
|
|
5e4cdfdc7c | ||
|
|
c5fa0d6661 | ||
|
|
3018d90d98 | ||
|
|
42aa8e3321 | ||
|
|
bfbc7f72a4 | ||
|
|
f8c2fdeaab | ||
|
|
25d0003fa0 | ||
|
|
0c8ce43bca | ||
|
|
09cf3aec05 | ||
|
|
9eab9f81ef | ||
|
|
573d4dc0f6 | ||
|
|
7e3dc87ec3 | ||
|
|
1f9b6162e9 | ||
|
|
3423f368ae | ||
|
|
52aa4dfbb3 | ||
|
|
f5034970df | ||
|
|
aa77361096 | ||
|
|
d58c2f9101 | ||
|
|
be514816f9 | ||
|
|
b3d2a16c65 | ||
|
|
a703de0a62 | ||
|
|
e91008b8fb | ||
|
|
f6b4a4e16a | ||
|
|
abae220e13 | ||
|
|
2c444f9cfd | ||
|
|
2577df43ac | ||
|
|
705720928b | ||
|
|
0d3b7f3fa6 | ||
|
|
6a40121d15 | ||
|
|
296b5b634a | ||
|
|
20b06b7192 | ||
|
|
a419f2af80 | ||
|
|
ebf2c9773c | ||
|
|
1b6d691766 | ||
|
|
b1796fa902 | ||
|
|
71407ca75b | ||
|
|
8bda2e10ae | ||
|
|
7fb1156d5a | ||
|
|
a3e3f7d44f | ||
|
|
4149368385 | ||
|
|
951e7da5f7 | ||
|
|
70bd4cc6d3 | ||
|
|
6c8c5baa91 | ||
|
|
32c3681178 | ||
|
|
d276baacc6 | ||
|
|
b6ca6dad7d | ||
|
|
1c5e3459cf | ||
|
|
e457545781 | ||
|
|
b716d666e4 | ||
|
|
7bab17651c | ||
|
|
5a5d7389c8 | ||
|
|
21c716a82f | ||
|
|
6f89fbe8f6 | ||
|
|
38d80899a4 | ||
|
|
b99fdf83f6 | ||
|
|
67f8a2836c | ||
|
|
62c58ac894 | ||
|
|
4c35b59e97 | ||
|
|
ac9f4598e2 | ||
|
|
9342eb0400 | ||
|
|
965f00d7ef | ||
|
|
0432fac31a | ||
|
|
ce24a5eb5c | ||
|
|
c0e9045185 | ||
|
|
6b07859910 | ||
|
|
e69717e736 | ||
|
|
306b400f2b | ||
|
|
e8a5a71f3f | ||
|
|
767bd09854 | ||
|
|
d894f20be6 | ||
|
|
a8f988c5d6 | ||
|
|
f52721a794 | ||
|
|
95df919491 | ||
|
|
d64a0bd5f7 | ||
|
|
e1e5e537da | ||
|
|
ddf92256c0 | ||
|
|
2182c19785 | ||
|
|
8f924af425 | ||
|
|
375944f6eb | ||
|
|
42675138b9 | ||
|
|
9efbff8c1c | ||
|
|
a7dcb4d340 | ||
|
|
48d42bde77 | ||
|
|
950ff4f1fb | ||
|
|
acd8846c18 | ||
|
|
a9481dad36 | ||
|
|
33061cb96c | ||
|
|
3ea7b9c2b4 | ||
|
|
a45395115f | ||
|
|
53cf041839 | ||
|
|
035f26a567 | ||
|
|
3d6547d1ff | ||
|
|
936fff3544 | ||
|
|
391cc26130 | ||
|
|
70a7b85481 | ||
|
|
3c9401d46f | ||
|
|
856f2daffc | ||
|
|
0dc9238b0a | ||
|
|
0adf9d91b4 | ||
|
|
a19f683fc2 | ||
|
|
b22ccc498c | ||
|
|
422f3fe33b | ||
|
|
4f84009ceb | ||
|
|
33e7bd1c30 | ||
|
|
fc61ab17fc | ||
|
|
747db66591 | ||
|
|
69cb8c5e1a | ||
|
|
3b2da11a14 | ||
|
|
5b72ab1c7d | ||
|
|
03a4d5c5dc | ||
|
|
a70d6b0be2 | ||
|
|
3966537247 | ||
|
|
6e259c549e | ||
|
|
c645761e8e | ||
|
|
8c96522980 | ||
|
|
688c5b5c5a | ||
|
|
d99135d60a | ||
|
|
eb4915fb54 | ||
|
|
fd0de89732 | ||
|
|
21dc51e2cf | ||
|
|
8d17de3904 | ||
|
|
f1aaccaee5 | ||
|
|
b805ed780b | ||
|
|
fe71db905b | ||
|
|
eb7ca0d614 | ||
|
|
bdddbf5156 | ||
|
|
6c697ee0c7 | ||
|
|
6820f7f6c7 | ||
|
|
b6dddea2df | ||
|
|
03990489e7 | ||
|
|
fb3a32d3e1 | ||
|
|
e48472538f | ||
|
|
9f34857553 | ||
|
|
45ed3479be | ||
|
|
d24972474e | ||
|
|
fe0a466bbc | ||
|
|
84dc725cc2 | ||
|
|
0e85bfbc75 | ||
|
|
4ff333e408 | ||
|
|
e283eb9417 | ||
|
|
3b1c11529b | ||
|
|
24556375d3 | ||
|
|
13057e1237 | ||
|
|
092e1b4495 | ||
|
|
1b9023f7f6 | ||
|
|
0642417712 | ||
|
|
2e6256fb24 | ||
|
|
9d42847cad | ||
|
|
177448d9c6 | ||
|
|
3b1697262c | ||
|
|
0ae45e2585 | ||
|
|
9c59c07c78 | ||
|
|
6cf12f458e | ||
|
|
0fa68e1ed5 | ||
|
|
1f2d6b30e8 | ||
|
|
a4f1030321 | ||
|
|
4e334480d0 | ||
|
|
9f2d87486f | ||
|
|
d38ff4c8f5 | ||
|
|
047d02b257 | ||
|
|
c634032add | ||
|
|
85a920d91e | ||
|
|
300e71550a | ||
|
|
ea20256e1f | ||
|
|
4bc3271632 | ||
|
|
88e435c756 | ||
|
|
b2eaac27a0 | ||
|
|
29f852c054 | ||
|
|
eda8749a3b | ||
|
|
62c6688cda | ||
|
|
223967604d | ||
|
|
f7eac5e279 | ||
|
|
d1e4580988 | ||
|
|
5cf0f9cbc3 | ||
|
|
e08217ade2 | ||
|
|
dd08908e0b | ||
|
|
645dc1c651 | ||
|
|
098eb69aec | ||
|
|
03ae97a1e6 | ||
|
|
ecad9b14ff | ||
|
|
83626d1f69 | ||
|
|
bc7de9df37 | ||
|
|
e533e0f3de | ||
|
|
ae575ff2e9 | ||
|
|
6d0a5a40a0 | ||
|
|
bb28e74934 | ||
|
|
d29d3bf807 | ||
|
|
d117f954b4 | ||
|
|
2a81f7ffa0 | ||
|
|
a26b112401 | ||
|
|
0bcc14b673 | ||
|
|
c93e8fe2eb | ||
|
|
0bb65a8c11 | ||
|
|
c39117b64b | ||
|
|
c8ea8415a3 | ||
|
|
a73837624e | ||
|
|
0f84188727 | ||
|
|
392c787263 | ||
|
|
4438993e89 | ||
|
|
9881d86c01 | ||
|
|
7e92494d84 | ||
|
|
b08e0cd2c4 | ||
|
|
959d9dca9a | ||
|
|
bd0f4e3500 | ||
|
|
9a1c0a8092 | ||
|
|
d29548bb21 | ||
|
|
84a49a37ec | ||
|
|
743a9eb4ec | ||
|
|
7829a20425 | ||
|
|
b8577cbd7e | ||
|
|
caf9c59b92 | ||
|
|
9905669de0 | ||
|
|
87283c7103 | ||
|
|
b9871f8462 | ||
|
|
0ebf1bea50 | ||
|
|
4e14c91f62 | ||
|
|
e3af862207 | ||
|
|
f0a571cc32 | ||
|
|
7cd8e423d6 | ||
|
|
0a15335da3 | ||
|
|
ae34d1a7ff | ||
|
|
ee0d5b8319 | ||
|
|
9120e3783f | ||
|
|
821c1bac8e | ||
|
|
f43a4753f1 | ||
|
|
cabdd6776b | ||
|
|
c7e77958e8 | ||
|
|
038446a18a | ||
|
|
a9ae9e6b9e | ||
|
|
62d114ed82 | ||
|
|
12605002df | ||
|
|
c2e8d47292 | ||
|
|
c576fd9f6f | ||
|
|
8c87f8c736 | ||
|
|
35d1cbe4d9 | ||
|
|
d6a612c68d | ||
|
|
ade9bfb16c | ||
|
|
a08ab7123b | ||
|
|
93e745e912 | ||
|
|
f4b3bc709d | ||
|
|
41a4c1e746 | ||
|
|
67500a266f | ||
|
|
556936369d | ||
|
|
abd09e5bf4 | ||
|
|
0565a24caf | ||
|
|
44598f8ac3 | ||
|
|
9b8b989790 | ||
|
|
18cd6048ed | ||
|
|
35bd87bedf | ||
|
|
439275af73 | ||
|
|
3892467e7b | ||
|
|
5ea5172bc2 | ||
|
|
9eb7e1a9fb | ||
|
|
99647e3ec5 | ||
|
|
5483ce91d7 | ||
|
|
5f9874d282 | ||
|
|
f02ae46798 | ||
|
|
59e4e15479 | ||
|
|
ea0bfd4ebb | ||
|
|
1143a37b64 | ||
|
|
de314a7539 | ||
|
|
ae1dc2e3e7 | ||
|
|
d19ec07078 | ||
|
|
c85ff69fc4 | ||
|
|
de089a6716 | ||
|
|
ce4051350d | ||
|
|
3dbeb07305 | ||
|
|
98a738a036 | ||
|
|
8136cc73f9 | ||
|
|
da430883f5 | ||
|
|
5541955913 | ||
|
|
235d0a3d4e | ||
|
|
5c345434e3 | ||
|
|
8af20c5e8f | ||
|
|
0fb21e4b3b | ||
|
|
f38a79e540 | ||
|
|
84d44f2bf8 | ||
|
|
52146ac79a | ||
|
|
47fc38d5ce | ||
|
|
bf284ac5bb | ||
|
|
138830fbd8 | ||
|
|
44aed13e13 | ||
|
|
8c8844fab4 | ||
|
|
1411997684 | ||
|
|
789f863137 | ||
|
|
282498314b | ||
|
|
f3892b3940 | ||
|
|
5d545866ba | ||
|
|
fe258b8a5a | ||
|
|
bd7c73f413 | ||
|
|
1759cc9413 | ||
|
|
df27f5a1ae | ||
|
|
b17a0e4df4 | ||
|
|
89485a9886 | ||
|
|
5b667d7a99 | ||
|
|
af9a6ee749 | ||
|
|
b24a1685b9 | ||
|
|
ae2a8c6711 | ||
|
|
37f566949e | ||
|
|
19921dccaa | ||
|
|
38a598c165 | ||
|
|
9224f829b5 |
No files matched your search
@@ -0,0 +1,26 @@
|
||||
# SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
# SPDX-FileCopyrightText: 2026 Milen Pivchev
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
# SPM packages declared in Nextcloud.xcodeproj (NextcloudKit, Realm, Firebase, …)
|
||||
- package-ecosystem: "swift"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 10
|
||||
labels:
|
||||
- "dependencies"
|
||||
commit-message:
|
||||
prefix: "fix(deps)"
|
||||
|
||||
# Keep the GitHub Actions used by our workflows up to date
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
labels:
|
||||
- "dependencies"
|
||||
commit-message:
|
||||
prefix: "ci"
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
steps:
|
||||
- name: Set env var
|
||||
run: echo "DEVELOPER_DIR=$(xcode-select --print-path)" >> $GITHUB_ENV
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v7
|
||||
- name: Download GoogleService-Info.plist
|
||||
run: wget "https://raw.githubusercontent.com/firebase/quickstart-ios/master/mock-GoogleService-Info.plist" -O GoogleService-Info.plist
|
||||
- name: Build iOS Share
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: GitHub Action for SwiftLint
|
||||
uses: norio-nomura/[email protected]
|
||||
@@ -19,6 +19,7 @@ env:
|
||||
PROJECT: Nextcloud.xcodeproj
|
||||
DESTINATION: platform=iOS Simulator,name=iPhone 16,OS=18.5
|
||||
SCHEME: Nextcloud
|
||||
XCODE_VERSION: '26.0.1'
|
||||
SERVER_BRANCH: stable30
|
||||
PHP_VERSION: 8.3
|
||||
|
||||
@@ -29,15 +30,15 @@ jobs:
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Download GoogleService-Info.plist
|
||||
run: wget "https://raw.githubusercontent.com/firebase/quickstart-ios/master/mock-GoogleService-Info.plist" -O GoogleService-Info.plist
|
||||
|
||||
- name: Setup Xcode
|
||||
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
|
||||
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
|
||||
with:
|
||||
xcode-version: 16.4
|
||||
xcode-version: ${{ env.XCODE_VERSION }}
|
||||
|
||||
- name: Run Xcode Build
|
||||
run: |
|
||||
@@ -49,7 +50,7 @@ jobs:
|
||||
| xcbeautify --quieter
|
||||
|
||||
- name: Upload Build Products
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Nextcloud for iOS
|
||||
path: DerivedData/Build/Products
|
||||
@@ -60,12 +61,15 @@ jobs:
|
||||
runs-on: macos-15
|
||||
needs: [build]
|
||||
|
||||
# Temporarily, project has no effective tests except UI tests which are unfeasible on virtualized GitHub runners (see #3291)
|
||||
# Previously: github.event.pull_request.draft == false
|
||||
if: false
|
||||
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Setup Xcode
|
||||
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
|
||||
with:
|
||||
xcode-version: ${{ env.XCODE_VERSION }}
|
||||
|
||||
- name: Prepare PHP ${{ env.PHP_VERSION }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
@@ -78,7 +82,7 @@ jobs:
|
||||
ini-values: apc.enable_cli=on, disable_functions=
|
||||
|
||||
- name: Checkout Nextcloud Server
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: true
|
||||
repository: nextcloud/server
|
||||
@@ -86,7 +90,7 @@ jobs:
|
||||
ref: ${{ env.SERVER_BRANCH }}
|
||||
|
||||
- name: Checkout Download Limits App
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
repository: nextcloud/files_downloadlimit
|
||||
path: server/apps/files_downloadlimit
|
||||
@@ -99,14 +103,12 @@ jobs:
|
||||
./server/occ config:system:set hashing_default_password --value=true --type=boolean
|
||||
./server/occ config:system:set auth.bruteforce.protection.enabled --value false --type bool
|
||||
./server/occ config:system:set ratelimit.protection.enabled --value false --type bool
|
||||
./server/occ config:system:set memcache.local --value="\\OC\\Memcache\\APCu"
|
||||
./server/occ config:system:set memcache.distributed --value="\\OC\\Memcache\\APCu"
|
||||
./server/occ app:enable files_downloadlimit
|
||||
./server/occ background:cron
|
||||
PHP_CLI_SERVER_WORKERS=5 php -S localhost:8080 -t server/ &
|
||||
|
||||
- name: Download Build
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: Nextcloud for iOS
|
||||
|
||||
@@ -139,7 +141,7 @@ jobs:
|
||||
-resultBundlePath "TestResult.xcresult"
|
||||
|
||||
- name: Upload Xcode Test Results
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: TestResult.xcresult
|
||||
|
||||
@@ -35,12 +35,8 @@ DerivedData
|
||||
*.hmap
|
||||
*.xccheckout
|
||||
|
||||
## Package
|
||||
Carthage/
|
||||
|
||||
### SwiftPackageManager ###
|
||||
.swiftpm
|
||||
Package.resolved
|
||||
|
||||
*.generated.swift
|
||||
/.env-vars
|
||||
## Claude Code
|
||||
.claude/
|
||||
@@ -47,5 +47,6 @@ excluded:
|
||||
- iOSClient/NCGlobal.swift
|
||||
- iOSClient/Utility/NCLivePhoto.swift
|
||||
- DerivedData
|
||||
- .claude
|
||||
|
||||
reporter: "xcode"
|
||||
@@ -0,0 +1,93 @@
|
||||
<!--
|
||||
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
- SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# AGENTS.md
|
||||
|
||||
## Your Role
|
||||
|
||||
- You are an experienced engineer specialized in Swift and familiar with the platform-specific details of iOS.
|
||||
- You implement features and fix bugs.
|
||||
- Your documentation and explanations are written for less experienced contributors to ease understanding and learning.
|
||||
- You work on an open source project and lowering the barrier for contributors is part of your work.
|
||||
|
||||
## Project Overview
|
||||
|
||||
The Nextcloud iOS Client is a tool to access and synchronize files from Nextcloud Server on your iPhone or iPad.
|
||||
Swift, UIKit and SwiftUI are the key technologies used for building the app on iOS.
|
||||
Server communication is handled by the NextcloudKit library — a separate repository (https://github.com/nextcloud/NextcloudKit) consumed as a Swift Package pinned to an exact version in `Nextcloud.xcodeproj`. Prefer its APIs over hand-rolled networking code; server API changes belong in that repo.
|
||||
Other key dependencies (all Swift Packages): Realm (local database), Alamofire (HTTP), Firebase (crash reporting), OpenSSL (end-to-end encryption), VLCKit (media playback). Prefer existing dependencies over adding new ones.
|
||||
Other platforms like Android are irrelevant for this project.
|
||||
|
||||
## Project Structure: AI Agent Handling Guidelines
|
||||
|
||||
| Directory | Description | Agent Action |
|
||||
|-----------------|-----------------------------------------------------|----------------------|
|
||||
| `.github` | GitHub CI workflows (build & test, SwiftLint, extension-target builds) and issue templates. | Keep all three checks green: `xcode.yml` (builds the `Nextcloud` scheme and runs its tests against a Nextcloud server provisioned in CI), `lint.yml` (SwiftLint), `additional-targets.yml` (build-checks the extension schemes). CI skips draft PRs. |
|
||||
| `iOSClient` | Main iOS client source code. | — |
|
||||
| `iOSClient/Supporting Files` | Translation files synced with Transifex (see `iOSClient/.tx/config`). | Only add new strings to `en.lproj` (`Localizable.strings`, plurals in `Localizable.stringsdict`); never edit the other `*.lproj` dirs — Transifex overwrites them. |
|
||||
| `Brand` | Branding layer: `NCBrand.swift` (app constants, colors), `Database.swift` (Realm database name and schema version), Info.plists and entitlements for all targets, launch screen and intro screens. | Bump `databaseSchemaVersion` in `Brand/Database.swift` when changing Realm models. |
|
||||
| `File Provider Extension` | Contains business logic for the iOS File Provider extension. | — |
|
||||
| `File Provider Extension UI` | Contains UI logic for the iOS File Provider extension. | — |
|
||||
| `Share` | Contains code for the iOS Share extension. | — |
|
||||
| `Widget` | Contains code for iOS Widgets. | — |
|
||||
| `WidgetDashboardIntentHandler` | Contains the intent handler for the dashboard widget. | — |
|
||||
| `Notification Service Extension` | Contains the push notification service extension. | — |
|
||||
| `Action Assistant` | iOS Action extension that receives shared text from other apps and forwards it to the in-app Nextcloud Assistant. | — |
|
||||
| `AppIcon.icon` | Icon Composer app-icon bundle. | Do not edit by hand; use Icon Composer. |
|
||||
| `Tests` | Unit tests (`NextcloudUnitTests`), UI tests (`NextcloudUITests`) and integration tests (`NextcloudIntegrationTests`), plus `TestConstants.swift` and the `Server.sh` test-server script. | Prefer `NextcloudUnitTests` for new tests. Try to add unit tests for new features, where applicable and makes sense; do not overcomplicate them. |
|
||||
|
||||
Keep this table up to date: when a change adds, removes or repurposes a directory listed here, update the table in the same PR.
|
||||
|
||||
## General Guidance
|
||||
|
||||
The project is licensed under GPL-3.0-or-later (`LICENSE.txt`) with an Apple App Store exception (`COPYING.iOS`).
|
||||
|
||||
Every new file needs to get a SPDX header in the first rows according to this template.
|
||||
Replace `<YEAR>` with the year the file is created and `<Author Name>` with the contributing author (Nextcloud has no CLA; copyright stays with the individual contributors).
|
||||
The commenting signs need to be used depending on the file type.
|
||||
|
||||
```plaintext
|
||||
SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
SPDX-FileCopyrightText: <YEAR> <Author Name>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
```
|
||||
|
||||
Some older files still carry legacy “Created by … All rights reserved” Xcode headers — do not copy that style into new files. There is no automated SPDX check in CI, so header correctness is on you.
|
||||
|
||||
Avoid creating source files that implement multiple types; instead, place each type in its own dedicated source file.
|
||||
|
||||
## Commit and Pull Request Guidelines
|
||||
|
||||
- **DCO sign-off (required)**: All commits must comply with the Developer Certificate of Origin (DCO) as described in `README.md` and include a `Signed-off-by: …` line in the commit message. Sign off with `git commit -s`; the DCO status check blocks PRs otherwise.
|
||||
- **Commits**: In addition to the DCO sign-off, follow the Conventional Commits format for the subject line where reasonable. Use `feat: ...`, `fix: ...`, or `refactor: ...` as appropriate in the commit message prefix.
|
||||
- Include a short summary of what changed. *Example:* `fix: prevent crash on empty file name`.
|
||||
- **Pull Request**: When the agent creates a PR, it should include a description summarizing the changes and why they were made. If a GitHub issue exists, reference it (e.g., “Closes #123”). Target `master` (the default branch); `stable-XX.Y.Z` branches are only for backports. Note that `README.md` still mentions a `develop` branch — it no longer exists.
|
||||
- **AI-assisted changes**: Declare AI tool use in the PR description (the org-level PR template includes an AI checkbox) and add an `Assisted-by: AGENT_NAME:MODEL_VERSION` trailer to each affected commit, per the org-wide policy in `nextcloud/.github`.
|
||||
|
||||
## iOS Specifics
|
||||
|
||||
The following details are important when working on the iOS client.
|
||||
|
||||
### Requirements
|
||||
|
||||
- Use at least the Xcode version pinned in `.github/workflows/xcode.yml` — that is what CI builds and tests with.
|
||||
- A `GoogleService-Info.plist` must exist at the repo root to build; CI downloads Firebase's mock plist (see `xcode.yml`).
|
||||
|
||||
### Code Style
|
||||
|
||||
- Write new code to be Swift 6-compatible and strict-concurrency-friendly (proper actor isolation, `Sendable` types). Note that the project currently builds in Swift 5 language mode without strict concurrency checking, so the compiler will not enforce this.
|
||||
- CI runs SwiftLint on every non-draft PR using the root `.swiftlint.yml`; `Tests/`, `Brand/NCBrand.swift`, `iOSClient/NCGlobal.swift` and `iOSClient/Utility/NCLivePhoto.swift` are excluded from linting.
|
||||
|
||||
### Tests
|
||||
|
||||
- When implementing new test suites, prefer Swift Testing over XCTest for implementation. UI tests are the exception — XCUITest requires XCTest, so new UI tests are XCTest classes subclassing `BaseUIXCTestCase` in `Tests/NextcloudUITests`.
|
||||
- New unit tests go in `Tests/NextcloudUnitTests` as Swift Testing `@Suite` structs with `@testable import Nextcloud`; they need no server.
|
||||
- When implementing test cases using Swift Testing, do not prefix test method names with "test".
|
||||
- If the implementation of mock types is inevitable, implement them in dedicated source code files and in a generic way, so they can be reused across all tests in a test target. Currently no mock types or mocking library exist; reusable UI-test helpers live in `Tests/NextcloudUITests` (`UITestBackend` and its `Responses/` decodables) — extend these before adding new ones.
|
||||
- If the implementation of an existing mock type does not fulfill the requirements introduced by new tests, prefer updating the existing type before implementing a mostly redundant alternative type.
|
||||
- UI tests require a Nextcloud server at `http://localhost:8080` (credentials `admin`/`admin`, see `Tests/TestConstants.swift`); start one with `Tests/Server.sh` (requires Docker). CI provisions the same server.
|
||||
- `NextcloudIntegrationTests` is currently an empty target: `LoginIntegrationTests.swift` is on disk but excluded from the build and references a nonexistent `EnvVars` type — do not model new tests on it.
|
||||
- Verify that all tests are passing and correct them if necessary.
|
||||
- Run tests the way CI does (see `.github/workflows/xcode.yml`): `xcodebuild test -scheme Nextcloud -destination "platform=iOS Simulator,name=iPhone 16,OS=18.5"` (adjust the simulator to what is installed locally). Without a local test server, restrict to `-only-testing:NextcloudUnitTests`.
|
||||
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// ActionViewController.swift
|
||||
// Action Assistant
|
||||
//
|
||||
// Created by Marino Faggiana on 14/05/2026.
|
||||
// Copyright © 2026 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import NextcloudKit
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
final class ActionViewController: UIViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.isHidden = true
|
||||
view.alpha = 0
|
||||
view.backgroundColor = .clear
|
||||
preferredContentSize = .zero
|
||||
|
||||
Task {
|
||||
await handleAction()
|
||||
}
|
||||
}
|
||||
|
||||
private func handleAction() async {
|
||||
guard let text = await loadText() else {
|
||||
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
|
||||
return
|
||||
}
|
||||
|
||||
NCAssistantSharedTextStore.save(text)
|
||||
openMainAppForAssistantSharedText()
|
||||
}
|
||||
|
||||
private func loadText() async -> String? {
|
||||
guard let extensionItems = extensionContext?.inputItems as? [NSExtensionItem] else {
|
||||
return nil
|
||||
}
|
||||
|
||||
for extensionItem in extensionItems {
|
||||
guard let attachments = extensionItem.attachments else {
|
||||
continue
|
||||
}
|
||||
|
||||
for provider in attachments {
|
||||
if provider.hasItemConformingToTypeIdentifier(UTType.plainText.identifier) {
|
||||
return await loadText(from: provider, typeIdentifier: UTType.plainText.identifier)
|
||||
}
|
||||
|
||||
if provider.hasItemConformingToTypeIdentifier(UTType.utf8PlainText.identifier) {
|
||||
return await loadText(from: provider, typeIdentifier: UTType.utf8PlainText.identifier)
|
||||
}
|
||||
|
||||
if provider.hasItemConformingToTypeIdentifier(UTType.text.identifier) {
|
||||
return await loadText(from: provider, typeIdentifier: UTType.text.identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
private func loadText(from provider: NSItemProvider, typeIdentifier: String) async -> String? {
|
||||
await withCheckedContinuation { continuation in
|
||||
provider.loadItem(forTypeIdentifier: typeIdentifier, options: nil) { item, _ in
|
||||
let text: String?
|
||||
|
||||
if let string = item as? String {
|
||||
text = string
|
||||
} else if let attributedString = item as? NSAttributedString {
|
||||
text = attributedString.string
|
||||
} else if let data = item as? Data {
|
||||
text = String(data: data, encoding: .utf8)
|
||||
} else if let url = item as? URL {
|
||||
text = try? String(contentsOf: url, encoding: .utf8)
|
||||
} else {
|
||||
text = nil
|
||||
}
|
||||
|
||||
guard let text, !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||
continuation.resume(returning: nil)
|
||||
return
|
||||
}
|
||||
|
||||
continuation.resume(returning: text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func openMainAppForAssistantSharedText() {
|
||||
guard let url = URL(string: "nextcloud://assistant/shared-text") else {
|
||||
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
|
||||
return
|
||||
}
|
||||
|
||||
openAssistantSharedTextURLThroughResponderChain(url)
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
||||
self?.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the Assistant shared-text deep link from the Share extension.
|
||||
///
|
||||
/// Share extensions cannot use `UIApplication.shared` directly because it is not
|
||||
/// extension-safe. This method walks the responder chain until it finds the hidden
|
||||
/// `UIApplication` responder and invokes the modern `open(_:options:completionHandler:)`
|
||||
/// Objective-C selector dynamically.
|
||||
///
|
||||
/// This is intentionally isolated because it relies on Objective-C runtime dispatch.
|
||||
///
|
||||
/// - Parameter url: Deep link URL to open in the containing application.
|
||||
private func openAssistantSharedTextURLThroughResponderChain(_ url: URL) {
|
||||
let selector = NSSelectorFromString("openURL:options:completionHandler:")
|
||||
let applicationClass: AnyClass? = NSClassFromString("UIApplication")
|
||||
var responder: UIResponder? = self
|
||||
|
||||
while let currentResponder = responder {
|
||||
guard let applicationClass,
|
||||
currentResponder.isKind(of: applicationClass),
|
||||
currentResponder.responds(to: selector),
|
||||
let implementation = currentResponder.method(for: selector) else {
|
||||
responder = currentResponder.next
|
||||
continue
|
||||
}
|
||||
|
||||
typealias CompletionBlock = @convention(block) (Bool) -> Void
|
||||
typealias OpenURLFunction = @convention(c) (AnyObject, Selector, NSURL, NSDictionary, CompletionBlock?) -> Void
|
||||
|
||||
let openURL = unsafeBitCast(implementation, to: OpenURLFunction.self)
|
||||
|
||||
let completion: CompletionBlock = { success in
|
||||
if success {
|
||||
nkLog(debug: "Assistant shared text deep link performed through modern responder chain")
|
||||
} else {
|
||||
nkLog(error: "Assistant shared text deep link modern responder chain returned false")
|
||||
}
|
||||
}
|
||||
|
||||
openURL(currentResponder, selector, url as NSURL, NSDictionary(), completion)
|
||||
return
|
||||
}
|
||||
|
||||
nkLog(error: "Assistant shared text deep link failed because no UIApplication responder can open URL")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24765" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ObA-dk-sSI">
|
||||
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24743"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Image-->
|
||||
<scene sceneID="7MM-of-jgj">
|
||||
<objects>
|
||||
<viewController title="Image" id="ObA-dk-sSI" customClass="ActionViewController" customModule="Action_Assistant" sceneMemberID="viewController">
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<size key="freeformSize" width="320" height="528"/>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="X47-rx-isc" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="139" y="131"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Senza titolo.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"filename" : "Senza titolo 1.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "tinted"
|
||||
}
|
||||
],
|
||||
"filename" : "Senza titolo 2.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.4 MiB |
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" version="1.1" viewBox="0 0 141.49 99.6">
|
||||
<!-- Generator: Adobe Illustrator 30.3.0, SVG Export Plug-In . SVG Version: 2.1.3 Build 182) -->
|
||||
<defs>
|
||||
<style>
|
||||
.st0 {
|
||||
fill: #fff;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<path id="path1052" class="st0" d="M70.83,22.15c-12.59,0-23.26,8.54-26.57,20.1-2.88-6.14-9.1-10.43-16.28-10.43-9.87,0-17.98,8.11-17.98,17.98s8.11,17.99,17.98,17.99c7.18,0,13.41-4.3,16.28-10.44,3.31,11.57,13.98,20.11,26.57,20.11s23.12-8.41,26.51-19.85c2.93,6,9.08,10.18,16.15,10.18,9.87,0,17.99-8.12,17.99-17.99s-8.12-17.98-17.99-17.98c-7.07,0-13.23,4.18-16.15,10.17-3.39-11.44-14.01-19.84-26.51-19.84h0ZM70.83,32.7c9.51,0,17.1,7.59,17.1,17.1s-7.59,17.1-17.1,17.1-17.1-7.59-17.1-17.1,7.59-17.1,17.1-17.1ZM27.98,42.37c4.16,0,7.43,3.26,7.43,7.43s-3.26,7.43-7.43,7.43-7.43-3.26-7.43-7.43,3.26-7.43,7.43-7.43ZM113.5,42.37c4.17,0,7.43,3.26,7.43,7.43s-3.26,7.43-7.43,7.43-7.43-3.26-7.43-7.43,3.26-7.43,7.43-7.43Z" inkscape:connector-curvature="0" inkscape:export-filename="Nextcloud Hub logo variants.png" inkscape:export-xdpi="300" inkscape:export-ydpi="300"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"fill" : {
|
||||
"linear-gradient" : [
|
||||
"display-p3:0.10980,0.68627,1.00000,1.00000",
|
||||
"srgb:0.00000,0.50980,0.78824,1.00000"
|
||||
],
|
||||
"orientation" : {
|
||||
"start" : {
|
||||
"x" : 0.5,
|
||||
"y" : 0
|
||||
},
|
||||
"stop" : {
|
||||
"x" : 0.5,
|
||||
"y" : 0.7
|
||||
}
|
||||
}
|
||||
},
|
||||
"groups" : [
|
||||
{
|
||||
"layers" : [
|
||||
{
|
||||
"image-name" : "Nextcloud-logo-white.svg",
|
||||
"name" : "Nextcloud-logo-white",
|
||||
"position" : {
|
||||
"scale" : 6.8,
|
||||
"translation-in-points" : [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow" : {
|
||||
"kind" : "neutral",
|
||||
"opacity" : 0.5
|
||||
},
|
||||
"translucency" : {
|
||||
"enabled" : true,
|
||||
"value" : 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms" : {
|
||||
"circles" : [
|
||||
"watchOS"
|
||||
],
|
||||
"squares" : "shared"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.it.twsweb.Crypto-Cloud</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)it.twsweb.Crypto-Cloud</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST-1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Nextcloud Assistant</string>
|
||||
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>NSExtensionActivationRule</key>
|
||||
<dict>
|
||||
<key>NSExtensionActivationSupportsText</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
<string>MainInterface</string>
|
||||
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.ui-services</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,158 +1,14 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "57x57",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "57x57",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "50x50",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "50x50",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "72x72",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "72x72",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "83.5x83.5",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "[email protected]",
|
||||
"scale" : "1x"
|
||||
"filename" : "[email protected]",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 699 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
@@ -8,4 +8,4 @@ import Foundation
|
||||
//
|
||||
let databaseName = "nextcloud.realm"
|
||||
let tableAccountBackup = "tableAccountBackup.json"
|
||||
let databaseSchemaVersion: UInt64 = 404
|
||||
let databaseSchemaVersion: UInt64 = 414
|
||||
@@ -6,17 +6,6 @@
|
||||
<string>Nextcloud</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionFileProviderActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSExtensionFileProviderActionActivationRule</key>
|
||||
<string>TRUEPREDICATE</string>
|
||||
<key>NSExtensionFileProviderActionIdentifier</key>
|
||||
<string>com.mycompany.FileProviderUI.CustomAction</string>
|
||||
<key>NSExtensionFileProviderActionName</key>
|
||||
<string>Custom Action</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
<string>MainInterface</string>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
|
||||
@@ -22,6 +22,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
|
||||
private var timer: Timer?
|
||||
private var textColor: UIColor = .white
|
||||
private var textColorOpponent: UIColor = .black
|
||||
private var activeLoginProvider: NCLoginProvider?
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
@@ -53,7 +54,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
|
||||
if !NCManageDatabase.shared.getAllTableAccount().isEmpty {
|
||||
let navigationItemCancel = UIBarButtonItem(image: UIImage(systemName: "xmark"), style: .plain, target: self, action: #selector(actionCancel(_:)))
|
||||
navigationItemCancel.tintColor = textColor
|
||||
navigationItem.leftBarButtonItem = navigationItemCancel
|
||||
navigationItem.rightBarButtonItem = navigationItemCancel
|
||||
}
|
||||
|
||||
pageControl.currentPageIndicatorTintColor = textColor
|
||||
@@ -164,11 +165,12 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
|
||||
}
|
||||
|
||||
@IBAction func signupWithProvider(_ sender: Any) {
|
||||
if let viewController = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginProvider") as? NCLoginProvider {
|
||||
viewController.controller = self.controller
|
||||
viewController.initialURLString = NCBrandOptions.shared.linkloginPreferredProviders
|
||||
self.navigationController?.pushViewController(viewController, animated: true)
|
||||
}
|
||||
let loginProvider = NCLoginProvider()
|
||||
loginProvider.controller = self.controller
|
||||
loginProvider.initialURLString = NCBrandOptions.shared.linkloginPreferredProviders
|
||||
loginProvider.presentingViewController = self
|
||||
loginProvider.startAuthentication()
|
||||
self.activeLoginProvider = loginProvider
|
||||
}
|
||||
|
||||
@IBAction func host(_ sender: Any) {
|
||||
|
||||
@@ -20,12 +20,49 @@ let userAgent: String = {
|
||||
The codename embodies the concept of dynamic, living matter — reflecting our vision of a platform that is not only powerful and reliable, but also capable of continuous transformation and intelligent adaptation.
|
||||
*/
|
||||
|
||||
struct NextcloudVersion: Comparable {
|
||||
let major: Int
|
||||
let minor: Int
|
||||
let micro: Int
|
||||
|
||||
init(_ major: Int, _ minor: Int = 0, _ micro: Int = 0) {
|
||||
self.major = major
|
||||
self.minor = minor
|
||||
self.micro = micro
|
||||
}
|
||||
|
||||
init(_ capabilities: NKCapabilities.Capabilities) {
|
||||
self.major = capabilities.serverVersionMajor
|
||||
self.minor = capabilities.serverVersionMinor
|
||||
self.micro = capabilities.serverVersionMicro
|
||||
}
|
||||
|
||||
static let v18 = NextcloudVersion(18)
|
||||
static let v20 = NextcloudVersion(20)
|
||||
static let v23 = NextcloudVersion(23)
|
||||
static let v24 = NextcloudVersion(24)
|
||||
static let v25 = NextcloudVersion(25)
|
||||
static let v26 = NextcloudVersion(26)
|
||||
static let v27 = NextcloudVersion(27)
|
||||
static let v28 = NextcloudVersion(28)
|
||||
static let v30 = NextcloudVersion(30)
|
||||
static let v31 = NextcloudVersion(31)
|
||||
static let v32 = NextcloudVersion(32)
|
||||
static let v32_0_2 = NextcloudVersion(32, 0, 2)
|
||||
static let v33 = NextcloudVersion(33)
|
||||
static let v34 = NextcloudVersion(34)
|
||||
|
||||
static func < (lhs: NextcloudVersion, rhs: NextcloudVersion) -> Bool {
|
||||
(lhs.major, lhs.minor, lhs.micro) < (rhs.major, rhs.minor, rhs.micro)
|
||||
}
|
||||
}
|
||||
|
||||
final class NCBrandOptions: @unchecked Sendable {
|
||||
static let shared = NCBrandOptions()
|
||||
|
||||
var brand: String = "Nextcloud"
|
||||
var brandUserAgent: String = ""
|
||||
var textCopyrightNextcloudiOS: String = "Nextcloud Matheria for iOS %@ © 2025"
|
||||
var textCopyrightNextcloudiOS: String = "Nextcloud Matheria for iOS %@ © 2026"
|
||||
var textCopyrightNextcloudServer: String = "Nextcloud Server %@"
|
||||
var loginBaseUrl: String = "https://cloud.nextcloud.com"
|
||||
var pushNotificationServerProxy: String = ""
|
||||
@@ -68,23 +105,23 @@ final class NCBrandOptions: @unchecked Sendable {
|
||||
var enforce_servers: [(name: String, url: String)] = []
|
||||
|
||||
// Internal option behaviour
|
||||
var cleanUpDay: Int = 0 // Set default "Delete all cached files older than" possible days value are: 0, 1, 7, 30, 90, 180, 365
|
||||
var cleanUpDay: Int = 0 // Set default "Delete all cached files older than". Possible days value are: 0, 1, 7, 30, 90, 180, 365
|
||||
|
||||
// Max request/download/upload concurrent
|
||||
// Max request/download/upload concurrent connections per host, default is 8 (same as iOS default)
|
||||
let httpMaximumConnectionsPerHost: Int = 8
|
||||
let httpMaximumConnectionsPerHostInDownload: Int = 8
|
||||
let httpMaximumConnectionsPerHostInUpload: Int = 8
|
||||
|
||||
// Max request/download/upload process
|
||||
// Max request/download/upload processes
|
||||
let numMaximumProcess: Int = 20
|
||||
|
||||
// Number of failed attempts after reset app
|
||||
// Number of failed attempts before resetting the app
|
||||
let resetAppPasscodeAttempts: Int = 10
|
||||
let passcodeSecondsFail: Int = 60
|
||||
|
||||
// Info Paging
|
||||
enum NCInfoPagingTab: Int, CaseIterable {
|
||||
case activity, sharing
|
||||
case activity, sharing, details
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -127,13 +164,18 @@ final class NCBrandOptions: @unchecked Sendable {
|
||||
@objc func getUserAgent() -> String {
|
||||
return userAgent
|
||||
}
|
||||
|
||||
func isServerVersion(_ capabilities: NKCapabilities.Capabilities,
|
||||
greaterOrEqualTo version: NextcloudVersion) -> Bool {
|
||||
return NextcloudVersion(capabilities) >= version
|
||||
}
|
||||
}
|
||||
|
||||
final class NCBrandColor: @unchecked Sendable {
|
||||
static let shared = NCBrandColor()
|
||||
|
||||
// This is rewrited from customet theme, default is Nextcloud color
|
||||
let customer: UIColor = UIColor(red: 0.0 / 255.0, green: 130.0 / 255.0, blue: 201.0 / 255.0, alpha: 1.0) // Nextcloud : #0082C9
|
||||
let customer: UIColor = UIColor(red: 0.0 / 255.0, green: 130.0 / 255.0, blue: 201.0 / 255.0, alpha: 1.0) // Nextcloud default: #0082C9
|
||||
var customerText: UIColor = .white
|
||||
|
||||
// INTERNAL DEFINE COLORS
|
||||
@@ -310,12 +352,14 @@ final class NCBrandColor: @unchecked Sendable {
|
||||
return false
|
||||
}
|
||||
|
||||
/*
|
||||
public func getTheming(account: String?) -> UIColor {
|
||||
if let account, let color = self.themingColor[account] {
|
||||
return color
|
||||
}
|
||||
return customer
|
||||
}
|
||||
*/
|
||||
|
||||
public func getElement(account: String?) -> UIColor {
|
||||
if let account, let color = self.themingColorElement[account] {
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>NSExtensionActivationRule</key>
|
||||
<string>SUBQUERY (extensionItems, $extensionItem, SUBQUERY ($extensionItem.attachments,$attachment,(ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data")).@count == $extensionItem.attachments.@count).@count > 0
|
||||
</string>
|
||||
<string>SUBQUERY (extensionItems, $extensionItem, SUBQUERY ($extensionItem.attachments, $attachment, (ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.data" OR ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.text")).@count == $extensionItem.attachments.@count).@count > 0</string>
|
||||
</dict>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
<string>MainInterface</string>
|
||||
@@ -39,4 +38,4 @@
|
||||
<string>com.apple.share-services</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
</plist>
|
||||
@@ -2,11 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Camera access is required to scan documents and make photo and video.</string>
|
||||
<string>Camera access is required to scan documents and take photos in this app.</string>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
<string>Face ID is required to authenticate using face recognition.</string>
|
||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||
@@ -75,9 +75,9 @@
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Microphone access is required to create voice notes.</string>
|
||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||
<string>Photo library access is required to upload your photos and videos to your cloud.</string>
|
||||
<string>This lets you upload and save photos using this app. Photos can then be browsed and viewed via the Media tab.</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Photo library access is required to upload your photos and videos to your cloud.</string>
|
||||
<string>This lets you upload and save photos using this app. Photos can then be browsed and viewed via the Media tab.</string>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>AccountIntent</string>
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
//
|
||||
// NCApplicationHandle.swift
|
||||
// Nextcloud
|
||||
//
|
||||
// Created by Marino Faggiana on 25/11/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import NextcloudKit
|
||||
import UIKit
|
||||
import Parchment
|
||||
|
||||
class NCApplicationHandle: NSObject {
|
||||
|
||||
// class: AppDelegate
|
||||
// func nextcloudPushNotificationAction(data: [String: AnyObject])
|
||||
func nextcloudPushNotificationAction(data: [String: AnyObject]) -> [String: AnyObject]? {
|
||||
return data
|
||||
}
|
||||
|
||||
// class: AppDelegate
|
||||
// func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void)
|
||||
func applicationOpenUserActivity(_ userActivity: NSUserActivity) -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// class: AppDelegate
|
||||
// func: application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])
|
||||
func applicationOpenURL(_ url: URL) -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// class: NCFunctionCenter
|
||||
// func: downloadedFile(_ notification: NSNotification)
|
||||
func downloadedFile(selector: String, metadata: tableMetadata) {
|
||||
}
|
||||
|
||||
// class: NCCollectionViewCommon (+Menu)
|
||||
// func: toggleMenu(metadata: tableMetadata, imageIcon: UIImage?)
|
||||
func addCollectionViewCommonMenu(metadata: tableMetadata, image: UIImage?, actions: inout [NCMenuAction]) {
|
||||
}
|
||||
|
||||
// class: NCMore
|
||||
// func: loadItems()
|
||||
func loadItems(functionMenu: inout [NKExternalSite]) {
|
||||
}
|
||||
|
||||
// class: NCMore
|
||||
// func: tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
|
||||
func didSelectItem(_ item: NKExternalSite, viewController: UIViewController) {
|
||||
}
|
||||
|
||||
// class: NCSharePaging
|
||||
// func pagingViewController(_: PagingViewController, viewControllerAt index: Int) -> UIViewController
|
||||
func pagingViewController(_: PagingViewController, viewControllerAt index: Int, metadata: tableMetadata, topHeight: CGFloat) -> UIViewController {
|
||||
return UIViewController()
|
||||
}
|
||||
|
||||
// class: NCSharePaging
|
||||
// func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem
|
||||
func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem {
|
||||
return PagingIndexItem(index: index, title: "")
|
||||
}
|
||||
|
||||
// class: NCActionCenter
|
||||
func filterPages(pages: [NCBrandOptions.NCInfoPagingTab], page: NCBrandOptions.NCInfoPagingTab, metadata: tableMetadata) -> ([NCBrandOptions.NCInfoPagingTab], NCBrandOptions.NCInfoPagingTab) {
|
||||
return (pages, page)
|
||||
}
|
||||
|
||||
// class: NCNotification
|
||||
func didSelectNotification(_ notification: NKNotifications, viewController: UIViewController) -> NKNotifications? {
|
||||
return notification
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,14 @@
|
||||
|
||||
import UIKit
|
||||
import NextcloudKit
|
||||
import FileProvider
|
||||
|
||||
class FileProviderData: NSObject {
|
||||
static let shared = FileProviderData()
|
||||
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let global = NCGlobal.shared
|
||||
let database = NCManageDatabase.shared
|
||||
|
||||
var domain: NSFileProviderDomain?
|
||||
var session: NCSession.Session?
|
||||
private var isPaginated: Bool?
|
||||
|
||||
var listFavoriteIdentifierRank: [String: NSNumber] = [:]
|
||||
var fileProviderSignalDeleteContainerItemIdentifier: [NSFileProviderItemIdentifier: NSFileProviderItemIdentifier] = [:]
|
||||
@@ -40,8 +38,8 @@ class FileProviderData: NSObject {
|
||||
func setupAccount(domain: NSFileProviderDomain? = nil,
|
||||
tblAccount: tableAccount? = nil,
|
||||
providerExtension: NSFileProviderExtension) -> tableAccount? {
|
||||
let version = NSString(format: NCBrandOptions.shared.textCopyrightNextcloudiOS as NSString, NCUtility().getVersionBuild()) as String
|
||||
let tblAccounts = self.database.getAllTableAccount()
|
||||
let version = NSString(format: NCBrandOptions.shared.textCopyrightNextcloudiOS as NSString, fileProviderUtility().getVersionBuild()) as String
|
||||
let tblAccounts = NCManageDatabase.shared.getAllTableAccount()
|
||||
var matchAccount: tableAccount?
|
||||
|
||||
NextcloudKit.configureLogger(logLevel: (NCBrandOptions.shared.disable_log ? .disabled : NCPreferences().log))
|
||||
@@ -55,9 +53,9 @@ class FileProviderData: NSObject {
|
||||
}
|
||||
let accountDomain = "\($0.userId) (\(host))"
|
||||
return accountDomain == domain.identifier.rawValue
|
||||
}) ?? self.database.getActiveTableAccount()
|
||||
}) ?? NCManageDatabase.shared.getActiveTableAccount()
|
||||
} else {
|
||||
matchAccount = self.database.getActiveTableAccount()
|
||||
matchAccount = NCManageDatabase.shared.getActiveTableAccount()
|
||||
}
|
||||
|
||||
guard let matchAccount else {
|
||||
@@ -86,11 +84,24 @@ class FileProviderData: NSObject {
|
||||
return matchAccount
|
||||
}
|
||||
|
||||
// Get capabilities -> Paginate is availible from NC server 32.0.2
|
||||
func isPaginatedAvailabile(serverUrl: String, session: NCSession.Session) async -> Bool {
|
||||
if let isPaginated {
|
||||
return isPaginated
|
||||
} else if serverUrl == NCUtilityFileSystem().getHomeServer(session: session),
|
||||
let capabilities = await NextcloudKit.shared.getCapabilitiesAsync(account: session.account).capabilities,
|
||||
NCBrandOptions.shared.isServerVersion(capabilities, greaterOrEqualTo: .v32_0_2) {
|
||||
isPaginated = true
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
@discardableResult
|
||||
func signalEnumerator(ocId: String, type: TypeSignal) async -> FileProviderItem? {
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(ocId),
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocId),
|
||||
let parentItemIdentifier = await fileProviderUtility().getParentItemIdentifierAsync(metadata: metadata) else {
|
||||
return nil
|
||||
}
|
||||
@@ -136,14 +147,11 @@ class FileProviderData: NSObject {
|
||||
|
||||
func downloadComplete(fileName: String,
|
||||
serverUrl: String,
|
||||
etag: String?,
|
||||
date: Date?,
|
||||
dateLastModified: Date?,
|
||||
length: Int64,
|
||||
allHeaderFields: [AnyHashable: Any]?,
|
||||
task: URLSessionTask,
|
||||
error: NKError) async {
|
||||
let taskIdentifier = task.taskIdentifier
|
||||
let metadata = await self.database.getMetadataAsync(predicate: NSPredicate(format: "serverUrl == %@ AND fileName == %@", serverUrl, fileName))
|
||||
let metadata = await NCManageDatabase.shared.getMetadataAsync(predicate: NSPredicate(format: "serverUrl == %@ AND fileName == %@", serverUrl, fileName))
|
||||
|
||||
guard let metadata else {
|
||||
downloadPendingCompletionHandlers[taskIdentifier]?(nil)
|
||||
@@ -154,17 +162,18 @@ class FileProviderData: NSObject {
|
||||
}
|
||||
|
||||
let ocId = metadata.ocId
|
||||
let etag = NextcloudKit.shared.nkCommonInstance.findHeader("oc-etag", allHeaderFields: allHeaderFields)
|
||||
|
||||
await self.database.setMetadataSessionAsync(ocId: ocId,
|
||||
session: "",
|
||||
sessionTaskIdentifier: 0,
|
||||
sessionError: "",
|
||||
status: self.global.metadataStatusNormal,
|
||||
etag: etag)
|
||||
await NCManageDatabase.shared.setMetadataSessionAsync(ocId: ocId,
|
||||
session: "",
|
||||
sessionTaskIdentifier: 0,
|
||||
sessionError: "",
|
||||
status: NCGlobal.shared.metadataStatusNormal,
|
||||
etag: etag)
|
||||
|
||||
if error == .success {
|
||||
if let metadata = await self.database.getMetadataFromOcIdAsync(ocId) {
|
||||
await self.database.addLocalFilesAsync(metadatas: [metadata])
|
||||
if let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocId) {
|
||||
await NCManageDatabase.shared.addLocalFilesAsync(metadatas: [metadata])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,27 +194,29 @@ class FileProviderData: NSObject {
|
||||
ocId: String?,
|
||||
etag: String?,
|
||||
date: Date?,
|
||||
size: Int64,
|
||||
ownerId: String?,
|
||||
permissions: String?,
|
||||
task: URLSessionTask,
|
||||
error: NKError) async {
|
||||
guard let metadata = await self.database.getMetadataAsync(predicate: NSPredicate(format: "serverUrl == %@ AND fileName == %@ AND sessionTaskIdentifier == %d", serverUrl, fileName, task.taskIdentifier)) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataAsync(predicate: NSPredicate(format: "serverUrl == %@ AND fileName == %@ AND sessionTaskIdentifier == %d", serverUrl, fileName, task.taskIdentifier)) else {
|
||||
let predicate = NSPredicate(format: "fileName == %@ AND serverUrl == %@", fileName, serverUrl)
|
||||
await self.database.deleteMetadataAsync(predicate: predicate)
|
||||
await NCManageDatabase.shared.deleteMetadataAsync(predicate: predicate)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if let ocId, !metadata.ocIdTransfer.isEmpty {
|
||||
let atPath = self.utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocIdTransfer, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
let toPath = self.utilityFileSystem.getDirectoryProviderStorageOcId(ocId, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
self.utilityFileSystem.copyFile(atPath: atPath, toPath: toPath)
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let atPath = utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocIdTransfer, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
let toPath = utilityFileSystem.getDirectoryProviderStorageOcId(ocId, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
utilityFileSystem.copyFile(atPath: atPath, toPath: toPath)
|
||||
}
|
||||
|
||||
if error == .success, let ocId {
|
||||
await signalEnumerator(ocId: metadata.ocIdTransfer, type: .delete)
|
||||
|
||||
if !metadata.ocIdTransfer.isEmpty, ocId != metadata.ocIdTransfer {
|
||||
await self.database.deleteMetadataAsync(id: metadata.ocIdTransfer)
|
||||
await NCManageDatabase.shared.deleteMetadataAsync(id: metadata.ocIdTransfer)
|
||||
}
|
||||
|
||||
metadata.fileName = fileName
|
||||
@@ -213,11 +224,22 @@ class FileProviderData: NSObject {
|
||||
metadata.uploadDate = (date as? NSDate) ?? NSDate()
|
||||
metadata.etag = etag ?? ""
|
||||
metadata.ocId = ocId
|
||||
metadata.size = size
|
||||
if let fileId = NCUtility().ocIdToFileId(ocId: ocId) {
|
||||
|
||||
if let fileId = fileProviderUtility().ocIdToFileId(ocId: ocId) {
|
||||
metadata.fileId = fileId
|
||||
}
|
||||
|
||||
if let ownerId, !ownerId.isEmpty {
|
||||
metadata.ownerId = ownerId
|
||||
if let ownerDisplayName = await NCManageDatabase.shared.getOwnerDisplayName(account: metadata.account, ownerId: ownerId) {
|
||||
metadata.ownerDisplayName = ownerDisplayName
|
||||
}
|
||||
}
|
||||
|
||||
if let permissions, !permissions.isEmpty {
|
||||
metadata.permissions = permissions
|
||||
}
|
||||
|
||||
metadata.sceneIdentifier = nil
|
||||
metadata.session = ""
|
||||
metadata.sessionError = ""
|
||||
@@ -226,14 +248,14 @@ class FileProviderData: NSObject {
|
||||
metadata.sessionTaskIdentifier = 0
|
||||
metadata.status = NCGlobal.shared.metadataStatusNormal
|
||||
|
||||
await self.database.addMetadataAsync(metadata)
|
||||
await self.database.addLocalFilesAsync(metadatas: [metadata])
|
||||
await NCManageDatabase.shared.addMetadataAsync(metadata)
|
||||
await NCManageDatabase.shared.addLocalFilesAsync(metadatas: [metadata])
|
||||
|
||||
await signalEnumerator(ocId: ocId, type: .update)
|
||||
|
||||
} else {
|
||||
|
||||
await self.database.deleteMetadataAsync(id: metadata.ocIdTransfer)
|
||||
await NCManageDatabase.shared.deleteMetadataAsync(id: metadata.ocIdTransfer)
|
||||
|
||||
await signalEnumerator(ocId: metadata.ocIdTransfer, type: .delete)
|
||||
}
|
||||
|
||||
@@ -10,33 +10,40 @@ import NextcloudKit
|
||||
class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||
var enumeratedItemIdentifier: NSFileProviderItemIdentifier
|
||||
var serverUrl: String?
|
||||
let fileProviderData = FileProviderData.shared
|
||||
let providerUtility = fileProviderUtility()
|
||||
let database = NCManageDatabase.shared
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
var anchor: UInt64 = 0
|
||||
var readCapabilities: Bool = false
|
||||
|
||||
// X-NC-PAGINATE
|
||||
var recordsPerPage: Int = 100
|
||||
#if DEBUG
|
||||
var paginateCount: Int = 50
|
||||
#else
|
||||
var paginateCount: Int = 200
|
||||
#endif
|
||||
// X-NC-PAGINATE
|
||||
|
||||
var paginateToken: String?
|
||||
var paginatedTotal: Int = 0
|
||||
|
||||
struct PageInfo {
|
||||
let page: Int
|
||||
let items: Int
|
||||
}
|
||||
var paginateItems: [PageInfo] = []
|
||||
|
||||
init(enumeratedItemIdentifier: NSFileProviderItemIdentifier) {
|
||||
self.enumeratedItemIdentifier = enumeratedItemIdentifier
|
||||
super.init()
|
||||
|
||||
guard let session = fileProviderData.session else {
|
||||
guard let session = FileProviderData.shared.session else {
|
||||
return
|
||||
}
|
||||
|
||||
if enumeratedItemIdentifier == .rootContainer {
|
||||
self.serverUrl = NCUtilityFileSystem().getHomeServer(session: session)
|
||||
} else {
|
||||
if let metadata = providerUtility.getTableMetadataFromItemIdentifier(enumeratedItemIdentifier),
|
||||
let directorySource = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
|
||||
serverUrl = utilityFileSystem.createServerUrl(serverUrl: directorySource.serverUrl, fileName: metadata.fileName)
|
||||
if let metadata = fileProviderUtility().getTableMetadataFromItemIdentifier(enumeratedItemIdentifier),
|
||||
let directorySource = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
|
||||
serverUrl = NCUtilityFileSystem().createServerUrl(serverUrl: directorySource.serverUrl, fileName: metadata.fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +53,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||
func enumerateItems(for observer: NSFileProviderEnumerationObserver, startingAt page: NSFileProviderPage) {
|
||||
Task {
|
||||
var items: [NSFileProviderItemProtocol] = []
|
||||
guard let session = fileProviderData.session else {
|
||||
guard let session = FileProviderData.shared.session else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,27 +62,27 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||
var itemIdentifierMetadata: [NSFileProviderItemIdentifier: tableMetadata] = [:]
|
||||
|
||||
// Tags
|
||||
if let tags = await self.database.getTagsAsync(predicate: NSPredicate(format: "account == %@", session.account)) {
|
||||
if let tags = await NCManageDatabase.shared.getTagsAsync(predicate: NSPredicate(format: "account == %@", session.account)) {
|
||||
for tag in tags {
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(tag.ocId) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(tag.ocId) else {
|
||||
continue
|
||||
}
|
||||
itemIdentifierMetadata[providerUtility.getItemIdentifier(metadata: metadata)] = metadata
|
||||
itemIdentifierMetadata[fileProviderUtility().getItemIdentifier(metadata: metadata)] = metadata
|
||||
}
|
||||
}
|
||||
|
||||
// Favorite
|
||||
fileProviderData.listFavoriteIdentifierRank = await self.database.getTableMetadatasDirectoryFavoriteIdentifierRankAsync(account: session.account)
|
||||
for (identifier, _) in fileProviderData.listFavoriteIdentifierRank {
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(identifier) else {
|
||||
FileProviderData.shared.listFavoriteIdentifierRank = await NCManageDatabase.shared.getTableMetadatasDirectoryFavoriteIdentifierRankAsync(account: session.account)
|
||||
for (identifier, _) in FileProviderData.shared.listFavoriteIdentifierRank {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(identifier) else {
|
||||
continue
|
||||
}
|
||||
itemIdentifierMetadata[providerUtility.getItemIdentifier(metadata: metadata)] = metadata
|
||||
itemIdentifierMetadata[fileProviderUtility().getItemIdentifier(metadata: metadata)] = metadata
|
||||
}
|
||||
|
||||
// Create items
|
||||
for (_, metadata) in itemIdentifierMetadata {
|
||||
if let parentItemIdentifier = await providerUtility.getParentItemIdentifierAsync(metadata: metadata) {
|
||||
if let parentItemIdentifier = await fileProviderUtility().getParentItemIdentifierAsync(metadata: metadata) {
|
||||
let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier)
|
||||
items.append(item)
|
||||
}
|
||||
@@ -84,8 +91,6 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||
observer.finishEnumerating(upTo: nil)
|
||||
|
||||
} else {
|
||||
|
||||
// ServerUrl
|
||||
guard let serverUrl = serverUrl else {
|
||||
observer.finishEnumerating(upTo: nil)
|
||||
return
|
||||
@@ -96,28 +101,15 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||
pageNumber = intPage
|
||||
}
|
||||
|
||||
let (metadatas, isPaginated) = await fetchItemsForPage(serverUrl: serverUrl, pageNumber: pageNumber, account: session.account)
|
||||
|
||||
if let metadatas {
|
||||
for metadata in metadatas {
|
||||
if metadata.e2eEncrypted || (!metadata.session.isEmpty && metadata.session != NCNetworking.shared.sessionUploadBackgroundExt) {
|
||||
continue
|
||||
}
|
||||
if let parentItemIdentifier = await self.providerUtility.getParentItemIdentifierAsync(metadata: metadata) {
|
||||
let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier)
|
||||
items.append(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let (items, ncPaginated) = await fetchItemsForPage(session: session,
|
||||
serverUrl: serverUrl,
|
||||
pageNumber: pageNumber)
|
||||
observer.didEnumerate(items)
|
||||
|
||||
if let metadatas,
|
||||
isPaginated,
|
||||
metadatas.count == self.recordsPerPage {
|
||||
if !items.isEmpty,
|
||||
ncPaginated {
|
||||
pageNumber += 1
|
||||
let providerPage = NSFileProviderPage("\(pageNumber)".data(using: .utf8)!)
|
||||
observer.finishEnumerating(upTo: providerPage)
|
||||
observer.finishEnumerating(upTo: NSFileProviderPage(Data("\(pageNumber)".utf8)))
|
||||
} else {
|
||||
observer.finishEnumerating(upTo: nil)
|
||||
}
|
||||
@@ -131,113 +123,170 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
|
||||
|
||||
// Report the deleted items
|
||||
if self.enumeratedItemIdentifier == .workingSet {
|
||||
for (itemIdentifier, _) in fileProviderData.fileProviderSignalDeleteWorkingSetItemIdentifier {
|
||||
for (itemIdentifier, _) in FileProviderData.shared.fileProviderSignalDeleteWorkingSetItemIdentifier {
|
||||
itemsDelete.append(itemIdentifier)
|
||||
}
|
||||
fileProviderData.fileProviderSignalDeleteWorkingSetItemIdentifier.removeAll()
|
||||
FileProviderData.shared.fileProviderSignalDeleteWorkingSetItemIdentifier.removeAll()
|
||||
} else {
|
||||
for (itemIdentifier, _) in fileProviderData.fileProviderSignalDeleteContainerItemIdentifier {
|
||||
for (itemIdentifier, _) in FileProviderData.shared.fileProviderSignalDeleteContainerItemIdentifier {
|
||||
itemsDelete.append(itemIdentifier)
|
||||
}
|
||||
fileProviderData.fileProviderSignalDeleteContainerItemIdentifier.removeAll()
|
||||
FileProviderData.shared.fileProviderSignalDeleteContainerItemIdentifier.removeAll()
|
||||
}
|
||||
|
||||
// Report the updated items
|
||||
if self.enumeratedItemIdentifier == .workingSet {
|
||||
for (_, item) in fileProviderData.fileProviderSignalUpdateWorkingSetItem {
|
||||
for (_, item) in FileProviderData.shared.fileProviderSignalUpdateWorkingSetItem {
|
||||
itemsUpdate.append(item)
|
||||
}
|
||||
fileProviderData.fileProviderSignalUpdateWorkingSetItem.removeAll()
|
||||
FileProviderData.shared.fileProviderSignalUpdateWorkingSetItem.removeAll()
|
||||
} else {
|
||||
for (_, item) in fileProviderData.fileProviderSignalUpdateContainerItem {
|
||||
for (_, item) in FileProviderData.shared.fileProviderSignalUpdateContainerItem {
|
||||
itemsUpdate.append(item)
|
||||
}
|
||||
fileProviderData.fileProviderSignalUpdateContainerItem.removeAll()
|
||||
FileProviderData.shared.fileProviderSignalUpdateContainerItem.removeAll()
|
||||
}
|
||||
|
||||
observer.didDeleteItems(withIdentifiers: itemsDelete)
|
||||
observer.didUpdate(itemsUpdate)
|
||||
|
||||
let data = "\(self.anchor)".data(using: .utf8)
|
||||
observer.finishEnumeratingChanges(upTo: NSFileProviderSyncAnchor(data!), moreComing: false)
|
||||
let data = Data("\(self.anchor)".utf8)
|
||||
observer.finishEnumeratingChanges(upTo: NSFileProviderSyncAnchor(data), moreComing: false)
|
||||
}
|
||||
|
||||
func currentSyncAnchor(completionHandler: @escaping (NSFileProviderSyncAnchor?) -> Void) {
|
||||
let data = "\(self.anchor)".data(using: .utf8)
|
||||
|
||||
completionHandler(NSFileProviderSyncAnchor(data!))
|
||||
let data = Data("\(self.anchor)".utf8)
|
||||
completionHandler(NSFileProviderSyncAnchor(data))
|
||||
}
|
||||
|
||||
func fetchItemsForPage(serverUrl: String, pageNumber: Int, account: String) async -> (metadatas: [tableMetadata]?, isPaginated: Bool) {
|
||||
var serverUrlMetadataFolder: String?
|
||||
var isPaginated: Bool = false
|
||||
var paginateCount = recordsPerPage
|
||||
if pageNumber == 0 {
|
||||
paginateCount += 1
|
||||
func fetchItemsForPage(session: NCSession.Session, serverUrl: String, pageNumber: Int) async -> (items: [NSFileProviderItem], ncPaginate: Bool) {
|
||||
let fileProviderUtility = fileProviderUtility()
|
||||
let createMetadata = NCManageDatabaseCreateMetadata()
|
||||
|
||||
func getItemsFrom(metadatas: [tableMetadata], addOnDB: Bool) async -> [NSFileProviderItem] {
|
||||
var items: [NSFileProviderItem] = []
|
||||
|
||||
// Get parentItemIdentifier
|
||||
guard let directory = await NCManageDatabase.shared.getTableDirectoryAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", session.account, serverUrl)),
|
||||
let parentItemIdentifier = await fileProviderUtility.getParentItemIdentifierAsync(
|
||||
session: session,
|
||||
directory: directory
|
||||
) else {
|
||||
return ([])
|
||||
}
|
||||
|
||||
// make items
|
||||
for metadata in metadatas {
|
||||
// NO E2EE OR NO VIDEO PART OF LIVE PHOTO
|
||||
if metadata.e2eEncrypted || (metadata.classFile == NKTypeClassFile.video.rawValue && !metadata.livePhotoFile.isEmpty) {
|
||||
continue
|
||||
}
|
||||
|
||||
if addOnDB {
|
||||
if metadata.directory {
|
||||
await NCManageDatabase.shared.createDirectory(metadata: metadata)
|
||||
}
|
||||
await NCManageDatabase.shared.addMetadataAsync(metadata)
|
||||
}
|
||||
|
||||
autoreleasepool {
|
||||
let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier)
|
||||
items.append(item)
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
var offset = pageNumber * recordsPerPage
|
||||
|
||||
// Request pagination
|
||||
//
|
||||
let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account)
|
||||
var paginateOffset = 0
|
||||
if pageNumber > 0 {
|
||||
offset += 1
|
||||
paginateOffset = getOffset(for: pageNumber)
|
||||
}
|
||||
let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: account)
|
||||
let options = NKRequestOptions(paginate: true,
|
||||
let optionsPaginate = await FileProviderData.shared.isPaginatedAvailabile(serverUrl: serverUrl, session: session)
|
||||
let options = NKRequestOptions(paginate: optionsPaginate,
|
||||
paginateToken: self.paginateToken,
|
||||
paginateOffset: offset,
|
||||
paginateOffset: paginateOffset,
|
||||
paginateCount: paginateCount,
|
||||
queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
||||
queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue
|
||||
)
|
||||
|
||||
print("PAGINATE OFFSET: \(offset) COUNT: \(paginateCount) TOTAL: \(self.paginatedTotal)")
|
||||
// Read folder metadata
|
||||
//
|
||||
let resultsRead = await NextcloudKit.shared.readFileOrFolderAsync(
|
||||
serverUrlFileName: serverUrl,
|
||||
depth: "1",
|
||||
showHiddenFiles: showHiddenFiles,
|
||||
account: session.account,
|
||||
options: options
|
||||
)
|
||||
|
||||
let resultsRead = await NextcloudKit.shared.readFileOrFolderAsync(serverUrlFileName: serverUrl,
|
||||
depth: "1",
|
||||
showHiddenFiles: showHiddenFiles,
|
||||
account: account,
|
||||
options: options)
|
||||
print("PAGINATE OFFSET: \(paginateOffset) COUNT: \(resultsRead.files?.count ?? 0) PAGE NUMBER: \(pageNumber) TOTAL: \(self.paginatedTotal) SERVERURL: \(serverUrl)")
|
||||
|
||||
// Header for paginate
|
||||
//
|
||||
var ncPaginate: Bool = false
|
||||
if let headers = resultsRead.responseData?.response?.allHeaderFields as? [String: String] {
|
||||
let normalizedHeaders = Dictionary(uniqueKeysWithValues: headers.map { ($0.key.lowercased(), $0.value) })
|
||||
isPaginated = Bool(normalizedHeaders["x-nc-paginate"] ?? "false") ?? false
|
||||
ncPaginate = Bool(normalizedHeaders["x-nc-paginate"] ?? "false") ?? false
|
||||
self.paginateToken = normalizedHeaders["x-nc-paginate-token"]
|
||||
self.paginatedTotal = Int(normalizedHeaders["x-nc-paginate-total"] ?? "0") ?? 0
|
||||
if let totalString = normalizedHeaders["x-nc-paginate-total"],
|
||||
let total = Int(totalString) {
|
||||
self.paginatedTotal = total
|
||||
}
|
||||
}
|
||||
|
||||
if resultsRead.error == .success, let files = resultsRead.files {
|
||||
let (metadataFolder, metadatas) = await createMetadata.convertFilesToMetadatasAsync(files, serverUrlMetadataFolder: pageNumber == 0 ? serverUrl : nil)
|
||||
self.paginateItems.append(PageInfo(page: pageNumber, items: metadatas.count))
|
||||
|
||||
if pageNumber == 0 {
|
||||
await self.database.deleteMetadataAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d AND fileName != %@", account, serverUrl, NCGlobal.shared.metadataStatusNormal, NextcloudKit.shared.nkCommonInstance.rootFileName))
|
||||
serverUrlMetadataFolder = serverUrl
|
||||
await NCManageDatabase.shared.deleteMetadataAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", session.account, serverUrl, NCGlobal.shared.metadataStatusNormal))
|
||||
await NCManageDatabase.shared.createDirectory(metadata: metadataFolder)
|
||||
}
|
||||
|
||||
let (metadataFolder, metadatas) = await self.database.convertFilesToMetadatasAsync(files, serverUrlMetadataFolder: serverUrlMetadataFolder)
|
||||
|
||||
// FOLDER
|
||||
if serverUrlMetadataFolder != nil {
|
||||
await self.database.createDirectory(metadata: metadataFolder)
|
||||
let items = await getItemsFrom(metadatas: Array(metadatas), addOnDB: true)
|
||||
if self.totalItems() >= self.paginatedTotal {
|
||||
ncPaginate = false
|
||||
}
|
||||
|
||||
// METADATA
|
||||
var metadataToInsert: [tableMetadata] = []
|
||||
for metadata in metadatas {
|
||||
if metadata.directory {
|
||||
await self.database.createDirectory(metadata: metadata)
|
||||
} else {
|
||||
metadataToInsert.append(metadata)
|
||||
}
|
||||
}
|
||||
await self.database.addMetadatasAsync(metadataToInsert)
|
||||
|
||||
return(metadatas, isPaginated)
|
||||
|
||||
return (items, ncPaginate)
|
||||
} else {
|
||||
if isPaginated {
|
||||
let predicate = NSPredicate(
|
||||
format: """
|
||||
account == %@ AND
|
||||
serverUrl == %@ AND
|
||||
status == %d AND
|
||||
(
|
||||
classFile != 'video' OR
|
||||
(classFile == 'video' AND livePhotoFile == '')
|
||||
)
|
||||
""",
|
||||
session.account,
|
||||
serverUrl,
|
||||
NCGlobal.shared.metadataStatusNormal
|
||||
)
|
||||
|
||||
return (nil, isPaginated)
|
||||
|
||||
} else {
|
||||
|
||||
let metadatas = await self.database.getMetadatasAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl))
|
||||
|
||||
return (metadatas, isPaginated)
|
||||
guard let metadatas = await NCManageDatabase.shared.getResultsMetadatasAsync(predicate: predicate) else {
|
||||
return ([], false)
|
||||
}
|
||||
let items = await getItemsFrom(metadatas: Array(metadatas), addOnDB: false)
|
||||
return (items, false)
|
||||
}
|
||||
}
|
||||
|
||||
func getOffset(for page: Int) -> Int {
|
||||
let items = paginateItems
|
||||
.filter { $0.page < page }
|
||||
.map { $0.items }
|
||||
.reduce(0, +)
|
||||
// + 1 for the next
|
||||
return items == 0 ? 0 : items + 1
|
||||
}
|
||||
|
||||
func totalItems() -> Int {
|
||||
let total = paginateItems.map { $0.items }.reduce(0, +)
|
||||
// + 1 for the first "root directory"
|
||||
return total == 0 ? 0 : total + 1
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,13 @@ import NextcloudKit
|
||||
extension FileProviderExtension {
|
||||
override func createDirectory(withName directoryName: String, inParentItemIdentifier parentItemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
|
||||
Task {
|
||||
guard let session = fileProviderData.session,
|
||||
let tableDirectory = await providerUtility.getTableDirectoryFromParentItemIdentifierAsync(parentItemIdentifier, account: session.account, homeServerUrl: utilityFileSystem.getHomeServer(session: session)) else {
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
guard let session = FileProviderData.shared.session,
|
||||
let tableDirectory = await fileProviderUtility().getTableDirectoryFromParentItemIdentifierAsync(parentItemIdentifier, account: session.account, homeServerUrl: utilityFileSystem.getHomeServer(session: session)) else {
|
||||
return completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
}
|
||||
let account = session.account
|
||||
let fileNameFolder = utilityFileSystem.createFileName(directoryName, serverUrl: tableDirectory.serverUrl, account: account)
|
||||
let fileNameFolder = fileProviderUtility().createFileName(directoryName, serverUrl: tableDirectory.serverUrl, account: account)
|
||||
let serverUrlFileName = utilityFileSystem.createServerUrl(serverUrl: tableDirectory.serverUrl, fileName: fileNameFolder)
|
||||
let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: account)
|
||||
|
||||
@@ -24,8 +25,10 @@ extension FileProviderExtension {
|
||||
let resultsReadFile = await NextcloudKit.shared.readFileOrFolderAsync(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: showHiddenFiles, account: account)
|
||||
|
||||
if resultsReadFile.error == .success, let file = resultsReadFile.files?.first {
|
||||
let metadata = await self.database.convertFileToMetadataAsync(file)
|
||||
await self.database.createDirectory(metadata: metadata)
|
||||
let metadata = await NCManageDatabaseCreateMetadata().convertFileToMetadataAsync(file)
|
||||
await NCManageDatabase.shared.createDirectory(metadata: metadata)
|
||||
|
||||
NCUtilityFileSystem().getDirectoryProviderStorageOcId(metadata.ocId, fileName: metadata.fileName, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
|
||||
let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier)
|
||||
|
||||
@@ -49,10 +52,11 @@ extension FileProviderExtension {
|
||||
|
||||
override func deleteItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping (Error?) -> Void) {
|
||||
Task {
|
||||
guard let metadata = await providerUtility.getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
guard let metadata = await fileProviderUtility().getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
completionHandler(NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let ocId = metadata.ocId
|
||||
let serverUrlFileName = utilityFileSystem.createServerUrl(serverUrl: metadata.serverUrl, fileName: metadata.fileName)
|
||||
let isDirectory = metadata.directory
|
||||
@@ -63,21 +67,21 @@ extension FileProviderExtension {
|
||||
let resultsDelete = await NextcloudKit.shared.deleteFileOrFolderAsync(serverUrlFileName: serverUrlFileName, account: account)
|
||||
|
||||
if resultsDelete.error == .success {
|
||||
let fileNamePath = self.utilityFileSystem.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
let fileNamePath = utilityFileSystem.getDirectoryProviderStorageOcId(itemIdentifier.rawValue, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
|
||||
do {
|
||||
try self.providerUtility.fileManager.removeItem(atPath: fileNamePath)
|
||||
try fileProviderUtility().fileManager.removeItem(atPath: fileNamePath)
|
||||
} catch let error {
|
||||
print("error: \(error)")
|
||||
}
|
||||
|
||||
if isDirectory {
|
||||
let dirForDelete = self.utilityFileSystem.createServerUrl(serverUrl: serverUrl, fileName: fileName)
|
||||
await self.database.deleteDirectoryAndSubDirectoryAsync(serverUrl: dirForDelete, account: account)
|
||||
let dirForDelete = utilityFileSystem.createServerUrl(serverUrl: serverUrl, fileName: fileName)
|
||||
await NCManageDatabase.shared.deleteDirectoryAndSubDirectoryAsync(serverUrl: dirForDelete, account: account)
|
||||
}
|
||||
|
||||
await self.database.deleteMetadataAsync(id: ocId)
|
||||
await self.database.deleteLocalFileAsync(id: ocId)
|
||||
await NCManageDatabase.shared.deleteMetadataAsync(id: ocId)
|
||||
await NCManageDatabase.shared.deleteLocalFileAsync(id: ocId)
|
||||
|
||||
completionHandler(nil)
|
||||
return
|
||||
@@ -93,16 +97,17 @@ extension FileProviderExtension {
|
||||
override func reparentItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier, toParentItemWithIdentifier parentItemIdentifier: NSFileProviderItemIdentifier, newName: String?, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
|
||||
Task {
|
||||
guard let itemFrom = try? item(for: itemIdentifier),
|
||||
let metadataFrom = await providerUtility.getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
let metadataFrom = await fileProviderUtility().getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let ocIdFrom = metadataFrom.ocId
|
||||
let serverUrlFrom = metadataFrom.serverUrl
|
||||
let fileNameFrom = utilityFileSystem.createServerUrl(serverUrl: serverUrlFrom, fileName: itemFrom.filename)
|
||||
let account = metadataFrom.account
|
||||
|
||||
guard let tableDirectoryTo = await providerUtility.getTableDirectoryFromParentItemIdentifierAsync(parentItemIdentifier, account: account, homeServerUrl: utilityFileSystem.getHomeServer(urlBase: metadataFrom.urlBase, userId: metadataFrom.userId)) else {
|
||||
guard let tableDirectoryTo = await fileProviderUtility().getTableDirectoryFromParentItemIdentifierAsync(parentItemIdentifier, account: account, homeServerUrl: utilityFileSystem.getHomeServer(urlBase: metadataFrom.urlBase, userId: metadataFrom.userId)) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
@@ -117,12 +122,12 @@ extension FileProviderExtension {
|
||||
|
||||
if resultsMove.error == .success {
|
||||
if metadataFrom.directory {
|
||||
await self.database.deleteDirectoryAndSubDirectoryAsync(serverUrl: serverUrlFrom, account: account)
|
||||
await self.database.renameDirectoryAsync(ocId: ocIdFrom, serverUrl: serverUrlTo)
|
||||
await NCManageDatabase.shared.deleteDirectoryAndSubDirectoryAsync(serverUrl: serverUrlFrom, account: account)
|
||||
await NCManageDatabase.shared.renameDirectoryAsync(ocId: ocIdFrom, serverUrl: serverUrlTo)
|
||||
}
|
||||
await self.database.moveMetadataAsync(ocId: ocIdFrom, serverUrlTo: serverUrlTo)
|
||||
await NCManageDatabase.shared.moveMetadataAsync(ocId: ocIdFrom, serverUrlTo: serverUrlTo)
|
||||
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(ocIdFrom) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocIdFrom) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
@@ -142,10 +147,11 @@ extension FileProviderExtension {
|
||||
|
||||
override func renameItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier, toName itemName: String, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
|
||||
Task {
|
||||
guard let metadata = await providerUtility.getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
guard let metadata = await fileProviderUtility().getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let fileNameFrom = metadata.fileNameView
|
||||
let fileNamePathFrom = utilityFileSystem.createServerUrl(serverUrl: metadata.serverUrl, fileName: fileNameFrom)
|
||||
let fileNamePathTo = utilityFileSystem.createServerUrl(serverUrl: metadata.serverUrl, fileName: itemName)
|
||||
@@ -154,11 +160,11 @@ extension FileProviderExtension {
|
||||
let resultsMove = await NextcloudKit.shared.moveFileOrFolderAsync(serverUrlFileNameSource: fileNamePathFrom, serverUrlFileNameDestination: fileNamePathTo, overwrite: false, account: metadata.account)
|
||||
|
||||
if resultsMove.error == .success {
|
||||
await self.database.renameMetadata(fileNameNew: itemName, ocId: ocId)
|
||||
await self.database.setMetadataServerUrlFileNameStatusNormalAsync(ocId: ocId)
|
||||
await NCManageDatabase.shared.renameMetadata(fileNameNew: itemName, ocId: ocId)
|
||||
await NCManageDatabase.shared.setMetadataServerUrlFileNameStatusNormalAsync(ocId: ocId)
|
||||
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(ocId),
|
||||
let parentItemIdentifier = await self.providerUtility.getParentItemIdentifierAsync(metadata: metadata) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocId),
|
||||
let parentItemIdentifier = await fileProviderUtility().getParentItemIdentifierAsync(metadata: metadata) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
@@ -184,7 +190,7 @@ extension FileProviderExtension {
|
||||
|
||||
override func setFavoriteRank(_ favoriteRank: NSNumber?, forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
|
||||
Task {
|
||||
guard let metadata = await providerUtility.getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
guard let metadata = await fileProviderUtility().getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
@@ -192,43 +198,43 @@ extension FileProviderExtension {
|
||||
let ocId = metadata.ocId
|
||||
|
||||
if favoriteRank == nil {
|
||||
fileProviderData.listFavoriteIdentifierRank.removeValue(forKey: itemIdentifier.rawValue)
|
||||
FileProviderData.shared.listFavoriteIdentifierRank.removeValue(forKey: itemIdentifier.rawValue)
|
||||
} else {
|
||||
if fileProviderData.listFavoriteIdentifierRank[itemIdentifier.rawValue] == nil {
|
||||
fileProviderData.listFavoriteIdentifierRank[itemIdentifier.rawValue] = favoriteRank
|
||||
if FileProviderData.shared.listFavoriteIdentifierRank[itemIdentifier.rawValue] == nil {
|
||||
FileProviderData.shared.listFavoriteIdentifierRank[itemIdentifier.rawValue] = favoriteRank
|
||||
}
|
||||
favorite = true
|
||||
}
|
||||
|
||||
if (favorite == true && !metadata.favorite) || (!favorite && metadata.favorite) {
|
||||
let fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
|
||||
let fileNamePath = NCUtilityFileSystem().getRelativeFilePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
|
||||
let resultsFavorite = await NextcloudKit.shared.setFavoriteAsync(fileName: fileNamePath, favorite: favorite, account: metadata.account)
|
||||
|
||||
if resultsFavorite.error == .success {
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(ocId) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocId) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
|
||||
// Change DB
|
||||
metadata.favorite = favorite
|
||||
await self.database.addMetadataAsync(metadata)
|
||||
await NCManageDatabase.shared.addMetadataAsync(metadata)
|
||||
|
||||
let item = await fileProviderData.signalEnumerator(ocId: metadata.ocId, type: .workingSet)
|
||||
let item = await FileProviderData.shared.signalEnumerator(ocId: metadata.ocId, type: .workingSet)
|
||||
|
||||
completionHandler(item, nil)
|
||||
return
|
||||
|
||||
} else {
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAsync(ocId) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocId) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
|
||||
// Errore, remove from listFavoriteIdentifierRank
|
||||
fileProviderData.listFavoriteIdentifierRank.removeValue(forKey: itemIdentifier.rawValue)
|
||||
FileProviderData.shared.listFavoriteIdentifierRank.removeValue(forKey: itemIdentifier.rawValue)
|
||||
|
||||
let item = await fileProviderData.signalEnumerator(ocId: metadata.ocId, type: .workingSet)
|
||||
let item = await FileProviderData.shared.signalEnumerator(ocId: metadata.ocId, type: .workingSet)
|
||||
|
||||
completionHandler(item, NSFileProviderError(.serverUnreachable))
|
||||
return
|
||||
@@ -239,16 +245,16 @@ extension FileProviderExtension {
|
||||
|
||||
override func setTagData(_ tagData: Data?, forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
|
||||
Task {
|
||||
guard let metadataForTag = await providerUtility.getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
guard let metadataForTag = await fileProviderUtility().getTableMetadataFromItemIdentifierAsync(itemIdentifier) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
let ocId = metadataForTag.ocId
|
||||
let account = metadataForTag.account
|
||||
|
||||
await self.database.addTagAsunc(ocId, tagIOS: tagData, account: account)
|
||||
await NCManageDatabase.shared.addTagAsync(ocId, tagIOS: tagData, account: account)
|
||||
|
||||
let item = await fileProviderData.signalEnumerator(ocId: ocId, type: .workingSet)
|
||||
let item = await FileProviderData.shared.signalEnumerator(ocId: ocId, type: .workingSet)
|
||||
|
||||
completionHandler(item, nil)
|
||||
}
|
||||
@@ -257,8 +263,8 @@ extension FileProviderExtension {
|
||||
override func setLastUsedDate(_ lastUsedDate: Date?, forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
|
||||
|
||||
Task {
|
||||
guard let metadata = await providerUtility.getTableMetadataFromItemIdentifierAsync(itemIdentifier),
|
||||
let parentItemIdentifier = await providerUtility.getParentItemIdentifierAsync(metadata: metadata) else {
|
||||
guard let metadata = await fileProviderUtility().getTableMetadataFromItemIdentifierAsync(itemIdentifier),
|
||||
let parentItemIdentifier = await fileProviderUtility().getParentItemIdentifierAsync(metadata: metadata) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -12,9 +12,10 @@ extension FileProviderExtension {
|
||||
|
||||
let progress = Progress(totalUnitCount: Int64(itemIdentifiers.count))
|
||||
var counterProgress: Int64 = 0
|
||||
let fileProviderUtility = fileProviderUtility()
|
||||
|
||||
for itemIdentifier in itemIdentifiers {
|
||||
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier),
|
||||
guard let metadata = fileProviderUtility.getTableMetadataFromItemIdentifier(itemIdentifier),
|
||||
metadata.hasPreview
|
||||
else {
|
||||
counterProgress += 1
|
||||
|
||||
@@ -7,50 +7,21 @@ import UniformTypeIdentifiers
|
||||
import FileProvider
|
||||
import NextcloudKit
|
||||
import Alamofire
|
||||
|
||||
/* -----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
STRUCT item
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
itemIdentifier = NSFileProviderItemIdentifier.rootContainer.rawValue --> _ROOT_
|
||||
parentItemIdentifier = NSFileProviderItemIdentifier.rootContainer.rawValue --> _ROOT_
|
||||
|
||||
↓
|
||||
|
||||
itemIdentifier = metadata.ocId (ex. 00ABC1) --> func getItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier
|
||||
parentItemIdentifier = NSFileProviderItemIdentifier.rootContainer.rawValue --> func getParentItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier?
|
||||
|
||||
↓
|
||||
|
||||
itemIdentifier = metadata.ocId (ex. 00CCC) --> func getItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier
|
||||
parentItemIdentifier = parent itemIdentifier (00ABC1) --> func getParentItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier?
|
||||
|
||||
↓
|
||||
|
||||
itemIdentifier = metadata.ocId (ex. 000DD) --> func getItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier
|
||||
parentItemIdentifier = parent itemIdentifier (00CCC) --> func getParentItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier?
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------- */
|
||||
import RealmSwift
|
||||
|
||||
final class FileProviderExtension: NSFileProviderExtension {
|
||||
lazy var providerUtility = fileProviderUtility()
|
||||
lazy var utilityFileSystem = NCUtilityFileSystem()
|
||||
let fileProviderData = FileProviderData.shared
|
||||
let global = NCGlobal.shared
|
||||
let database = NCManageDatabase.shared
|
||||
let backgroundSession = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance)
|
||||
|
||||
override init() { }
|
||||
|
||||
deinit { }
|
||||
|
||||
// MARK: - Enumeration
|
||||
|
||||
override func enumerator(for containerItemIdentifier: NSFileProviderItemIdentifier) throws -> NSFileProviderEnumerator {
|
||||
// Skip authentication checks for the working set container
|
||||
if containerItemIdentifier != .workingSet {
|
||||
let versionApp = NCUtility().getVersionMaintenance()
|
||||
let versionApp = fileProviderUtility().getVersionMaintenance()
|
||||
|
||||
// Verify / Open REALM
|
||||
guard let url = NCManageDatabase.shared.databaseURL,
|
||||
let version = try? schemaVersionAtURL(url),
|
||||
version == databaseSchemaVersion else {
|
||||
throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: ["code": NSNumber(value: NCGlobal.shared.errorVersionMismatch)])
|
||||
}
|
||||
NCManageDatabase.shared.openRealm()
|
||||
|
||||
// Verify version
|
||||
if let groupDefaults = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup) {
|
||||
@@ -61,7 +32,7 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
}
|
||||
|
||||
// Ensure a valid account is configured for the extension
|
||||
guard fileProviderData.setupAccount(domain: self.domain, providerExtension: self) != nil else {
|
||||
guard FileProviderData.shared.setupAccount(domain: self.domain, providerExtension: self) != nil else {
|
||||
throw NSError(domain: NSFileProviderErrorDomain, code: NSFileProviderError.notAuthenticated.rawValue, userInfo: [:])
|
||||
}
|
||||
|
||||
@@ -83,26 +54,27 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
// MARK: - Item
|
||||
|
||||
override func item(for identifier: NSFileProviderItemIdentifier) throws -> NSFileProviderItem {
|
||||
if identifier == .rootContainer, let session = fileProviderData.session {
|
||||
let metadata = database.createMetadataDirectory(fileName: NextcloudKit.shared.nkCommonInstance.rootFileName,
|
||||
ocId: NSFileProviderItemIdentifier.rootContainer.rawValue,
|
||||
serverUrl: utilityFileSystem.getHomeServer(session: session),
|
||||
session: session)
|
||||
if identifier == .rootContainer, let session = FileProviderData.shared.session {
|
||||
let metadata = NCManageDatabaseCreateMetadata().createMetadataDirectory(
|
||||
fileName: NextcloudKit.shared.nkCommonInstance.rootFileName,
|
||||
ocId: NSFileProviderItemIdentifier.rootContainer.rawValue,
|
||||
serverUrl: NCUtilityFileSystem().getHomeServer(session: session),
|
||||
session: session)
|
||||
|
||||
return FileProviderItem(metadata: metadata, parentItemIdentifier: NSFileProviderItemIdentifier(NSFileProviderItemIdentifier.rootContainer.rawValue))
|
||||
} else {
|
||||
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(identifier),
|
||||
let parentItemIdentifier = providerUtility.getParentItemIdentifier(metadata: metadata) else {
|
||||
let fileProviderUtility = fileProviderUtility()
|
||||
guard let metadata = fileProviderUtility.getTableMetadataFromItemIdentifier(identifier),
|
||||
let parentItemIdentifier = fileProviderUtility.getParentItemIdentifier(metadata: metadata) else {
|
||||
throw NSFileProviderError(.noSuchItem)
|
||||
}
|
||||
let item = FileProviderItem(metadata: metadata, parentItemIdentifier: parentItemIdentifier)
|
||||
|
||||
return item
|
||||
}
|
||||
}
|
||||
|
||||
override func urlForItem(withPersistentIdentifier identifier: NSFileProviderItemIdentifier) -> URL? {
|
||||
guard let session = fileProviderData.session,
|
||||
guard let session = FileProviderData.shared.session,
|
||||
let item = try? item(for: identifier),
|
||||
let rootURL = fileProviderUtility().getDocumentStorageURL(for: domain, userId: session.userId, urlBase: session.urlBase) else {
|
||||
return nil
|
||||
@@ -112,7 +84,6 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
|
||||
// (fix copy/paste directory -> isDirectory = false)
|
||||
url = url.appendingPathComponent(item.filename, isDirectory: false)
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -123,7 +94,6 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
assert(pathComponents.count > 2)
|
||||
|
||||
let itemIdentifier = NSFileProviderItemIdentifier(pathComponents[pathComponents.count - 2])
|
||||
|
||||
return itemIdentifier
|
||||
}
|
||||
|
||||
@@ -139,7 +109,6 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
|
||||
completionHandler(nil)
|
||||
} catch {
|
||||
|
||||
completionHandler(error)
|
||||
}
|
||||
}
|
||||
@@ -148,9 +117,11 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
Task {
|
||||
autoreleasepool {
|
||||
Task {
|
||||
let backgroundSession = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance)
|
||||
let pathComponents = url.pathComponents
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let itemIdentifier = NSFileProviderItemIdentifier(pathComponents[pathComponents.count - 2])
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAndocIdTransferAsync(itemIdentifier.rawValue) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAndocIdTransferAsync(itemIdentifier.rawValue) else {
|
||||
completionHandler(NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
}
|
||||
@@ -166,14 +137,14 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
let ocId = metadata.ocId
|
||||
|
||||
// Exists
|
||||
if let tableLocalFile = await self.database.getTableLocalFileAsync(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)),
|
||||
fileProviderUtility().fileProviderStorageExists(metadata),
|
||||
if let tableLocalFile = await NCManageDatabase.shared.getTableLocalFileAsync(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)),
|
||||
NCUtilityFileSystem().fileProviderStorageExists(metadata),
|
||||
tableLocalFile.etag == metadata.etag {
|
||||
completionHandler(nil)
|
||||
return
|
||||
}
|
||||
|
||||
await fileProviderData.signalEnumerator(ocId: ocId, type: .update)
|
||||
await FileProviderData.shared.signalEnumerator(ocId: ocId, type: .update)
|
||||
|
||||
let (task, error) = backgroundSession.download(serverUrlFileName: serverUrlFileName,
|
||||
fileNameLocalPath: fileNameLocalPath,
|
||||
@@ -182,12 +153,13 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
sessionIdentifier: NCNetworking.shared.sessionDownloadBackgroundExt)
|
||||
|
||||
if let task, error == .success {
|
||||
await self.database.setMetadataSessionAsync(ocId: metadata.ocId,
|
||||
session: NCNetworking.shared.sessionDownload,
|
||||
sessionTaskIdentifier: task.taskIdentifier,
|
||||
sessionError: "",
|
||||
selector: "",
|
||||
status: NCGlobal.shared.metadataStatusDownloading)
|
||||
await NCManageDatabase.shared.setMetadataSessionAsync(
|
||||
ocId: metadata.ocId,
|
||||
session: NCNetworking.shared.sessionDownload,
|
||||
sessionTaskIdentifier: task.taskIdentifier,
|
||||
sessionError: "",
|
||||
selector: "",
|
||||
status: NCGlobal.shared.metadataStatusDownloading)
|
||||
do {
|
||||
if let domain = self.domain,
|
||||
let manager = NSFileProviderManager(for: domain) {
|
||||
@@ -199,9 +171,9 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
print(error)
|
||||
}
|
||||
|
||||
await fileProviderData.signalEnumerator(ocId: metadata.ocId, type: .update)
|
||||
await FileProviderData.shared.signalEnumerator(ocId: metadata.ocId, type: .update)
|
||||
|
||||
fileProviderData.downloadPendingCompletionHandlers[task.taskIdentifier] = completionHandler
|
||||
FileProviderData.shared.downloadPendingCompletionHandlers[task.taskIdentifier] = completionHandler
|
||||
|
||||
task.resume()
|
||||
}
|
||||
@@ -214,24 +186,26 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
Task {
|
||||
autoreleasepool {
|
||||
Task {
|
||||
let backgroundSession = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance)
|
||||
let pathComponents = url.pathComponents
|
||||
assert(pathComponents.count > 2)
|
||||
let itemIdentifier = NSFileProviderItemIdentifier(pathComponents[pathComponents.count - 2])
|
||||
let fileName = pathComponents[pathComponents.count - 1]
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAndocIdTransferAsync(itemIdentifier.rawValue),
|
||||
metadata.status == global.metadataStatusNormal else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAndocIdTransferAsync(itemIdentifier.rawValue),
|
||||
metadata.status == NCGlobal.shared.metadataStatusNormal else {
|
||||
return
|
||||
}
|
||||
let serverUrlFileName = utilityFileSystem.createServerUrl(serverUrl: metadata.serverUrl, fileName: fileName)
|
||||
let serverUrlFileName = NCUtilityFileSystem().createServerUrl(serverUrl: metadata.serverUrl, fileName: fileName)
|
||||
let ocId = metadata.ocId
|
||||
let account = metadata.account
|
||||
|
||||
await self.database.setMetadataSessionAsync(ocId: ocId,
|
||||
session: NCNetworking.shared.sessionUploadBackgroundExt,
|
||||
sessionTaskIdentifier: 0,
|
||||
sessionError: "",
|
||||
selector: "",
|
||||
status: NCGlobal.shared.metadataStatusUploading)
|
||||
await NCManageDatabase.shared.setMetadataSessionAsync(
|
||||
ocId: ocId,
|
||||
session: NCNetworking.shared.sessionUploadBackgroundExt,
|
||||
sessionTaskIdentifier: 0,
|
||||
sessionError: "",
|
||||
selector: "",
|
||||
status: NCGlobal.shared.metadataStatusUploading)
|
||||
|
||||
let (task, error) = await backgroundSession.uploadAsync(serverUrlFileName: serverUrlFileName,
|
||||
fileNameLocalPath: url.path,
|
||||
@@ -243,9 +217,10 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
sessionIdentifier: NCNetworking.shared.sessionUploadBackgroundExt)
|
||||
|
||||
if let task, error == .success {
|
||||
await self.database.setMetadataSessionAsync(ocId: ocId,
|
||||
sessionTaskIdentifier: task.taskIdentifier,
|
||||
status: NCGlobal.shared.metadataStatusUploading)
|
||||
await NCManageDatabase.shared.setMetadataSessionAsync(
|
||||
ocId: ocId,
|
||||
sessionTaskIdentifier: task.taskIdentifier,
|
||||
status: NCGlobal.shared.metadataStatusUploading)
|
||||
|
||||
do {
|
||||
if let domain = self.domain,
|
||||
@@ -258,7 +233,7 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
print(error)
|
||||
}
|
||||
|
||||
await fileProviderData.signalEnumerator(ocId: ocId, type: .update)
|
||||
await FileProviderData.shared.signalEnumerator(ocId: ocId, type: .update)
|
||||
|
||||
task.resume()
|
||||
}
|
||||
@@ -272,7 +247,7 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
let pathComponents = url.pathComponents
|
||||
assert(pathComponents.count > 2)
|
||||
let itemIdentifier = NSFileProviderItemIdentifier(pathComponents[pathComponents.count - 2])
|
||||
guard let metadata = await self.database.getMetadataFromOcIdAndocIdTransferAsync(itemIdentifier.rawValue) else {
|
||||
guard let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAndocIdTransferAsync(itemIdentifier.rawValue) else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -298,11 +273,12 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
Task {
|
||||
autoreleasepool {
|
||||
Task {
|
||||
guard let session = fileProviderData.session,
|
||||
let tableDirectory = await self.providerUtility.getTableDirectoryFromParentItemIdentifierAsync(
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
guard let session = FileProviderData.shared.session,
|
||||
let tableDirectory = await fileProviderUtility().getTableDirectoryFromParentItemIdentifierAsync(
|
||||
parentItemIdentifier,
|
||||
account: session.account,
|
||||
homeServerUrl: self.utilityFileSystem.getHomeServer(session: session)
|
||||
homeServerUrl: utilityFileSystem.getHomeServer(session: session)
|
||||
) else {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
return
|
||||
@@ -313,7 +289,7 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
_ = fileURL.startAccessingSecurityScopedResource()
|
||||
|
||||
do {
|
||||
let attributes = try self.providerUtility.fileManager.attributesOfItem(atPath: fileURL.path)
|
||||
let attributes = try fileProviderUtility().fileManager.attributesOfItem(atPath: fileURL.path)
|
||||
size = attributes[.size] as? Int64 ?? 0
|
||||
if attributes[.type] as? FileAttributeType == .typeDirectory {
|
||||
completionHandler(nil, NSFileProviderError(.noSuchItem))
|
||||
@@ -324,34 +300,38 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
return
|
||||
}
|
||||
|
||||
let fileName = self.utilityFileSystem.createFileName(fileURL.lastPathComponent,
|
||||
serverUrl: tableDirectory.serverUrl,
|
||||
account: session.account)
|
||||
let fileName = fileProviderUtility().createFileName(fileURL.lastPathComponent,
|
||||
serverUrl: tableDirectory.serverUrl,
|
||||
account: session.account)
|
||||
let ocIdTransfer = UUID().uuidString.lowercased()
|
||||
|
||||
NSFileCoordinator().coordinate(readingItemAt: fileURL,
|
||||
options: .withoutChanges,
|
||||
error: &errorCoordinator) { url in
|
||||
self.providerUtility.copyFile(url.path,
|
||||
toPath: self.utilityFileSystem.getDirectoryProviderStorageOcId(ocIdTransfer,
|
||||
fileName: fileName,
|
||||
userId: session.userId,
|
||||
urlBase: session.urlBase))
|
||||
NSFileCoordinator().coordinate(
|
||||
readingItemAt: fileURL,
|
||||
options: .withoutChanges,
|
||||
error: &errorCoordinator) { url in
|
||||
NCUtilityFileSystem().copyFile(
|
||||
atPath: url.path,
|
||||
toPath: utilityFileSystem.getDirectoryProviderStorageOcId(
|
||||
ocIdTransfer,
|
||||
fileName: fileName,
|
||||
userId: session.userId,
|
||||
urlBase: session.urlBase))
|
||||
}
|
||||
|
||||
fileURL.stopAccessingSecurityScopedResource()
|
||||
|
||||
let metadata = await self.database.createMetadataAsync(fileName: fileName,
|
||||
ocId: ocIdTransfer,
|
||||
serverUrl: tableDirectory.serverUrl,
|
||||
session: session,
|
||||
sceneIdentifier: nil)
|
||||
let metadata = await NCManageDatabaseCreateMetadata().createMetadataAsync(
|
||||
fileName: fileName,
|
||||
ocId: ocIdTransfer,
|
||||
serverUrl: tableDirectory.serverUrl,
|
||||
session: session,
|
||||
sceneIdentifier: nil)
|
||||
|
||||
metadata.session = NCNetworking.shared.sessionUploadBackgroundExt
|
||||
metadata.size = size
|
||||
metadata.status = NCGlobal.shared.metadataStatusUploading
|
||||
|
||||
await database.addMetadataAsync(metadata)
|
||||
await NCManageDatabase.shared.addMetadataAsync(metadata)
|
||||
let serverUrlFileName = utilityFileSystem.createServerUrl(serverUrl: tableDirectory.serverUrl, fileName: fileName)
|
||||
let fileNameLocalPath = utilityFileSystem.getDirectoryProviderStorageOcId(ocIdTransfer,
|
||||
fileName: fileName,
|
||||
@@ -369,9 +349,10 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
sessionIdentifier: metadata.session)
|
||||
|
||||
if let task, error == .success {
|
||||
await self.database.setMetadataSessionAsync(ocId: metadata.ocId,
|
||||
sessionTaskIdentifier: task.taskIdentifier,
|
||||
status: NCGlobal.shared.metadataStatusUploading)
|
||||
await NCManageDatabase.shared.setMetadataSessionAsync(
|
||||
ocId: metadata.ocId,
|
||||
sessionTaskIdentifier: task.taskIdentifier,
|
||||
status: NCGlobal.shared.metadataStatusUploading)
|
||||
|
||||
do {
|
||||
if let domain = self.domain,
|
||||
@@ -384,7 +365,7 @@ final class FileProviderExtension: NSFileProviderExtension {
|
||||
print(error)
|
||||
}
|
||||
|
||||
await fileProviderData.signalEnumerator(ocId: metadata.ocId, type: .update)
|
||||
await FileProviderData.shared.signalEnumerator(ocId: metadata.ocId, type: .update)
|
||||
|
||||
task.resume()
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
|
||||
|
||||
/// Providing Required Properties
|
||||
var itemIdentifier: NSFileProviderItemIdentifier {
|
||||
return fileProviderUtility().getItemIdentifier(metadata: metadata)
|
||||
return NSFileProviderItemIdentifier(metadata.ocId)
|
||||
}
|
||||
var filename: String {
|
||||
return metadata.fileNameView
|
||||
@@ -58,11 +58,15 @@ class FileProviderItem: NSObject, NSFileProviderItem {
|
||||
return metadata.etag.data(using: .utf8)
|
||||
}
|
||||
var isMostRecentVersionDownloaded: Bool {
|
||||
if NCManageDatabase.shared.getResultTableLocalFile(ocId: metadata.ocId) == nil {
|
||||
return false
|
||||
} else {
|
||||
if metadata.directory {
|
||||
return true
|
||||
}
|
||||
let path = NCUtilityFileSystem().getDirectoryProviderStorageOcId(metadata.ocId, fileName: metadata.fileName, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
guard let attributes = try? FileManager.default.attributesOfItem(atPath: path),
|
||||
let fileSize = attributes[.size] as? UInt64 else {
|
||||
return false
|
||||
}
|
||||
return fileSize > 0
|
||||
}
|
||||
/// Monitoring File Transfers
|
||||
var isUploading: Bool {
|
||||
@@ -90,11 +94,15 @@ class FileProviderItem: NSObject, NSFileProviderItem {
|
||||
}
|
||||
}
|
||||
var isDownloaded: Bool {
|
||||
if NCUtilityFileSystem().fileProviderStorageExists(metadata) {
|
||||
if metadata.directory {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
let path = NCUtilityFileSystem().getDirectoryProviderStorageOcId(metadata.ocId, fileName: metadata.fileName, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
guard let attributes = try? FileManager.default.attributesOfItem(atPath: path),
|
||||
let fileSize = attributes[.size] as? UInt64 else {
|
||||
return false
|
||||
}
|
||||
return fileSize > 0
|
||||
}
|
||||
var downloadingError: Error? {
|
||||
if metadata.status == NCGlobal.shared.metadataStatusDownloadError {
|
||||
@@ -106,11 +114,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
|
||||
/// Sharing
|
||||
/// Managing Metadata
|
||||
var tagData: Data? {
|
||||
if let tableTag = NCManageDatabase.shared.getTag(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
|
||||
return tableTag.tagIOS
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
var favoriteRank: NSNumber? {
|
||||
if let rank = FileProviderData.shared.listFavoriteIdentifierRank[metadata.ocId] {
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
|
||||
import UIKit
|
||||
import NextcloudKit
|
||||
import FileProvider
|
||||
|
||||
class fileProviderUtility: NSObject {
|
||||
let fileManager = FileManager()
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let database = NCManageDatabase.shared
|
||||
|
||||
/// Returns the expected documentStorageURL for a specific domain or constructs a fallback path manually.
|
||||
/// This is used to ensure consistency even in single-domain fallback mode.
|
||||
func getDocumentStorageURL(for domain: NSFileProviderDomain?, userId: String, urlBase: String) -> URL? {
|
||||
guard let urlBase = NSURL(string: urlBase),
|
||||
let host = urlBase.host else {
|
||||
@@ -39,17 +36,17 @@ class fileProviderUtility: NSObject {
|
||||
|
||||
func getAccountFromItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) -> String? {
|
||||
let ocId = itemIdentifier.rawValue
|
||||
return self.database.getMetadataFromOcId(ocId)?.account
|
||||
return NCManageDatabase.shared.getMetadataFromOcId(ocId)?.account
|
||||
}
|
||||
|
||||
func getTableMetadataFromItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) -> tableMetadata? {
|
||||
let ocId = itemIdentifier.rawValue
|
||||
return self.database.getMetadataFromOcId(ocId)
|
||||
return NCManageDatabase.shared.getMetadataFromOcId(ocId)
|
||||
}
|
||||
|
||||
func getTableMetadataFromItemIdentifierAsync(_ itemIdentifier: NSFileProviderItemIdentifier) async -> tableMetadata? {
|
||||
let ocId = itemIdentifier.rawValue
|
||||
return await self.database.getMetadataFromOcIdAsync(ocId)
|
||||
return await NCManageDatabase.shared.getMetadataFromOcIdAsync(ocId)
|
||||
}
|
||||
|
||||
func getItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier {
|
||||
@@ -57,13 +54,13 @@ class fileProviderUtility: NSObject {
|
||||
}
|
||||
|
||||
func getParentItemIdentifier(metadata: tableMetadata) -> NSFileProviderItemIdentifier? {
|
||||
let homeServerUrl = utilityFileSystem.getHomeServer(urlBase: metadata.urlBase, userId: metadata.userId)
|
||||
if let directory = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
|
||||
let homeServerUrl = NCUtilityFileSystem().getHomeServer(urlBase: metadata.urlBase, userId: metadata.userId)
|
||||
if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
|
||||
if directory.serverUrl == homeServerUrl {
|
||||
return NSFileProviderItemIdentifier(NSFileProviderItemIdentifier.rootContainer.rawValue)
|
||||
} else {
|
||||
// get the metadata.ocId of parent Directory
|
||||
if let metadata = self.database.getMetadataFromOcId(directory.ocId) {
|
||||
if let metadata = NCManageDatabase.shared.getMetadataFromOcId(directory.ocId) {
|
||||
let identifier = getItemIdentifier(metadata: metadata)
|
||||
return identifier
|
||||
}
|
||||
@@ -73,13 +70,13 @@ class fileProviderUtility: NSObject {
|
||||
}
|
||||
|
||||
func getParentItemIdentifierAsync(metadata: tableMetadata) async -> NSFileProviderItemIdentifier? {
|
||||
let homeServerUrl = utilityFileSystem.getHomeServer(urlBase: metadata.urlBase, userId: metadata.userId)
|
||||
if let directory = await self.database.getTableDirectoryAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
|
||||
let homeServerUrl = NCUtilityFileSystem().getHomeServer(urlBase: metadata.urlBase, userId: metadata.userId)
|
||||
if let directory = await NCManageDatabase.shared.getTableDirectoryAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
|
||||
if directory.serverUrl == homeServerUrl {
|
||||
return NSFileProviderItemIdentifier(NSFileProviderItemIdentifier.rootContainer.rawValue)
|
||||
} else {
|
||||
// get the metadata.ocId of parent Directory
|
||||
if let metadata = await self.database.getMetadataFromOcIdAsync(directory.ocId) {
|
||||
if let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(directory.ocId) {
|
||||
let identifier = getItemIdentifier(metadata: metadata)
|
||||
return identifier
|
||||
}
|
||||
@@ -88,6 +85,23 @@ class fileProviderUtility: NSObject {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getParentItemIdentifierAsync(session: NCSession.Session, directory: tableDirectory?) async -> NSFileProviderItemIdentifier? {
|
||||
let homeServerUrl = NCUtilityFileSystem().getHomeServer(urlBase: session.urlBase, userId: session.userId)
|
||||
guard let directory else {
|
||||
return nil
|
||||
}
|
||||
if directory.serverUrl == homeServerUrl {
|
||||
return NSFileProviderItemIdentifier(NSFileProviderItemIdentifier.rootContainer.rawValue)
|
||||
} else {
|
||||
// get the metadata.ocId of parent Directory
|
||||
if let metadata = await NCManageDatabase.shared.getMetadataFromOcIdAsync(directory.ocId) {
|
||||
let identifier = getItemIdentifier(metadata: metadata)
|
||||
return identifier
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getTableDirectoryFromParentItemIdentifier(_ parentItemIdentifier: NSFileProviderItemIdentifier, account: String, homeServerUrl: String) -> tableDirectory? {
|
||||
var predicate: NSPredicate
|
||||
if parentItemIdentifier == .rootContainer {
|
||||
@@ -96,7 +110,7 @@ class fileProviderUtility: NSObject {
|
||||
guard let metadata = getTableMetadataFromItemIdentifier(parentItemIdentifier) else { return nil }
|
||||
predicate = NSPredicate(format: "ocId == %@", metadata.ocId)
|
||||
}
|
||||
guard let directory = self.database.getTableDirectory(predicate: predicate) else { return nil }
|
||||
guard let directory = NCManageDatabase.shared.getTableDirectory(predicate: predicate) else { return nil }
|
||||
return directory
|
||||
}
|
||||
|
||||
@@ -110,80 +124,80 @@ class fileProviderUtility: NSObject {
|
||||
}
|
||||
predicate = NSPredicate(format: "ocId == %@", metadata.ocId)
|
||||
}
|
||||
guard let directory = await self.database.getTableDirectoryAsync(predicate: predicate) else {
|
||||
guard let directory = await NCManageDatabase.shared.getTableDirectoryAsync(predicate: predicate) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return directory
|
||||
}
|
||||
|
||||
func copyFile(_ atPath: String, toPath: String) {
|
||||
if !fileManager.fileExists(atPath: atPath) { return }
|
||||
func createFileName(_ fileName: String, serverUrl: String, account: String) -> String {
|
||||
var resultFileName = fileName
|
||||
var exitLoop = false
|
||||
|
||||
do {
|
||||
try fileManager.removeItem(atPath: toPath)
|
||||
} catch let error {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
}
|
||||
do {
|
||||
try fileManager.copyItem(atPath: atPath, toPath: toPath)
|
||||
} catch let error {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
while exitLoop == false {
|
||||
if NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "fileNameView ==[c] %@ AND serverUrl == %@ AND account == %@", resultFileName, serverUrl, account)) != nil {
|
||||
var name = NSString(string: resultFileName).deletingPathExtension
|
||||
let ext = NSString(string: resultFileName).pathExtension
|
||||
let characters = Array(name)
|
||||
|
||||
func moveFile(_ atPath: String, toPath: String) {
|
||||
if !fileManager.fileExists(atPath: atPath) { return }
|
||||
|
||||
do {
|
||||
try fileManager.removeItem(atPath: toPath)
|
||||
} catch let error {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
}
|
||||
do {
|
||||
try fileManager.moveItem(atPath: atPath, toPath: toPath)
|
||||
} catch let error {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
func getFileSize(from url: URL) -> Int64? {
|
||||
do {
|
||||
let attributes = try fileManager.attributesOfItem(atPath: url.path)
|
||||
|
||||
if let fileSize = attributes[FileAttributeKey.size] as? Int64 {
|
||||
return fileSize
|
||||
if characters.count < 2 {
|
||||
if ext.isEmpty {
|
||||
resultFileName = name + " " + "1"
|
||||
} else {
|
||||
resultFileName = name + " " + "1" + "." + ext
|
||||
}
|
||||
} else {
|
||||
let space = characters[characters.count - 2]
|
||||
let numChar = characters[characters.count - 1]
|
||||
var num = Int(String(numChar))
|
||||
if space == " " && num != nil {
|
||||
name = String(name.dropLast())
|
||||
num = num! + 1
|
||||
if ext.isEmpty {
|
||||
resultFileName = name + "\(num!)"
|
||||
} else {
|
||||
resultFileName = name + "\(num!)" + "." + ext
|
||||
}
|
||||
} else {
|
||||
if ext.isEmpty {
|
||||
resultFileName = name + " " + "1"
|
||||
} else {
|
||||
resultFileName = name + " " + "1" + "." + ext
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print("Failed to retrieve file size.")
|
||||
return nil
|
||||
exitLoop = true
|
||||
}
|
||||
} catch {
|
||||
print("Error: \(error.localizedDescription)")
|
||||
return nil
|
||||
}
|
||||
|
||||
return resultFileName
|
||||
}
|
||||
|
||||
func fileProviderStorageExists(_ metadata: tableMetadata) -> Bool {
|
||||
let pathA = utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileName: metadata.fileName, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
let pathB = utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileName: metadata.fileNameView, userId: metadata.userId, urlBase: metadata.urlBase)
|
||||
|
||||
let sizeA = fileSize(at: pathA)
|
||||
let sizeB = fileSize(at: pathB)
|
||||
|
||||
if metadata.isDirectoryE2EE == true {
|
||||
return (sizeA == metadata.size || sizeB == metadata.size) && sizeB > 0
|
||||
func getVersionBuild() -> String {
|
||||
if let dictionary = Bundle.main.infoDictionary,
|
||||
let version = dictionary["CFBundleShortVersionString"],
|
||||
let build = dictionary["CFBundleVersion"] {
|
||||
return "\(version).\(build)"
|
||||
}
|
||||
|
||||
return sizeB == metadata.size && metadata.size > 0
|
||||
return ""
|
||||
}
|
||||
|
||||
private func fileSize(at path: String) -> UInt64 {
|
||||
do {
|
||||
let attr = try fileManager.attributesOfItem(atPath: path)
|
||||
return attr[.size] as? UInt64 ?? 0
|
||||
} catch {
|
||||
nkLog(error: " [fileSize] Errore accesso a '\(path)': \(error)")
|
||||
return 0
|
||||
func getVersionMaintenance() -> String {
|
||||
if let dictionary = Bundle.main.infoDictionary,
|
||||
let version = dictionary["CFBundleShortVersionString"] {
|
||||
return "\(version)"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func ocIdToFileId(ocId: String?) -> String? {
|
||||
guard let ocId = ocId else { return nil }
|
||||
let items = ocId.components(separatedBy: "oc")
|
||||
|
||||
if items.count < 2 { return nil }
|
||||
guard let intFileId = Int(items[0]) else { return nil }
|
||||
return String(intFileId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2025 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Foundation
|
||||
import NextcloudKit
|
||||
import RealmSwift
|
||||
|
||||
final class NCManageDatabase {
|
||||
static let shared = NCManageDatabase()
|
||||
|
||||
internal let core: NCManageDatabaseCore
|
||||
internal let databaseURL: URL?
|
||||
|
||||
private init() {
|
||||
self.core = NCManageDatabaseCore()
|
||||
|
||||
if let dirGroup = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup) {
|
||||
self.databaseURL = dirGroup
|
||||
.appendingPathComponent(NCGlobal.shared.appDatabaseNextcloud)
|
||||
.appendingPathComponent(databaseName)
|
||||
} else {
|
||||
self.databaseURL = nil
|
||||
}
|
||||
}
|
||||
|
||||
func openRealm() {
|
||||
do {
|
||||
let configuration = Realm.Configuration(
|
||||
fileURL: databaseURL,
|
||||
schemaVersion: databaseSchemaVersion,
|
||||
objectTypes: [
|
||||
NCKeyValue.self, tableMetadata.self, tableMetadataTag.self, tableLocalFile.self,
|
||||
tableDirectory.self, tableTag.self, tableAccount.self
|
||||
]
|
||||
)
|
||||
Realm.Configuration.defaultConfiguration = configuration
|
||||
|
||||
let realm = try Realm(configuration: configuration)
|
||||
if let url = realm.configuration.fileURL {
|
||||
nkLog(tag: NCGlobal.shared.logTagDatabase, emoji: .start, message: "Realm is located at: \(url.path)", consoleOnly: true)
|
||||
}
|
||||
} catch let error {
|
||||
nkLog(tag: NCGlobal.shared.logTagDatabase, emoji: .error, message: "Realm error: \(error)")
|
||||
isSuspendingDatabaseOperation = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
{
|
||||
"originHash" : "b092e04dd25276db24ca02e5c41e732c10cb4045264d961e3b6b734943656553",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "abseil-cpp-binary",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/abseil-cpp-binary.git",
|
||||
"state" : {
|
||||
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5",
|
||||
"version" : "1.2024072200.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "alamofire",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Alamofire/Alamofire",
|
||||
"state" : {
|
||||
"revision" : "3494b7c1d4e08be98bbb2244fd55ca5a029ff4a2",
|
||||
"version" : "5.12.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "app-check",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/app-check.git",
|
||||
"state" : {
|
||||
"revision" : "3e33dd27dd4c69bd81c7c81fe61d8ccf58846902",
|
||||
"version" : "11.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "codescanner",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/twostraws/CodeScanner.git",
|
||||
"state" : {
|
||||
"revision" : "5e886430238944c7200fc9e10dbf2d9550dba865",
|
||||
"version" : "2.5.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "dropdown",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/AssistoLab/DropDown",
|
||||
"state" : {
|
||||
"branch" : "master",
|
||||
"revision" : "2ab6f6ce19f0117d1a76ea043ef8f57722c65d16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "easytipview",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/marinofaggiana/EasyTipView",
|
||||
"state" : {
|
||||
"branch" : "master",
|
||||
"revision" : "bb25a13c8fa5d65144c8e5b5d31237b80a001b07"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "firebase-ios-sdk",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/firebase-ios-sdk",
|
||||
"state" : {
|
||||
"revision" : "346daa9f46316aa372b35b317e18224acc2e9063",
|
||||
"version" : "12.18.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "google-ads-on-device-conversion-ios-sdk",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/googleads/google-ads-on-device-conversion-ios-sdk",
|
||||
"state" : {
|
||||
"revision" : "dc39082d8881109d35b94b1c122164c0e8d08a55",
|
||||
"version" : "3.6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "googleappmeasurement",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleAppMeasurement.git",
|
||||
"state" : {
|
||||
"revision" : "f04760d460296cc0fa430935a7be212e5bd67fc5",
|
||||
"version" : "12.18.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "googledatatransport",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleDataTransport.git",
|
||||
"state" : {
|
||||
"revision" : "ba3358d3c3dbae8ef230b58a46b97ad65e84e974",
|
||||
"version" : "10.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "googleutilities",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleUtilities.git",
|
||||
"state" : {
|
||||
"revision" : "92c8f6dc3ac375d6febdfcb3db68bc3d10633db3",
|
||||
"version" : "8.1.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "grpc-binary",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/grpc-binary.git",
|
||||
"state" : {
|
||||
"revision" : "75b31c842f664a0f46a2e590a570e370249fd8f6",
|
||||
"version" : "1.69.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "gtm-session-fetcher",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/gtm-session-fetcher.git",
|
||||
"state" : {
|
||||
"revision" : "724a52eea6329b7e12d3ad8300d76ca9f3895fcc",
|
||||
"version" : "5.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "gzipswift",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/1024jp/GzipSwift",
|
||||
"state" : {
|
||||
"revision" : "99cf703b461916279cbbb50068e904df86c37133",
|
||||
"version" : "6.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "interop-ios-for-google-sdks",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
|
||||
"state" : {
|
||||
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
|
||||
"version" : "101.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "keychainaccess",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/kishikawakatsumi/KeychainAccess",
|
||||
"state" : {
|
||||
"revision" : "84e546727d66f1adc5439debad16270d0fdd04e7",
|
||||
"version" : "4.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "leveldb",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/leveldb.git",
|
||||
"state" : {
|
||||
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
|
||||
"version" : "1.22.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "lucidbanner",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/marinofaggiana/LucidBanner",
|
||||
"state" : {
|
||||
"revision" : "d7ea11cac476f32f63e0ad60f393bc7937b1d019",
|
||||
"version" : "0.7.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "mantis",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/marinofaggiana/Mantis",
|
||||
"state" : {
|
||||
"revision" : "d145ce2403e0d94d4926eb8510bc4966fbf1bfca",
|
||||
"version" : "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "markdownkit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/bmoliveira/MarkdownKit",
|
||||
"state" : {
|
||||
"revision" : "39ea7a3fc7e65bcafe55152592b834859be574a5",
|
||||
"version" : "1.7.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "nanopb",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/nanopb.git",
|
||||
"state" : {
|
||||
"revision" : "3851d94a41890dea16dc3db34caf60e585cb4163",
|
||||
"version" : "2.30910.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "nextcloudkit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/nextcloud/NextcloudKit",
|
||||
"state" : {
|
||||
"branch" : "unified-sharing",
|
||||
"revision" : "1897d66c1687d85ec7c5acbf9fe7fd396b511257"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "openssl",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/krzyzanowskim/OpenSSL",
|
||||
"state" : {
|
||||
"revision" : "4b1188ba947ddc23d03b13096b9e44b804e146c9",
|
||||
"version" : "3.6.3000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "popupview",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/exyte/PopupView.git",
|
||||
"state" : {
|
||||
"revision" : "62e1698164c352e4cae074bb30eff011ef1b9af6",
|
||||
"version" : "5.0.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "promises",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/promises.git",
|
||||
"state" : {
|
||||
"revision" : "f4a19a3c313dc2616c70bb49d29a799fb16be837",
|
||||
"version" : "2.4.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "qrcodereader.swift",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/yannickl/QRCodeReader.swift",
|
||||
"state" : {
|
||||
"revision" : "5020b5a47199d8ba80c83a4b4fafd70e9dc9dc7f",
|
||||
"version" : "10.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "realm-core",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/realm/realm-core.git",
|
||||
"state" : {
|
||||
"revision" : "b4192c46305570577c4d08df790fddec5ab3aa04",
|
||||
"version" : "20.1.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "realm-swift",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/realm/realm-swift",
|
||||
"state" : {
|
||||
"revision" : "ca03df491ec5e4bb8af0bca1e9957d08c10ec2da",
|
||||
"version" : "20.0.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-atomics",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-atomics.git",
|
||||
"state" : {
|
||||
"revision" : "0442cb5a3f98ab802acb777929fdb446bda11a34",
|
||||
"version" : "1.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-collections.git",
|
||||
"state" : {
|
||||
"revision" : "a0cb0954ecb21e4e31b0070e6ed5674e8556685a",
|
||||
"version" : "1.6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio.git",
|
||||
"state" : {
|
||||
"revision" : "a931f2c1de8dd49381ce3bf2e279d033f68d8865",
|
||||
"version" : "2.102.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio-ssl",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-ssl",
|
||||
"state" : {
|
||||
"revision" : "03827c1a9fdb2b6b00a4e93ede8861520263af8c",
|
||||
"version" : "2.37.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-system",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-system.git",
|
||||
"state" : {
|
||||
"revision" : "869129b7bf4ecc57b97d0193ad29690ca2134750",
|
||||
"version" : "1.8.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swifter",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/httpswift/swifter.git",
|
||||
"state" : {
|
||||
"branch" : "stable",
|
||||
"revision" : "1e4f51c92d7ca486242d8bf0722b99de2c3531aa"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftrichstring",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/malcommac/SwiftRichString",
|
||||
"state" : {
|
||||
"revision" : "9bf4b5af6bb4386865636fc504d6c588c2b65040",
|
||||
"version" : "3.7.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftyjson",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/SwiftyJSON/SwiftyJSON",
|
||||
"state" : {
|
||||
"revision" : "af76cf3ef710b6ca5f8c05f3a31307d44a3c5828",
|
||||
"version" : "5.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftyxmlparser",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/yahoojapan/SwiftyXMLParser",
|
||||
"state" : {
|
||||
"revision" : "d7a1d23f04c86c1cd2e8f19247dd15d74e0ea8be",
|
||||
"version" : "5.6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "taglistview",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/ElaWorkshop/TagListView",
|
||||
"state" : {
|
||||
"revision" : "b30b61826736f4d9ec04aef5df891f3914423f16",
|
||||
"version" : "1.4.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "tlphotopicker",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/tilltue/TLPhotoPicker",
|
||||
"state" : {
|
||||
"revision" : "91d7bca65721928af30c6a2bb1a1f517f7862964",
|
||||
"version" : "2.1.21"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "vlckit-spm",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/tylerjonesio/vlckit-spm",
|
||||
"state" : {
|
||||
"revision" : "e932bbd488872fdb74f6654d28c2f291eae03daf",
|
||||
"version" : "3.6.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
@@ -121,9 +121,9 @@
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<RemoteRunnable
|
||||
runnableDebuggingMode = "0"
|
||||
runnableDebuggingMode = "1"
|
||||
BundleIdentifier = "it.twsweb.Nextcloud"
|
||||
RemotePath = "/var/containers/Bundle/Application/92F13FE8-7056-4509-8468-5856675AB1CA/Nextcloud.app">
|
||||
RemotePath = "/Users/marinofaggiana/Library/Developer/CoreSimulator/Devices/F424A0A4-ADE0-4955-969F-C6426054B5C6/data/Containers/Bundle/Application/76DC966F-BA80-4ECE-B970-4FCAF9F503D8/Nextcloud.app">
|
||||
</RemoteRunnable>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -140,6 +140,10 @@
|
||||
argument = "whitelist:NETWORKING TASKS"
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "-FIRDebugEnabled"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "blacklist:"
|
||||
isEnabled = "NO">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1630"
|
||||
LastUpgradeVersion = "2640"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
|
||||
@@ -21,12 +21,14 @@
|
||||
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
import os
|
||||
import NextcloudKit
|
||||
|
||||
class NotificationService: UNNotificationServiceExtension {
|
||||
var contentHandler: ((UNNotificationContent) -> Void)?
|
||||
var bestAttemptContent: UNMutableNotificationContent?
|
||||
var request: UNNotificationRequest?
|
||||
private let deliveryLock = OSAllocatedUnfairLock()
|
||||
|
||||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||
self.contentHandler = contentHandler
|
||||
@@ -35,59 +37,101 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
|
||||
NextcloudKit.configureLogger(logLevel: .verbose)
|
||||
|
||||
if let bestAttemptContent = bestAttemptContent {
|
||||
bestAttemptContent.title = ""
|
||||
bestAttemptContent.body = "Nextcloud notification"
|
||||
do {
|
||||
if let message = bestAttemptContent.userInfo["subject"] as? String {
|
||||
for tableAccount in NCManageDatabase.shared.getAllTableAccount() {
|
||||
guard let privateKey = NCPreferences().getPushNotificationPrivateKey(account: tableAccount.account) else {
|
||||
bestAttemptContent.body = "Error retrieving private key for \(tableAccount.account)"
|
||||
continue
|
||||
}
|
||||
guard let bestAttemptContent else { return }
|
||||
|
||||
let prefixData = Data(privateKey.prefix(8))
|
||||
let prefixBase64 = prefixData.base64EncodedString()
|
||||
nkLog(debug: "🔑 Loaded private key for \(tableAccount.account): prefix(Base64)=\(prefixBase64)")
|
||||
bestAttemptContent.title = ""
|
||||
bestAttemptContent.body = "Nextcloud notification"
|
||||
|
||||
guard let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey) else {
|
||||
bestAttemptContent.body = "Error decryption for \(tableAccount.account)"
|
||||
continue
|
||||
}
|
||||
guard let data = decryptedMessage.data(using: .utf8) else {
|
||||
bestAttemptContent.body = "Error decryption data utf8 for \(tableAccount.account)"
|
||||
continue
|
||||
}
|
||||
var matchedAccount: tableAccount?
|
||||
var payload: [String: AnyObject]?
|
||||
|
||||
if var json = try JSONSerialization.jsonObject(with: data) as? [String: AnyObject],
|
||||
let subject = json["subject"] as? String {
|
||||
bestAttemptContent.body = subject
|
||||
if let pref = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup) {
|
||||
json["account"] = tableAccount.account as AnyObject
|
||||
pref.set(json, forKey: "NOTIFICATION_DATA")
|
||||
pref.synchronize()
|
||||
}
|
||||
} else {
|
||||
bestAttemptContent.body = "Error JSON Serialization for \(tableAccount.account)"
|
||||
}
|
||||
break
|
||||
do {
|
||||
if let message = bestAttemptContent.userInfo["subject"] as? String {
|
||||
for tableAccount in NCManageDatabase.shared.getAllTableAccount() {
|
||||
guard let privateKey = NCPreferences().getPushNotificationPrivateKey(account: tableAccount.account) else {
|
||||
bestAttemptContent.body = "Error retrieving private key for \(tableAccount.account)"
|
||||
continue
|
||||
}
|
||||
|
||||
let prefixData = Data(privateKey.prefix(8))
|
||||
let prefixBase64 = prefixData.base64EncodedString()
|
||||
nkLog(debug: "🔑 Loaded private key for \(tableAccount.account): prefix(Base64)=\(prefixBase64)")
|
||||
|
||||
guard let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey) else {
|
||||
bestAttemptContent.body = "Error decrypting notification for \(tableAccount.account)"
|
||||
continue
|
||||
}
|
||||
guard let data = decryptedMessage.data(using: .utf8) else {
|
||||
bestAttemptContent.body = "Error decrypting UTF8 notification data for \(tableAccount.account)"
|
||||
continue
|
||||
}
|
||||
|
||||
if var json = try JSONSerialization.jsonObject(with: data) as? [String: AnyObject],
|
||||
let subject = json["subject"] as? String {
|
||||
bestAttemptContent.body = subject
|
||||
if let pref = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup) {
|
||||
json["account"] = tableAccount.account as AnyObject
|
||||
pref.set(json, forKey: "NOTIFICATION_DATA")
|
||||
pref.synchronize()
|
||||
}
|
||||
|
||||
matchedAccount = tableAccount
|
||||
payload = json
|
||||
} else {
|
||||
bestAttemptContent.body = "Error with notification JSON for \(tableAccount.account)"
|
||||
}
|
||||
break
|
||||
}
|
||||
} catch let error as NSError {
|
||||
nkLog(error: "Failed : \(error.localizedDescription)")
|
||||
}
|
||||
} catch let error as NSError {
|
||||
nkLog(error: "Failed : \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
guard let tblAccount = matchedAccount,
|
||||
let nid = payload?["nid"] as? Int,
|
||||
payload?["delete"] as? Bool != true,
|
||||
payload?["delete-all"] as? Bool != true else {
|
||||
deliver()
|
||||
return
|
||||
}
|
||||
|
||||
// NextcloudKit Session
|
||||
NextcloudKit.shared.setup(groupIdentifier: NCBrandOptions.shared.capabilitiesGroup, delegate: NCNetworking.shared)
|
||||
NextcloudKit.shared.appendSession(account: tblAccount.account,
|
||||
urlBase: tblAccount.urlBase,
|
||||
user: tblAccount.user,
|
||||
userId: tblAccount.userId,
|
||||
password: NCPreferences().getPassword(account: tblAccount.account),
|
||||
userAgent: userAgent,
|
||||
groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
|
||||
|
||||
Task {
|
||||
let results = await NextcloudKit.shared.getNotificationsAsync(idNotification: nid,
|
||||
account: tblAccount.account,
|
||||
options: NKRequestOptions(timeout: 20))
|
||||
|
||||
if results.error == .success, let notification = results.notifications?.first {
|
||||
bestAttemptContent.title = notification.message.isEmpty ? NCBrandOptions.shared.brand : notification.subject
|
||||
bestAttemptContent.body = notification.message.isEmpty ? notification.subject : notification.message
|
||||
}
|
||||
|
||||
contentHandler(bestAttemptContent)
|
||||
deliver()
|
||||
}
|
||||
}
|
||||
|
||||
override func serviceExtensionTimeWillExpire() {
|
||||
// Called just before the extension will be terminated by the system.
|
||||
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
||||
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
|
||||
bestAttemptContent.title = ""
|
||||
bestAttemptContent.body = "Nextcloud Notification Time Will Expire"
|
||||
contentHandler(bestAttemptContent)
|
||||
deliver()
|
||||
}
|
||||
|
||||
private func deliver() {
|
||||
let handler = deliveryLock.withLock {
|
||||
let handler = contentHandler
|
||||
contentHandler = nil
|
||||
return handler
|
||||
}
|
||||
|
||||
if let handler, let bestAttemptContent {
|
||||
handler(bestAttemptContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
[](https://github.com/nextcloud/ios/releases/latest) [](https://github.com/nextcloud/ios/actions/workflows/xcode.yml) [](https://github.com/nextcloud/ios/actions/workflows/lint.yml)
|
||||
[](https://webchat.freenode.net/?channels=nextcloud-mobile)
|
||||
|
||||
<img src="Animation.gif" alt="Demo of the Nextcloud iOS files app" width="277" height="600"><img src="widget.png" alt="Widget of the Nextcloud iOS files app" width="277" height="600">
|
||||
<img src="Animation.gif" alt="Demo of the Nextcloud iOS files app" width="277" height="600">
|
||||
|
||||
[<img src="https://developer.apple.com/assets/elements/badges/download-on-the-app-store.svg"
|
||||
alt="Demo of the Nextcloud iOS files app"
|
||||
@@ -38,7 +38,7 @@ branch. Maybe start working on [starter issues](https://github.com/nextcloud/ios
|
||||
|
||||
Easy starting points are also reviewing [pull requests](https://github.com/nextcloud/ios/pulls)
|
||||
|
||||
### Xcode 16 Project Setup
|
||||
### Xcode 26.1 Project Setup
|
||||
|
||||
#### Dependencies
|
||||
|
||||
|
||||
@@ -59,12 +59,18 @@
|
||||
<constraint firstAttribute="height" constant="40" id="wvf-Ey-woY"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="filename" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rz6-pe-DB5">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="750" verticalHuggingPriority="251" horizontalCompressionResistancePriority="250" text="filename" textAlignment="natural" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rz6-pe-DB5">
|
||||
<rect key="frame" x="60" y="10" width="284" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ext-Lb-scl">
|
||||
<rect key="frame" x="344" y="10" width="0.0" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="size" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QFh-Vy-b4Z">
|
||||
<rect key="frame" x="60" y="29.999999999999996" width="284" height="14.333333333333332"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
@@ -92,13 +98,16 @@
|
||||
<constraint firstItem="uvl-De-S9p" firstAttribute="leading" secondItem="WGN-Zn-lR8" secondAttribute="leading" constant="10" id="ko0-iM-oWa"/>
|
||||
<constraint firstItem="rz6-pe-DB5" firstAttribute="top" secondItem="WGN-Zn-lR8" secondAttribute="top" constant="10" id="rF0-WD-Hfk"/>
|
||||
<constraint firstAttribute="trailing" secondItem="OGY-95-ZYi" secondAttribute="trailing" constant="10" id="si1-LI-Ldn"/>
|
||||
<constraint firstItem="OGY-95-ZYi" firstAttribute="leading" secondItem="rz6-pe-DB5" secondAttribute="trailing" constant="10" id="vCb-2c-vWa"/>
|
||||
<constraint firstItem="Ext-Lb-scl" firstAttribute="leading" secondItem="rz6-pe-DB5" secondAttribute="trailing" id="ext-ld-scl"/>
|
||||
<constraint firstItem="Ext-Lb-scl" firstAttribute="firstBaseline" secondItem="rz6-pe-DB5" secondAttribute="firstBaseline" id="ext-bl-scl"/>
|
||||
<constraint firstItem="OGY-95-ZYi" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Ext-Lb-scl" secondAttribute="trailing" constant="10" id="vCb-2c-vWa"/>
|
||||
<constraint firstItem="QFh-Vy-b4Z" firstAttribute="leading" secondItem="uvl-De-S9p" secondAttribute="trailing" constant="10" id="xAp-ri-eOc"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||
<connections>
|
||||
<outlet property="fileNameCell" destination="rz6-pe-DB5" id="e8w-G7-bBe"/>
|
||||
<outlet property="fileNameExtensionCell" destination="Ext-Lb-scl" id="ext-out-scl"/>
|
||||
<outlet property="imageCell" destination="uvl-De-S9p" id="S4F-TD-YGI"/>
|
||||
<outlet property="moreButton" destination="OGY-95-ZYi" id="vA3-mU-S1e"/>
|
||||
<outlet property="sizeCell" destination="QFh-Vy-b4Z" id="rmM-qr-QXU"/>
|
||||
|
||||
@@ -15,6 +15,7 @@ protocol NCShareCellDelegate: AnyObject {
|
||||
class NCShareCell: UITableViewCell {
|
||||
@IBOutlet weak var imageCell: UIImageView!
|
||||
@IBOutlet weak var fileNameCell: UILabel!
|
||||
@IBOutlet weak var fileNameExtensionCell: UILabel!
|
||||
@IBOutlet weak var moreButton: UIButton!
|
||||
@IBOutlet weak var sizeCell: UILabel!
|
||||
weak var delegate: (NCShareCellDelegate & UIViewController)?
|
||||
@@ -41,7 +42,7 @@ class NCShareCell: UITableViewCell {
|
||||
imageCell.contentMode = .scaleAspectFit
|
||||
}
|
||||
|
||||
fileNameCell?.text = fileName
|
||||
setBidiSafeFilename(fileName, isDirectory: false, titleLabel: fileNameCell, extensionLabel: fileNameExtensionCell)
|
||||
|
||||
let fileSize = utilityFileSystem.getFileSize(filePath: (NSTemporaryDirectory() + fileName))
|
||||
sizeCell?.text = utilityFileSystem.transformedSize(fileSize)
|
||||
@@ -50,7 +51,11 @@ class NCShareCell: UITableViewCell {
|
||||
}
|
||||
|
||||
@IBAction func buttonTapped(_ sender: Any) {
|
||||
let alertController = UIAlertController(title: "", message: fileName, preferredStyle: .alert)
|
||||
let nsName = fileName as NSString
|
||||
let ext = nsName.pathExtension
|
||||
let base = nsName.deletingPathExtension
|
||||
let displayName = ext.isEmpty || base.isEmpty ? fileName : base + "." + ext
|
||||
let alertController = UIAlertController(title: "", message: displayName, preferredStyle: .alert)
|
||||
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("_rename_file_", comment: ""), style: .default) { _ in
|
||||
self.delegate?.showRenameFileDialog(named: self.fileName, account: self.account)
|
||||
|
||||
@@ -19,6 +19,7 @@ extension NCShareExtension: UICollectionViewDelegate {
|
||||
|
||||
if metadata.e2eEncrypted && !NCPreferences().isEndToEndEnabled(account: tblAccount.account) {
|
||||
self.showAlert(title: "_info_", description: "_e2e_goto_settings_for_enable_")
|
||||
return
|
||||
}
|
||||
let capabilities = await NKCapabilities.shared.getCapabilities(for: tblAccount.account)
|
||||
|
||||
@@ -81,19 +82,11 @@ extension NCShareExtension: UICollectionViewDataSource {
|
||||
return cell
|
||||
}
|
||||
|
||||
cell.fileOcId = metadata.ocId
|
||||
cell.fileOcIdTransfer = metadata.ocIdTransfer
|
||||
cell.fileUser = metadata.ownerId
|
||||
cell.labelTitle.text = metadata.fileNameView
|
||||
cell.metadata = metadata
|
||||
cell.setBidiSafeFilename(metadata.fileNameView, isDirectory: metadata.directory, titleLabel: cell.labelTitle, extensionLabel: cell.labelExtension)
|
||||
cell.labelTitle.textColor = NCBrandColor.shared.textColor
|
||||
cell.imageSelect.image = nil
|
||||
cell.imageStatus.image = nil
|
||||
cell.imageLocal.image = nil
|
||||
cell.imageFavorite.image = nil
|
||||
cell.imageShared.image = nil
|
||||
cell.imageMore.image = nil
|
||||
cell.imageItem.image = nil
|
||||
cell.imageItem.backgroundColor = nil
|
||||
cell.labelExtension?.textColor = NCBrandColor.shared.textColor
|
||||
cell.setButtonsHidden(true)
|
||||
|
||||
if metadata.directory {
|
||||
setupDirectoryCell(cell, indexPath: indexPath, with: metadata)
|
||||
@@ -103,11 +96,7 @@ extension NCShareExtension: UICollectionViewDataSource {
|
||||
cell.imageFavorite.image = NCImageCache.shared.getImageFavorite()
|
||||
}
|
||||
|
||||
cell.imageSelect.isHidden = true
|
||||
cell.backgroundView = nil
|
||||
cell.hideButtonMore(true)
|
||||
cell.hideButtonShare(true)
|
||||
cell.selected(false, isEditMode: false)
|
||||
cell.writeInfoDateSize(date: metadata.date, size: metadata.size)
|
||||
|
||||
if metadata.isLivePhoto {
|
||||
cell.imageStatus.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor2])
|
||||
@@ -115,6 +104,13 @@ extension NCShareExtension: UICollectionViewDataSource {
|
||||
|
||||
cell.setTags(tags: Array(metadata.tags))
|
||||
|
||||
let accessibilityLabel = [metadata.fileNameView, cell.labelInfo.text, cell.labelSubinfo.text]
|
||||
.compactMap { $0?.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
.filter { !$0.isEmpty }
|
||||
.joined(separator: ", ")
|
||||
cell.setAccessibility(label: accessibilityLabel, value: "")
|
||||
cell.accessibilityTraits = .button
|
||||
|
||||
cell.separator.isHidden = collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1
|
||||
|
||||
return cell
|
||||
@@ -155,7 +151,7 @@ extension NCShareExtension: UICollectionViewDataSource {
|
||||
|
||||
// Local image: offline
|
||||
if tableDirectory != nil && tableDirectory!.offline {
|
||||
cell.imageLocal.image = NCImageCache.shared.getImageOfflineFlag()
|
||||
cell.imageLocal?.image = NCImageCache.shared.getImageOfflineFlag()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,22 @@ extension NCShareExtension {
|
||||
func reloadData() async {
|
||||
let session = NCShareExtensionData.shared.getSession()
|
||||
let layoutForView = NCManageDatabase.shared.getLayoutForView(account: session.account, key: keyLayout, serverUrl: serverUrl)
|
||||
let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName != %@ AND directory == true", session.account, serverUrl, NextcloudKit.shared.nkCommonInstance.rootFileName)
|
||||
let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account)
|
||||
let predicate = showHiddenFiles
|
||||
? NSPredicate(
|
||||
format: "account == %@ AND serverUrl == %@ AND fileName != %@ AND directory == true",
|
||||
session.account,
|
||||
serverUrl,
|
||||
NextcloudKit.shared.nkCommonInstance.rootFileName
|
||||
)
|
||||
: NSPredicate(
|
||||
format: "account == %@ AND serverUrl == %@ AND fileName != %@ AND directory == true AND NOT fileName BEGINSWITH[c] %@",
|
||||
session.account,
|
||||
serverUrl,
|
||||
NextcloudKit.shared.nkCommonInstance.rootFileName,
|
||||
"."
|
||||
)
|
||||
|
||||
let metadatas = await NCManageDatabase.shared.getMetadatasAsync(predicate: predicate,
|
||||
withLayout: layoutForView,
|
||||
withAccount: session.account)
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import UniformTypeIdentifiers
|
||||
import NextcloudKit
|
||||
import LucidBanner
|
||||
import SwiftUI
|
||||
|
||||
enum NCShareExtensionError: Error {
|
||||
case cancel, fileUpload, noAccount, noFiles, versionMismatch
|
||||
@@ -42,11 +45,13 @@ class NCShareExtension: UIViewController {
|
||||
var progress: CGFloat = 0
|
||||
var counterUploaded: Int = 0
|
||||
var uploadMetadata: [tableMetadata] = []
|
||||
let hud = NCHud()
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let utility = NCUtility()
|
||||
let global = NCGlobal.shared
|
||||
var maintenanceMode: Bool = false
|
||||
var token: Int?
|
||||
var banner: LucidBanner?
|
||||
var sceneIdentifier: String = UUID().uuidString
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
@@ -88,6 +93,13 @@ class NCShareExtension: UIViewController {
|
||||
|
||||
NCBrandColor.shared.createUserColors()
|
||||
|
||||
registerForTraitChanges([UITraitUserInterfaceStyle.self]) { (self: Self, _) in
|
||||
guard !self.maintenanceMode else {
|
||||
return
|
||||
}
|
||||
self.updateAppearance()
|
||||
}
|
||||
|
||||
NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { _ in
|
||||
if NCPreferences().presentPasscode {
|
||||
NCPasscode.shared.presentPasscode(viewController: self, delegate: self) {
|
||||
@@ -109,6 +121,12 @@ class NCShareExtension: UIViewController {
|
||||
if let account = NCShareExtensionData.shared.getTblAccoun()?.account {
|
||||
accountRequestChangeAccount(account: account, controller: nil)
|
||||
}
|
||||
|
||||
NCNetworking.shared.setupScene(sceneIdentifier: sceneIdentifier, controller: self)
|
||||
|
||||
if let windowScene = view.window?.windowScene {
|
||||
banner = LucidBannerRegistry.shared.banner(for: windowScene)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -133,20 +151,22 @@ class NCShareExtension: UIViewController {
|
||||
return
|
||||
}
|
||||
|
||||
NCFilesExtensionHandler(items: inputItems) { fileNames in
|
||||
self.filesName = fileNames
|
||||
DispatchQueue.main.async {
|
||||
self.setCommandView()
|
||||
Task { @MainActor in
|
||||
NCFilesExtensionHandler(items: inputItems) { fileNames in
|
||||
self.filesName = fileNames
|
||||
DispatchQueue.main.async {
|
||||
self.setCommandView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if NCPreferences().presentPasscode {
|
||||
NCPasscode.shared.presentPasscode(viewController: self, delegate: self) {
|
||||
NCPasscode.shared.enableTouchFaceID()
|
||||
if NCPreferences().presentPasscode {
|
||||
NCPasscode.shared.presentPasscode(viewController: self, delegate: self) {
|
||||
NCPasscode.shared.enableTouchFaceID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.collectionView.reloadData()
|
||||
self.collectionView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
@@ -157,20 +177,19 @@ class NCShareExtension: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
|
||||
if !maintenanceMode {
|
||||
collectionView.reloadData()
|
||||
tableView.reloadData()
|
||||
}
|
||||
private func updateAppearance() {
|
||||
collectionView.visibleCells.forEach { $0.setNeedsLayout() }
|
||||
tableView.visibleCells.forEach { $0.setNeedsLayout() }
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
func cancel(with error: NCShareExtensionError) {
|
||||
// make sure no uploads are continued
|
||||
extensionContext?.cancelRequest(withError: error)
|
||||
func cancel(with error: NCShareExtensionError? = nil) {
|
||||
if let error {
|
||||
extensionContext?.cancelRequest(withError: error)
|
||||
} else {
|
||||
extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
||||
func showAlert(title: String = "_error_", description: String, onDismiss: (() -> Void)? = nil) {
|
||||
@@ -259,7 +278,7 @@ class NCShareExtension: UIViewController {
|
||||
// MARK: ACTION
|
||||
|
||||
@IBAction func actionCancel(_ sender: UIBarButtonItem) {
|
||||
cancel(with: .cancel)
|
||||
cancel()
|
||||
}
|
||||
|
||||
@objc func actionCreateFolder(_ sender: Any?) {
|
||||
@@ -267,7 +286,7 @@ class NCShareExtension: UIViewController {
|
||||
guard let capabilities = NCNetworking.shared.capabilities[session.account] else {
|
||||
return
|
||||
}
|
||||
let alertController = UIAlertController.createFolder(serverUrl: serverUrl, session: session, capabilities: capabilities) { error in
|
||||
let alertController = UIAlertController.createFolderWith(serverUrl: serverUrl, session: session, capabilities: capabilities) { error in
|
||||
if error == .success {
|
||||
Task {
|
||||
await self.loadFolder()
|
||||
@@ -324,11 +343,12 @@ extension NCShareExtension {
|
||||
guard utilityFileSystem.copyFile(atPath: (NSTemporaryDirectory() + fileName), toPath: toPath) else {
|
||||
continue
|
||||
}
|
||||
let metadataForUpload = await NCManageDatabase.shared.createMetadataAsync(fileName: fileName,
|
||||
ocId: ocId,
|
||||
serverUrl: serverUrl,
|
||||
session: session,
|
||||
sceneIdentifier: nil)
|
||||
let metadataForUpload = await NCManageDatabaseCreateMetadata().createMetadataAsync(
|
||||
fileName: fileName,
|
||||
ocId: ocId,
|
||||
serverUrl: serverUrl,
|
||||
session: session,
|
||||
sceneIdentifier: self.sceneIdentifier)
|
||||
|
||||
metadataForUpload.session = NCNetworking.shared.sessionUpload
|
||||
metadataForUpload.sessionSelector = NCGlobal.shared.selectorUploadFileShareExtension
|
||||
@@ -361,8 +381,33 @@ extension NCShareExtension {
|
||||
|
||||
@MainActor
|
||||
func uploadAndExit() async {
|
||||
// A Share extension process can be reused by the system. Treat each
|
||||
// explicit share operation as a new server-key validation cycle.
|
||||
await NCNetworkingE2EE.beginNewServerKeyValidationCycle()
|
||||
|
||||
var error: NKError?
|
||||
guard let window = self.view.window else {
|
||||
return
|
||||
}
|
||||
let payload = LucidBannerPayload(stage: .button,
|
||||
vPosition: .center,
|
||||
blocksTouches: true)
|
||||
(banner, token) = showUploadBanner(windowScene: window.windowScene,
|
||||
payload: payload,
|
||||
allowMinimizeOnTap: false,
|
||||
onButtonTap: {
|
||||
self.cancel()
|
||||
})
|
||||
|
||||
for metadata in self.uploadMetadata {
|
||||
// BANNER
|
||||
let payloadUpdate = LucidBannerPayload.Update(
|
||||
title: NSLocalizedString("_upload_file_", comment: "") + " \(self.counterUploaded + 1) " + NSLocalizedString("_of_", comment: "") + " \(self.filesName.count)",
|
||||
systemImage: "arrowshape.up.circle",
|
||||
imageAnimation: .breathe,
|
||||
progress: 0)
|
||||
banner?.update(payload: payloadUpdate)
|
||||
|
||||
error = await self.upload(metadata: metadata)
|
||||
if error != .success {
|
||||
break
|
||||
@@ -370,14 +415,16 @@ extension NCShareExtension {
|
||||
}
|
||||
|
||||
if error == .success {
|
||||
self.hud.success()
|
||||
banner?.update(payload: LucidBannerPayload.Update(stage: .success, horizontalLayout: .centered(width: 100)), for: self.token)
|
||||
} else {
|
||||
self.hud.error(text: error?.errorDescription)
|
||||
banner?.update(payload: LucidBannerPayload.Update(subtitle: error?.errorDescription, stage: .error), for: self.token)
|
||||
}
|
||||
|
||||
try? await Task.sleep(nanoseconds: 1_500_000_000)
|
||||
|
||||
self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
|
||||
Task { @MainActor in
|
||||
try? await Task.sleep(for: .seconds(2))
|
||||
banner?.dismiss()
|
||||
extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@@ -406,38 +453,49 @@ extension NCShareExtension {
|
||||
metadata.e2eEncrypted = metadata.isDirectoryE2EE
|
||||
|
||||
self.counterUploaded += 1
|
||||
hud.ringProgress(view: self.view, text: NSLocalizedString("_upload_file_", comment: "") + " \(self.counterUploaded) " + NSLocalizedString("_of_", comment: "") + " \(self.filesName.count)")
|
||||
|
||||
if metadata.isDirectoryE2EE {
|
||||
error = await NCNetworkingE2EEUpload().upload(metadata: metadata, session: session, controller: self)
|
||||
error = await NCNetworkingE2EEUpload().upload(metadata: metadata,
|
||||
session: session,
|
||||
controller: self,
|
||||
banner: banner,
|
||||
stageBanner: nil,
|
||||
tokenBanner: self.token)
|
||||
} else if metadata.chunk > 0 {
|
||||
var numChunks = 0
|
||||
var countUpload: Int = 0
|
||||
var taskHandler: URLSessionTask?
|
||||
|
||||
hud.pieProgress(text: NSLocalizedString("_wait_file_preparation_", comment: ""), tapToCancelDetailText: true) {
|
||||
NotificationCenter.default.postOnMainThread(name: NextcloudKit.shared.nkCommonInstance.notificationCenterChunkedFileStop.rawValue)
|
||||
}
|
||||
|
||||
let results = await NCNetworking.shared.uploadChunkFile(metadata: metadata) { num in
|
||||
numChunks = num
|
||||
} counterChunk: { counter in
|
||||
self.hud.progress(num: Float(counter), total: Float(numChunks))
|
||||
} startFilesChunk: { _ in
|
||||
self.hud.pieProgress(text: NSLocalizedString("_keep_active_for_upload_", comment: ""), tapToCancelDetailText: true) {
|
||||
taskHandler?.cancel()
|
||||
banner?.update(payload: LucidBannerPayload.Update(systemImage: "gearshape.arrow.triangle.2.circlepath",
|
||||
imageAnimation: .rotate),
|
||||
for: self.token)
|
||||
let task = Task { () -> (account: String, file: NKFile?, error: NKError) in
|
||||
let results = await NCNetworking.shared.uploadChunkFile(metadata: metadata) { total, counter in
|
||||
Task {@MainActor in
|
||||
self.banner?.update(payload: LucidBannerPayload.Update(progress: Double(counter) / Double(total)), for: self.token)
|
||||
}
|
||||
} uploadStart: { _ in
|
||||
Task {@MainActor in
|
||||
let payload = LucidBannerPayload.Update(
|
||||
systemImage: "arrowshape.up.circle",
|
||||
imageAnimation: .breathe
|
||||
)
|
||||
self.banner?.update(payload: payload, for: self.token)
|
||||
}
|
||||
} uploadProgressHandler: { _, _, progress in
|
||||
Task {@MainActor in
|
||||
self.banner?.update(payload: LucidBannerPayload.Update(progress: progress), for: self.token)
|
||||
}
|
||||
} assembling: {
|
||||
Task {@MainActor in
|
||||
let payload = LucidBannerPayload.Update(
|
||||
systemImage: "gearshape.arrow.triangle.2.circlepath",
|
||||
imageAnimation: .rotate
|
||||
)
|
||||
self.banner?.update(payload: payload, for: self.token)
|
||||
}
|
||||
}
|
||||
} requestHandler: { _ in
|
||||
self.hud.progress(num: Float(countUpload), total: Float(numChunks))
|
||||
countUpload += 1
|
||||
} taskHandler: { task in
|
||||
taskHandler = task
|
||||
} assembling: {
|
||||
self.hud.setText(NSLocalizedString("_wait_", comment: ""))
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
hud.dismiss()
|
||||
|
||||
let results = await task.value
|
||||
error = results.error
|
||||
} else {
|
||||
let fileNameLocalPath = utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId,
|
||||
@@ -445,14 +503,16 @@ extension NCShareExtension {
|
||||
userId: metadata.userId,
|
||||
urlBase: metadata.urlBase)
|
||||
|
||||
let results = await NCNetworking.shared.uploadFile(fileNameLocalPath: fileNameLocalPath,
|
||||
let results = await NCNetworking.shared.uploadFile(account: metadata.account,
|
||||
fileNameLocalPath: fileNameLocalPath,
|
||||
serverUrlFileName: metadata.serverUrlFileName,
|
||||
creationDate: metadata.creationDate as Date,
|
||||
dateModificationFile: metadata.date as Date,
|
||||
account: metadata.account,
|
||||
metadata: metadata) { _ in
|
||||
dateModificationFile: metadata.date as Date) { _ in
|
||||
} progressHandler: { _, _, fractionCompleted in
|
||||
self.hud.progress(fractionCompleted)
|
||||
Task {@MainActor in
|
||||
self.banner?.update(payload: LucidBannerPayload.Update(progress: fractionCompleted),
|
||||
for: self.token)
|
||||
}
|
||||
}
|
||||
error = results.error
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// There are no unit tests yet.
|
||||
// This is an empty placeholder file.
|
||||
// The compiler requires at least an empty file for every target.
|
||||
@@ -1,153 +1,153 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import XCTest
|
||||
|
||||
///
|
||||
/// User interface tests for the download limits management on shares.
|
||||
///
|
||||
@MainActor
|
||||
final class AssistantUITests: BaseUIXCTestCase {
|
||||
let taskInputCreated = "TestTaskCreated" + UUID().uuidString
|
||||
let taskInputRetried = "TestTaskRetried" + UUID().uuidString
|
||||
let taskInputToEdit = "TestTaskToEdit" + UUID().uuidString
|
||||
let taskInputDeleted = "TestTaskDeleted" + UUID().uuidString
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
override func setUp() async throws {
|
||||
try await super.setUp()
|
||||
continueAfterFailure = false
|
||||
|
||||
// Handle alerts presented by the system.
|
||||
addUIInterruptionMonitor(withDescription: "Allow Notifications", for: "Allow")
|
||||
addUIInterruptionMonitor(withDescription: "Save Password", for: "Not Now")
|
||||
|
||||
// Launch the app.
|
||||
app = XCUIApplication()
|
||||
app.launchArguments = ["UI_TESTING"]
|
||||
app.launch()
|
||||
|
||||
try await logIn()
|
||||
|
||||
// Set up test backend communication.
|
||||
backend = UITestBackend()
|
||||
|
||||
try await backend.assertCapability(true, capability: \.assistant)
|
||||
}
|
||||
|
||||
///
|
||||
/// Leads to the Assistant screen.
|
||||
///
|
||||
private func goToAssistant() {
|
||||
let button = app.tabBars["Tab Bar"].buttons["More"]
|
||||
guard button.await() else { return }
|
||||
button.tap()
|
||||
|
||||
let talkStaticText = app.tables.staticTexts["Assistant"]
|
||||
talkStaticText.tap()
|
||||
}
|
||||
|
||||
private func createTask(input: String) {
|
||||
app.navigationBars["Assistant"].buttons["CreateButton"].tap()
|
||||
|
||||
let inputTextEditor = app.textViews["InputTextEditor"]
|
||||
inputTextEditor.await()
|
||||
inputTextEditor.typeText(input)
|
||||
app.navigationBars["New Free text to text prompt task"].buttons["Create"].tap()
|
||||
}
|
||||
|
||||
private func retryTask() {
|
||||
let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
cell.staticTexts[taskInputRetried].press(forDuration: 2);
|
||||
|
||||
let retryButton = app.buttons["TaskRetryContextMenu"]
|
||||
XCTAssertTrue(retryButton.waitForExistence(timeout: 2), "Edit button not found in context menu")
|
||||
retryButton.tap()
|
||||
}
|
||||
|
||||
private func editTask() {
|
||||
let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
cell.staticTexts[taskInputToEdit].press(forDuration: 2);
|
||||
|
||||
let editButton = app.buttons["TaskEditContextMenu"]
|
||||
XCTAssertTrue(editButton.waitForExistence(timeout: 2), "Edit button not found in context menu")
|
||||
editButton.tap()
|
||||
|
||||
app.textViews["InputTextEditor"].typeText("Edited")
|
||||
app.navigationBars["Edit Free text to text prompt task"].buttons["Edit"].tap()
|
||||
}
|
||||
|
||||
private func deleteTask() {
|
||||
let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
cell.staticTexts[taskInputDeleted].press(forDuration: 2);
|
||||
|
||||
let deleteButton = app.buttons["TaskDeleteContextMenu"]
|
||||
XCTAssertTrue(deleteButton.waitForExistence(timeout: 2), "Edit button not found in context menu")
|
||||
deleteButton.tap()
|
||||
|
||||
app.sheets.scrollViews.otherElements.buttons["Delete"].tap()
|
||||
}
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
func testCreateAssistantTask() async throws {
|
||||
goToAssistant()
|
||||
|
||||
createTask(input: taskInputCreated)
|
||||
|
||||
pullToRefresh()
|
||||
|
||||
try await aMoment()
|
||||
|
||||
let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
XCTAssert(cell.staticTexts[taskInputCreated].exists)
|
||||
}
|
||||
|
||||
func testRetryAssistantTask() async throws {
|
||||
goToAssistant()
|
||||
|
||||
createTask(input: taskInputRetried)
|
||||
|
||||
retryTask()
|
||||
|
||||
pullToRefresh()
|
||||
|
||||
try await aMoment()
|
||||
|
||||
let matchingElements = app.collectionViews.cells.staticTexts.matching(identifier: taskInputRetried)
|
||||
print(app.collectionViews.staticTexts.debugDescription)
|
||||
XCTAssertEqual(matchingElements.count, 2, "Expected 2 elements")
|
||||
}
|
||||
|
||||
func testEditAssistantTask() async throws {
|
||||
goToAssistant()
|
||||
|
||||
createTask(input: taskInputToEdit)
|
||||
|
||||
editTask()
|
||||
|
||||
pullToRefresh()
|
||||
|
||||
try await aMoment()
|
||||
|
||||
let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
XCTAssert(cell.staticTexts[taskInputToEdit + "Edited"].exists)
|
||||
}
|
||||
|
||||
func testDeleteAssistantTask() async throws {
|
||||
goToAssistant()
|
||||
|
||||
createTask(input: taskInputDeleted)
|
||||
|
||||
deleteTask()
|
||||
|
||||
pullToRefresh()
|
||||
|
||||
try await aMoment()
|
||||
|
||||
let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
XCTAssert(!cell.staticTexts[taskInputDeleted].exists)
|
||||
}
|
||||
}
|
||||
//// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
//// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
//// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
//import XCTest
|
||||
//
|
||||
/////
|
||||
///// User interface tests for the download limits management on shares.
|
||||
/////
|
||||
//@MainActor
|
||||
//final class AssistantUITests: BaseUIXCTestCase {
|
||||
// let taskInputCreated = "TestTaskCreated" + UUID().uuidString
|
||||
// let taskInputRetried = "TestTaskRetried" + UUID().uuidString
|
||||
// let taskInputToEdit = "TestTaskToEdit" + UUID().uuidString
|
||||
// let taskInputDeleted = "TestTaskDeleted" + UUID().uuidString
|
||||
//
|
||||
// // MARK: - Lifecycle
|
||||
//
|
||||
// override func setUp() async throws {
|
||||
// try await super.setUp()
|
||||
// continueAfterFailure = false
|
||||
//
|
||||
// // Handle alerts presented by the system.
|
||||
// addUIInterruptionMonitor(withDescription: "Allow Notifications", for: "Allow")
|
||||
// addUIInterruptionMonitor(withDescription: "Save Password", for: "Not Now")
|
||||
//
|
||||
// // Launch the app.
|
||||
// app = XCUIApplication()
|
||||
// app.launchArguments = ["UI_TESTING"]
|
||||
// app.launch()
|
||||
//
|
||||
// try await logIn()
|
||||
//
|
||||
// // Set up test backend communication.
|
||||
// backend = UITestBackend()
|
||||
//
|
||||
// try await backend.assertCapability(true, capability: \.assistant)
|
||||
// }
|
||||
//
|
||||
// ///
|
||||
// /// Leads to the Assistant screen.
|
||||
// ///
|
||||
// private func goToAssistant() {
|
||||
// let button = app.tabBars["Tab Bar"].buttons["More"]
|
||||
// guard button.await() else { return }
|
||||
// button.tap()
|
||||
//
|
||||
// let talkStaticText = app.tables.staticTexts["Assistant"]
|
||||
// talkStaticText.tap()
|
||||
// }
|
||||
//
|
||||
// private func createTask(input: String) {
|
||||
// app.navigationBars["Assistant"].buttons["ConversationsButton"].tap()
|
||||
//
|
||||
// let inputTextEditor = app.textViews["InputTextEditor"]
|
||||
// inputTextEditor.await()
|
||||
// inputTextEditor.typeText(input)
|
||||
// app.navigationBars["New Free text to text prompt task"].buttons["Create"].tap()
|
||||
// }
|
||||
//
|
||||
// private func retryTask() {
|
||||
// let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
// cell.staticTexts[taskInputRetried].press(forDuration: 2);
|
||||
//
|
||||
// let retryButton = app.buttons["TaskRetryContextMenu"]
|
||||
// XCTAssertTrue(retryButton.waitForExistence(timeout: 2), "Edit button not found in context menu")
|
||||
// retryButton.tap()
|
||||
// }
|
||||
//
|
||||
// private func editTask() {
|
||||
// let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
// cell.staticTexts[taskInputToEdit].press(forDuration: 2);
|
||||
//
|
||||
// let editButton = app.buttons["TaskEditContextMenu"]
|
||||
// XCTAssertTrue(editButton.waitForExistence(timeout: 2), "Edit button not found in context menu")
|
||||
// editButton.tap()
|
||||
//
|
||||
// app.textViews["InputTextEditor"].typeText("Edited")
|
||||
// app.navigationBars["Edit Free text to text prompt task"].buttons["Edit"].tap()
|
||||
// }
|
||||
//
|
||||
// private func deleteTask() {
|
||||
// let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
// cell.staticTexts[taskInputDeleted].press(forDuration: 2);
|
||||
//
|
||||
// let deleteButton = app.buttons["TaskDeleteContextMenu"]
|
||||
// XCTAssertTrue(deleteButton.waitForExistence(timeout: 2), "Edit button not found in context menu")
|
||||
// deleteButton.tap()
|
||||
//
|
||||
// app.sheets.scrollViews.otherElements.buttons["Delete"].tap()
|
||||
// }
|
||||
//
|
||||
// // MARK: - Tests
|
||||
//
|
||||
// func testCreateAssistantTask() async throws {
|
||||
// goToAssistant()
|
||||
//
|
||||
// createTask(input: taskInputCreated)
|
||||
//
|
||||
// pullToRefresh()
|
||||
//
|
||||
// try await aMoment()
|
||||
//
|
||||
// let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
// XCTAssert(cell.staticTexts[taskInputCreated].exists)
|
||||
// }
|
||||
//
|
||||
// func testRetryAssistantTask() async throws {
|
||||
// goToAssistant()
|
||||
//
|
||||
// createTask(input: taskInputRetried)
|
||||
//
|
||||
// retryTask()
|
||||
//
|
||||
// pullToRefresh()
|
||||
//
|
||||
// try await aMoment()
|
||||
//
|
||||
// let matchingElements = app.collectionViews.cells.staticTexts.matching(identifier: taskInputRetried)
|
||||
// print(app.collectionViews.staticTexts.debugDescription)
|
||||
// XCTAssertEqual(matchingElements.count, 2, "Expected 2 elements")
|
||||
// }
|
||||
//
|
||||
// func testEditAssistantTask() async throws {
|
||||
// goToAssistant()
|
||||
//
|
||||
// createTask(input: taskInputToEdit)
|
||||
//
|
||||
// editTask()
|
||||
//
|
||||
// pullToRefresh()
|
||||
//
|
||||
// try await aMoment()
|
||||
//
|
||||
// let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
// XCTAssert(cell.staticTexts[taskInputToEdit + "Edited"].exists)
|
||||
// }
|
||||
//
|
||||
// func testDeleteAssistantTask() async throws {
|
||||
// goToAssistant()
|
||||
//
|
||||
// createTask(input: taskInputDeleted)
|
||||
//
|
||||
// deleteTask()
|
||||
//
|
||||
// pullToRefresh()
|
||||
//
|
||||
// try await aMoment()
|
||||
//
|
||||
// let cell = app.collectionViews.children(matching: .cell).element(boundBy: 0)
|
||||
// XCTAssert(!cell.staticTexts[taskInputDeleted].exists)
|
||||
// }
|
||||
//}
|
||||
@@ -1,127 +1,127 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import XCTest
|
||||
|
||||
///
|
||||
/// User interface tests for the download limits management on shares.
|
||||
///
|
||||
@MainActor
|
||||
final class AutoUploadUITests: BaseUIXCTestCase {
|
||||
// MARK: - Lifecycle
|
||||
override func setUp() async throws {
|
||||
try await super.setUp()
|
||||
continueAfterFailure = false
|
||||
|
||||
// Handle alerts presented by the system.
|
||||
addUIInterruptionMonitor(withDescription: "Allow Notifications", for: "Allow")
|
||||
addUIInterruptionMonitor(withDescription: "Save Password", for: "Not Now")
|
||||
|
||||
// Launch the app.
|
||||
app = XCUIApplication()
|
||||
app.launchArguments = ["UI_TESTING"]
|
||||
app.launch()
|
||||
|
||||
try await logIn()
|
||||
|
||||
// Set up test backend communication.
|
||||
backend = UITestBackend()
|
||||
}
|
||||
|
||||
private func goToAutoUpload() async throws {
|
||||
addUIInterruptionMonitor(withDescription: "Are you sure you want to upload all photos?", for: "Confirm")
|
||||
|
||||
app.tabBars["Tab Bar"].buttons["More"].tap()
|
||||
|
||||
app.tables/*@START_MENU_TOKEN@*/.staticTexts["Settings"]/*[[".cells.staticTexts[\"Settings\"]",".staticTexts[\"Settings\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
|
||||
|
||||
let collectionViewsQuery = app.collectionViews
|
||||
collectionViewsQuery/*@START_MENU_TOKEN@*/.staticTexts["Auto upload"]/*[[".cells",".buttons[\"Auto upload\"].staticTexts[\"Auto upload\"]",".staticTexts[\"Auto upload\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/.tap()
|
||||
|
||||
try await aSmallMoment()
|
||||
|
||||
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
|
||||
let allowButton = springboard.buttons["Allow Full Access"]
|
||||
|
||||
if allowButton.await() {
|
||||
allowButton.tap()
|
||||
}
|
||||
}
|
||||
|
||||
func testAutoUploadAllPhotos() async throws {
|
||||
try await goToAutoUpload()
|
||||
|
||||
let collectionViewsQuery = app.collectionViews
|
||||
|
||||
let turnOnAutoUploadingSwitch = collectionViewsQuery.switches["Turn on auto uploading"]
|
||||
|
||||
collectionViewsQuery/*@START_MENU_TOKEN@*/.switches["Auto upload photos"]/*[[".cells.switches[\"Auto upload photos\"]",".switches[\"Auto upload photos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.swipeUp()
|
||||
|
||||
if turnOnAutoUploadingSwitch.await() {
|
||||
turnOnAutoUploadingSwitch.tap()
|
||||
}
|
||||
|
||||
app.tabBars["Tab Bar"].buttons["Files"].tap()
|
||||
|
||||
try await aSmallMoment()
|
||||
|
||||
pullToRefresh()
|
||||
|
||||
let photosItem = app.collectionViews["NCCollectionViewCommon"]/*@START_MENU_TOKEN@*/.staticTexts["Photos"]/*[[".cells[\"Photos\"].staticTexts[\"Photos\"]",".cells[\"Cell\/Photos\"].staticTexts[\"Photos\"]",".staticTexts[\"Photos\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
|
||||
if photosItem.await() {
|
||||
photosItem.tap()
|
||||
}
|
||||
|
||||
try await aSmallMoment()
|
||||
|
||||
XCTAssertTrue(app.collectionViews.cells.count == 6)
|
||||
}
|
||||
|
||||
func testAutoUploadNewPhotos() async throws {
|
||||
try await goToAutoUpload()
|
||||
|
||||
let backUpNewPhotosVideosOnlySwitch = app.collectionViews.switches["NewPhotosToggle"]
|
||||
|
||||
if backUpNewPhotosVideosOnlySwitch.await() {
|
||||
backUpNewPhotosVideosOnlySwitch.switches.firstMatch.tap()
|
||||
}
|
||||
|
||||
let collectionViewsQuery = app.collectionViews
|
||||
|
||||
let turnOnAutoUploadingSwitch = collectionViewsQuery.switches["Turn on auto uploading"]
|
||||
|
||||
collectionViewsQuery/*@START_MENU_TOKEN@*/.switches["Auto upload photos"]/*[[".cells.switches[\"Auto upload photos\"]",".switches[\"Auto upload photos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.swipeUp()
|
||||
|
||||
if turnOnAutoUploadingSwitch.await() {
|
||||
turnOnAutoUploadingSwitch.tap()
|
||||
}
|
||||
|
||||
app.tabBars["Tab Bar"].buttons["Files"].tap()
|
||||
|
||||
try await aSmallMoment()
|
||||
|
||||
pullToRefresh()
|
||||
|
||||
let photosItem = app.collectionViews["NCCollectionViewCommon"]/*@START_MENU_TOKEN@*/.staticTexts["Photos"]/*[[".cells[\"Photos\"].staticTexts[\"Photos\"]",".cells[\"Cell\/Photos\"].staticTexts[\"Photos\"]",".staticTexts[\"Photos\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
|
||||
|
||||
// Does not seem possible to take a screenshot on Simulator or easily transfer a new photo in Simulator.
|
||||
// Thus for now we can only rely on the Photos folder not existing at all to test this.
|
||||
XCTAssertFalse(photosItem.exists)
|
||||
}
|
||||
|
||||
override func tearDown() async throws {
|
||||
let tabBar = app.tabBars["Tab Bar"]
|
||||
tabBar.buttons["Files"].tap()
|
||||
let nccollectionviewcommonCollectionView = app.collectionViews["NCCollectionViewCommon"]
|
||||
let cell = nccollectionviewcommonCollectionView/*@START_MENU_TOKEN@*/.cells["Cell/Photos"]/*[[".cells[\"Photos\"]",".cells[\"Cell\/Photos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
|
||||
if !cell.exists { return }
|
||||
|
||||
cell.otherElements.containing(.button, identifier:"Cell/Photos/shareButton").children(matching: .button).element(boundBy: 1).tap()
|
||||
let tablesQuery = app.tables
|
||||
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Delete folder"]/*[[".cells.staticTexts[\"Delete folder\"]",".staticTexts[\"Delete folder\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
|
||||
app.alerts["Delete folder?"].scrollViews.otherElements.buttons["Yes"].tap()
|
||||
|
||||
cell.awaitInexistence()
|
||||
}
|
||||
}
|
||||
//// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
//// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
//// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
//import XCTest
|
||||
//
|
||||
/////
|
||||
///// User interface tests for the download limits management on shares.
|
||||
/////
|
||||
//@MainActor
|
||||
//final class AutoUploadUITests: BaseUIXCTestCase {
|
||||
// // MARK: - Lifecycle
|
||||
// override func setUp() async throws {
|
||||
// try await super.setUp()
|
||||
// continueAfterFailure = false
|
||||
//
|
||||
// // Handle alerts presented by the system.
|
||||
// addUIInterruptionMonitor(withDescription: "Allow Notifications", for: "Allow")
|
||||
// addUIInterruptionMonitor(withDescription: "Save Password", for: "Not Now")
|
||||
//
|
||||
// // Launch the app.
|
||||
// app = XCUIApplication()
|
||||
// app.launchArguments = ["UI_TESTING"]
|
||||
// app.launch()
|
||||
//
|
||||
// try await logIn()
|
||||
//
|
||||
// // Set up test backend communication.
|
||||
// backend = UITestBackend()
|
||||
// }
|
||||
//
|
||||
// private func goToAutoUpload() async throws {
|
||||
// addUIInterruptionMonitor(withDescription: "Are you sure you want to upload all photos?", for: "Confirm")
|
||||
//
|
||||
// app.tabBars["Tab Bar"].buttons["More"].tap()
|
||||
//
|
||||
// app.tables/*@START_MENU_TOKEN@*/.staticTexts["Settings"]/*[[".cells.staticTexts[\"Settings\"]",".staticTexts[\"Settings\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
|
||||
//
|
||||
// let collectionViewsQuery = app.collectionViews
|
||||
// collectionViewsQuery/*@START_MENU_TOKEN@*/.staticTexts["Auto upload"]/*[[".cells",".buttons[\"Auto upload\"].staticTexts[\"Auto upload\"]",".staticTexts[\"Auto upload\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/.tap()
|
||||
//
|
||||
// try await aSmallMoment()
|
||||
//
|
||||
// let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
|
||||
// let allowButton = springboard.buttons["Allow Full Access"]
|
||||
//
|
||||
// if allowButton.await() {
|
||||
// allowButton.tap()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func testAutoUploadAllPhotos() async throws {
|
||||
// try await goToAutoUpload()
|
||||
//
|
||||
// let collectionViewsQuery = app.collectionViews
|
||||
//
|
||||
// let turnOnAutoUploadingSwitch = collectionViewsQuery.switches["Turn on auto uploading"]
|
||||
//
|
||||
// collectionViewsQuery/*@START_MENU_TOKEN@*/.switches["Auto upload photos"]/*[[".cells.switches[\"Auto upload photos\"]",".switches[\"Auto upload photos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.swipeUp()
|
||||
//
|
||||
// if turnOnAutoUploadingSwitch.await() {
|
||||
// turnOnAutoUploadingSwitch.tap()
|
||||
// }
|
||||
//
|
||||
// app.tabBars["Tab Bar"].buttons["Files"].tap()
|
||||
//
|
||||
// try await aSmallMoment()
|
||||
//
|
||||
// pullToRefresh()
|
||||
//
|
||||
// let photosItem = app.collectionViews["NCCollectionViewCommon"]/*@START_MENU_TOKEN@*/.staticTexts["Photos"]/*[[".cells[\"Photos\"].staticTexts[\"Photos\"]",".cells[\"Cell\/Photos\"].staticTexts[\"Photos\"]",".staticTexts[\"Photos\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
|
||||
// if photosItem.await() {
|
||||
// photosItem.tap()
|
||||
// }
|
||||
//
|
||||
// try await aSmallMoment()
|
||||
//
|
||||
// XCTAssertTrue(app.collectionViews.cells.count == 6)
|
||||
// }
|
||||
//
|
||||
// func testAutoUploadNewPhotos() async throws {
|
||||
// try await goToAutoUpload()
|
||||
//
|
||||
// let backUpNewPhotosVideosOnlySwitch = app.collectionViews.switches["NewPhotosToggle"]
|
||||
//
|
||||
// if backUpNewPhotosVideosOnlySwitch.await() {
|
||||
// backUpNewPhotosVideosOnlySwitch.switches.firstMatch.tap()
|
||||
// }
|
||||
//
|
||||
// let collectionViewsQuery = app.collectionViews
|
||||
//
|
||||
// let turnOnAutoUploadingSwitch = collectionViewsQuery.switches["Turn on auto uploading"]
|
||||
//
|
||||
// collectionViewsQuery/*@START_MENU_TOKEN@*/.switches["Auto upload photos"]/*[[".cells.switches[\"Auto upload photos\"]",".switches[\"Auto upload photos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.swipeUp()
|
||||
//
|
||||
// if turnOnAutoUploadingSwitch.await() {
|
||||
// turnOnAutoUploadingSwitch.tap()
|
||||
// }
|
||||
//
|
||||
// app.tabBars["Tab Bar"].buttons["Files"].tap()
|
||||
//
|
||||
// try await aSmallMoment()
|
||||
//
|
||||
// pullToRefresh()
|
||||
//
|
||||
// let photosItem = app.collectionViews["NCCollectionViewCommon"]/*@START_MENU_TOKEN@*/.staticTexts["Photos"]/*[[".cells[\"Photos\"].staticTexts[\"Photos\"]",".cells[\"Cell\/Photos\"].staticTexts[\"Photos\"]",".staticTexts[\"Photos\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
|
||||
//
|
||||
// // Does not seem possible to take a screenshot on Simulator or easily transfer a new photo in Simulator.
|
||||
// // Thus for now we can only rely on the Photos folder not existing at all to test this.
|
||||
// XCTAssertFalse(photosItem.exists)
|
||||
// }
|
||||
//
|
||||
// override func tearDown() async throws {
|
||||
// let tabBar = app.tabBars["Tab Bar"]
|
||||
// tabBar.buttons["Files"].tap()
|
||||
// let nccollectionviewcommonCollectionView = app.collectionViews["NCCollectionViewCommon"]
|
||||
// let cell = nccollectionviewcommonCollectionView/*@START_MENU_TOKEN@*/.cells["Cell/Photos"]/*[[".cells[\"Photos\"]",".cells[\"Cell\/Photos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
|
||||
// if !cell.exists { return }
|
||||
//
|
||||
// cell.otherElements.containing(.button, identifier:"Cell/Photos/shareButton").children(matching: .button).element(boundBy: 1).tap()
|
||||
// let tablesQuery = app.tables
|
||||
// tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Delete folder"]/*[[".cells.staticTexts[\"Delete folder\"]",".staticTexts[\"Delete folder\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
|
||||
// app.alerts["Delete folder?"].scrollViews.otherElements.buttons["Yes"].tap()
|
||||
//
|
||||
// cell.awaitInexistence()
|
||||
// }
|
||||
//}
|
||||
@@ -1,484 +1,484 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import XCTest
|
||||
|
||||
///
|
||||
/// User interface tests for the download limits management on shares.
|
||||
///
|
||||
@MainActor
|
||||
final class DownloadLimitUITests: BaseUIXCTestCase {
|
||||
///
|
||||
/// Name of the file to work with.
|
||||
///
|
||||
/// The leading underscore is required for the file to appear at the top of the list.
|
||||
/// Obviously, this is fragile by making some assumptions of the user interface state.
|
||||
///
|
||||
let testFileName = "_Xcode UI Test Subject.md"
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
override func setUp() async throws {
|
||||
try await super.setUp()
|
||||
continueAfterFailure = false
|
||||
|
||||
// Handle alerts presented by the system.
|
||||
addUIInterruptionMonitor(withDescription: "Allow Notifications", for: "Allow")
|
||||
addUIInterruptionMonitor(withDescription: "Save Password", for: "Not Now")
|
||||
|
||||
// Launch the app.
|
||||
app = XCUIApplication()
|
||||
app.launchArguments = ["UI_TESTING"]
|
||||
app.launch()
|
||||
|
||||
try await logIn()
|
||||
|
||||
// Set up test backend communication.
|
||||
backend = UITestBackend()
|
||||
|
||||
try await backend.assertCapability(true, capability: \.downloadLimit)
|
||||
try await backend.delete(testFileName)
|
||||
try await backend.prepareTestFile(testFileName)
|
||||
}
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
func testShareWithoutDownloadLimitCapability() async throws {
|
||||
// This cannot be implemented at the time of writing.
|
||||
// There is no way to disable and enable server apps via web API.
|
||||
// The Xcode UI test process cannot access Docker.
|
||||
throw XCTSkip("Not implemented yet!")
|
||||
}
|
||||
|
||||
func testNewShareWithoutDownloadLimit() async throws {
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
|
||||
guard shareButton.exists else {
|
||||
throw UITestError.waitForExistence(shareButton)
|
||||
}
|
||||
|
||||
shareButton.tap()
|
||||
|
||||
// Tap add share link button.
|
||||
|
||||
let addShareLinkButton = app.buttons["addShareLink"]
|
||||
guard addShareLinkButton.await() else { return }
|
||||
addShareLinkButton.tap()
|
||||
|
||||
// Tap confirm share button.
|
||||
|
||||
let confirmShareButton = app.buttons["confirmShare"]
|
||||
|
||||
guard confirmShareButton.exists else {
|
||||
throw UITestError.waitForExistence(confirmShareButton)
|
||||
}
|
||||
|
||||
confirmShareButton.tap()
|
||||
confirmShareButton.awaitInexistence()
|
||||
|
||||
// Then
|
||||
let shares = try await backend.getShares(byPath: "/\(testFileName)")
|
||||
XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
throw UITestError.missingValue
|
||||
}
|
||||
|
||||
try await backend.assertNoDownloadLimit(by: token)
|
||||
}
|
||||
|
||||
func testNewShareWithDownloadLimit() async throws {
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
guard shareButton.await() else { return }
|
||||
shareButton.tap()
|
||||
|
||||
// Tap add share link button.
|
||||
|
||||
let addShareLinkButton = app.buttons["addShareLink"]
|
||||
guard addShareLinkButton.await() else { return }
|
||||
addShareLinkButton.tap()
|
||||
|
||||
// Tap download limits.
|
||||
|
||||
let downloadLimitCell = app.cells["downloadLimit"]
|
||||
guard downloadLimitCell.await() else { return }
|
||||
downloadLimitCell.tap()
|
||||
|
||||
// Tap download limit switch.
|
||||
|
||||
let downloadLimitSwitch = app.switches["downloadLimitSwitch"]
|
||||
guard downloadLimitSwitch.await() else { return }
|
||||
downloadLimitSwitch.tap()
|
||||
|
||||
// Update allowed downloads.
|
||||
|
||||
let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
guard allowedDownloadsTextField.await() else { return }
|
||||
allowedDownloadsTextField.tap()
|
||||
allowedDownloadsTextField.typeText("3")
|
||||
|
||||
// Tap navigation back button.
|
||||
|
||||
app.navigationBars.buttons.firstMatch.tap()
|
||||
|
||||
// Tap confirm share button.
|
||||
|
||||
let confirmShareButton = app.buttons["confirmShare"]
|
||||
guard confirmShareButton.await() else { return }
|
||||
confirmShareButton.tap()
|
||||
confirmShareButton.awaitInexistence()
|
||||
|
||||
// Then
|
||||
let shares = try await backend.getShares(byPath: "/\(testFileName)")
|
||||
XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
throw UITestError.missingValue
|
||||
}
|
||||
|
||||
try await backend.assertDownloadLimit(by: token, count: 0, limit: 3)
|
||||
}
|
||||
|
||||
func testShareOfFolder() async throws {
|
||||
let testSubject = "_Xcode UI Test Subject"
|
||||
try await backend.createFolder(testSubject)
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testSubject)/shareButton"]
|
||||
guard shareButton.await() else { return }
|
||||
shareButton.tap()
|
||||
|
||||
// Tap add share link button.
|
||||
|
||||
let addShareLinkButton = app.buttons["addShareLink"]
|
||||
guard addShareLinkButton.await() else { return }
|
||||
addShareLinkButton.tap()
|
||||
|
||||
// Verify download limits being unavailable.
|
||||
|
||||
let downloadLimitCell = app.cells["downloadLimit"]
|
||||
XCTAssertFalse(downloadLimitCell.exists, "Folder shares cannot have download limits")
|
||||
|
||||
// Cleanup
|
||||
|
||||
try await backend.delete(testSubject)
|
||||
}
|
||||
|
||||
func testAddingDownloadLimitToExistingShare() async throws {
|
||||
try await backend.createShare(byPath: testFileName)
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
guard shareButton.await() else { return }
|
||||
shareButton.tap()
|
||||
|
||||
// Tap show share link details button.
|
||||
|
||||
let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
guard showShareLinkDetailsButton.await() else { return }
|
||||
showShareLinkDetailsButton.tap()
|
||||
|
||||
// Tap share link details button in share menu sheet.
|
||||
|
||||
let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
guard shareMenuDetailsCell.await() else { return }
|
||||
shareMenuDetailsCell.tap()
|
||||
|
||||
// Tap download limits.
|
||||
|
||||
let downloadLimitCell = app.cells["downloadLimit"]
|
||||
guard downloadLimitCell.await() else { return }
|
||||
downloadLimitCell.tap()
|
||||
|
||||
// Tap download limit switch.
|
||||
|
||||
let downloadLimitSwitch = app.switches["downloadLimitSwitch"]
|
||||
guard downloadLimitSwitch.await() else { return }
|
||||
downloadLimitSwitch.tap()
|
||||
|
||||
// Update allowed downloads.
|
||||
|
||||
let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
guard allowedDownloadsTextField.await() else { return }
|
||||
allowedDownloadsTextField.tap()
|
||||
allowedDownloadsTextField.typeText("3")
|
||||
|
||||
// Tap navigation back button.
|
||||
|
||||
app.navigationBars.buttons.firstMatch.tap()
|
||||
|
||||
// Tap confirm share button.
|
||||
|
||||
let confirmShareButton = app.buttons["confirmShare"]
|
||||
guard confirmShareButton.await() else { return }
|
||||
confirmShareButton.tap()
|
||||
confirmShareButton.awaitInexistence()
|
||||
|
||||
// Then
|
||||
let shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
throw UITestError.missingValue
|
||||
}
|
||||
|
||||
try await aMoment()
|
||||
try await backend.assertDownloadLimit(by: token, count: 0, limit: 3)
|
||||
}
|
||||
|
||||
func testUpdatingDownloadLimitOnExistingShare() async throws {
|
||||
try await backend.createShare(byPath: testFileName)
|
||||
var shares = try await backend.getShares(byPath: testFileName)
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
XCTFail("Failed to fetch token of share for test file!")
|
||||
return
|
||||
}
|
||||
|
||||
try await backend.setDownloadLimit(to: 4, by: token)
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
guard shareButton.await() else { return }
|
||||
shareButton.tap()
|
||||
|
||||
// Tap show share link details button.
|
||||
|
||||
let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
guard showShareLinkDetailsButton.await() else { return }
|
||||
showShareLinkDetailsButton.tap()
|
||||
|
||||
// Tap share link details button in share menu sheet.
|
||||
|
||||
let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
guard shareMenuDetailsCell.await() else { return }
|
||||
shareMenuDetailsCell.tap()
|
||||
|
||||
// Tap download limits.
|
||||
|
||||
let downloadLimitCell = app.cells["downloadLimit"]
|
||||
guard downloadLimitCell.await() else { return }
|
||||
downloadLimitCell.tap()
|
||||
|
||||
// Check download limit switch.
|
||||
|
||||
let downloadLimitSwitch = app.switches["downloadLimitSwitch"].firstMatch
|
||||
guard downloadLimitSwitch.await() else { return }
|
||||
|
||||
guard let downloadLimitSwitchValue = (downloadLimitSwitch.value as? String) else {
|
||||
XCTFail("Failed to get value of user interface control!")
|
||||
return
|
||||
}
|
||||
|
||||
guard downloadLimitSwitchValue == "1" else {
|
||||
XCTFail("The switch is not on!")
|
||||
return
|
||||
}
|
||||
|
||||
// Check and update allowed downloads.
|
||||
|
||||
let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
guard allowedDownloadsTextField.await() else { return }
|
||||
|
||||
guard let allowedDownloadsTextFieldValue = (allowedDownloadsTextField.value as? String) else {
|
||||
XCTFail("Failed to get value of user interface control!")
|
||||
return
|
||||
}
|
||||
|
||||
guard allowedDownloadsTextFieldValue == "4" else {
|
||||
XCTFail("The text field value is wrong!")
|
||||
return
|
||||
}
|
||||
|
||||
allowedDownloadsTextField.tap()
|
||||
allowedDownloadsTextField.typeText("6")
|
||||
|
||||
// Tap navigation back button.
|
||||
|
||||
app.navigationBars.buttons.firstMatch.tap()
|
||||
|
||||
// Tap confirm share button.
|
||||
|
||||
let confirmShareButton = app.buttons["confirmShare"]
|
||||
guard confirmShareButton.await() else { return }
|
||||
confirmShareButton.tap()
|
||||
confirmShareButton.awaitInexistence()
|
||||
|
||||
// Then
|
||||
shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
throw UITestError.missingValue
|
||||
}
|
||||
|
||||
try await aMoment()
|
||||
try await backend.assertDownloadLimit(by: token, count: 0, limit: 6)
|
||||
}
|
||||
|
||||
func testDiscardingDownloadLimitChangesOnExistingShare() async throws {
|
||||
try await backend.createShare(byPath: testFileName)
|
||||
var shares = try await backend.getShares(byPath: testFileName)
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
XCTFail("Failed to fetch token of share for test file!")
|
||||
return
|
||||
}
|
||||
|
||||
try await backend.setDownloadLimit(to: 8, by: token)
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
guard shareButton.await() else { return }
|
||||
shareButton.tap()
|
||||
|
||||
// Tap show share link details button.
|
||||
|
||||
let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
guard showShareLinkDetailsButton.await() else { return }
|
||||
showShareLinkDetailsButton.tap()
|
||||
|
||||
// Tap share link details button in share menu sheet.
|
||||
|
||||
let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
guard shareMenuDetailsCell.await() else { return }
|
||||
shareMenuDetailsCell.tap()
|
||||
|
||||
// Tap download limits.
|
||||
|
||||
let downloadLimitCell = app.cells["downloadLimit"]
|
||||
guard downloadLimitCell.await() else { return }
|
||||
downloadLimitCell.tap()
|
||||
|
||||
// Check download limit switch.
|
||||
|
||||
let downloadLimitSwitch = app.switches["downloadLimitSwitch"].firstMatch
|
||||
guard downloadLimitSwitch.await() else { return }
|
||||
|
||||
guard let downloadLimitSwitchValue = (downloadLimitSwitch.value as? String) else {
|
||||
XCTFail("Failed to get value of user interface control!")
|
||||
return
|
||||
}
|
||||
|
||||
guard downloadLimitSwitchValue == "1" else {
|
||||
XCTFail("The switch is not on!")
|
||||
return
|
||||
}
|
||||
|
||||
// Check and update allowed downloads.
|
||||
|
||||
let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
guard allowedDownloadsTextField.await() else { return }
|
||||
|
||||
guard let allowedDownloadsTextFieldValue = (allowedDownloadsTextField.value as? String) else {
|
||||
XCTFail("Failed to get value of user interface control!")
|
||||
return
|
||||
}
|
||||
|
||||
allowedDownloadsTextField.tap()
|
||||
allowedDownloadsTextField.typeText("9")
|
||||
|
||||
// Tap navigation back button.
|
||||
|
||||
app.navigationBars.buttons.firstMatch.tap()
|
||||
|
||||
// Tap confirm share button.
|
||||
|
||||
let cancelShareButton = app.buttons["cancelShare"]
|
||||
guard cancelShareButton.await() else { return }
|
||||
cancelShareButton.tap()
|
||||
|
||||
// Then
|
||||
shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
throw UITestError.missingValue
|
||||
}
|
||||
|
||||
try await aMoment()
|
||||
try await backend.assertDownloadLimit(by: token, count: 0, limit: 8)
|
||||
}
|
||||
|
||||
func testRemovingDownloadLimitFromExistingShare() async throws {
|
||||
try await backend.createShare(byPath: testFileName)
|
||||
var shares = try await backend.getShares(byPath: testFileName)
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
XCTFail("Failed to fetch token of share for test file!")
|
||||
return
|
||||
}
|
||||
|
||||
try await backend.setDownloadLimit(to: 4, by: token)
|
||||
pullToRefresh()
|
||||
|
||||
// Tap share button.
|
||||
|
||||
let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
guard shareButton.await() else { return }
|
||||
shareButton.tap()
|
||||
|
||||
// Tap show share link details button.
|
||||
|
||||
let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
guard showShareLinkDetailsButton.await() else { return }
|
||||
showShareLinkDetailsButton.tap()
|
||||
|
||||
// Tap share link details button in share menu sheet.
|
||||
|
||||
let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
guard shareMenuDetailsCell.await() else { return }
|
||||
shareMenuDetailsCell.tap()
|
||||
|
||||
// Tap download limits.
|
||||
|
||||
let downloadLimitCell = app.cells["downloadLimit"]
|
||||
guard downloadLimitCell.await() else { return }
|
||||
downloadLimitCell.tap()
|
||||
|
||||
// Check download limit switch.
|
||||
|
||||
let downloadLimitSwitch = app.switches["downloadLimitSwitch"].firstMatch
|
||||
guard downloadLimitSwitch.await() else { return }
|
||||
downloadLimitSwitch.tap()
|
||||
|
||||
// Tap navigation back button.
|
||||
|
||||
app.navigationBars.buttons.firstMatch.tap()
|
||||
|
||||
// Tap confirm share button.
|
||||
|
||||
let confirmShareButton = app.buttons["confirmShare"]
|
||||
guard confirmShareButton.await() else { return }
|
||||
confirmShareButton.tap()
|
||||
confirmShareButton.awaitInexistence()
|
||||
|
||||
// Then
|
||||
shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
|
||||
guard let token = shares.first?.token else {
|
||||
throw UITestError.missingValue
|
||||
}
|
||||
|
||||
try await aMoment()
|
||||
try await backend.assertDownloadLimit(by: token, count: nil, limit: nil)
|
||||
}
|
||||
}
|
||||
//// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
//// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
//// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
//import XCTest
|
||||
//
|
||||
/////
|
||||
///// User interface tests for the download limits management on shares.
|
||||
/////
|
||||
//@MainActor
|
||||
//final class DownloadLimitUITests: BaseUIXCTestCase {
|
||||
// ///
|
||||
// /// Name of the file to work with.
|
||||
// ///
|
||||
// /// The leading underscore is required for the file to appear at the top of the list.
|
||||
// /// Obviously, this is fragile by making some assumptions of the user interface state.
|
||||
// ///
|
||||
// let testFileName = "_Xcode UI Test Subject.md"
|
||||
//
|
||||
// // MARK: - Lifecycle
|
||||
//
|
||||
// override func setUp() async throws {
|
||||
// try await super.setUp()
|
||||
// continueAfterFailure = false
|
||||
//
|
||||
// // Handle alerts presented by the system.
|
||||
// addUIInterruptionMonitor(withDescription: "Allow Notifications", for: "Allow")
|
||||
// addUIInterruptionMonitor(withDescription: "Save Password", for: "Not Now")
|
||||
//
|
||||
// // Launch the app.
|
||||
// app = XCUIApplication()
|
||||
// app.launchArguments = ["UI_TESTING"]
|
||||
// app.launch()
|
||||
//
|
||||
// try await logIn()
|
||||
//
|
||||
// // Set up test backend communication.
|
||||
// backend = UITestBackend()
|
||||
//
|
||||
// try await backend.assertCapability(true, capability: \.downloadLimit)
|
||||
// try await backend.delete(testFileName)
|
||||
// try await backend.prepareTestFile(testFileName)
|
||||
// }
|
||||
//
|
||||
// // MARK: - Tests
|
||||
//
|
||||
// func testShareWithoutDownloadLimitCapability() async throws {
|
||||
// // This cannot be implemented at the time of writing.
|
||||
// // There is no way to disable and enable server apps via web API.
|
||||
// // The Xcode UI test process cannot access Docker.
|
||||
// throw XCTSkip("Not implemented yet!")
|
||||
// }
|
||||
//
|
||||
// func testNewShareWithoutDownloadLimit() async throws {
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
//
|
||||
// guard shareButton.exists else {
|
||||
// throw UITestError.waitForExistence(shareButton)
|
||||
// }
|
||||
//
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap add share link button.
|
||||
//
|
||||
// let addShareLinkButton = app.buttons["addShareLink"]
|
||||
// guard addShareLinkButton.await() else { return }
|
||||
// addShareLinkButton.tap()
|
||||
//
|
||||
// // Tap confirm share button.
|
||||
//
|
||||
// let confirmShareButton = app.buttons["confirmShare"]
|
||||
//
|
||||
// guard confirmShareButton.exists else {
|
||||
// throw UITestError.waitForExistence(confirmShareButton)
|
||||
// }
|
||||
//
|
||||
// confirmShareButton.tap()
|
||||
// confirmShareButton.awaitInexistence()
|
||||
//
|
||||
// // Then
|
||||
// let shares = try await backend.getShares(byPath: "/\(testFileName)")
|
||||
// XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// throw UITestError.missingValue
|
||||
// }
|
||||
//
|
||||
// try await backend.assertNoDownloadLimit(by: token)
|
||||
// }
|
||||
//
|
||||
// func testNewShareWithDownloadLimit() async throws {
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
// guard shareButton.await() else { return }
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap add share link button.
|
||||
//
|
||||
// let addShareLinkButton = app.buttons["addShareLink"]
|
||||
// guard addShareLinkButton.await() else { return }
|
||||
// addShareLinkButton.tap()
|
||||
//
|
||||
// // Tap download limits.
|
||||
//
|
||||
// let downloadLimitCell = app.cells["downloadLimit"]
|
||||
// guard downloadLimitCell.await() else { return }
|
||||
// downloadLimitCell.tap()
|
||||
//
|
||||
// // Tap download limit switch.
|
||||
//
|
||||
// let downloadLimitSwitch = app.switches["downloadLimitSwitch"]
|
||||
// guard downloadLimitSwitch.await() else { return }
|
||||
// downloadLimitSwitch.tap()
|
||||
//
|
||||
// // Update allowed downloads.
|
||||
//
|
||||
// let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
// guard allowedDownloadsTextField.await() else { return }
|
||||
// allowedDownloadsTextField.tap()
|
||||
// allowedDownloadsTextField.typeText("3")
|
||||
//
|
||||
// // Tap navigation back button.
|
||||
//
|
||||
// app.navigationBars.buttons.firstMatch.tap()
|
||||
//
|
||||
// // Tap confirm share button.
|
||||
//
|
||||
// let confirmShareButton = app.buttons["confirmShare"]
|
||||
// guard confirmShareButton.await() else { return }
|
||||
// confirmShareButton.tap()
|
||||
// confirmShareButton.awaitInexistence()
|
||||
//
|
||||
// // Then
|
||||
// let shares = try await backend.getShares(byPath: "/\(testFileName)")
|
||||
// XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// throw UITestError.missingValue
|
||||
// }
|
||||
//
|
||||
// try await backend.assertDownloadLimit(by: token, count: 0, limit: 3)
|
||||
// }
|
||||
//
|
||||
// func testShareOfFolder() async throws {
|
||||
// let testSubject = "_Xcode UI Test Subject"
|
||||
// try await backend.createFolder(testSubject)
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testSubject)/shareButton"]
|
||||
// guard shareButton.await() else { return }
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap add share link button.
|
||||
//
|
||||
// let addShareLinkButton = app.buttons["addShareLink"]
|
||||
// guard addShareLinkButton.await() else { return }
|
||||
// addShareLinkButton.tap()
|
||||
//
|
||||
// // Verify download limits being unavailable.
|
||||
//
|
||||
// let downloadLimitCell = app.cells["downloadLimit"]
|
||||
// XCTAssertFalse(downloadLimitCell.exists, "Folder shares cannot have download limits")
|
||||
//
|
||||
// // Cleanup
|
||||
//
|
||||
// try await backend.delete(testSubject)
|
||||
// }
|
||||
//
|
||||
// func testAddingDownloadLimitToExistingShare() async throws {
|
||||
// try await backend.createShare(byPath: testFileName)
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
// guard shareButton.await() else { return }
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap show share link details button.
|
||||
//
|
||||
// let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
// guard showShareLinkDetailsButton.await() else { return }
|
||||
// showShareLinkDetailsButton.tap()
|
||||
//
|
||||
// // Tap share link details button in share menu sheet.
|
||||
//
|
||||
// let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
// guard shareMenuDetailsCell.await() else { return }
|
||||
// shareMenuDetailsCell.tap()
|
||||
//
|
||||
// // Tap download limits.
|
||||
//
|
||||
// let downloadLimitCell = app.cells["downloadLimit"]
|
||||
// guard downloadLimitCell.await() else { return }
|
||||
// downloadLimitCell.tap()
|
||||
//
|
||||
// // Tap download limit switch.
|
||||
//
|
||||
// let downloadLimitSwitch = app.switches["downloadLimitSwitch"]
|
||||
// guard downloadLimitSwitch.await() else { return }
|
||||
// downloadLimitSwitch.tap()
|
||||
//
|
||||
// // Update allowed downloads.
|
||||
//
|
||||
// let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
// guard allowedDownloadsTextField.await() else { return }
|
||||
// allowedDownloadsTextField.tap()
|
||||
// allowedDownloadsTextField.typeText("3")
|
||||
//
|
||||
// // Tap navigation back button.
|
||||
//
|
||||
// app.navigationBars.buttons.firstMatch.tap()
|
||||
//
|
||||
// // Tap confirm share button.
|
||||
//
|
||||
// let confirmShareButton = app.buttons["confirmShare"]
|
||||
// guard confirmShareButton.await() else { return }
|
||||
// confirmShareButton.tap()
|
||||
// confirmShareButton.awaitInexistence()
|
||||
//
|
||||
// // Then
|
||||
// let shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
// XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// throw UITestError.missingValue
|
||||
// }
|
||||
//
|
||||
// try await aMoment()
|
||||
// try await backend.assertDownloadLimit(by: token, count: 0, limit: 3)
|
||||
// }
|
||||
//
|
||||
// func testUpdatingDownloadLimitOnExistingShare() async throws {
|
||||
// try await backend.createShare(byPath: testFileName)
|
||||
// var shares = try await backend.getShares(byPath: testFileName)
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// XCTFail("Failed to fetch token of share for test file!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// try await backend.setDownloadLimit(to: 4, by: token)
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
// guard shareButton.await() else { return }
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap show share link details button.
|
||||
//
|
||||
// let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
// guard showShareLinkDetailsButton.await() else { return }
|
||||
// showShareLinkDetailsButton.tap()
|
||||
//
|
||||
// // Tap share link details button in share menu sheet.
|
||||
//
|
||||
// let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
// guard shareMenuDetailsCell.await() else { return }
|
||||
// shareMenuDetailsCell.tap()
|
||||
//
|
||||
// // Tap download limits.
|
||||
//
|
||||
// let downloadLimitCell = app.cells["downloadLimit"]
|
||||
// guard downloadLimitCell.await() else { return }
|
||||
// downloadLimitCell.tap()
|
||||
//
|
||||
// // Check download limit switch.
|
||||
//
|
||||
// let downloadLimitSwitch = app.switches["downloadLimitSwitch"].firstMatch
|
||||
// guard downloadLimitSwitch.await() else { return }
|
||||
//
|
||||
// guard let downloadLimitSwitchValue = (downloadLimitSwitch.value as? String) else {
|
||||
// XCTFail("Failed to get value of user interface control!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard downloadLimitSwitchValue == "1" else {
|
||||
// XCTFail("The switch is not on!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// // Check and update allowed downloads.
|
||||
//
|
||||
// let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
// guard allowedDownloadsTextField.await() else { return }
|
||||
//
|
||||
// guard let allowedDownloadsTextFieldValue = (allowedDownloadsTextField.value as? String) else {
|
||||
// XCTFail("Failed to get value of user interface control!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard allowedDownloadsTextFieldValue == "4" else {
|
||||
// XCTFail("The text field value is wrong!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// allowedDownloadsTextField.tap()
|
||||
// allowedDownloadsTextField.typeText("6")
|
||||
//
|
||||
// // Tap navigation back button.
|
||||
//
|
||||
// app.navigationBars.buttons.firstMatch.tap()
|
||||
//
|
||||
// // Tap confirm share button.
|
||||
//
|
||||
// let confirmShareButton = app.buttons["confirmShare"]
|
||||
// guard confirmShareButton.await() else { return }
|
||||
// confirmShareButton.tap()
|
||||
// confirmShareButton.awaitInexistence()
|
||||
//
|
||||
// // Then
|
||||
// shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
// XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// throw UITestError.missingValue
|
||||
// }
|
||||
//
|
||||
// try await aMoment()
|
||||
// try await backend.assertDownloadLimit(by: token, count: 0, limit: 6)
|
||||
// }
|
||||
//
|
||||
// func testDiscardingDownloadLimitChangesOnExistingShare() async throws {
|
||||
// try await backend.createShare(byPath: testFileName)
|
||||
// var shares = try await backend.getShares(byPath: testFileName)
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// XCTFail("Failed to fetch token of share for test file!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// try await backend.setDownloadLimit(to: 8, by: token)
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
// guard shareButton.await() else { return }
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap show share link details button.
|
||||
//
|
||||
// let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
// guard showShareLinkDetailsButton.await() else { return }
|
||||
// showShareLinkDetailsButton.tap()
|
||||
//
|
||||
// // Tap share link details button in share menu sheet.
|
||||
//
|
||||
// let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
// guard shareMenuDetailsCell.await() else { return }
|
||||
// shareMenuDetailsCell.tap()
|
||||
//
|
||||
// // Tap download limits.
|
||||
//
|
||||
// let downloadLimitCell = app.cells["downloadLimit"]
|
||||
// guard downloadLimitCell.await() else { return }
|
||||
// downloadLimitCell.tap()
|
||||
//
|
||||
// // Check download limit switch.
|
||||
//
|
||||
// let downloadLimitSwitch = app.switches["downloadLimitSwitch"].firstMatch
|
||||
// guard downloadLimitSwitch.await() else { return }
|
||||
//
|
||||
// guard let downloadLimitSwitchValue = (downloadLimitSwitch.value as? String) else {
|
||||
// XCTFail("Failed to get value of user interface control!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard downloadLimitSwitchValue == "1" else {
|
||||
// XCTFail("The switch is not on!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// // Check and update allowed downloads.
|
||||
//
|
||||
// let allowedDownloadsTextField = app.textFields["downloadLimitTextField"]
|
||||
// guard allowedDownloadsTextField.await() else { return }
|
||||
//
|
||||
// guard let allowedDownloadsTextFieldValue = (allowedDownloadsTextField.value as? String) else {
|
||||
// XCTFail("Failed to get value of user interface control!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// allowedDownloadsTextField.tap()
|
||||
// allowedDownloadsTextField.typeText("9")
|
||||
//
|
||||
// // Tap navigation back button.
|
||||
//
|
||||
// app.navigationBars.buttons.firstMatch.tap()
|
||||
//
|
||||
// // Tap confirm share button.
|
||||
//
|
||||
// let cancelShareButton = app.buttons["cancelShare"]
|
||||
// guard cancelShareButton.await() else { return }
|
||||
// cancelShareButton.tap()
|
||||
//
|
||||
// // Then
|
||||
// shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
// XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// throw UITestError.missingValue
|
||||
// }
|
||||
//
|
||||
// try await aMoment()
|
||||
// try await backend.assertDownloadLimit(by: token, count: 0, limit: 8)
|
||||
// }
|
||||
//
|
||||
// func testRemovingDownloadLimitFromExistingShare() async throws {
|
||||
// try await backend.createShare(byPath: testFileName)
|
||||
// var shares = try await backend.getShares(byPath: testFileName)
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// XCTFail("Failed to fetch token of share for test file!")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// try await backend.setDownloadLimit(to: 4, by: token)
|
||||
// pullToRefresh()
|
||||
//
|
||||
// // Tap share button.
|
||||
//
|
||||
// let shareButton = app.buttons["Cell/\(testFileName)/shareButton"]
|
||||
// guard shareButton.await() else { return }
|
||||
// shareButton.tap()
|
||||
//
|
||||
// // Tap show share link details button.
|
||||
//
|
||||
// let showShareLinkDetailsButton = app.buttons["showShareLinkDetails"]
|
||||
// guard showShareLinkDetailsButton.await() else { return }
|
||||
// showShareLinkDetailsButton.tap()
|
||||
//
|
||||
// // Tap share link details button in share menu sheet.
|
||||
//
|
||||
// let shareMenuDetailsCell = app.cells["shareMenu/details"]
|
||||
// guard shareMenuDetailsCell.await() else { return }
|
||||
// shareMenuDetailsCell.tap()
|
||||
//
|
||||
// // Tap download limits.
|
||||
//
|
||||
// let downloadLimitCell = app.cells["downloadLimit"]
|
||||
// guard downloadLimitCell.await() else { return }
|
||||
// downloadLimitCell.tap()
|
||||
//
|
||||
// // Check download limit switch.
|
||||
//
|
||||
// let downloadLimitSwitch = app.switches["downloadLimitSwitch"].firstMatch
|
||||
// guard downloadLimitSwitch.await() else { return }
|
||||
// downloadLimitSwitch.tap()
|
||||
//
|
||||
// // Tap navigation back button.
|
||||
//
|
||||
// app.navigationBars.buttons.firstMatch.tap()
|
||||
//
|
||||
// // Tap confirm share button.
|
||||
//
|
||||
// let confirmShareButton = app.buttons["confirmShare"]
|
||||
// guard confirmShareButton.await() else { return }
|
||||
// confirmShareButton.tap()
|
||||
// confirmShareButton.awaitInexistence()
|
||||
//
|
||||
// // Then
|
||||
// shares = try await backend.getShares(byPath: "\(testFileName)")
|
||||
// XCTAssertEqual(shares.count, 1, "Only one share existing on \(testFileName)")
|
||||
//
|
||||
// guard let token = shares.first?.token else {
|
||||
// throw UITestError.missingValue
|
||||
// }
|
||||
//
|
||||
// try await aMoment()
|
||||
// try await backend.assertDownloadLimit(by: token, count: nil, limit: nil)
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,270 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Milen Pivchev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Testing
|
||||
import UIKit
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("setBidiSafeTitle")
|
||||
@MainActor
|
||||
struct SetBidiSafeTitleTests {
|
||||
|
||||
@Test("Normal file splits into base and extension labels")
|
||||
func normalFile() {
|
||||
let navItem = UINavigationItem()
|
||||
navItem.setBidiSafeTitle("document.pdf")
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
#expect(stack.arrangedSubviews.count == 2)
|
||||
|
||||
let baseLabel = stack.arrangedSubviews[0] as? UILabel
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(baseLabel?.text == "document")
|
||||
#expect(extLabel?.text == ".pdf")
|
||||
#expect(navItem.title == nil)
|
||||
}
|
||||
|
||||
@Test("Multiple extensions splits on last dot")
|
||||
func multipleExtensions() {
|
||||
let navItem = UINavigationItem()
|
||||
navItem.setBidiSafeTitle("archive.tar.gz")
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let baseLabel = stack.arrangedSubviews[0] as? UILabel
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(baseLabel?.text == "archive.tar")
|
||||
#expect(extLabel?.text == ".gz")
|
||||
}
|
||||
|
||||
@Test("No extension uses plain title")
|
||||
func noExtension() {
|
||||
let navItem = UINavigationItem()
|
||||
navItem.setBidiSafeTitle("README")
|
||||
|
||||
#expect(navItem.titleView == nil)
|
||||
#expect(navItem.title == "README")
|
||||
}
|
||||
|
||||
@Test("Dotfile uses plain title")
|
||||
func dotfile() {
|
||||
let navItem = UINavigationItem()
|
||||
navItem.setBidiSafeTitle(".hidden")
|
||||
|
||||
#expect(navItem.titleView == nil)
|
||||
#expect(navItem.title == ".hidden")
|
||||
}
|
||||
|
||||
@Test("Empty string uses plain title")
|
||||
func emptyString() {
|
||||
let navItem = UINavigationItem()
|
||||
navItem.setBidiSafeTitle("")
|
||||
|
||||
#expect(navItem.titleView == nil)
|
||||
#expect(navItem.title == "")
|
||||
}
|
||||
|
||||
@Test("RLO override isolates the real extension")
|
||||
func rloOverride() {
|
||||
let navItem = UINavigationItem()
|
||||
// U+202E (RLO) reverses displayed text: "malware\u{202E}fdp.exe" looks like "malwareexe.pdf"
|
||||
let malicious = "malware\u{202E}fdp.exe"
|
||||
navItem.setBidiSafeTitle(malicious)
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(extLabel?.text == ".exe")
|
||||
}
|
||||
|
||||
@Test("RLI override isolates the real extension")
|
||||
func rliOverride() {
|
||||
let navItem = UINavigationItem()
|
||||
// U+2067 (RLI) Right-to-Left Isolate
|
||||
let malicious = "invoice\u{2067}cod.exe"
|
||||
navItem.setBidiSafeTitle(malicious)
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(extLabel?.text == ".exe")
|
||||
}
|
||||
|
||||
@Test("LRO override isolates the real extension")
|
||||
func lroOverride() {
|
||||
let navItem = UINavigationItem()
|
||||
// U+202D (LRO) Left-to-Right Override
|
||||
let malicious = "report\u{202D}exe.pdf"
|
||||
navItem.setBidiSafeTitle(malicious)
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(extLabel?.text == ".pdf")
|
||||
}
|
||||
|
||||
@Test("Multiple bidi characters isolates the real extension")
|
||||
func multipleBidiChars() {
|
||||
let navItem = UINavigationItem()
|
||||
// Stacked overrides: RLO + LRI
|
||||
let malicious = "\u{202E}\u{2066}safe_document\u{2069}cod.exe"
|
||||
navItem.setBidiSafeTitle(malicious)
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(extLabel?.text == ".exe")
|
||||
}
|
||||
|
||||
@Test("Bidi override with PDF isolate in extension")
|
||||
func bidiPDFIsolate() {
|
||||
let navItem = UINavigationItem()
|
||||
// U+2069 (PDI) Pop Directional Isolate used to terminate an isolate
|
||||
let malicious = "image\u{2066}exe.jpg\u{2069}.png"
|
||||
navItem.setBidiSafeTitle(malicious)
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(extLabel?.text == ".png")
|
||||
}
|
||||
|
||||
@Test("FSI override isolates the real extension")
|
||||
func fsiOverride() {
|
||||
let navItem = UINavigationItem()
|
||||
// U+2068 (FSI) First Strong Isolate
|
||||
let malicious = "notes\u{2068}exe.bat"
|
||||
navItem.setBidiSafeTitle(malicious)
|
||||
|
||||
let stack = try! #require(navItem.titleView as? UIStackView)
|
||||
let extLabel = stack.arrangedSubviews[1] as? UILabel
|
||||
#expect(extLabel?.text == ".bat")
|
||||
}
|
||||
}
|
||||
|
||||
@Suite("setBidiSafeFilename")
|
||||
@MainActor
|
||||
struct SetBidiSafeFilenameTests {
|
||||
|
||||
@Test("Normal file splits labels")
|
||||
func normalFile() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
view.setBidiSafeFilename("photo.jpg", isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(titleLabel.text == "photo")
|
||||
#expect(extensionLabel.text == ".jpg")
|
||||
#expect(extensionLabel.isHidden == false)
|
||||
}
|
||||
|
||||
@Test("Directory shows full name and hides extension label")
|
||||
func directory() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
view.setBidiSafeFilename("My Folder.backup", isDirectory: true, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(titleLabel.text == "My Folder.backup")
|
||||
#expect(extensionLabel.text == "")
|
||||
#expect(extensionLabel.isHidden == true)
|
||||
}
|
||||
|
||||
@Test("No extension shows full name")
|
||||
func noExtension() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
view.setBidiSafeFilename("Makefile", isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(titleLabel.text == "Makefile")
|
||||
#expect(extensionLabel.text == "")
|
||||
#expect(extensionLabel.isHidden == true)
|
||||
}
|
||||
|
||||
@Test("Dotfile shows full name")
|
||||
func dotfile() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
view.setBidiSafeFilename(".gitignore", isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(titleLabel.text == ".gitignore")
|
||||
#expect(extensionLabel.text == "")
|
||||
#expect(extensionLabel.isHidden == true)
|
||||
}
|
||||
|
||||
@Test("Multiple extensions splits on last dot")
|
||||
func multipleExtensions() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
view.setBidiSafeFilename("backup.tar.gz", isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(titleLabel.text == "backup.tar")
|
||||
#expect(extensionLabel.text == ".gz")
|
||||
#expect(extensionLabel.isHidden == false)
|
||||
}
|
||||
|
||||
@Test("RLO override isolates the real extension")
|
||||
func rloOverride() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
// U+202E (RLO) reverses displayed text
|
||||
let malicious = "malware\u{202E}fdp.exe"
|
||||
view.setBidiSafeFilename(malicious, isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(extensionLabel.text == ".exe")
|
||||
#expect(extensionLabel.isHidden == false)
|
||||
}
|
||||
|
||||
@Test("RLI override isolates the real extension")
|
||||
func rliOverride() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
// U+2067 (RLI) Right-to-Left Isolate
|
||||
let malicious = "invoice\u{2067}cod.exe"
|
||||
view.setBidiSafeFilename(malicious, isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(extensionLabel.text == ".exe")
|
||||
#expect(extensionLabel.isHidden == false)
|
||||
}
|
||||
|
||||
@Test("Multiple bidi characters isolates the real extension")
|
||||
func multipleBidiChars() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
// Stacked overrides: RLO + LRI
|
||||
let malicious = "\u{202E}\u{2066}safe_document\u{2069}cod.exe"
|
||||
view.setBidiSafeFilename(malicious, isDirectory: false, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(extensionLabel.text == ".exe")
|
||||
#expect(extensionLabel.isHidden == false)
|
||||
}
|
||||
|
||||
@Test("Bidi override on directory still shows full name")
|
||||
func bidiDirectory() {
|
||||
let view = UIView()
|
||||
let titleLabel = UILabel()
|
||||
let extensionLabel = UILabel()
|
||||
|
||||
let malicious = "folder\u{202E}exe.txt"
|
||||
view.setBidiSafeFilename(malicious, isDirectory: true, titleLabel: titleLabel, extensionLabel: extensionLabel)
|
||||
|
||||
#expect(titleLabel.text == malicious)
|
||||
#expect(extensionLabel.text == "")
|
||||
#expect(extensionLabel.isHidden == true)
|
||||
}
|
||||
|
||||
@Test("Nil labels does not crash")
|
||||
func nilLabels() {
|
||||
let view = UIView()
|
||||
view.setBidiSafeFilename("test.txt", isDirectory: false, titleLabel: nil, extensionLabel: nil)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import AVFoundation
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("NCCameraRoll image format conversion")
|
||||
struct NCCameraRollTests {
|
||||
|
||||
@Test("Animated and lossless formats retain their filenames")
|
||||
func formatsPreserved() {
|
||||
for fileName in ["animation.gif", "image.png", "animation.webp", "image.tiff", "image.jpg"] {
|
||||
let fileExtension = (fileName as NSString).pathExtension
|
||||
|
||||
#expect(!NCCameraRoll.shouldConvertToJPEG(fileExtension: fileExtension, nativeFormat: false))
|
||||
#expect(
|
||||
NCCameraRoll.outputFileName(
|
||||
for: fileName,
|
||||
sourceFileExtension: fileExtension,
|
||||
nativeFormat: false
|
||||
) == fileName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test("Compatibility formats are converted to JPEG")
|
||||
func compatibilityFormatsConverted() {
|
||||
for fileName in ["image.heic", "image.heif", "image.dng"] {
|
||||
let fileExtension = (fileName as NSString).pathExtension
|
||||
|
||||
#expect(NCCameraRoll.shouldConvertToJPEG(fileExtension: fileExtension, nativeFormat: false))
|
||||
#expect(
|
||||
NCCameraRoll.outputFileName(
|
||||
for: fileName,
|
||||
sourceFileExtension: fileExtension,
|
||||
nativeFormat: false
|
||||
) == "image.jpg"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test("Native format preserves HEIC, HEIF and RAW filenames")
|
||||
func nativeFormatsPreserved() {
|
||||
for fileName in ["image.heic", "image.heif", "image.dng"] {
|
||||
let fileExtension = (fileName as NSString).pathExtension
|
||||
|
||||
#expect(!NCCameraRoll.shouldConvertToJPEG(fileExtension: fileExtension, nativeFormat: true))
|
||||
#expect(
|
||||
NCCameraRoll.outputFileName(
|
||||
for: fileName,
|
||||
sourceFileExtension: fileExtension,
|
||||
nativeFormat: true
|
||||
) == fileName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test("Generated upload names keep their base name")
|
||||
func generatedNameConverted() {
|
||||
#expect(
|
||||
NCCameraRoll.outputFileName(
|
||||
for: "2026-08-04 09-30-00.heic",
|
||||
sourceFileExtension: "heic",
|
||||
nativeFormat: false
|
||||
) == "2026-08-04 09-30-00.jpg"
|
||||
)
|
||||
}
|
||||
|
||||
@Test("Video passthrough retains its original container")
|
||||
func videoContainerPreserved() {
|
||||
#expect(NCCameraRoll.videoOutputFileType(fileExtension: "mov") == .mov)
|
||||
#expect(NCCameraRoll.videoOutputFileType(fileExtension: "MP4") == .mp4)
|
||||
#expect(NCCameraRoll.videoOutputFileType(fileExtension: "m4v") == .m4v)
|
||||
#expect(NCCameraRoll.videoOutputFileType(fileExtension: "jpg") == nil)
|
||||
}
|
||||
|
||||
@Test("Concurrent extractions use distinct temporary paths")
|
||||
func extractionTemporaryPathsAreUnique() {
|
||||
let directory = FileManager.default.temporaryDirectory
|
||||
let firstURL = NCCameraRoll.extractionTemporaryURL(
|
||||
fileName: "26-08-04 10-51-42 7473.jpg",
|
||||
ocId: "camera-roll-transfer",
|
||||
directory: directory
|
||||
)
|
||||
let secondURL = NCCameraRoll.extractionTemporaryURL(
|
||||
fileName: "26-08-04 10-51-42 7473.jpg",
|
||||
ocId: "camera-roll-transfer",
|
||||
directory: directory
|
||||
)
|
||||
|
||||
#expect(firstURL != secondURL)
|
||||
#expect(firstURL.deletingLastPathComponent() == directory)
|
||||
#expect(firstURL.pathExtension == "uploading")
|
||||
#expect(firstURL.lastPathComponent.contains("camera-roll-transfer"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("End-to-end key set archive")
|
||||
struct NCEndToEndKeySetArchiveTests {
|
||||
@Test("Archiving does not change the active credentials")
|
||||
func preservesNormalActiveCredentials() throws {
|
||||
let account = "e2ee-archive-\(UUID().uuidString)"
|
||||
let preferences = NCPreferences()
|
||||
defer {
|
||||
preferences.clearAllKeysEndToEnd(account: account)
|
||||
}
|
||||
|
||||
setKeySet(on: preferences, account: account)
|
||||
try preferences.archiveCurrentEndToEndKeySet(account: account)
|
||||
|
||||
#expect(preferences.isEndToEndEnabled(account: account))
|
||||
#expect(preferences.getEndToEndCertificate(account: account) == "certificate")
|
||||
#expect(preferences.getEndToEndPrivateKey(account: account) == "private-key")
|
||||
#expect(preferences.getEndToEndPublicKey(account: account) == "public-key")
|
||||
#expect(preferences.getEndToEndPassphrase(account: account) == "passphrase")
|
||||
}
|
||||
|
||||
@Test("Archiving preserves active credentials after they are cleared")
|
||||
func preservesActiveCredentials() throws {
|
||||
let account = "e2ee-archive-\(UUID().uuidString)"
|
||||
let preferences = NCPreferences()
|
||||
defer {
|
||||
preferences.clearAllKeysEndToEnd(account: account)
|
||||
}
|
||||
|
||||
setKeySet(on: preferences, account: account)
|
||||
let archivedKeySet = try preferences.archiveCurrentEndToEndKeySet(account: account)
|
||||
let snapshot = try #require(archivedKeySet)
|
||||
|
||||
preferences.clearCurrentKeysEndToEnd(account: account)
|
||||
|
||||
#expect(preferences.getEndToEndCertificate(account: account) == nil)
|
||||
#expect(preferences.getEndToEndPrivateKey(account: account) == nil)
|
||||
#expect(preferences.getEndToEndPublicKey(account: account) == nil)
|
||||
#expect(preferences.getEndToEndPassphrase(account: account) == nil)
|
||||
|
||||
let archivedKeySets = try preferences.getArchivedEndToEndKeySets(account: account)
|
||||
#expect(archivedKeySets == [snapshot])
|
||||
#expect(snapshot.certificate == "certificate")
|
||||
#expect(snapshot.privateKey == "private-key")
|
||||
#expect(snapshot.publicKey == "public-key")
|
||||
#expect(snapshot.passphrase == "passphrase")
|
||||
}
|
||||
|
||||
@Test("Explicit local removal also clears stale server-key state")
|
||||
func removalClearsStaleState() {
|
||||
let account = "e2ee-archive-\(UUID().uuidString)"
|
||||
let preferences = NCPreferences()
|
||||
|
||||
preferences.setEndToEndServerKeyStale(account: account, stale: true)
|
||||
preferences.clearAllKeysEndToEnd(account: account)
|
||||
|
||||
#expect(!preferences.isEndToEndServerKeyStale(account: account))
|
||||
}
|
||||
|
||||
@Test("Archiving the same credentials does not create duplicates")
|
||||
func avoidsDuplicates() throws {
|
||||
let account = "e2ee-archive-\(UUID().uuidString)"
|
||||
let preferences = NCPreferences()
|
||||
defer {
|
||||
preferences.clearAllKeysEndToEnd(account: account)
|
||||
}
|
||||
|
||||
setKeySet(on: preferences, account: account)
|
||||
let firstArchivedKeySet = try preferences.archiveCurrentEndToEndKeySet(account: account)
|
||||
let secondArchivedKeySet = try preferences.archiveCurrentEndToEndKeySet(account: account)
|
||||
let firstSnapshot = try #require(firstArchivedKeySet)
|
||||
let secondSnapshot = try #require(secondArchivedKeySet)
|
||||
|
||||
#expect(secondSnapshot.identifier == firstSnapshot.identifier)
|
||||
#expect(try preferences.getArchivedEndToEndKeySets(account: account).count == 1)
|
||||
}
|
||||
|
||||
@Test("A partial setup is archived when it contains usable key material")
|
||||
func preservesPartialKeyMaterial() throws {
|
||||
let account = "e2ee-archive-\(UUID().uuidString)"
|
||||
let preferences = NCPreferences()
|
||||
defer {
|
||||
preferences.clearAllKeysEndToEnd(account: account)
|
||||
}
|
||||
|
||||
preferences.setEndToEndPrivateKey(account: account, privateKey: "private-key")
|
||||
|
||||
let archivedKeySet = try preferences.archiveCurrentEndToEndKeySet(account: account)
|
||||
let snapshot = try #require(archivedKeySet)
|
||||
|
||||
#expect(snapshot.privateKey == "private-key")
|
||||
#expect(snapshot.certificate == nil)
|
||||
#expect(snapshot.publicKey == nil)
|
||||
#expect(snapshot.passphrase == nil)
|
||||
}
|
||||
|
||||
private func setKeySet(on preferences: NCPreferences, account: String) {
|
||||
preferences.setEndToEndCertificate(account: account, certificate: "certificate")
|
||||
preferences.setEndToEndPrivateKey(account: account, privateKey: "private-key")
|
||||
preferences.setEndToEndPublicKey(account: account, publicKey: "public-key")
|
||||
preferences.setEndToEndPassphrase(account: account, passphrase: "passphrase")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("End-to-end key set resolver")
|
||||
struct NCEndToEndKeySetResolverTests {
|
||||
@Test("The active key set has priority over archived key sets")
|
||||
func activeKeySetHasPriority() throws {
|
||||
let active = try #require(makeKeySet(identifier: "active"))
|
||||
let archived = try #require(makeKeySet(identifier: "archived"))
|
||||
|
||||
let access = NCEndToEndKeySetResolver().select(
|
||||
currentKeySet: active,
|
||||
archivedKeySets: [archived],
|
||||
canDecrypt: { _ in true }
|
||||
)
|
||||
|
||||
#expect(access == .active(active))
|
||||
#expect(access.canWrite)
|
||||
#expect(access.writeAccessError == .success)
|
||||
}
|
||||
|
||||
@Test("Equivalent PEM formatting identifies the same public key")
|
||||
func equivalentPublicKeysMatch() {
|
||||
let compact = "-----BEGIN PUBLIC KEY-----\nYWJjZA==\n-----END PUBLIC KEY-----"
|
||||
let wrapped = "-----BEGIN PUBLIC KEY-----\nYWJj\nZA==\n-----END PUBLIC KEY-----\n"
|
||||
let empty = "-----BEGIN PUBLIC KEY-----\n-----END PUBLIC KEY-----"
|
||||
|
||||
#expect(NCNetworkingE2EE().publicKeysMatch(compact, wrapped))
|
||||
#expect(!NCNetworkingE2EE().publicKeysMatch(compact, "different-key"))
|
||||
#expect(!NCNetworkingE2EE().publicKeysMatch(empty, empty))
|
||||
}
|
||||
|
||||
@Test("A stale local key is excluded from active write access")
|
||||
func staleKeyIsNotActive() throws {
|
||||
let account = "e2ee-stale-\(UUID().uuidString)"
|
||||
let preferences = NCPreferences()
|
||||
defer {
|
||||
preferences.clearAllKeysEndToEnd(account: account)
|
||||
}
|
||||
|
||||
preferences.setEndToEndCertificate(account: account, certificate: "certificate")
|
||||
preferences.setEndToEndPrivateKey(account: account, privateKey: "private-key")
|
||||
preferences.setEndToEndPublicKey(account: account, publicKey: "public-key")
|
||||
preferences.setEndToEndPassphrase(account: account, passphrase: "passphrase")
|
||||
try preferences.archiveCurrentEndToEndKeySet(account: account)
|
||||
preferences.setEndToEndServerKeyStale(account: account, stale: true)
|
||||
|
||||
let resolver = NCEndToEndKeySetResolver(preferences: preferences)
|
||||
let archivedKeySets = try preferences.getArchivedEndToEndKeySets(account: account)
|
||||
let archivedKeySet = try #require(archivedKeySets.last)
|
||||
let access = resolver.select(
|
||||
currentKeySet: resolver.currentKeySet(account: account),
|
||||
archivedKeySets: archivedKeySets,
|
||||
canDecrypt: { _ in true }
|
||||
)
|
||||
|
||||
#expect(access == .archived(archivedKeySet))
|
||||
#expect(!access.canWrite)
|
||||
}
|
||||
|
||||
@Test("The most recently archived matching key set is selected")
|
||||
func newestArchivedKeySetHasPriority() throws {
|
||||
let oldest = try #require(makeKeySet(identifier: "oldest"))
|
||||
let newest = try #require(makeKeySet(identifier: "newest"))
|
||||
|
||||
let access = NCEndToEndKeySetResolver().select(
|
||||
currentKeySet: nil,
|
||||
archivedKeySets: [oldest, newest],
|
||||
canDecrypt: { _ in true }
|
||||
)
|
||||
|
||||
#expect(access == .archived(newest))
|
||||
#expect(access.isReadOnly)
|
||||
#expect(access.writeAccessError.errorCode == NCGlobal.shared.errorE2EEReadOnly)
|
||||
}
|
||||
|
||||
@Test("Access is unavailable when no key set can decrypt metadata")
|
||||
func unavailableWithoutMatchingKeySet() throws {
|
||||
let active = try #require(makeKeySet(identifier: "active"))
|
||||
let archived = try #require(makeKeySet(identifier: "archived"))
|
||||
|
||||
let access = NCEndToEndKeySetResolver().select(
|
||||
currentKeySet: active,
|
||||
archivedKeySets: [archived],
|
||||
canDecrypt: { _ in false }
|
||||
)
|
||||
|
||||
#expect(access == .unavailable)
|
||||
#expect(!access.canWrite)
|
||||
#expect(!access.isReadOnly)
|
||||
#expect(access.writeAccessError.errorCode == NCGlobal.shared.errorE2EENoUserFound)
|
||||
}
|
||||
|
||||
@Test("A V2 child folder inherits its encrypted root metadata key")
|
||||
func childFolderUsesRootEncryptedMetadataKey() {
|
||||
let encryptedMetadataKey = NCEndToEndKeySetResolver().encryptedMetadataKey(
|
||||
users: nil,
|
||||
userId: "user",
|
||||
rootEncryptedMetadataKey: "root-key"
|
||||
)
|
||||
|
||||
#expect(encryptedMetadataKey == "root-key")
|
||||
}
|
||||
|
||||
@Test("A V2 child folder with an empty users array inherits its encrypted root metadata key")
|
||||
func childFolderWithEmptyUsersUsesRootEncryptedMetadataKey() {
|
||||
let encryptedMetadataKey = NCEndToEndKeySetResolver().encryptedMetadataKey(
|
||||
users: [],
|
||||
userId: "user",
|
||||
rootEncryptedMetadataKey: "root-key"
|
||||
)
|
||||
|
||||
#expect(encryptedMetadataKey == "root-key")
|
||||
}
|
||||
|
||||
@Test("A V2 root never falls back to a previously saved user key")
|
||||
func rootWithoutCurrentUserDoesNotUseSavedKey() {
|
||||
let otherUser = NCEndToEndMetadata.E2eeV2.Users(
|
||||
userId: "other-user",
|
||||
certificate: "certificate",
|
||||
encryptedMetadataKey: "other-key"
|
||||
)
|
||||
|
||||
let encryptedMetadataKey = NCEndToEndKeySetResolver().encryptedMetadataKey(
|
||||
users: [otherUser],
|
||||
userId: "user",
|
||||
rootEncryptedMetadataKey: "saved-root-key"
|
||||
)
|
||||
|
||||
#expect(encryptedMetadataKey == nil)
|
||||
}
|
||||
|
||||
private func makeKeySet(identifier: String) -> NCEndToEndKeySet? {
|
||||
NCEndToEndKeySet(
|
||||
certificate: "certificate-" + identifier,
|
||||
privateKey: "private-key-" + identifier,
|
||||
publicKey: "public-key-" + identifier,
|
||||
passphrase: "passphrase-" + identifier,
|
||||
identifier: identifier,
|
||||
archivedAt: Date(timeIntervalSince1970: 0)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Testing
|
||||
import UIKit
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("Image zoom view")
|
||||
@MainActor
|
||||
struct NCImageZoomViewTests {
|
||||
@Test("Replacing an image preserves its zoom scale and focal point")
|
||||
func preservesZoomStateWhenImageChanges() throws {
|
||||
let (coordinator, scrollView, imageView) = makeZoomView(
|
||||
imageSize: CGSize(width: 400, height: 300)
|
||||
)
|
||||
|
||||
scrollView.setZoomScale(3, animated: false)
|
||||
scrollView.contentOffset = CGPoint(x: 220, y: 70)
|
||||
|
||||
let zoomState = try #require(coordinator.zoomState())
|
||||
|
||||
imageView.image = makeImage(
|
||||
size: CGSize(width: 300, height: 400)
|
||||
)
|
||||
coordinator.layoutImageView(preserving: zoomState)
|
||||
|
||||
let restoredZoomState = try #require(coordinator.zoomState())
|
||||
|
||||
#expect(abs(restoredZoomState.zoomScale - zoomState.zoomScale) < 0.001)
|
||||
#expect(abs(restoredZoomState.normalizedCenter.x - zoomState.normalizedCenter.x) < 0.001)
|
||||
#expect(abs(restoredZoomState.normalizedCenter.y - zoomState.normalizedCenter.y) < 0.001)
|
||||
}
|
||||
|
||||
@Test("Relayout without a saved state resets zoom")
|
||||
func resetsZoomWithoutSavedState() {
|
||||
let (coordinator, scrollView, imageView) = makeZoomView(
|
||||
imageSize: CGSize(width: 400, height: 300)
|
||||
)
|
||||
|
||||
scrollView.setZoomScale(3, animated: false)
|
||||
imageView.image = makeImage(
|
||||
size: CGSize(width: 800, height: 600)
|
||||
)
|
||||
|
||||
coordinator.layoutImageViewResettingZoom()
|
||||
|
||||
#expect(scrollView.zoomScale == scrollView.minimumZoomScale)
|
||||
#expect(coordinator.zoomState() == nil)
|
||||
}
|
||||
|
||||
@Test("A full orientation round trip preserves zoom and focal point")
|
||||
func preservesZoomStateAfterOrientationRoundTrip() throws {
|
||||
let (coordinator, scrollView, _) = makeZoomView(
|
||||
imageSize: CGSize(width: 400, height: 300)
|
||||
)
|
||||
|
||||
scrollView.setZoomScale(3, animated: false)
|
||||
scrollView.contentOffset = CGPoint(x: 0, y: 70)
|
||||
coordinator.recordCurrentZoomState()
|
||||
|
||||
let zoomState = try #require(coordinator.zoomState())
|
||||
|
||||
for _ in 0..<3 {
|
||||
scrollView.bounds = CGRect(
|
||||
origin: scrollView.bounds.origin,
|
||||
size: CGSize(width: 480, height: 320)
|
||||
)
|
||||
coordinator.layoutImageViewPreservingOnBoundsChange()
|
||||
|
||||
// UIKit can deliver automatic scrolling after a rotation finishes.
|
||||
scrollView.contentOffset = .zero
|
||||
coordinator.scrollViewDidScroll(scrollView)
|
||||
|
||||
scrollView.bounds = CGRect(
|
||||
origin: scrollView.bounds.origin,
|
||||
size: CGSize(width: 320, height: 480)
|
||||
)
|
||||
coordinator.layoutImageViewPreservingOnBoundsChange()
|
||||
|
||||
let restoredZoomState = try #require(coordinator.zoomState())
|
||||
#expect(abs(restoredZoomState.zoomScale - zoomState.zoomScale) < 0.001)
|
||||
#expect(abs(restoredZoomState.normalizedCenter.x - zoomState.normalizedCenter.x) < 0.001)
|
||||
#expect(abs(restoredZoomState.normalizedCenter.y - zoomState.normalizedCenter.y) < 0.001)
|
||||
}
|
||||
}
|
||||
|
||||
@Test("Double-tap zoom survives view recreation and rotation")
|
||||
func preservesDoubleTapZoomAfterViewRecreation() throws {
|
||||
var persistedZoomState: NCImageZoomView.ZoomState?
|
||||
let (firstCoordinator, firstScrollView, firstImageView) = makeZoomView(
|
||||
imageSize: CGSize(width: 400, height: 300),
|
||||
onZoomStateChanged: { persistedZoomState = $0 }
|
||||
)
|
||||
|
||||
firstCoordinator.toggleZoom(
|
||||
at: CGPoint(
|
||||
x: firstImageView.bounds.midX,
|
||||
y: firstImageView.bounds.midY
|
||||
),
|
||||
animated: false
|
||||
)
|
||||
|
||||
let expectedZoomState = try #require(persistedZoomState)
|
||||
#expect(abs(firstScrollView.zoomScale - expectedZoomState.zoomScale) < 0.001)
|
||||
|
||||
let (restoredCoordinator, restoredScrollView, _) = makeZoomView(
|
||||
imageSize: CGSize(width: 400, height: 300),
|
||||
initialZoomState: expectedZoomState
|
||||
)
|
||||
|
||||
restoredScrollView.bounds = CGRect(
|
||||
origin: restoredScrollView.bounds.origin,
|
||||
size: CGSize(width: 480, height: 320)
|
||||
)
|
||||
restoredCoordinator.layoutImageViewPreservingOnBoundsChange()
|
||||
|
||||
let restoredZoomState = try #require(restoredCoordinator.zoomState())
|
||||
#expect(abs(restoredZoomState.zoomScale - expectedZoomState.zoomScale) < 0.001)
|
||||
#expect(abs(restoredZoomState.normalizedCenter.x - expectedZoomState.normalizedCenter.x) < 0.001)
|
||||
#expect(abs(restoredZoomState.normalizedCenter.y - expectedZoomState.normalizedCenter.y) < 0.001)
|
||||
}
|
||||
|
||||
@Test("Live Photo playback uses the still image zoom and focal point")
|
||||
func livePhotoPlaybackPreservesZoomState() {
|
||||
let zoomState = NCImageZoomView.ZoomState(
|
||||
zoomScale: 3,
|
||||
normalizedCenter: CGPoint(x: 0.6, y: 0.55)
|
||||
)
|
||||
let layout = NCLivePhotoPlaybackLayout(
|
||||
containerSize: CGSize(width: 320, height: 480),
|
||||
photoSize: CGSize(width: 400, height: 300),
|
||||
zoomState: zoomState
|
||||
)
|
||||
|
||||
#expect(abs(layout.frame.width - 960) < 0.001)
|
||||
#expect(abs(layout.frame.height - 720) < 0.001)
|
||||
#expect(abs(
|
||||
layout.frame.origin.x + layout.frame.width * zoomState.normalizedCenter.x - 160
|
||||
) < 0.001)
|
||||
#expect(abs(
|
||||
layout.frame.origin.y + layout.frame.height * zoomState.normalizedCenter.y - 240
|
||||
) < 0.001)
|
||||
}
|
||||
|
||||
@Test("Live Photo playback remains aspect-fit without zoom")
|
||||
func livePhotoPlaybackUsesAspectFitWithoutZoom() {
|
||||
let layout = NCLivePhotoPlaybackLayout(
|
||||
containerSize: CGSize(width: 320, height: 480),
|
||||
photoSize: CGSize(width: 400, height: 300),
|
||||
zoomState: nil
|
||||
)
|
||||
|
||||
#expect(layout.frame == CGRect(x: 0, y: 120, width: 320, height: 240))
|
||||
}
|
||||
|
||||
@Test("Live Photo playback clamps transient elastic zoom")
|
||||
func livePhotoPlaybackClampsElasticZoom() {
|
||||
let layout = NCLivePhotoPlaybackLayout(
|
||||
containerSize: CGSize(width: 320, height: 480),
|
||||
photoSize: CGSize(width: 400, height: 300),
|
||||
zoomState: NCImageZoomView.ZoomState(
|
||||
zoomScale: 20,
|
||||
normalizedCenter: CGPoint(x: 0.5, y: 0.5)
|
||||
)
|
||||
)
|
||||
|
||||
#expect(layout.frame == CGRect(x: -640, y: -360, width: 1_600, height: 1_200))
|
||||
}
|
||||
|
||||
@Test("Persisted zoom state clamps transient elastic zoom")
|
||||
func persistedZoomStateClampsElasticZoom() throws {
|
||||
var persistedZoomState: NCImageZoomView.ZoomState?
|
||||
let (coordinator, scrollView, _) = makeZoomView(
|
||||
imageSize: CGSize(width: 400, height: 300),
|
||||
onZoomStateChanged: { persistedZoomState = $0 }
|
||||
)
|
||||
|
||||
// Allow the test scroll view to reproduce the temporary value that
|
||||
// UIScrollView can report while bouncesZoom is active.
|
||||
scrollView.maximumZoomScale = 20
|
||||
scrollView.setZoomScale(20, animated: false)
|
||||
coordinator.scrollViewDidEndZooming(
|
||||
scrollView,
|
||||
with: nil,
|
||||
atScale: scrollView.zoomScale
|
||||
)
|
||||
|
||||
let zoomState = try #require(persistedZoomState)
|
||||
|
||||
#expect(zoomState.zoomScale == coordinator.maximumZoomScale)
|
||||
}
|
||||
|
||||
private func makeZoomView(
|
||||
imageSize: CGSize,
|
||||
initialZoomState: NCImageZoomView.ZoomState? = nil,
|
||||
onZoomStateChanged: @escaping (NCImageZoomView.ZoomState?) -> Void = { _ in }
|
||||
) -> (
|
||||
NCImageZoomView.Coordinator,
|
||||
NCImageZoomView.NCZoomScrollView,
|
||||
UIImageView
|
||||
) {
|
||||
let coordinator = NCImageZoomView.Coordinator()
|
||||
let scrollView = NCImageZoomView.NCZoomScrollView(
|
||||
frame: CGRect(x: 0, y: 0, width: 320, height: 480)
|
||||
)
|
||||
let imageView = UIImageView(
|
||||
image: makeImage(size: imageSize)
|
||||
)
|
||||
|
||||
scrollView.minimumZoomScale = 1
|
||||
scrollView.maximumZoomScale = 5
|
||||
scrollView.delegate = coordinator
|
||||
scrollView.addSubview(imageView)
|
||||
|
||||
coordinator.minimumZoomScale = 1
|
||||
coordinator.maximumZoomScale = 5
|
||||
coordinator.scrollView = scrollView
|
||||
coordinator.imageView = imageView
|
||||
coordinator.onZoomStateChanged = onZoomStateChanged
|
||||
coordinator.restorePersistedZoomState(initialZoomState)
|
||||
coordinator.layoutImageView(preserving: initialZoomState)
|
||||
|
||||
return (coordinator, scrollView, imageView)
|
||||
}
|
||||
|
||||
private func makeImage(size: CGSize) -> UIImage {
|
||||
UIGraphicsImageRenderer(size: size).image { context in
|
||||
UIColor.black.setFill()
|
||||
context.fill(CGRect(origin: .zero, size: size))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Testing
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("Media playback completion options")
|
||||
@MainActor
|
||||
struct NCMediaPlaybackOptionsTests {
|
||||
@Test("Playback stops when no completion option is enabled")
|
||||
func stopsByDefault() {
|
||||
let options = NCMediaPlaybackOptions(preferences: nil)
|
||||
|
||||
#expect(options.completionAction == .stop)
|
||||
}
|
||||
|
||||
@Test("Automatic advance plays the next compatible item")
|
||||
func advancesAutomatically() {
|
||||
let options = NCMediaPlaybackOptions(preferences: nil)
|
||||
|
||||
options.toggleAutoAdvance()
|
||||
|
||||
#expect(options.completionAction == .playNextItem)
|
||||
}
|
||||
|
||||
@Test("Disabling repeat restores normal stop behavior")
|
||||
func disablingRepeatRestoresStop() {
|
||||
let options = NCMediaPlaybackOptions(preferences: nil)
|
||||
|
||||
options.toggleRepeat()
|
||||
#expect(options.completionAction == .repeatCurrentItem)
|
||||
|
||||
options.toggleRepeat()
|
||||
#expect(options.completionAction == .stop)
|
||||
}
|
||||
|
||||
@Test("Repeat takes precedence over automatic advance")
|
||||
func repeatTakesPrecedence() {
|
||||
let options = NCMediaPlaybackOptions(preferences: nil)
|
||||
|
||||
options.toggleAutoAdvance()
|
||||
options.toggleRepeat()
|
||||
|
||||
#expect(options.completionAction == .repeatCurrentItem)
|
||||
|
||||
options.toggleRepeat()
|
||||
|
||||
#expect(options.completionAction == .playNextItem)
|
||||
}
|
||||
|
||||
@Test("Playback options restore and save their preferences")
|
||||
func persistsPlaybackOptions() {
|
||||
let preferences = NCPreferences()
|
||||
let originalRepeat = preferences.mediaViewerRepeatCurrentItem
|
||||
let originalAutoAdvance = preferences.mediaViewerAutoAdvance
|
||||
|
||||
defer {
|
||||
preferences.mediaViewerRepeatCurrentItem = originalRepeat
|
||||
preferences.mediaViewerAutoAdvance = originalAutoAdvance
|
||||
}
|
||||
|
||||
preferences.mediaViewerRepeatCurrentItem = true
|
||||
preferences.mediaViewerAutoAdvance = false
|
||||
|
||||
let options = NCMediaPlaybackOptions(preferences: preferences)
|
||||
|
||||
#expect(options.isRepeatEnabled)
|
||||
#expect(!options.isAutoAdvanceEnabled)
|
||||
|
||||
options.toggleRepeat()
|
||||
options.toggleAutoAdvance()
|
||||
|
||||
#expect(!preferences.mediaViewerRepeatCurrentItem)
|
||||
#expect(preferences.mediaViewerAutoAdvance)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Testing
|
||||
import UIKit
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("Media viewer floating title")
|
||||
@MainActor
|
||||
struct NCMediaViewerFloatingTitleViewTests {
|
||||
@Test("Preserves the system foreground color")
|
||||
func preservesSystemForegroundColor() throws {
|
||||
let titleView = NCMediaViewerFloatingTitleView()
|
||||
|
||||
titleView.update(
|
||||
primaryText: "Photo.jpg",
|
||||
secondaryText: "13 Aug 2026 at 09:17"
|
||||
)
|
||||
|
||||
let titleButton = try #require(
|
||||
titleView.subviews.first as? UIButton
|
||||
)
|
||||
titleView.frame = CGRect(x: 0, y: 0, width: 300, height: 44)
|
||||
titleView.layoutIfNeeded()
|
||||
|
||||
let configuration = try #require(titleButton.configuration)
|
||||
let transformer = try #require(
|
||||
configuration.titleTextAttributesTransformer
|
||||
)
|
||||
var incoming = AttributeContainer()
|
||||
incoming.uiKit.foregroundColor = .white
|
||||
let outgoing = transformer(incoming)
|
||||
|
||||
#expect(configuration.baseForegroundColor == nil)
|
||||
#expect(titleButton.isEnabled)
|
||||
#expect(titleButton.isUserInteractionEnabled)
|
||||
#expect(titleButton.state == .normal)
|
||||
#expect(titleButton.tintAdjustmentMode == .normal)
|
||||
#expect(
|
||||
titleView.hitTest(
|
||||
CGPoint(x: titleView.bounds.midX, y: titleView.bounds.midY),
|
||||
with: nil
|
||||
) == nil
|
||||
)
|
||||
#expect(titleButton.titleLabel?.text == "Photo.jpg")
|
||||
#expect(titleButton.subtitleLabel?.text == "13 Aug 2026 at 09:17")
|
||||
#expect(outgoing.uiKit.foregroundColor == .white)
|
||||
#expect(
|
||||
outgoing.uiKit.font == UIFont.systemFont(
|
||||
ofSize: 13,
|
||||
weight: .semibold
|
||||
)
|
||||
)
|
||||
|
||||
let normalTextColor = titleButton.titleLabel?.textColor
|
||||
titleView.tintAdjustmentMode = .dimmed
|
||||
titleView.layoutIfNeeded()
|
||||
|
||||
#expect(titleButton.isEnabled)
|
||||
#expect(titleButton.state == .normal)
|
||||
#expect(titleButton.tintAdjustmentMode == .normal)
|
||||
#expect(titleButton.titleLabel?.text == "Photo.jpg")
|
||||
#expect(titleButton.titleLabel?.textColor == normalTextColor)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Testing
|
||||
import NextcloudKit
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("Media viewer model")
|
||||
@MainActor
|
||||
struct NCMediaViewerModelTests {
|
||||
@Test("Duplicate media identifiers produce a single viewer page")
|
||||
func removesDuplicateIdentifiers() {
|
||||
let metadata = tableMetadata()
|
||||
metadata.ocId = "current"
|
||||
|
||||
let model = NCMediaViewerInitialModel(
|
||||
currentMetadata: metadata,
|
||||
ocIds: ["first", "current", "current", "last", "first"]
|
||||
)
|
||||
|
||||
#expect(model.normalizedOcIds == ["first", "current", "last"])
|
||||
#expect(model.currentSelectedIndex == 1)
|
||||
}
|
||||
|
||||
@Test("Missing current media is inserted before the supplied identifiers")
|
||||
func insertsMissingCurrentIdentifier() {
|
||||
let metadata = tableMetadata()
|
||||
metadata.ocId = "current"
|
||||
|
||||
let model = NCMediaViewerInitialModel(
|
||||
currentMetadata: metadata,
|
||||
ocIds: ["next", "next"]
|
||||
)
|
||||
|
||||
#expect(model.normalizedOcIds == ["current", "next"])
|
||||
#expect(model.currentSelectedIndex == 0)
|
||||
}
|
||||
|
||||
@Test("Programmatic paging deactivates media until the target settles")
|
||||
func programmaticPagingActivatesOnlySettledTarget() {
|
||||
let model = makeViewerModel()
|
||||
|
||||
#expect(model.activePageIndex == 0)
|
||||
|
||||
model.beginPageTransition(
|
||||
to: 1,
|
||||
shouldAutoPlay: true
|
||||
)
|
||||
|
||||
#expect(model.pageTransition == .programmatic(targetIndex: 1))
|
||||
#expect(model.selectedIndex == 0)
|
||||
#expect(model.activePageIndex == nil)
|
||||
#expect(model.autoPlayTargetIndex == 1)
|
||||
|
||||
model.finishPageTransition(at: 1)
|
||||
|
||||
#expect(model.pageTransition == .idle)
|
||||
#expect(model.selectedIndex == 1)
|
||||
#expect(model.activePageIndex == 1)
|
||||
#expect(model.autoPlayTargetIndex == 1)
|
||||
}
|
||||
|
||||
@Test("Interactive paging keeps intermediate pages inactive")
|
||||
func interactivePagingKeepsIntermediatePagesInactive() {
|
||||
let model = makeViewerModel()
|
||||
|
||||
model.beginPageTransition(
|
||||
to: nil,
|
||||
shouldAutoPlay: false
|
||||
)
|
||||
model.updateSelectedIndexDuringTransition(1)
|
||||
|
||||
#expect(model.pageTransition == .interactive)
|
||||
#expect(model.selectedIndex == 1)
|
||||
#expect(model.activePageIndex == nil)
|
||||
|
||||
model.finishPageTransition(at: 1)
|
||||
|
||||
#expect(model.pageTransition == .idle)
|
||||
#expect(model.activePageIndex == 1)
|
||||
}
|
||||
|
||||
@Test("Settling on an unexpected page cancels pending autoplay")
|
||||
func unexpectedSettledPageCancelsAutoPlay() {
|
||||
let model = makeViewerModel()
|
||||
|
||||
model.beginPageTransition(
|
||||
to: 2,
|
||||
shouldAutoPlay: true
|
||||
)
|
||||
model.finishPageTransition(at: 1)
|
||||
|
||||
#expect(model.pageTransition == .idle)
|
||||
#expect(model.activePageIndex == 1)
|
||||
#expect(model.autoPlayTargetIndex == nil)
|
||||
}
|
||||
|
||||
@Test("Selection updates are ignored outside an interactive transition")
|
||||
func ignoresTransitionUpdatesWhileIdle() {
|
||||
let model = makeViewerModel()
|
||||
|
||||
model.updateSelectedIndexDuringTransition(1)
|
||||
|
||||
#expect(model.selectedIndex == 0)
|
||||
#expect(model.activePageIndex == 0)
|
||||
}
|
||||
|
||||
@Test("Loading a page does not implicitly change the selection")
|
||||
func loadingDoesNotSelectPage() async {
|
||||
let model = makeViewerModel()
|
||||
|
||||
await model.displayPage(at: 1)
|
||||
|
||||
#expect(model.selectedIndex == 0)
|
||||
#expect(model.activePageIndex == 0)
|
||||
}
|
||||
|
||||
@Test("Regular image previews do not require the original file")
|
||||
func regularImagePreviewDoesNotRequireOriginal() {
|
||||
let metadata = imageMetadata(fileName: "photo.HEIC")
|
||||
let policy = NCMediaViewerLoadingPolicy.standard
|
||||
|
||||
#expect(!policy.shouldDownloadOriginalImage(
|
||||
for: metadata,
|
||||
hasUsablePreview: true
|
||||
))
|
||||
}
|
||||
|
||||
@Test("GIF and SVG images always require the original file")
|
||||
func specialImageFormatsRequireOriginal() {
|
||||
let policy = NCMediaViewerLoadingPolicy.standard
|
||||
|
||||
#expect(policy.shouldDownloadOriginalImage(
|
||||
for: imageMetadata(fileName: "animation.GIF"),
|
||||
hasUsablePreview: true
|
||||
))
|
||||
#expect(policy.shouldDownloadOriginalImage(
|
||||
for: imageMetadata(fileName: "drawing.svg"),
|
||||
hasUsablePreview: true
|
||||
))
|
||||
}
|
||||
|
||||
@Test("A missing preview falls back to the original file")
|
||||
func missingPreviewRequiresOriginal() {
|
||||
let metadata = imageMetadata(fileName: "photo.jpg")
|
||||
let policy = NCMediaViewerLoadingPolicy.standard
|
||||
|
||||
#expect(policy.shouldDownloadOriginalImage(
|
||||
for: metadata,
|
||||
hasUsablePreview: false
|
||||
))
|
||||
}
|
||||
|
||||
@Test("The internal switch restores automatic original downloads")
|
||||
func internalSwitchEnablesOriginalDownloads() {
|
||||
let metadata = imageMetadata(fileName: "photo.jpg")
|
||||
let policy = NCMediaViewerLoadingPolicy(
|
||||
automaticallyDownloadsOriginalImages: true,
|
||||
automaticallyDownloadsLivePhotoResources: false
|
||||
)
|
||||
|
||||
#expect(policy.shouldDownloadOriginalImage(
|
||||
for: metadata,
|
||||
hasUsablePreview: true
|
||||
))
|
||||
}
|
||||
|
||||
@Test("Live Photo resources remain on demand unless their switch is enabled")
|
||||
func livePhotoResourcesRespectInternalSwitch() {
|
||||
let metadata = imageMetadata(fileName: "live-photo.heic")
|
||||
metadata.livePhotoFile = "live-photo.mov"
|
||||
|
||||
#expect(!NCMediaViewerLoadingPolicy.standard.shouldDownloadLivePhotoResources(
|
||||
for: metadata
|
||||
))
|
||||
|
||||
let automaticPolicy = NCMediaViewerLoadingPolicy(
|
||||
automaticallyDownloadsOriginalImages: false,
|
||||
automaticallyDownloadsLivePhotoResources: true
|
||||
)
|
||||
|
||||
#expect(automaticPolicy.shouldDownloadLivePhotoResources(for: metadata))
|
||||
#expect(automaticPolicy.shouldDownloadOriginalImage(
|
||||
for: metadata,
|
||||
hasUsablePreview: true
|
||||
))
|
||||
}
|
||||
|
||||
private func makeViewerModel() -> NCMediaViewerModel {
|
||||
let metadata = tableMetadata()
|
||||
metadata.ocId = "first"
|
||||
|
||||
return NCMediaViewerModel(
|
||||
currentMetadata: metadata,
|
||||
ocIds: ["first", "second", "third"],
|
||||
session: NCSession().getSession(account: ""),
|
||||
loader: NCMediaViewerLoader()
|
||||
)
|
||||
}
|
||||
|
||||
private func imageMetadata(fileName: String) -> tableMetadata {
|
||||
let metadata = tableMetadata()
|
||||
metadata.classFile = NKTypeClassFile.image.rawValue
|
||||
metadata.fileName = fileName
|
||||
metadata.fileNameView = fileName
|
||||
return metadata
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2026 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Testing
|
||||
@testable import Nextcloud
|
||||
|
||||
@Suite("Video playback presentation context")
|
||||
struct NCVideoPlaybackPresentationContextTests {
|
||||
@Test("User-initiated playback starts with visible controls")
|
||||
func userInitiatedPlaybackShowsControls() {
|
||||
var context = NCVideoPlaybackPresentationContext(
|
||||
startReason: .userInitiated
|
||||
)
|
||||
|
||||
context.prepareForPlaybackStart()
|
||||
|
||||
#expect(context.shouldShowControlsOnStart)
|
||||
#expect(context.playbackTransition == .idle)
|
||||
#expect(!context.shouldSuppressAutomaticControlsPresentation)
|
||||
}
|
||||
|
||||
@Test("Automatic advancement starts without presenting controls")
|
||||
func automaticAdvanceSuppressesControls() {
|
||||
var context = NCVideoPlaybackPresentationContext(
|
||||
startReason: .automaticAdvance
|
||||
)
|
||||
|
||||
context.prepareForPlaybackStart()
|
||||
|
||||
#expect(!context.shouldShowControlsOnStart)
|
||||
#expect(context.playbackTransition == .automaticStart)
|
||||
#expect(context.shouldSuppressAutomaticControlsPresentation)
|
||||
|
||||
context.finishPlaybackTransition()
|
||||
|
||||
#expect(context.playbackTransition == .idle)
|
||||
#expect(!context.shouldSuppressAutomaticControlsPresentation)
|
||||
#expect(context.shouldShowControlsOnStart)
|
||||
}
|
||||
|
||||
@Test("Repeat restart suppresses automatic control presentation")
|
||||
func repeatRestartSuppressesControls() {
|
||||
var context = NCVideoPlaybackPresentationContext(
|
||||
startReason: .userInitiated
|
||||
)
|
||||
|
||||
context.beginRepeatRestart()
|
||||
|
||||
#expect(context.playbackTransition == .repeatRestart)
|
||||
#expect(context.shouldSuppressAutomaticControlsPresentation)
|
||||
|
||||
context.finishPlaybackTransition()
|
||||
|
||||
#expect(context.playbackTransition == .idle)
|
||||
#expect(!context.shouldSuppressAutomaticControlsPresentation)
|
||||
}
|
||||
|
||||
@Test("Seeking is represented by the shared transition state")
|
||||
func seekingUsesSharedTransition() {
|
||||
var context = NCVideoPlaybackPresentationContext(
|
||||
startReason: .userInitiated
|
||||
)
|
||||
|
||||
context.beginSeeking()
|
||||
|
||||
#expect(context.interaction == .seeking)
|
||||
#expect(context.isSeeking)
|
||||
#expect(context.shouldSuppressAutomaticControlsPresentation)
|
||||
|
||||
context.finishSeeking()
|
||||
|
||||
#expect(!context.isSeeking)
|
||||
}
|
||||
|
||||
@Test("Playback callbacks preserve seeking and complete automatic start")
|
||||
func playbackCallbackPreservesSeekingAndCompletesAutomaticStart() {
|
||||
var context = NCVideoPlaybackPresentationContext(
|
||||
startReason: .automaticAdvance
|
||||
)
|
||||
|
||||
context.prepareForPlaybackStart()
|
||||
context.beginSeeking()
|
||||
context.finishPlaybackTransition()
|
||||
|
||||
#expect(context.isSeeking)
|
||||
#expect(context.playbackTransition == .idle)
|
||||
#expect(context.shouldShowControlsOnStart)
|
||||
#expect(context.shouldSuppressAutomaticControlsPresentation)
|
||||
|
||||
context.finishSeeking()
|
||||
|
||||
#expect(!context.shouldSuppressAutomaticControlsPresentation)
|
||||
}
|
||||
|
||||
@Test("Reset clears playback and interaction transitions")
|
||||
func resetClearsAllTransitions() {
|
||||
var context = NCVideoPlaybackPresentationContext(
|
||||
startReason: .automaticAdvance
|
||||
)
|
||||
|
||||
context.prepareForPlaybackStart()
|
||||
context.beginSeeking()
|
||||
context.reset()
|
||||
|
||||
#expect(context.playbackTransition == .idle)
|
||||
#expect(context.interaction == .idle)
|
||||
#expect(!context.shouldSuppressAutomaticControlsPresentation)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2025 Iva Horn
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// There are no unit tests yet.
|
||||
// This is an empty placeholder file.
|
||||
// The compiler requires at least an empty file for every target.
|
||||
@@ -1,32 +1,12 @@
|
||||
//
|
||||
// DashboardData.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 20/08/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
import Intents
|
||||
import NextcloudKit
|
||||
import RealmSwift
|
||||
import SVGKit
|
||||
|
||||
struct DashboardDataEntry: TimelineEntry {
|
||||
let date: Date
|
||||
@@ -48,22 +28,22 @@ struct DashboardData: Identifiable, Hashable {
|
||||
let subTitle: String
|
||||
let link: URL
|
||||
let icon: UIImage
|
||||
let template: Bool
|
||||
let avatar: Bool
|
||||
let circle: Bool
|
||||
let imageSystem: Bool
|
||||
let imageColor: UIColor?
|
||||
}
|
||||
|
||||
let dashboardDatasTest: [DashboardData] = [
|
||||
.init(id: 0, title: "title0", subTitle: "subTitle-description0", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 1, title: "title1", subTitle: "subTitle-description1", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 2, title: "title2", subTitle: "subTitle-description2", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 3, title: "title3", subTitle: "subTitle-description3", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 4, title: "title4", subTitle: "subTitle-description4", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 5, title: "title5", subTitle: "subTitle-description5", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 6, title: "title6", subTitle: "subTitle-description6", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 7, title: "title7", subTitle: "subTitle-description7", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 8, title: "title8", subTitle: "subTitle-description8", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
|
||||
.init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil)
|
||||
.init(id: 0, title: "title0", subTitle: "subTitle-description0", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "document")!, circle: false, imageSystem: true, imageColor: nil),
|
||||
.init(id: 1, title: "title1", subTitle: "subTitle-description1", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "document")!, circle: false, imageSystem: true, imageColor: nil),
|
||||
.init(id: 2, title: "title2", subTitle: "subTitle-description2", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "document")!, circle: true, imageSystem: false, imageColor: nil),
|
||||
.init(id: 3, title: "title3", subTitle: "subTitle-description3", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "document")!, circle: false, imageSystem: false, imageColor: nil),
|
||||
.init(id: 4, title: "title4", subTitle: "subTitle-description4", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "circle.fill")!, circle: false, imageSystem: false, imageColor: nil),
|
||||
.init(id: 5, title: "title5", subTitle: "subTitle-description5", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "circle.fill")!, circle: false, imageSystem: false, imageColor: nil),
|
||||
.init(id: 6, title: "title6", subTitle: "subTitle-description6", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "circle.fill")!, circle: false, imageSystem: false, imageColor: nil),
|
||||
.init(id: 7, title: "title7", subTitle: "subTitle-description7", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "circle.fill")!, circle: false, imageSystem: false, imageColor: nil),
|
||||
.init(id: 8, title: "title8", subTitle: "subTitle-description8", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "circle.fill")!, circle: false, imageSystem: false, imageColor: nil),
|
||||
.init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(systemName: "circle.fill")!, circle: false, imageSystem: false, imageColor: nil)
|
||||
]
|
||||
|
||||
func getDashboardItems(displaySize: CGSize, withButton: Bool) -> Int {
|
||||
@@ -76,31 +56,7 @@ func getDashboardItems(displaySize: CGSize, withButton: Bool) -> Int {
|
||||
}
|
||||
}
|
||||
|
||||
func convertDataToImage(data: Data?, size: CGSize, fileNameToWrite: String?) -> UIImage? {
|
||||
guard let data = data else {
|
||||
return nil
|
||||
}
|
||||
var imageData: UIImage?
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
|
||||
if let image = UIImage(data: data), let image = image.resizeImage(size: size) {
|
||||
imageData = image
|
||||
} else if let image = SVGKImage(data: data) {
|
||||
image.size = size
|
||||
imageData = image.uiImage
|
||||
} else {
|
||||
print("error")
|
||||
}
|
||||
if let fileName = fileNameToWrite, let image = imageData {
|
||||
do {
|
||||
let fileNamePath: String = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryUserData, fileName: fileName + ".png")
|
||||
try image.pngData()?.write(to: URL(fileURLWithPath: fileNamePath), options: .atomic)
|
||||
} catch { }
|
||||
}
|
||||
return imageData
|
||||
}
|
||||
|
||||
func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
|
||||
func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, displaySize: CGSize) async -> DashboardDataEntry {
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let utility = NCUtility()
|
||||
let dashboardItems = getDashboardItems(displaySize: displaySize, withButton: false)
|
||||
@@ -108,14 +64,15 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
|
||||
var activeTableAccount: tableAccount?
|
||||
let versionApp = NCUtility().getVersionMaintenance()
|
||||
|
||||
if let groupDefaults = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup),
|
||||
guard let groupDefaults = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup),
|
||||
let lastVersion = groupDefaults.string(forKey: NCGlobal.shared.udLastVersion),
|
||||
lastVersion != versionApp {
|
||||
return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NSLocalizedString("_version_mismatch_error_", comment: ""), account: ""))
|
||||
lastVersion == versionApp else {
|
||||
return (DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(systemName: "circle.fill") ?? UIImage(), title: "Dashboard", footerImage: "checkmark.icloud", footerText: NSLocalizedString("_version_mismatch_error_", comment: ""), account: ""))
|
||||
}
|
||||
|
||||
if isPreview {
|
||||
return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard", account: ""))
|
||||
if isPreview,
|
||||
let image = UIImage(systemName: "circle.fill") {
|
||||
return (DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: image, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard", account: ""))
|
||||
}
|
||||
|
||||
let accountIdentifier: String = configuration?.accounts?.identifier ?? "active"
|
||||
@@ -126,22 +83,14 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
|
||||
}
|
||||
|
||||
guard let activeTableAccount else {
|
||||
return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", comment: ""), account: ""))
|
||||
return (DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(systemName: "circle.fill") ?? UIImage(), title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", comment: ""), account: ""))
|
||||
}
|
||||
|
||||
// Default widget
|
||||
let result = NCManageDatabase.shared.getDashboardWidgetApplications(account: activeTableAccount.account).first
|
||||
let id: String = configuration?.applications?.identifier ?? (result?.id ?? "recommendations")
|
||||
|
||||
// NETWORKING
|
||||
let password = NCPreferences().getPassword(account: activeTableAccount.account)
|
||||
|
||||
NextcloudKit.shared.setup(groupIdentifier: NCBrandOptions.shared.capabilitiesGroup, delegate: NCNetworking.shared)
|
||||
NextcloudKit.shared.appendSession(account: activeTableAccount.account,
|
||||
urlBase: activeTableAccount.urlBase,
|
||||
user: activeTableAccount.user,
|
||||
userId: activeTableAccount.userId,
|
||||
password: password,
|
||||
password: NCPreferences().getPassword(account: activeTableAccount.account),
|
||||
userAgent: userAgent,
|
||||
httpMaximumConnectionsPerHost: NCBrandOptions.shared.httpMaximumConnectionsPerHost,
|
||||
httpMaximumConnectionsPerHostInDownload: NCBrandOptions.shared.httpMaximumConnectionsPerHostInDownload,
|
||||
@@ -150,115 +99,109 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
|
||||
|
||||
// LOG
|
||||
let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, utility.getVersionBuild())
|
||||
|
||||
NextcloudKit.configureLogger(logLevel: (NCBrandOptions.shared.disable_log ? .disabled : NCPreferences().log))
|
||||
|
||||
nkLog(debug: "Start \(NCBrandOptions.shared.brand) dashboard widget session " + versionNextcloudiOS)
|
||||
|
||||
let (tableDashboard, tableButton) = NCManageDatabase.shared.getDashboardWidget(account: activeTableAccount.account, id: id)
|
||||
let existsButton = (tableButton?.isEmpty ?? true) ? false : true
|
||||
let title = tableDashboard?.title ?? id
|
||||
// Widget
|
||||
let widgetApplication = NCManageDatabase.shared.getDashboardWidgetApplications(account: activeTableAccount.account).first
|
||||
let widgetApplicationId: String = configuration?.applications?.identifier ?? (widgetApplication?.id ?? "recommendations")
|
||||
|
||||
var imagetmp = UIImage(named: "widget")!
|
||||
let (tableDashboard, tableButton) = NCManageDatabase.shared.getDashboardWidget(account: activeTableAccount.account, id: widgetApplicationId)
|
||||
let existsButton = (tableButton?.isEmpty ?? true) ? false : true
|
||||
let title = tableDashboard?.title ?? widgetApplicationId
|
||||
|
||||
var titleImage: UIImage = UIImage(systemName: "circle.fill") ?? UIImage()
|
||||
if let fileName = tableDashboard?.iconClass {
|
||||
let fileNamePath: String = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryUserData, fileName: fileName + ".png")
|
||||
if let image = UIImage(contentsOfFile: fileNamePath) {
|
||||
imagetmp = image.withTintColor(NCBrandColor.shared.iconImageColor, renderingMode: .alwaysOriginal)
|
||||
titleImage = image.withTintColor(NCBrandColor.shared.iconImageColor, renderingMode: .alwaysOriginal)
|
||||
}
|
||||
}
|
||||
let titleImage = imagetmp
|
||||
|
||||
let options = NKRequestOptions(timeout: 90, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
||||
NextcloudKit.shared.getDashboardWidgetsApplication(id, account: activeTableAccount.account, options: options) { account, results, responseData, error in
|
||||
Task {
|
||||
var datas = [DashboardData]()
|
||||
var numberItems = 0
|
||||
let resultsDashboardWidget = await NextcloudKit.shared.getDashboardWidgetsApplicationAsync(widgetApplicationId, account: activeTableAccount.account, options: options)
|
||||
|
||||
if let results = results {
|
||||
for result in results {
|
||||
if let items = result.items {
|
||||
numberItems = result.items?.count ?? 0
|
||||
var counter: Int = 0
|
||||
let dashboardItems = getDashboardItems(displaySize: displaySize, withButton: existsButton)
|
||||
for item in items {
|
||||
counter += 1
|
||||
let title = item.title ?? ""
|
||||
let subtitle = item.subtitle ?? ""
|
||||
var link = URL(string: "https://")!
|
||||
if let entryLink = item.link, let url = URL(string: entryLink) { link = url }
|
||||
var icon = UIImage(named: "file")!
|
||||
var iconFileName: String?
|
||||
var datas = [DashboardData]()
|
||||
var numberItems = 0
|
||||
|
||||
var imageTemplate: Bool = false
|
||||
var imageAvatar: Bool = false
|
||||
var imageColorized: Bool = false
|
||||
var imageColor: UIColor?
|
||||
if resultsDashboardWidget.error == .success,
|
||||
let dashboardApplications = resultsDashboardWidget.dashboardApplications {
|
||||
for dashboardApplication in dashboardApplications {
|
||||
if let items = dashboardApplication.items {
|
||||
numberItems = dashboardApplication.items?.count ?? 0
|
||||
var counter: Int = 0
|
||||
let dashboardItems = getDashboardItems(displaySize: displaySize, withButton: existsButton)
|
||||
for item in items {
|
||||
counter += 1
|
||||
|
||||
if let iconUrl = item.iconUrl, let url = URL(string: iconUrl) {
|
||||
if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
|
||||
let title = item.title ?? ""
|
||||
let subtitle = item.subtitle ?? ""
|
||||
|
||||
let path = (urlComponents.path as NSString)
|
||||
let pathComponents = path.components(separatedBy: "/")
|
||||
let queryItems = urlComponents.queryItems
|
||||
var link: URL = URL(string: "https://")!
|
||||
if let entryLink = item.link,
|
||||
let url = URL(string: entryLink) {
|
||||
link = url
|
||||
}
|
||||
var iconImage = UIImage(systemName: "document") ?? UIImage()
|
||||
var imageCircle: Bool = false
|
||||
var imageColorized: Bool = false
|
||||
var imageSystem: Bool = false
|
||||
var imageColor: UIColor?
|
||||
|
||||
if (pathComponents.last as? NSString)?.pathExtension.lowercased() == "svg" {
|
||||
imageTemplate = true
|
||||
}
|
||||
if let item = queryItems?.filter({ $0.name == "fileId" }).first?.value {
|
||||
iconFileName = item
|
||||
} else if pathComponents.contains("avatar") {
|
||||
iconFileName = pathComponents[pathComponents.count - 2]
|
||||
imageAvatar = true
|
||||
} else if pathComponents.contains("getCalendarDotSvg") {
|
||||
imageColorized = true
|
||||
} else {
|
||||
iconFileName = ((path.lastPathComponent) as NSString).deletingPathExtension
|
||||
}
|
||||
}
|
||||
// Color
|
||||
if imageColorized, let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
|
||||
let path = (urlComponents.path as NSString)
|
||||
let colorString = ((path.lastPathComponent) as NSString).deletingPathExtension
|
||||
imageColor = UIColor(hex: colorString)
|
||||
icon = utility.loadImage(named: "circle.fill")
|
||||
} else if let fileName = iconFileName {
|
||||
let fileNamePath: String = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryUserData, fileName: fileName + ".png")
|
||||
if FileManager().fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
|
||||
icon = image
|
||||
} else {
|
||||
let (_, _, error) = await NextcloudKit.shared.downloadPreviewAsync(url: url, account: activeTableAccount.account)
|
||||
if error == .success,
|
||||
let data = responseData?.data,
|
||||
let image = convertDataToImage(data: data, size: NCGlobal.shared.size256, fileNameToWrite: fileName) {
|
||||
icon = image
|
||||
}
|
||||
}
|
||||
}
|
||||
if let iconUrl = item.iconUrl, let url = URL(string: iconUrl) {
|
||||
if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
|
||||
let path = (urlComponents.path as NSString)
|
||||
let pathComponents = path.components(separatedBy: "/")
|
||||
|
||||
if pathComponents.contains("avatar") {
|
||||
imageCircle = true
|
||||
} else if pathComponents.contains("getCalendarDotSvg") {
|
||||
imageColorized = true
|
||||
}
|
||||
}
|
||||
// Color
|
||||
if imageColorized, let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
|
||||
let path = (urlComponents.path as NSString)
|
||||
let colorString = ((path.lastPathComponent) as NSString).deletingPathExtension
|
||||
imageColor = UIColor(hex: colorString)
|
||||
iconImage = UIImage(systemName: "circle.fill") ?? UIImage()
|
||||
} else {
|
||||
let results = await NextcloudKit.shared.downloadPreviewAsync(url: url, account: activeTableAccount.account)
|
||||
if results.error == .success,
|
||||
let data = results.responseData?.data {
|
||||
if let image = UIImage(data: data) {
|
||||
iconImage = image
|
||||
} else {
|
||||
imageSystem = true
|
||||
}
|
||||
/* NO MEMORY
|
||||
else if let image = try? await NCSVGRenderer().renderSVGToUIImage(svgData: data) {
|
||||
iconImage = image
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
let data = DashboardData(id: counter, title: title, subTitle: subtitle, link: link, icon: icon, template: imageTemplate, avatar: imageAvatar, imageColor: imageColor)
|
||||
datas.append(data)
|
||||
|
||||
if datas.count == dashboardItems { break }
|
||||
}
|
||||
}
|
||||
|
||||
let data = DashboardData(id: counter, title: title, subTitle: subtitle, link: link, icon: iconImage, circle: imageCircle, imageSystem: imageSystem, imageColor: imageColor)
|
||||
datas.append(data)
|
||||
|
||||
if datas.count == dashboardItems { break }
|
||||
}
|
||||
}
|
||||
|
||||
var buttons = tableButton
|
||||
if numberItems == datas.count, let tableButton = tableButton, tableButton.contains(where: { $0.type == "more"}) {
|
||||
buttons = tableButton.filter(({ $0.type != "more" }))
|
||||
}
|
||||
|
||||
let alias = (activeTableAccount.alias.isEmpty) ? "" : (" (" + activeTableAccount.alias + ")")
|
||||
let footerText = "Dashboard " + NSLocalizedString("_of_", comment: "") + " " + activeTableAccount.displayName + alias
|
||||
|
||||
if error != .success {
|
||||
completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: tableDashboard, buttons: buttons, isPlaceholder: true, isEmpty: false, titleImage: titleImage, title: title, footerImage: "xmark.icloud", footerText: error.errorDescription, account: account))
|
||||
} else {
|
||||
completion(DashboardDataEntry(date: Date(), datas: datas, dashboard: tableDashboard, buttons: buttons, isPlaceholder: false, isEmpty: datas.isEmpty, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: footerText, account: account))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var buttons = tableButton
|
||||
if numberItems == datas.count, let tableButton = tableButton, tableButton.contains(where: { $0.type == "more"}) {
|
||||
buttons = tableButton.filter(({ $0.type != "more" }))
|
||||
}
|
||||
|
||||
let alias = (activeTableAccount.alias.isEmpty) ? "" : (" (" + activeTableAccount.alias + ")")
|
||||
let footerText = "Dashboard " + NSLocalizedString("_of_", comment: "") + " " + activeTableAccount.displayName + alias
|
||||
|
||||
if resultsDashboardWidget.error != .success {
|
||||
return(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: tableDashboard, buttons: buttons, isPlaceholder: true, isEmpty: false, titleImage: titleImage, title: title, footerImage: "xmark.icloud", footerText: resultsDashboardWidget.error.errorDescription, account: activeTableAccount.account))
|
||||
} else {
|
||||
return(DashboardDataEntry(date: Date(), datas: datas, dashboard: tableDashboard, buttons: buttons, isPlaceholder: false, isEmpty: datas.isEmpty, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: footerText, account: activeTableAccount.account))
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,6 @@
|
||||
//
|
||||
// DashboardWidgetProvider.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 25/08/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
@@ -34,18 +15,20 @@ struct DashboardWidgetProvider: IntentTimelineProvider {
|
||||
let dashboardItems = getDashboardItems(displaySize: context.displaySize, withButton: false)
|
||||
let datasPlaceholder = Array(dashboardDatasTest[0...dashboardItems])
|
||||
let title = "Dashboard"
|
||||
let titleImage = UIImage(named: "widget")!
|
||||
let titleImage = UIImage(systemName: "circle.fill") ?? UIImage()
|
||||
return Entry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget", account: "")
|
||||
}
|
||||
|
||||
func getSnapshot(for configuration: DashboardIntent, in context: Context, completion: @escaping (DashboardDataEntry) -> Void) {
|
||||
getDashboardDataEntry(configuration: configuration, isPreview: false, displaySize: context.displaySize) { entry in
|
||||
Task {
|
||||
let entry = await getDashboardDataEntry(configuration: configuration, isPreview: false, displaySize: context.displaySize)
|
||||
completion(entry)
|
||||
}
|
||||
}
|
||||
|
||||
func getTimeline(for configuration: DashboardIntent, in context: Context, completion: @escaping (Timeline<DashboardDataEntry>) -> Void) {
|
||||
getDashboardDataEntry(configuration: configuration, isPreview: context.isPreview, displaySize: context.displaySize) { entry in
|
||||
Task {
|
||||
let entry = await getDashboardDataEntry(configuration: configuration, isPreview: context.isPreview, displaySize: context.displaySize)
|
||||
let timeLine = Timeline(entries: [entry], policy: .atEnd)
|
||||
completion(timeLine)
|
||||
}
|
||||
|
||||
@@ -1,25 +1,6 @@
|
||||
//
|
||||
// DashboardWidgetView.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 20/08/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
@@ -61,21 +42,13 @@ struct DashboardWidgetView: View {
|
||||
}
|
||||
.frame(width: geo.size.width - 20)
|
||||
.padding([.top, .leading, .trailing], 10)
|
||||
|
||||
if !entry.isEmpty {
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
|
||||
VStack(spacing: 0) {
|
||||
|
||||
ForEach(entry.datas, id: \.id) { element in
|
||||
|
||||
Link(destination: element.link) {
|
||||
|
||||
HStack {
|
||||
|
||||
let subTitleColor = Color(white: 0.5)
|
||||
|
||||
if entry.isPlaceholder {
|
||||
Circle()
|
||||
.fill(Color(.systemGray4))
|
||||
@@ -84,30 +57,17 @@ struct DashboardWidgetView: View {
|
||||
Image(uiImage: element.icon)
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
.frame(width: 35, height: 35)
|
||||
.foregroundColor(Color(color))
|
||||
} else if element.template {
|
||||
if entry.dashboard?.itemIconsRound ?? false {
|
||||
Image(uiImage: element.icon)
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundColor(.white)
|
||||
.padding(8)
|
||||
.background(Color(.systemGray4))
|
||||
.clipShape(Circle())
|
||||
} else {
|
||||
Image(uiImage: element.icon)
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: 25, height: 25)
|
||||
.clipped()
|
||||
.cornerRadius(5)
|
||||
}
|
||||
.scaleEffect(0.8)
|
||||
} else if element.imageSystem {
|
||||
Image(uiImage: element.icon)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 35, height: 35)
|
||||
.scaleEffect(0.8)
|
||||
} else {
|
||||
if entry.dashboard?.itemIconsRound ?? false || element.avatar {
|
||||
if entry.dashboard?.itemIconsRound ?? false || element.circle {
|
||||
Image(uiImage: element.icon)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
@@ -150,7 +110,6 @@ struct DashboardWidgetView: View {
|
||||
}
|
||||
|
||||
if let buttons = entry.buttons, !buttons.isEmpty, !entry.isPlaceholder {
|
||||
|
||||
HStack(spacing: 10) {
|
||||
let brandColor = Color(NCBrandColor.shared.getElement(account: entry.account))
|
||||
let brandTextColor = Color(NCBrandColor.shared.getText(account: entry.account))
|
||||
@@ -172,7 +131,6 @@ struct DashboardWidgetView: View {
|
||||
}
|
||||
|
||||
HStack {
|
||||
|
||||
Image(systemName: entry.footerImage)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
@@ -186,10 +144,10 @@ struct DashboardWidgetView: View {
|
||||
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getElement(account: entry.account)))
|
||||
}
|
||||
.padding(.horizontal, 15.0)
|
||||
.frame(maxWidth: geo.size.width, maxHeight: geo.size.height - 2, alignment: .bottomTrailing)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
||||
}
|
||||
}
|
||||
.widgetBackground(Color(UIColor.systemBackground))
|
||||
.containerBackground(.background, for: .widget)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,8 +155,8 @@ struct DashboardWidget_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let datas = Array(dashboardDatasTest[0...4])
|
||||
let title = "Dashboard"
|
||||
let titleImage = UIImage(named: "widget")!
|
||||
let entry = DashboardDataEntry(date: Date(), datas: datas, dashboard: nil, buttons: nil, isPlaceholder: false, isEmpty: true, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: "Nextcloud widget", account: "")
|
||||
let titleImage = UIImage(systemName: "circle.fill")!
|
||||
let entry = DashboardDataEntry(date: Date(), datas: datas, dashboard: nil, buttons: nil, isPlaceholder: false, isEmpty: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget", account: "")
|
||||
DashboardWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,6 @@
|
||||
//
|
||||
// FilesData.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 25/08/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
@@ -49,16 +30,16 @@ struct FilesData: Identifiable, Hashable {
|
||||
}
|
||||
|
||||
let filesDatasTest: [FilesData] = [
|
||||
.init(id: "0", image: UIImage(named: "widget")!, title: "title1", subTitle: "subTitle-description1", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "1", image: UIImage(named: "widget")!, title: "title2", subTitle: "subTitle-description2", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "2", image: UIImage(named: "widget")!, title: "title3", subTitle: "subTitle-description3", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "3", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "4", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "5", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "6", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "7", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "8", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "9", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!)
|
||||
.init(id: "0", image: UIImage(systemName: "circle.fill")!, title: "title1", subTitle: "subTitle-description1", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "1", image: UIImage(systemName: "circle.fill")!, title: "title2", subTitle: "subTitle-description2", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "2", image: UIImage(systemName: "circle.fill")!, title: "title3", subTitle: "subTitle-description3", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "3", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "4", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "5", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "6", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "7", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "8", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
|
||||
.init(id: "9", image: UIImage(systemName: "circle.fill")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!)
|
||||
]
|
||||
|
||||
func getTitleFilesWidget(tableAccount: tableAccount?) -> String {
|
||||
@@ -80,27 +61,22 @@ func getTitleFilesWidget(tableAccount: tableAccount?) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
func getFilesItems(displaySize: CGSize) -> Int {
|
||||
let items = Int((displaySize.height - 90) / 55)
|
||||
return items
|
||||
}
|
||||
|
||||
func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: FilesDataEntry) -> Void) {
|
||||
func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySize: CGSize) async -> FilesDataEntry {
|
||||
let utilityFileSystem = NCUtilityFileSystem()
|
||||
let utility = NCUtility()
|
||||
let filesItems = getFilesItems(displaySize: displaySize)
|
||||
let datasPlaceholder = Array(filesDatasTest[0...filesItems - 1])
|
||||
let maxItems = 5
|
||||
let datasPlaceholder = Array(filesDatasTest[0...maxItems - 1])
|
||||
var activeTableAccount: tableAccount?
|
||||
let versionApp = NCUtility().getVersionMaintenance()
|
||||
|
||||
if let groupDefaults = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup),
|
||||
let lastVersion = groupDefaults.string(forKey: NCGlobal.shared.udLastVersion),
|
||||
lastVersion != versionApp {
|
||||
return completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: getTitleFilesWidget(tableAccount: nil), footerImage: "checkmark.icloud", footerText: NSLocalizedString("_version_mismatch_error_", comment: "")))
|
||||
return (FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: getTitleFilesWidget(tableAccount: nil), footerImage: "checkmark.icloud", footerText: NSLocalizedString("_version_mismatch_error_", comment: "")))
|
||||
}
|
||||
|
||||
if isPreview {
|
||||
return completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: getTitleFilesWidget(tableAccount: nil), footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " files"))
|
||||
return (FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: getTitleFilesWidget(tableAccount: nil), footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " files"))
|
||||
}
|
||||
|
||||
let accountIdentifier: String = configuration?.accounts?.identifier ?? "active"
|
||||
@@ -111,18 +87,15 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
|
||||
}
|
||||
|
||||
guard let activeTableAccount else {
|
||||
return completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: getTitleFilesWidget(tableAccount: nil), footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
|
||||
return (FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: getTitleFilesWidget(tableAccount: nil), footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
|
||||
}
|
||||
|
||||
// NETWORKING
|
||||
let password = NCPreferences().getPassword(account: activeTableAccount.account)
|
||||
|
||||
NextcloudKit.shared.setup(groupIdentifier: NCBrandOptions.shared.capabilitiesGroup, delegate: NCNetworking.shared)
|
||||
NextcloudKit.shared.appendSession(account: activeTableAccount.account,
|
||||
urlBase: activeTableAccount.urlBase,
|
||||
user: activeTableAccount.user,
|
||||
userId: activeTableAccount.userId,
|
||||
password: password,
|
||||
password: NCPreferences().getPassword(account: activeTableAccount.account),
|
||||
userAgent: userAgent,
|
||||
httpMaximumConnectionsPerHost: NCBrandOptions.shared.httpMaximumConnectionsPerHost,
|
||||
httpMaximumConnectionsPerHostInDownload: NCBrandOptions.shared.httpMaximumConnectionsPerHostInDownload,
|
||||
@@ -189,82 +162,79 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
|
||||
|
||||
// LOG
|
||||
let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, utility.getVersionBuild())
|
||||
|
||||
NextcloudKit.configureLogger(logLevel: (NCBrandOptions.shared.disable_log ? .disabled : NCPreferences().log))
|
||||
|
||||
nkLog(debug: "Start \(NCBrandOptions.shared.brand) widget session " + versionNextcloudiOS)
|
||||
|
||||
let options = NKRequestOptions(timeout: 30, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
||||
NextcloudKit.shared.searchBodyRequest(serverUrl: activeTableAccount.urlBase, requestBody: requestBody, showHiddenFiles: showHiddenFiles, account: activeTableAccount.account, options: options) { _, files, data, error in
|
||||
Task {
|
||||
var datas: [FilesData] = []
|
||||
let title = getTitleFilesWidget(tableAccount: activeTableAccount)
|
||||
let files = files?.sorted(by: { ($0.date as Date) > ($1.date as Date) }) ?? []
|
||||
let results = await NextcloudKit.shared.searchBodyRequestAsync(serverUrl: activeTableAccount.urlBase, requestBody: requestBody, showHiddenFiles: showHiddenFiles, account: activeTableAccount.account, options: options)
|
||||
|
||||
for file in files {
|
||||
var useTypeIconFile = false
|
||||
var image: UIImage?
|
||||
var datas: [FilesData] = []
|
||||
let title = getTitleFilesWidget(tableAccount: activeTableAccount)
|
||||
let files = results.files?.sorted(by: { ($0.date as Date) > ($1.date as Date) }) ?? []
|
||||
|
||||
if file.directory || (!file.livePhotoFile.isEmpty && file.classFile == NKTypeClassFile.video.rawValue) {
|
||||
continue
|
||||
}
|
||||
for file in files {
|
||||
var useTypeIconFile = false
|
||||
var image: UIImage?
|
||||
|
||||
// SUBTITLE
|
||||
let subTitle = utility.getRelativeDateTitle(file.date as Date) + " · " + utilityFileSystem.transformedSize(file.size)
|
||||
if file.directory || (!file.livePhotoFile.isEmpty && file.classFile == NKTypeClassFile.video.rawValue) {
|
||||
continue
|
||||
}
|
||||
|
||||
// URL: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
|
||||
guard var path = utilityFileSystem.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
|
||||
if path.first == "/" { path = String(path.dropFirst())}
|
||||
guard let user = file.user.urlEncoded else { continue }
|
||||
let link = file.urlBase + "/f/" + file.fileId
|
||||
let urlString = "nextcloud://open-file?path=\(path)&user=\(user)&link=\(link)"
|
||||
guard let url = URL(string: urlString) else { continue }
|
||||
// SUBTITLE
|
||||
let subTitle = utility.getRelativeDateTitle(file.date as Date) + " · " + utilityFileSystem.transformedSize(file.size)
|
||||
|
||||
// IMAGE
|
||||
// URL: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
|
||||
guard var path = utilityFileSystem.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
|
||||
if path.first == "/" { path = String(path.dropFirst())}
|
||||
let link = file.urlBase + "/f/" + file.fileId
|
||||
let urlString = "nextcloud://open-file?path=\(path)&user=\(file.userId)&link=\(link)&account=\(file.account)"
|
||||
guard let url = URL(string: urlString) else { continue }
|
||||
|
||||
// IMAGE
|
||||
image = utility.getImage(ocId: file.ocId,
|
||||
etag: file.etag,
|
||||
ext: NCGlobal.shared.previewExt512,
|
||||
userId: activeTableAccount.userId,
|
||||
urlBase: activeTableAccount.urlBase)
|
||||
if image == nil, file.hasPreview {
|
||||
let result = await NextcloudKit.shared.downloadPreviewAsync(fileId: file.fileId,
|
||||
etag: file.etag,
|
||||
account: activeTableAccount.account,
|
||||
options: options)
|
||||
if result.error == .success, let data = result.responseData?.data {
|
||||
utility.createImageFileFrom(data: data,
|
||||
ocId: file.ocId,
|
||||
etag: file.etag,
|
||||
userId: activeTableAccount.userId,
|
||||
urlBase: activeTableAccount.urlBase)
|
||||
image = utility.getImage(ocId: file.ocId,
|
||||
etag: file.etag,
|
||||
ext: NCGlobal.shared.previewExt512,
|
||||
ext: NCGlobal.shared.previewExt256,
|
||||
userId: activeTableAccount.userId,
|
||||
urlBase: activeTableAccount.urlBase)
|
||||
if image == nil, file.hasPreview {
|
||||
let result = await NextcloudKit.shared.downloadPreviewAsync(fileId: file.fileId,
|
||||
etag: file.etag,
|
||||
account: activeTableAccount.account,
|
||||
options: options)
|
||||
if result.error == .success, let data = result.responseData?.data {
|
||||
utility.createImageFileFrom(data: data,
|
||||
ocId: file.ocId,
|
||||
etag: file.etag,
|
||||
userId: activeTableAccount.userId,
|
||||
urlBase: activeTableAccount.urlBase)
|
||||
image = utility.getImage(ocId: file.ocId,
|
||||
etag: file.etag,
|
||||
ext: NCGlobal.shared.previewExt256,
|
||||
userId: activeTableAccount.userId,
|
||||
urlBase: activeTableAccount.urlBase)
|
||||
}
|
||||
}
|
||||
if image == nil {
|
||||
image = utility.loadImage(named: file.iconName, useTypeIconFile: true, account: file.account)
|
||||
useTypeIconFile = true
|
||||
}
|
||||
|
||||
let metadata = await NCManageDatabase.shared.convertFileToMetadataAsync(file)
|
||||
|
||||
// DATA
|
||||
let data = FilesData(id: metadata.ocId, image: image ?? UIImage(), title: metadata.fileNameView, subTitle: subTitle, url: url, useTypeIconFile: useTypeIconFile)
|
||||
datas.append(data)
|
||||
if datas.count == filesItems { break}
|
||||
}
|
||||
|
||||
let alias = (activeTableAccount.alias.isEmpty) ? "" : (" (" + activeTableAccount.alias + ")")
|
||||
let footerText = "Files " + NSLocalizedString("_of_", comment: "") + " " + activeTableAccount.displayName + alias
|
||||
|
||||
if error != .success {
|
||||
completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: activeTableAccount.userId, url: activeTableAccount.urlBase, account: activeTableAccount.account, tile: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
|
||||
} else {
|
||||
completion(FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, isEmpty: datas.isEmpty, userId: activeTableAccount.userId, url: activeTableAccount.urlBase, account: activeTableAccount.account, tile: title, footerImage: "checkmark.icloud", footerText: footerText))
|
||||
}
|
||||
}
|
||||
if image == nil {
|
||||
image = utility.loadImage(named: file.iconName, useTypeIconFile: true, account: file.account)
|
||||
useTypeIconFile = true
|
||||
}
|
||||
|
||||
let metadata = await NCManageDatabaseCreateMetadata().convertFileToMetadataAsync(file)
|
||||
|
||||
// DATA
|
||||
let data = FilesData(id: metadata.ocId, image: image ?? UIImage(), title: metadata.fileNameView, subTitle: subTitle, url: url, useTypeIconFile: useTypeIconFile)
|
||||
datas.append(data)
|
||||
if datas.count == maxItems {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
let alias = (activeTableAccount.alias.isEmpty) ? "" : (" (" + activeTableAccount.alias + ")")
|
||||
let footerText = "Files " + NSLocalizedString("_of_", comment: "") + " " + activeTableAccount.displayName + alias
|
||||
|
||||
if results.error != .success {
|
||||
return(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: activeTableAccount.userId, url: activeTableAccount.urlBase, account: activeTableAccount.account, tile: title, footerImage: "xmark.icloud", footerText: results.error.errorDescription))
|
||||
} else {
|
||||
return(FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, isEmpty: datas.isEmpty, userId: activeTableAccount.userId, url: activeTableAccount.urlBase, account: activeTableAccount.account, tile: title, footerImage: "checkmark.icloud", footerText: footerText))
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,6 @@
|
||||
//
|
||||
// FilesWidgetProvider.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 25/08/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
@@ -31,20 +12,21 @@ struct FilesWidgetProvider: IntentTimelineProvider {
|
||||
typealias Intent = AccountIntent
|
||||
|
||||
func placeholder(in context: Context) -> Entry {
|
||||
let filesItems = getFilesItems(displaySize: context.displaySize)
|
||||
let datasPlaceholder = Array(filesDatasTest[0...filesItems - 1])
|
||||
let datasPlaceholder = Array(filesDatasTest[0...4])
|
||||
let title = getTitleFilesWidget(tableAccount: nil)
|
||||
return Entry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, isEmpty: false, userId: "", url: "", account: "", tile: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " files")
|
||||
}
|
||||
|
||||
func getSnapshot(for configuration: AccountIntent, in context: Context, completion: @escaping (Entry) -> Void) {
|
||||
getFilesDataEntry(configuration: configuration, isPreview: false, displaySize: context.displaySize) { entry in
|
||||
Task {
|
||||
let entry = await getFilesDataEntry(configuration: configuration, isPreview: false, displaySize: context.displaySize)
|
||||
completion(entry)
|
||||
}
|
||||
}
|
||||
|
||||
func getTimeline(for configuration: AccountIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {
|
||||
getFilesDataEntry(configuration: configuration, isPreview: context.isPreview, displaySize: context.displaySize) { entry in
|
||||
Task {
|
||||
let entry = await getFilesDataEntry(configuration: configuration, isPreview: context.isPreview, displaySize: context.displaySize)
|
||||
let timeLine = Timeline(entries: [entry], policy: .atEnd)
|
||||
completion(timeLine)
|
||||
}
|
||||
|
||||
@@ -1,35 +1,13 @@
|
||||
//
|
||||
// FilesWidgetView.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 25/08/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct FilesWidgetView: View {
|
||||
|
||||
var entry: FilesDataEntry
|
||||
|
||||
var body: some View {
|
||||
|
||||
let parameterLink = "&user=\(entry.userId)&url=\(entry.url)"
|
||||
let linkNoAction: URL = URL(string: NCGlobal.shared.widgetActionNoAction + parameterLink) != nil ? URL(string: NCGlobal.shared.widgetActionNoAction + parameterLink)! : URL(string: NCGlobal.shared.widgetActionNoAction)!
|
||||
let linkActionUploadAsset: URL = URL(string: NCGlobal.shared.widgetActionUploadAsset + parameterLink) != nil ? URL(string: NCGlobal.shared.widgetActionUploadAsset + parameterLink)! : URL(string: NCGlobal.shared.widgetActionUploadAsset)!
|
||||
@@ -55,7 +33,6 @@ struct FilesWidgetView: View {
|
||||
}
|
||||
|
||||
ZStack(alignment: .topLeading) {
|
||||
|
||||
HStack {
|
||||
Text(entry.tile)
|
||||
.font(.system(size: 12))
|
||||
@@ -72,39 +49,41 @@ struct FilesWidgetView: View {
|
||||
VStack(spacing: 0) {
|
||||
ForEach(entry.datas, id: \.id) { element in
|
||||
Link(destination: element.url) {
|
||||
HStack {
|
||||
if element.useTypeIconFile {
|
||||
Image(uiImage: element.image)
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(Color(NCBrandColor.shared.iconImageColor2))
|
||||
.scaledToFit()
|
||||
.frame(width: 35, height: 35)
|
||||
} else {
|
||||
Image(uiImage: element.image)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: 35, height: 35)
|
||||
.clipped()
|
||||
.cornerRadius(5)
|
||||
HStack(spacing: 10) {
|
||||
Group {
|
||||
if element.useTypeIconFile {
|
||||
Image(uiImage: element.image)
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(Color(NCBrandColor.shared.iconImageColor2))
|
||||
.scaledToFit()
|
||||
.frame(width: 35, height: 35)
|
||||
} else {
|
||||
Image(uiImage: element.image)
|
||||
.resizable()
|
||||
.frame(width: 35, height: 35)
|
||||
.background(Color(.secondarySystemBackground))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous))
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(element.title)
|
||||
.font(.system(size: 12))
|
||||
.fontWeight(.regular)
|
||||
FilesWidgetBidiFilename(filename: element.title)
|
||||
.lineLimit(1)
|
||||
Text(element.subTitle)
|
||||
.font(.system(size: CGFloat(10)))
|
||||
.font(.system(size: 10))
|
||||
.foregroundColor(Color(NCBrandColor.shared.iconImageColor2))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
Spacer()
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.padding(.leading, 10)
|
||||
.frame(height: 50)
|
||||
.padding(.horizontal, 10)
|
||||
.frame(height: 44)
|
||||
}
|
||||
if element != entry.datas.last {
|
||||
Divider()
|
||||
.padding(.leading, 54)
|
||||
.padding(.leading, 52)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,59 +92,67 @@ struct FilesWidgetView: View {
|
||||
.redacted(reason: entry.isPlaceholder ? .placeholder : [])
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
let sizeButton: CGFloat = 40
|
||||
HStack(spacing: 10) {
|
||||
let buttonSize: CGFloat = 40
|
||||
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionUploadAsset, label: {
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionUploadAsset) {
|
||||
Image(systemName: "photo.badge.plus")
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.scaledToFit()
|
||||
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getText(account: entry.account)))
|
||||
.frame(width: 18, height: 18)
|
||||
.padding(11)
|
||||
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getElement(account: entry.account)))
|
||||
.clipShape(Circle())
|
||||
.scaledToFit()
|
||||
.frame(width: geo.size.width / 4, height: sizeButton)
|
||||
})
|
||||
.frame(width: buttonSize, height: buttonSize)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionScanDocument, label: {
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionScanDocument) {
|
||||
Image(systemName: "doc.text.viewfinder")
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.scaledToFit()
|
||||
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getText(account: entry.account)))
|
||||
.frame(width: 18, height: 18)
|
||||
.padding(11)
|
||||
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getElement(account: entry.account)))
|
||||
.clipShape(Circle())
|
||||
.scaledToFit()
|
||||
.font(Font.system(.body).weight(.light))
|
||||
.frame(width: geo.size.width / 4, height: sizeButton)
|
||||
})
|
||||
.frame(width: buttonSize, height: buttonSize)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionTextDocument, label: {
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionTextDocument) {
|
||||
Image("note.text")
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.scaledToFit()
|
||||
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getText(account: entry.account)))
|
||||
.frame(width: 18, height: 18)
|
||||
.padding(11)
|
||||
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getElement(account: entry.account)))
|
||||
.clipShape(Circle())
|
||||
.scaledToFit()
|
||||
.frame(width: geo.size.width / 4, height: sizeButton)
|
||||
})
|
||||
.frame(width: buttonSize, height: buttonSize)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionVoiceMemo, label: {
|
||||
Link(destination: entry.isPlaceholder ? linkNoAction : linkActionVoiceMemo) {
|
||||
Image("microphone")
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.scaledToFit()
|
||||
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getText(account: entry.account)))
|
||||
.frame(width: 18, height: 18)
|
||||
.padding(11)
|
||||
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getElement(account: entry.account)))
|
||||
.clipShape(Circle())
|
||||
.scaledToFit()
|
||||
.frame(width: geo.size.width / 4, height: sizeButton)
|
||||
})
|
||||
.frame(width: buttonSize, height: buttonSize)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.frame(width: geo.size.width, height: geo.size.height - 22, alignment: .bottomTrailing)
|
||||
.padding(.horizontal, 10)
|
||||
.frame(maxWidth: .infinity, maxHeight: geo.size.height - 25, alignment: .bottom)
|
||||
.redacted(reason: entry.isPlaceholder ? .placeholder : [])
|
||||
|
||||
HStack {
|
||||
@@ -181,18 +168,43 @@ struct FilesWidgetView: View {
|
||||
.lineLimit(1)
|
||||
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.getElement(account: entry.account)))
|
||||
}
|
||||
.padding(.horizontal, 15.0)
|
||||
.frame(maxWidth: geo.size.width, maxHeight: geo.size.height - 2, alignment: .bottomTrailing)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
||||
}
|
||||
}
|
||||
.containerBackground(.background, for: .widget)
|
||||
}
|
||||
}
|
||||
|
||||
private struct FilesWidgetBidiFilename: View {
|
||||
let filename: String
|
||||
|
||||
var body: some View {
|
||||
let nsName = filename as NSString
|
||||
let ext = nsName.pathExtension
|
||||
let base = nsName.deletingPathExtension
|
||||
|
||||
if ext.isEmpty || base.isEmpty {
|
||||
Text(filename)
|
||||
.font(.system(size: 12))
|
||||
} else {
|
||||
HStack(spacing: 0) {
|
||||
Text(base)
|
||||
.font(.system(size: 12))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
Text("." + ext)
|
||||
.font(.system(size: 12))
|
||||
.lineLimit(1)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
}
|
||||
}
|
||||
.widgetBackground(Color(UIColor.systemBackground))
|
||||
}
|
||||
}
|
||||
|
||||
struct FilesWidget_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let datas = Array(filesDatasTest[0...4])
|
||||
let entry = FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, isEmpty: true, userId: "", url: "", account: "", tile: "Good afternoon, Marino Faggiana", footerImage: "checkmark.icloud", footerText: "Nextcloud files")
|
||||
let entry = FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, isEmpty: false, userId: "", url: "", account: "", tile: "Good afternoon, Marino Faggiana", footerImage: "checkmark.icloud", footerText: "Nextcloud files")
|
||||
FilesWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,6 @@
|
||||
//
|
||||
// LockscreenData.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 13/10/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
|
||||
@@ -1,25 +1,6 @@
|
||||
//
|
||||
// LockscreenWidgetProvider.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 13/10/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
|
||||
@@ -1,31 +1,11 @@
|
||||
//
|
||||
// LockscreenWidgetView.swift
|
||||
// Widget
|
||||
//
|
||||
// Created by Marino Faggiana on 13/10/22.
|
||||
// Copyright © 2022 Marino Faggiana. All rights reserved.
|
||||
//
|
||||
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// SPDX-FileCopyrightText: Nextcloud GmbH
|
||||
// SPDX-FileCopyrightText: 2022 Marino Faggiana
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct LockscreenWidgetView: View {
|
||||
|
||||
let entry: LockscreenData
|
||||
@Environment(\.widgetFamily) private var family
|
||||
|
||||
@@ -42,7 +22,7 @@ struct LockscreenWidgetView: View {
|
||||
}
|
||||
)
|
||||
.gaugeStyle(.accessoryCircularCapacity)
|
||||
.widgetBackground(Color.clear)
|
||||
.containerBackground(.clear, for: .widget)
|
||||
} else {
|
||||
Gauge(
|
||||
value: entry.quotaRelative,
|
||||
@@ -56,21 +36,19 @@ struct LockscreenWidgetView: View {
|
||||
)
|
||||
.gaugeStyle(.accessoryCircular)
|
||||
.redacted(reason: entry.isPlaceholder ? .placeholder : [])
|
||||
.widgetBackground(Color.clear)
|
||||
.containerBackground(.clear, for: .widget)
|
||||
}
|
||||
case .accessoryRectangular:
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
HStack(spacing: 1) {
|
||||
Image("activity")
|
||||
Image(systemName: "bolt.fill")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.foregroundColor(Color(NCBrandColor.shared.textColor2))
|
||||
.frame(width: 11, height: 11)
|
||||
Text(NSLocalizedString("_recent_activity_", comment: ""))
|
||||
.font(.system(size: 11))
|
||||
.fontWeight(.heavy)
|
||||
.foregroundColor(Color(NCBrandColor.shared.textColor2))
|
||||
}
|
||||
if entry.error {
|
||||
VStack(spacing: 1) {
|
||||
@@ -85,7 +63,7 @@ struct LockscreenWidgetView: View {
|
||||
}
|
||||
.widgetURL(entry.link)
|
||||
.redacted(reason: entry.isPlaceholder ? .placeholder : [])
|
||||
.widgetBackground(Color.clear)
|
||||
.containerBackground(.clear, for: .widget)
|
||||
default:
|
||||
Text("Not implemented")
|
||||
}
|
||||
|
||||