mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
Compare commits
625 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99465d04de | |||
| 73a7c4843b | |||
| 6e919696bb | |||
| d32cfb3635 | |||
| 31c9f40550 | |||
| 7ae4dcba51 | |||
| daa4e1dfcf | |||
| 9a7bce6fd8 | |||
| 0834d4f8fe | |||
| d8c28c9998 | |||
| 76ff6e15b1 | |||
| 3e0a2ef8ed | |||
| fd35f79c36 | |||
| 294a386d23 | |||
| ee79413653 | |||
| ec08915a16 | |||
| 40f9c020bb | |||
| 684a3bf5f5 | |||
| 26122a4208 | |||
| 9dc80760f7 | |||
| 090db8519d | |||
| efc55ac700 | |||
| 85b773420c | |||
| 771dab7c35 | |||
| ca7cdcebcc | |||
| 6bc27a259b | |||
| a2d9c2416d | |||
| fd1942afab | |||
| 23eabe1499 | |||
| bcc82db7bd | |||
| 26b220470a | |||
| cdc31967b2 | |||
| 4a435df6e4 | |||
| 21f4f7d5de | |||
| e3d195896c | |||
| 911bd825c1 | |||
| 81628d78ee | |||
| 69e791206e | |||
| e66330e226 | |||
| c970245e0d | |||
| cc0fe6ce2b | |||
| 39346ceca7 | |||
| 6dfba51f21 | |||
| 3973741509 | |||
| 3eac508baf | |||
| 7f6f2eb97c | |||
| f2cfbc4041 | |||
| 636fc7d0a6 | |||
| adcda60f7d | |||
| e8f808b67f | |||
| 70108e5694 | |||
| c75fb22289 | |||
| 621b2f17df | |||
| bc6728678b | |||
| 6040b60e86 | |||
| 2edf5f807a | |||
| fd864cc441 | |||
| b004d3b88e | |||
| 9b1bd6e435 | |||
| 73f3aa8309 | |||
| 82195c7418 | |||
| 9fd77b04fa | |||
| f1ea716305 | |||
| da1a02e7a8 | |||
| 9808e113e4 | |||
| 13e81c04ab | |||
| fd42d06d55 | |||
| e6f4f7a5f3 | |||
| 9497b586b7 | |||
| 77d90be4f8 | |||
| a884539a2b | |||
| 633df91bd6 | |||
| dd98469a02 | |||
| 223a7605ed | |||
| 0e04eeaf9a | |||
| aa77e21d4b | |||
| 8c8cfb5d5d | |||
| 9eeb59997e | |||
| 8179d7d707 | |||
| f211a1c614 | |||
| f42ef5246c | |||
| e1a5864406 | |||
| 62c03d71bf | |||
| f4ce2c2bd0 | |||
| d643f8c329 | |||
| 1b270806a1 | |||
| 2d7392c4c0 | |||
| a9cdb2f91c | |||
| 2983971c8b | |||
| e6a0a39a51 | |||
| 87612c0c79 | |||
| ff57883e3d | |||
| cd1a3fd433 | |||
| 377f22972b | |||
| fff7d123f6 | |||
| bedb70c479 | |||
| 3b8270edc3 | |||
| 6137aaf716 | |||
| 97a3389409 | |||
| 95ade9cbb2 | |||
| c4c278d2f3 | |||
| 2cb1964863 | |||
| 876cc5e0f0 | |||
| caae538056 | |||
| 1cebddac0e | |||
| 78bfa8183a | |||
| 43af349391 | |||
| 9c35343d9d | |||
| b0b1986377 | |||
| f11f021e15 | |||
| 6e7336b8d7 | |||
| 927fcab67f | |||
| c51f4f78bb | |||
| 12f4a40d7c | |||
| 3a6e91e26b | |||
| 680ce7324a | |||
| f5fbd60b5e | |||
| 8c1395c8f1 | |||
| 19bfa77ace | |||
| 2fb041a428 | |||
| be1983c9a4 | |||
| 2288487fe1 | |||
| b2384892a8 | |||
| 43e30ca28e | |||
| 42f0705f07 | |||
| e97dbc89c9 | |||
| 76dfbe0a00 | |||
| 424fa538e0 | |||
| 863ff62b6c | |||
| e2b0910e28 | |||
| cf9172f9e7 | |||
| 0e911608af | |||
| 95d067ad6d | |||
| ba043cb1c0 | |||
| 3a4c523509 | |||
| 057748c47a | |||
| e4457ed9eb | |||
| f430cbe59e | |||
| 5316362e9e | |||
| 900f2bfc30 | |||
| b7c8f0629c | |||
| 45fef1077a | |||
| ddb42ecf0a | |||
| 09295781f4 | |||
| 5938609f69 | |||
| d3cd484519 | |||
| 410d2393e0 | |||
| 44b6340be5 | |||
| 2f3dc4ea79 | |||
| af861e5816 | |||
| c1bbe27ac6 | |||
| 11f4373076 | |||
| f57fb7f9de | |||
| 96f2427518 | |||
| 3f51153dcc | |||
| fc37eb95d1 | |||
| 55607ff2f9 | |||
| 1ea08dcf0a | |||
| c6f6dd2d57 | |||
| 579df97bba | |||
| aa2f7ca8b4 | |||
| 17c9c0758f | |||
| 7340087353 | |||
| 910c98b971 | |||
| b144781e9f | |||
| a26db47cb6 | |||
| 9e5379d092 | |||
| 693acd5580 | |||
| c3f6177be1 | |||
| 60642cc18b | |||
| 54b843ae29 | |||
| 633e9bcdc1 | |||
| eab501925f | |||
| 2630d7e8ec | |||
| 116ba52fbb | |||
| e5fb6d9107 | |||
| 98529bc84c | |||
| 4a3ad562a7 | |||
| 518287ff12 | |||
| 0cdfb9eb42 | |||
| 4d0067a455 | |||
| 66d4431d26 | |||
| 293a48c26a | |||
| 80fca10784 | |||
| 830cd6e3b5 | |||
| 0f338d5484 | |||
| a99cd40f4d | |||
| f3ea50b17b | |||
| 2e3762afe1 | |||
| 17b47b38b9 | |||
| 494c848ec9 | |||
| c203b0a597 | |||
| b36fefdf5d | |||
| 8611359f7c | |||
| c8e48460b6 | |||
| 5ecf3001af | |||
| 2c5beee849 | |||
| a3f6635633 | |||
| 33d074c786 | |||
| e952586f60 | |||
| 35c0cd35ef | |||
| a1d753a975 | |||
| 35dbcc2103 | |||
| 3c054fffa0 | |||
| c1bad1204c | |||
| 9890f31d10 | |||
| 04e0dc26e1 | |||
| eb56e77600 | |||
| 1a50e7f0ac | |||
| 2a134babbc | |||
| 2180175040 | |||
| 856d1e5ea5 | |||
| ea5542f8eb | |||
| 40dea84085 | |||
| 89f7908359 | |||
| f02c4c57c3 | |||
| 5b0412bc2c | |||
| aa8d041a33 | |||
| 24bc132476 | |||
| f728b568ed | |||
| c4a2a91578 | |||
| a58d0117c6 | |||
| 439736e904 | |||
| 71510a62f3 | |||
| a65342574a | |||
| 783a697d95 | |||
| b8966330e0 | |||
| cb1b5dd88c | |||
| a1f063c703 | |||
| b65a1bb65c | |||
| d1cb0a418a | |||
| 5536d29cbf | |||
| 7bbb5a9f71 | |||
| a1bf57b71a | |||
| 87bcb5a519 | |||
| c72c8dcaf7 | |||
| bac4599d64 | |||
| 535761dbd5 | |||
| 5be521199f | |||
| f71acb08bd | |||
| d6905435ae | |||
| ba562c9047 | |||
| 6bcc49fc6f | |||
| 64847e906e | |||
| 75d458b06b | |||
| a76a96ccca | |||
| bfdbf4d811 | |||
| b068e593fc | |||
| d3ec833ab7 | |||
| 5e97123bdf | |||
| 2bcef51664 | |||
| 0f42b8b8ae | |||
| c67c95201b | |||
| e6f35158c5 | |||
| d541bfa838 | |||
| ef5deada83 | |||
| e1090d5427 | |||
| 335dd9c788 | |||
| c23518dae0 | |||
| 91f8deb3f3 | |||
| a40ae60abb | |||
| 5caa890523 | |||
| a3620f9e05 | |||
| dbda2d7d7c | |||
| b6a296ffea | |||
| ae3dfa2eb7 | |||
| bab1ca9dca | |||
| e1e8c4c63d | |||
| 5f49c87f4a | |||
| 01653f81e3 | |||
| a0764b9c96 | |||
| 94ac7673a5 | |||
| 5fe3dea4cc | |||
| 608f76f32c | |||
| a2cc7af695 | |||
| dfbe23e5b8 | |||
| 6ac7bd2d96 | |||
| a67361c6bd | |||
| 7a40225852 | |||
| 29816f81a9 | |||
| 4337969c2c | |||
| 6789ee1cb6 | |||
| 7ed15a77b4 | |||
| 4806c62976 | |||
| 3957b292be | |||
| 783f679124 | |||
| 7e1de86f0b | |||
| c13c288f00 | |||
| 89b67a791f | |||
| 2ee413368b | |||
| 1aa586d829 | |||
| 53833fd212 | |||
| a7adef5353 | |||
| bd11cd347d | |||
| b19bd8e709 | |||
| 8dedab0375 | |||
| cbd1800976 | |||
| 44f669cd0e | |||
| 1d052f725f | |||
| f7bad3c5b3 | |||
| 264f352502 | |||
| 32291ce8b4 | |||
| c35f39add1 | |||
| 993ed4b472 | |||
| e7db110417 | |||
| 011cc9f11f | |||
| 844d03a9cd | |||
| 1bfaf4ea98 | |||
| 6309064f40 | |||
| 7d3ed21a03 | |||
| f319b3610a | |||
| 81d27d8e8d | |||
| de7de4b8de | |||
| 340454cfc7 | |||
| 5f600cf263 | |||
| aa84d71302 | |||
| baa906fb6b | |||
| 53ebc9d632 | |||
| 332206089b | |||
| 57d0b42726 | |||
| d01f973e62 | |||
| d557f08e28 | |||
| 5dc1de0e5b | |||
| d2b12cd3dd | |||
| 64418489e2 | |||
| 7238f8ae25 | |||
| e525e0b838 | |||
| 2d95bf6744 | |||
| 41134cc455 | |||
| 27f12c2245 | |||
| 4796615439 | |||
| 154563f34d | |||
| 3365511b10 | |||
| c2c0535d52 | |||
| d6799d1205 | |||
| 9cbf31da27 | |||
| 71cc97822a | |||
| c2ba78253d | |||
| 75aeba29ed | |||
| bd58f17ec0 | |||
| 721a610a70 | |||
| eda27f1e59 | |||
| a08d4b944e | |||
| 5137bcb86a | |||
| 7861006bf5 | |||
| 5f6594f697 | |||
| fcbb538c24 | |||
| 43a8984e4c | |||
| e958a9a2bb | |||
| 986dabf11f | |||
| 318e71aa0c | |||
| 308daec14e | |||
| 3f68c8a50e | |||
| 74af74fb5e | |||
| 924b4e0787 | |||
| d5d9428cf2 | |||
| b9231ffb53 | |||
| 489ba93c0c | |||
| 2a448722c6 | |||
| cd53d0a895 | |||
| db6bb911c2 | |||
| 69552ffeef | |||
| 1f710bd217 | |||
| 11e4fe6ae3 | |||
| 3e98938c95 | |||
| 7283b75cac | |||
| cae04e83dd | |||
| 72e8b1f8d9 | |||
| 73ac4b29ad | |||
| 208af03212 | |||
| 8401428ca7 | |||
| 12406bbbf4 | |||
| 12ae32b69e | |||
| 5176dc29d6 | |||
| 0eac3a9f49 | |||
| 64b86c2403 | |||
| 66d85729ff | |||
| e7bff6681e | |||
| c7cfa5a64f | |||
| 72fc61a016 | |||
| a70eea5bf2 | |||
| c9c419b4ad | |||
| 6759277c3b | |||
| 10d5f3ed46 | |||
| 2934319722 | |||
| d4c81bc5f2 | |||
| 35e0613986 | |||
| ccfa92f650 | |||
| fdb2095ced | |||
| d6a6b49b6b | |||
| 0855bafca7 | |||
| a39f3fe40c | |||
| f13a0aa6ee | |||
| 10d1a61614 | |||
| 2bcfc1bfcb | |||
| b6e3c9bf39 | |||
| 736dc5dda9 | |||
| ae26a6c61c | |||
| 8979bd1fcd | |||
| 74d243d8e0 | |||
| 56b9bac031 | |||
| 4983b3407c | |||
| ed1728feec | |||
| 11472c05ff | |||
| f2ac12ca4f | |||
| b53130ca0d | |||
| a3a4f7cf79 | |||
| ac7094df05 | |||
| 80130f7946 | |||
| fc648bc7e4 | |||
| 9005d6b333 | |||
| 52f0fb882f | |||
| b8ec428ad1 | |||
| a1d3ffc2ce | |||
| 46b9df54bf | |||
| 3c0c3b3f6e | |||
| 5395d53332 | |||
| ec08032e98 | |||
| cc5eca5553 | |||
| 1323183cce | |||
| 009be05d22 | |||
| 860ffc1dee | |||
| c515f95d17 | |||
| 855bf8610a | |||
| 742edc4a79 | |||
| 1975a23aab | |||
| 80c8d9c602 | |||
| 948c9ef57b | |||
| bac968c0bf | |||
| 520562ef86 | |||
| 001253c39b | |||
| 5345b50d17 | |||
| a3622e91b6 | |||
| be305c3daf | |||
| ec78cfbdd0 | |||
| 8023be452a | |||
| 5112c96c05 | |||
| 04b1fb72bb | |||
| a9d11ccb2e | |||
| 848e3f90e1 | |||
| e83b6741ad | |||
| 0a3d93b59b | |||
| 102e2141ec | |||
| 768fd6f439 | |||
| 231a610466 | |||
| 7db5ec0721 | |||
| a2b9d96e86 | |||
| e0022c12c4 | |||
| 66b8f2c906 | |||
| 6fbe10fe63 | |||
| 278871a31e | |||
| bdcef33a3e | |||
| 8e8cff8105 | |||
| 6b086eaed5 | |||
| 0ac06555cb | |||
| 1b87c62847 | |||
| 98eae61b90 | |||
| 19956f2742 | |||
| 7506eaa4aa | |||
| 57c9c9d5f2 | |||
| 0b3d2873c2 | |||
| 1454b58ea1 | |||
| 2ab4459bc3 | |||
| 6ebb92af6c | |||
| 3ab4927cb7 | |||
| 6a0ae482d7 | |||
| 20eeaeb61f | |||
| 5cbe4e2fa3 | |||
| b124e1bc9c | |||
| 08034c4402 | |||
| 0577a9ccb9 | |||
| 2f03554a60 | |||
| 28079197e7 | |||
| 0b46b89b62 | |||
| 05caf67bc4 | |||
| 6d3c400e4a | |||
| 9932288b04 | |||
| 56b13541bd | |||
| d568e20f02 | |||
| f03d59bc22 | |||
| 0833ca28c2 | |||
| 3ed5f21a48 | |||
| 2eb6b79bea | |||
| 8dd2e9716d | |||
| 1cdde6e9a4 | |||
| 034cfb539a | |||
| 5420077b98 | |||
| 5cfc7a602a | |||
| b48e344749 | |||
| e58a880f34 | |||
| 17ff7f6bd8 | |||
| f03bb97d50 | |||
| ed0142be7d | |||
| 6e9f89a25f | |||
| a3c7c3d76a | |||
| c043ca4bba | |||
| 004c6212c0 | |||
| 07448e662c | |||
| d3bdc6de62 | |||
| a9bfcd0fd5 | |||
| 12caa7fbde | |||
| 1cbd4acf01 | |||
| 687e477ca5 | |||
| 3a66f2a8da | |||
| 7f52e424e8 | |||
| 2479e5661b | |||
| bc2fb1ce2d | |||
| ffa07b3d05 | |||
| 306753d6a1 | |||
| 80c04df4fc | |||
| c9a91bbdad | |||
| d06168d94a | |||
| d9baaa8957 | |||
| fede671f3b | |||
| b3113e66b9 | |||
| 286b0b09ec | |||
| c0b39abe18 | |||
| 6e3a6386b8 | |||
| 5e7d778740 | |||
| 3be87343b8 | |||
| 517efabbca | |||
| 1866dca818 | |||
| 1400b5d308 | |||
| b529cf4e57 | |||
| 6cc3d235b1 | |||
| a5b1156612 | |||
| c6ffd48e26 | |||
| afb6eae4c8 | |||
| cd1f39377d | |||
| 3a99e8576d | |||
| 36c8c5bc48 | |||
| 4ba7db90e6 | |||
| ab6cd7009e | |||
| b16ac683cf | |||
| 95d62b7a02 | |||
| e444e855c0 | |||
| 4ab42c06c9 | |||
| 9f6ab11839 | |||
| 5f711d5374 | |||
| 4d550112a1 | |||
| 26dc88181d | |||
| 3d4f8bfe12 | |||
| 5fb1838c7a | |||
| 38e5d76ad2 | |||
| a9af19f02a | |||
| 305b00ae01 | |||
| ed6724035e | |||
| eea83bb1c9 | |||
| 06c03cbded | |||
| b73f749880 | |||
| 53c18b861a | |||
| 9b1bf89382 | |||
| c7f144d3ff | |||
| cb41f08199 | |||
| eafb30555c | |||
| 4f1f48eec5 | |||
| 42341c2c76 | |||
| 6a60fc183a | |||
| 236b4c34ac | |||
| c6cb3dc64a | |||
| 3fc7487b58 | |||
| ac055d531f | |||
| 0ef3cbf520 | |||
| 3458238db0 | |||
| afaacec61a | |||
| 5f4fb5dae7 | |||
| 788b1f63d0 | |||
| bfb1b04f8d | |||
| a77ec6e225 | |||
| 2851eb7afe | |||
| 6c7605b4a6 | |||
| 3b286d04c3 | |||
| 21afe89b13 | |||
| 060a43ba64 | |||
| dedbf16f03 | |||
| 796f39fe1f | |||
| ee9cbce23d | |||
| 82fcdcd0fc | |||
| 3b7cdf516a | |||
| 41752887dc | |||
| b9d0d3397e | |||
| 2a2dfec247 | |||
| 21e07e20a1 | |||
| 322d5d5209 | |||
| 0346f9c13d | |||
| dfd87d413e | |||
| 27aab5c783 | |||
| a7cc1b9e57 | |||
| 8955790f17 | |||
| 61d925f3dd | |||
| bf00412863 | |||
| 2a6c771ad9 | |||
| 641b1882b5 | |||
| 5346182807 | |||
| 4dfccaa2a4 | |||
| 18a16d2aa2 | |||
| b7a91fc84e | |||
| bb725ac8d8 | |||
| b644235eb6 | |||
| d259ecb11c | |||
| 5d05363f36 | |||
| 6906f80ff8 | |||
| 7083667cbf | |||
| 0b7cee0b0d | |||
| 36ed0e0d23 | |||
| b1c0353548 | |||
| c204a25a9c | |||
| b008e010a5 | |||
| 02b0454b3d | |||
| 9c1e63e64b | |||
| dacc413c34 | |||
| b8f6a99895 | |||
| db82e04b49 | |||
| 3abc9eacf4 | |||
| 3a0edafdf0 | |||
| 35d2b19f4c | |||
| 6b5b2f614d | |||
| 92f10531d0 | |||
| d5ba4439f2 | |||
| 78a28e2747 | |||
| 71e3ddabed | |||
| e59af6dcb3 | |||
| 9755330113 | |||
| 5ca44453ae | |||
| 4461899910 |
@@ -0,0 +1,156 @@
|
|||||||
|
name: Set up Node and the workspaces
|
||||||
|
description: >-
|
||||||
|
Node from .nvmrc, the workspace dependencies from an exact cache or npm ci,
|
||||||
|
and optionally shared/dist from a cache or a build. Runs after checkout.
|
||||||
|
|
||||||
|
# A local action, so it is versioned with the workflow that calls it and needs
|
||||||
|
# no SHA pin. scripts/ci/changed-areas.mjs counts .github/actions/ like
|
||||||
|
# test.yml: a change here runs everything.
|
||||||
|
#
|
||||||
|
# node_modules is restored only on an exact key: the runner image, the scope,
|
||||||
|
# the Node ABI, the lockfile and every workspace package.json. There are no
|
||||||
|
# restore-keys, so a hit is the tree npm ci would build and a miss is a plain
|
||||||
|
# npm ci. The package.json files are in the key because npm ci is also the
|
||||||
|
# check that they agree with the lockfile: an edited range without a fresh
|
||||||
|
# lockfile misses the cache and fails the install, as it did when every job
|
||||||
|
# ran npm ci. Only pushes to dev and main save, the npm download cache
|
||||||
|
# included, so pull requests read what their base left and cannot evict it or
|
||||||
|
# fill the repository's cache quota with entries of their own.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
scope:
|
||||||
|
description: >-
|
||||||
|
Which workspaces to install: full (npm ci), client (shared and client)
|
||||||
|
or shared (shared alone).
|
||||||
|
required: true
|
||||||
|
build-shared:
|
||||||
|
description: "'true' to restore shared/dist, or build it on a miss."
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
|
||||||
|
# ImageOS and ImageVersion name the runner image, whose system libraries
|
||||||
|
# the native modules were built against. They live in the runner's
|
||||||
|
# environment, not in the env context, so the key is put together here. A
|
||||||
|
# job in a container has neither; the container's OS release stands in,
|
||||||
|
# and that job's tree is kept apart from the runner's.
|
||||||
|
- name: Work out the cache keys
|
||||||
|
id: keys
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SCOPE: ${{ inputs.scope }}
|
||||||
|
DEPS: ${{ hashFiles('.nvmrc', 'package-lock.json', 'package.json', 'client/package.json', 'server/package.json', 'shared/package.json') }}
|
||||||
|
SHARED: ${{ hashFiles('shared/src/**', 'shared/package.json', 'shared/tsconfig*.json', 'shared/tsdown.config.ts', 'package-lock.json') }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
case "$SCOPE" in
|
||||||
|
full | client | shared) ;;
|
||||||
|
*) echo "::error::scope must be full, client or shared, not '$SCOPE'"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
if [ -n "${ImageOS:-}" ]; then
|
||||||
|
image="$ImageOS-${ImageVersion:-unknown}"
|
||||||
|
else
|
||||||
|
image="container-$(. /etc/os-release && echo "$ID$VERSION_ID")"
|
||||||
|
fi
|
||||||
|
abi="$(node -p process.versions.modules)"
|
||||||
|
echo "nm=nm-$RUNNER_OS-$image-$SCOPE-node$abi-$DEPS" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "sd=sd-$RUNNER_OS-$SHARED" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "save=${{ github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Restore node_modules
|
||||||
|
id: nm
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
server/node_modules
|
||||||
|
client/node_modules
|
||||||
|
shared/node_modules
|
||||||
|
key: ${{ steps.keys.outputs.nm }}
|
||||||
|
|
||||||
|
# The npm download cache only matters when npm ci runs, so it is restored
|
||||||
|
# only then. It may fall back to an older lockfile's cache: npm ci checks
|
||||||
|
# every tarball against the lockfile's integrity hash and fetches what is
|
||||||
|
# missing, so a stale entry only costs downloads.
|
||||||
|
- name: Restore the npm download cache
|
||||||
|
id: npm
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
||||||
|
restore-keys: npm-${{ runner.os }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SCOPE: ${{ inputs.scope }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# better-sqlite3 ships no prebuilt binary and compiles on install. The
|
||||||
|
# hosted runners carry a compiler; the Playwright container of the e2e
|
||||||
|
# jobs does not, so on a cache miss there it gets one first. A hit,
|
||||||
|
# the usual case once a push to dev has saved the container's key,
|
||||||
|
# never reaches this step.
|
||||||
|
if ! command -v make >/dev/null || ! command -v g++ >/dev/null; then
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
timeout 300 apt-get update -qq
|
||||||
|
timeout 300 apt-get install -y -qq --no-install-recommends make g++
|
||||||
|
fi
|
||||||
|
case "$SCOPE" in
|
||||||
|
full) npm ci ;;
|
||||||
|
# The scoped install keeps @testing-library/dom (a peer of
|
||||||
|
# @testing-library/react) in the tree.
|
||||||
|
client) npm ci --workspace shared --workspace client ;;
|
||||||
|
shared) npm ci --workspace shared ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Save node_modules
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true' && steps.keys.outputs.save == 'true'
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
server/node_modules
|
||||||
|
client/node_modules
|
||||||
|
shared/node_modules
|
||||||
|
key: ${{ steps.keys.outputs.nm }}
|
||||||
|
|
||||||
|
# Only a full install saves the download cache, so the entry holds every
|
||||||
|
# tarball; a scoped job that finished first would otherwise claim the key
|
||||||
|
# with part of the tree and no later run would fill it.
|
||||||
|
- name: Save the npm download cache
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true' && steps.keys.outputs.save == 'true' && steps.npm.outputs.cache-hit != 'true' && inputs.scope == 'full'
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
||||||
|
|
||||||
|
# The key holds every input of the build: the sources, the package and
|
||||||
|
# build configs, and the lockfile that pins tsdown and zod.
|
||||||
|
- name: Restore shared/dist
|
||||||
|
id: sd
|
||||||
|
if: inputs.build-shared == 'true'
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: shared/dist
|
||||||
|
key: ${{ steps.keys.outputs.sd }}
|
||||||
|
|
||||||
|
- name: Build shared
|
||||||
|
if: inputs.build-shared == 'true' && steps.sd.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: npm run build --workspace=shared
|
||||||
|
|
||||||
|
- name: Save shared/dist
|
||||||
|
if: inputs.build-shared == 'true' && steps.sd.outputs.cache-hit != 'true' && steps.keys.outputs.save == 'true'
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
path: shared/dist
|
||||||
|
key: ${{ steps.keys.outputs.sd }}
|
||||||
+11
-1
@@ -7,8 +7,11 @@
|
|||||||
# enforce-target-branch.yml moves those onto dev.
|
# enforce-target-branch.yml moves those onto dev.
|
||||||
#
|
#
|
||||||
# Every PR runs test.yml like any other, so ci-ok decides whether it can
|
# Every PR runs test.yml like any other, so ci-ok decides whether it can
|
||||||
# merge. Dependabot runs get no Actions secrets, so s3-contract and the Sonar
|
# merge. Dependabot runs get no Actions secrets, so server-s3 and the Sonar
|
||||||
# scan skip themselves on these PRs and ci-ok counts the skip as passed.
|
# scan skip themselves on these PRs and ci-ok counts the skip as passed.
|
||||||
|
# A bump of @playwright/test also needs the Playwright container tag and
|
||||||
|
# digest in test.yml's client-e2e moved by hand; workflow-jobs.test.mjs
|
||||||
|
# fails the PR until they match.
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
# The root lockfile covers the client, server and shared workspaces.
|
# The root lockfile covers the client, server and shared workspaces.
|
||||||
@@ -25,6 +28,13 @@ updates:
|
|||||||
groups:
|
groups:
|
||||||
npm-minor-and-patch:
|
npm-minor-and-patch:
|
||||||
update-types: [minor, patch]
|
update-types: [minor, patch]
|
||||||
|
ignore:
|
||||||
|
# TypeScript 7 is the native compiler and has no JavaScript API yet:
|
||||||
|
# typescript-eslint, the coverage instrumenter and the Postgres probe all
|
||||||
|
# call into it (readConfigFile, ScriptTarget). It moves by hand once the
|
||||||
|
# tooling supports it.
|
||||||
|
- dependency-name: typescript
|
||||||
|
update-types: [version-update:semver-major]
|
||||||
|
|
||||||
# plugin-sdk is standalone with a lockfile of its own and ships to npm.
|
# plugin-sdk is standalone with a lockfile of its own and ships to npm.
|
||||||
- package-ecosystem: npm
|
- package-ecosystem: npm
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||||
|
|
||||||
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
|
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
@@ -236,7 +236,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||||
|
|
||||||
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
|
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ jobs:
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Derive version from git tags, no package.json dependency
|
# Derive version from git tags, no package.json dependency
|
||||||
STABLE_TAG=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | grep -v '\-pre\.' | sort -V | tail -1)
|
# Only a plain vX.Y.Z is a release: the glob alone also matches the apps' TestFlight tags
|
||||||
|
# (v5.1.0-tf.15), whose suffix then broke the arithmetic below.
|
||||||
|
STABLE_TAG=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
|
||||||
STABLE="${STABLE_TAG#v}"
|
STABLE="${STABLE_TAG#v}"
|
||||||
STABLE="${STABLE:-0.0.0}"
|
STABLE="${STABLE:-0.0.0}"
|
||||||
|
|
||||||
@@ -342,7 +344,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||||
|
|
||||||
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
|
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
@@ -401,7 +403,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||||
|
|
||||||
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
|
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|||||||
@@ -18,9 +18,16 @@ jobs:
|
|||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version-file: .nvmrc
|
node-version-file: .nvmrc
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: package-lock.json
|
||||||
|
|
||||||
|
# shared's ESLint and Prettier plugins are its own devDependencies, and
|
||||||
|
# the format ratchet in scripts/lib/ resolves prettier from the root, so
|
||||||
|
# shared plus the root is the whole tree these checks read. npm ci
|
||||||
|
# installs exactly what the lockfile says, where npm install could
|
||||||
|
# resolve anew.
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm ci --workspace shared --include-workspace-root
|
||||||
|
|
||||||
- name: Run lint & format check
|
- name: Run lint & format check
|
||||||
# Both are check-only: lint used to run eslint --fix, which rewrote the
|
# Both are check-only: lint used to run eslint --fix, which rewrote the
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
node-version-file: .nvmrc
|
node-version-file: .nvmrc
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 21
|
java-version: 21
|
||||||
@@ -111,19 +111,21 @@ jobs:
|
|||||||
|
|
||||||
ios:
|
ios:
|
||||||
if: github.repository == 'liketrek/TREK'
|
if: github.repository == 'liketrek/TREK'
|
||||||
runs-on: macos-15
|
runs-on: xcode-27
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
environment: store
|
environment: store
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
# App Store uploads must be built with Xcode 26; the image's default is older.
|
# The iOS 27.1 SDK, on the xcode-27 image: an app built against an older SDK
|
||||||
- name: Select Xcode 26
|
# runs letterboxed on the inner display of an iPhone Duo.
|
||||||
|
- name: Select Xcode 27.1
|
||||||
run: |
|
run: |
|
||||||
XCODE=$(ls -d /Applications/Xcode_26*.app | sort -V | tail -1)
|
XCODE=/Applications/Xcode_27.1.app
|
||||||
test -n "$XCODE"
|
test -d "$XCODE"
|
||||||
sudo xcode-select -s "$XCODE"
|
sudo xcode-select -s "$XCODE"
|
||||||
xcodebuild -version
|
xcodebuild -version
|
||||||
|
xcodebuild -showsdks | grep iphoneos27.1
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ permissions:
|
|||||||
#
|
#
|
||||||
# Unsigned on purpose: signing and store uploads need secrets that fork PRs do
|
# Unsigned on purpose: signing and store uploads need secrets that fork PRs do
|
||||||
# not get, and belong in a release workflow of their own.
|
# not get, and belong in a release workflow of their own.
|
||||||
|
#
|
||||||
|
# package-lock.json is not a trigger: every dependency bump touches it, and a
|
||||||
|
# Mac build per bump only held the queue. The shells link nothing but the
|
||||||
|
# @capacitor/* packages, all declared in client/package.json, and a Dependabot
|
||||||
|
# bump of one of them raises the range there too, so it still runs. The client
|
||||||
|
# typecheck and the watch and widget snapshot tests run in test.yml on every
|
||||||
|
# change under client/.
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
@@ -17,13 +24,13 @@ on:
|
|||||||
- 'client/ios/**'
|
- 'client/ios/**'
|
||||||
- 'client/native-shell/**'
|
- 'client/native-shell/**'
|
||||||
- 'client/src/native/trekShell.ts'
|
- 'client/src/native/trekShell.ts'
|
||||||
|
- 'client/src/native/watch.ts'
|
||||||
- 'client/src/native/serverAddress.ts'
|
- 'client/src/native/serverAddress.ts'
|
||||||
- 'client/capacitor.config.ts'
|
- 'client/capacitor.config.ts'
|
||||||
- 'client/vite.native.config.js'
|
- 'client/vite.native.config.js'
|
||||||
- 'client/scripts/check-store-metadata.mjs'
|
- 'client/scripts/check-store-metadata.mjs'
|
||||||
- 'client/fastlane/**'
|
- 'client/fastlane/**'
|
||||||
- 'client/package.json'
|
- 'client/package.json'
|
||||||
- 'package-lock.json'
|
|
||||||
- 'shared/src/i18n/*/native.ts'
|
- 'shared/src/i18n/*/native.ts'
|
||||||
- '.github/workflows/native.yml'
|
- '.github/workflows/native.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -59,7 +66,7 @@ jobs:
|
|||||||
node-version-file: .nvmrc
|
node-version-file: .nvmrc
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v6
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 21
|
java-version: 21
|
||||||
@@ -89,21 +96,23 @@ jobs:
|
|||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
ios:
|
ios:
|
||||||
runs-on: macos-15
|
runs-on: xcode-27
|
||||||
timeout-minutes: 40
|
timeout-minutes: 40
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
# App Store uploads must be built with Xcode 26; the image's default is older.
|
# The iOS 27.1 SDK, on the xcode-27 image: an app built against an older SDK
|
||||||
- name: Select Xcode 26
|
# runs letterboxed on the inner display of an iPhone Duo.
|
||||||
|
- name: Select Xcode 27.1
|
||||||
run: |
|
run: |
|
||||||
XCODE=$(ls -d /Applications/Xcode_26*.app | sort -V | tail -1)
|
XCODE=/Applications/Xcode_27.1.app
|
||||||
test -n "$XCODE"
|
test -d "$XCODE"
|
||||||
sudo xcode-select -s "$XCODE"
|
sudo xcode-select -s "$XCODE"
|
||||||
xcodebuild -version
|
xcodebuild -version
|
||||||
|
xcodebuild -showsdks | grep iphoneos27.1
|
||||||
|
|
||||||
- name: Check the property lists
|
- name: Check the property lists
|
||||||
run: plutil -lint client/ios/App/App/Info.plist client/ios/ExportOptions.plist client/ios/App/NotificationService/Info.plist client/ios/App/NotificationService/NotificationService.entitlements client/ios/App/App/App.entitlements client/ios/App/TREKWidgets/Info.plist client/ios/App/TREKWidgets/TREKWidgets.entitlements client/ios/App/TREKWidgets/*.lproj/Localizable.strings client/ios/App/ShareExtension/Info.plist client/ios/App/ShareExtension/ShareExtension.entitlements client/ios/App/ShareExtension/*.lproj/Localizable.strings
|
run: plutil -lint client/ios/App/App/Info.plist client/ios/ExportOptions.plist client/ios/App/NotificationService/Info.plist client/ios/App/NotificationService/NotificationService.entitlements client/ios/App/App/App.entitlements client/ios/App/TREKWidgets/Info.plist client/ios/App/TREKWidgets/TREKWidgets.entitlements client/ios/App/TREKWidgets/*.lproj/Localizable.strings client/ios/App/ShareExtension/Info.plist client/ios/App/ShareExtension/ShareExtension.entitlements client/ios/App/ShareExtension/*.lproj/Localizable.strings client/ios/App/TREKWatch/Info.plist client/ios/App/TREKWatch/TREKWatch.entitlements client/ios/App/TREKWatch/*.lproj/Localizable.strings client/ios/App/TREKWatchWidgets/Info.plist client/ios/App/TREKWatchWidgets/TREKWatchWidgets.entitlements
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
@@ -120,6 +129,23 @@ jobs:
|
|||||||
working-directory: client
|
working-directory: client
|
||||||
run: npm run cap:sync -- ios
|
run: npm run cap:sync -- ios
|
||||||
|
|
||||||
|
# Capacitor's xcframeworks come from GitHub release downloads, which answer
|
||||||
|
# 504 now and then; SwiftPM then reports the half-written file as "already
|
||||||
|
# exists in file system". Resolve on a clean artifact cache, a few times
|
||||||
|
# with growing pauses, before the build needs the packages.
|
||||||
|
- name: Resolve the Swift packages
|
||||||
|
working-directory: client/ios/App
|
||||||
|
run: |
|
||||||
|
for attempt in 1 2 3 4 5; do
|
||||||
|
rm -rf ~/Library/Caches/org.swift.swiftpm/artifacts
|
||||||
|
if xcodebuild -resolvePackageDependencies -project App.xcodeproj -scheme App; then exit 0; fi
|
||||||
|
echo "Resolving the Swift packages failed (attempt $attempt of 5)"
|
||||||
|
sleep $((attempt * 30))
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
# No -sdk: the scheme builds the embedded watch app and its complications
|
||||||
|
# against the watchOS simulator SDK and the rest against the iOS one.
|
||||||
- name: Build for the simulator
|
- name: Build for the simulator
|
||||||
working-directory: client/ios/App
|
working-directory: client/ios/App
|
||||||
run: |
|
run: |
|
||||||
@@ -127,14 +153,16 @@ jobs:
|
|||||||
-project App.xcodeproj \
|
-project App.xcodeproj \
|
||||||
-scheme App \
|
-scheme App \
|
||||||
-configuration Debug \
|
-configuration Debug \
|
||||||
-sdk iphonesimulator \
|
|
||||||
-destination 'generic/platform=iOS Simulator' \
|
-destination 'generic/platform=iOS Simulator' \
|
||||||
CODE_SIGNING_ALLOWED=NO
|
CODE_SIGNING_ALLOWED=NO
|
||||||
|
|
||||||
# The widgets drawn to PNGs (client/ios/WidgetPreviews): every size, light and
|
# The widgets drawn to PNGs (client/ios/WidgetPreviews): every size, light and
|
||||||
# dark, for a trip ahead, a trip under way and none, plus a home screen and
|
# dark, for a trip ahead, a trip under way and none, plus a home screen and
|
||||||
# a lock screen of them. Nobody has to install a build to see a widget change.
|
# a lock screen of them. Nobody has to install a build to see a widget change.
|
||||||
|
# Started by hand only (Run workflow): the apps are on TestFlight and Play now,
|
||||||
|
# where a change is looked at on a device; on every PR it only held the queue.
|
||||||
widget-previews:
|
widget-previews:
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
runs-on: macos-15
|
runs-on: macos-15
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
steps:
|
steps:
|
||||||
@@ -159,3 +187,71 @@ jobs:
|
|||||||
name: widget-previews
|
name: widget-previews
|
||||||
path: client/ios/WidgetPreviews/out
|
path: client/ios/WidgetPreviews/out
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
|
# The watch app on watchOS simulators in its screenshot mode (DemoMode.swift):
|
||||||
|
# every screen on the largest and the smallest watch, the main ones in every
|
||||||
|
# language, and the complications, as PNGs to look at without a watch.
|
||||||
|
# Started by hand only, like the widget previews: up to 90 minutes of macOS.
|
||||||
|
watch-screens:
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
runs-on: macos-15
|
||||||
|
timeout-minutes: 90
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Select Xcode 26
|
||||||
|
run: |
|
||||||
|
XCODE=$(ls -d /Applications/Xcode_26*.app | sort -V | tail -1)
|
||||||
|
test -n "$XCODE"
|
||||||
|
sudo xcode-select -s "$XCODE"
|
||||||
|
|
||||||
|
# The project resolves the Capacitor packages from node_modules, even for
|
||||||
|
# a target that uses none of them.
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: npm ci --workspace=shared --workspace=client
|
||||||
|
|
||||||
|
- name: Make sure a watchOS simulator runtime is there
|
||||||
|
run: |
|
||||||
|
xcrun simctl list runtimes | grep -q watchOS || xcodebuild -downloadPlatform watchOS
|
||||||
|
xcrun simctl list runtimes
|
||||||
|
|
||||||
|
# Capacitor's xcframeworks come from GitHub release downloads, which answer
|
||||||
|
# 504 now and then; SwiftPM then reports the half-written file as "already
|
||||||
|
# exists in file system". Resolve on a clean artifact cache, a few times
|
||||||
|
# with growing pauses, before the build needs the packages.
|
||||||
|
- name: Resolve the Swift packages
|
||||||
|
working-directory: client/ios/App
|
||||||
|
run: |
|
||||||
|
for attempt in 1 2 3 4 5; do
|
||||||
|
rm -rf ~/Library/Caches/org.swift.swiftpm/artifacts
|
||||||
|
if xcodebuild -resolvePackageDependencies -project App.xcodeproj -scheme App; then exit 0; fi
|
||||||
|
echo "Resolving the Swift packages failed (attempt $attempt of 5)"
|
||||||
|
sleep $((attempt * 30))
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Build the watch app for the simulator
|
||||||
|
working-directory: client/ios/App
|
||||||
|
run: |
|
||||||
|
xcodebuild build \
|
||||||
|
-project App.xcodeproj \
|
||||||
|
-target TREKWatch \
|
||||||
|
-configuration Debug \
|
||||||
|
-sdk watchsimulator \
|
||||||
|
SYMROOT="$PWD/build" \
|
||||||
|
CODE_SIGNING_ALLOWED=NO
|
||||||
|
|
||||||
|
- name: Capture the screens
|
||||||
|
run: bash client/ios/scripts/watch-screens.sh client/ios/App/build/Debug-watchsimulator/TREKWatch.app "$PWD/watch-screens"
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v6
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: watch-screens
|
||||||
|
path: watch-screens
|
||||||
|
retention-days: 14
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ name: Security Scan
|
|||||||
# - scout scans the built image, base image packages included. It needs
|
# - scout scans the built image, base image packages included. It needs
|
||||||
# the Docker Hub login, so it runs on PRs and pushes into main only and
|
# the Docker Hub login, so it runs on PRs and pushes into main only and
|
||||||
# skips fork PRs. Whether the image builds at all is test.yml's
|
# skips fork PRs. Whether the image builds at all is test.yml's
|
||||||
# docker-image job, which a red scan cannot hide.
|
# docker job, which a red scan cannot hide.
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, dev]
|
branches: [main, dev]
|
||||||
@@ -74,7 +74,7 @@ jobs:
|
|||||||
load: true
|
load: true
|
||||||
tags: trek:scan
|
tags: trek:scan
|
||||||
|
|
||||||
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
|
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|||||||
+929
-743
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,7 @@ Tests:
|
|||||||
npm run test # all workspaces
|
npm run test # all workspaces
|
||||||
npm run test --workspace=server # vitest run (server); also test:unit / test:integration / test:ws
|
npm run test --workspace=server # vitest run (server); also test:unit / test:integration / test:ws
|
||||||
npm run test:e2e # server e2e (boots Nest against a temp SQLite)
|
npm run test:e2e # server e2e (boots Nest against a temp SQLite)
|
||||||
|
npm run test:pg --workspace=server # the Postgres lane (vitest.pg.config.ts; needs TREK_TEST_DB_URL, e.g. postgres://postgres:trek@127.0.0.1:55432/postgres)
|
||||||
npm run test:cov # coverage (lcov) for all four packages incl. plugin-sdk
|
npm run test:cov # coverage (lcov) for all four packages incl. plugin-sdk
|
||||||
cd client && npm run test # client vitest run
|
cd client && npm run test # client vitest run
|
||||||
cd client && npm run e2e # Playwright (CI runs the public and app projects; the screenshot and help-media ones are local)
|
cd client && npm run e2e # Playwright (CI runs the public and app projects; the screenshot and help-media ones are local)
|
||||||
@@ -51,7 +52,9 @@ cd client && npm run lint:skips # no .only; skipped tests may
|
|||||||
cd client && npm run lint:i18n-keys # every key the client names exists in en; unused en keys may only shrink (CI gate)
|
cd client && npm run lint:i18n-keys # every key the client names exists in en; unused en keys may only shrink (CI gate)
|
||||||
cd server && npm run lint:boundaries # no new import cycles or cross-domain reach-ins (CI gate)
|
cd server && npm run lint:boundaries # no new import cycles or cross-domain reach-ins (CI gate)
|
||||||
cd server && npm run lint:dialect # SQLite-only SQL spellings may only shrink (CI gate; rules in server/CLAUDE.md)
|
cd server && npm run lint:dialect # SQLite-only SQL spellings may only shrink (CI gate; rules in server/CLAUDE.md)
|
||||||
|
cd server && npm run lint:engine-dispatch # engine checks outside src/db/dialect/ and src/db/engine/ may only shrink (CI gate)
|
||||||
cd server && npm run probe:pg # dialect helpers + the repository statements it reaches against Postgres (CI job; needs TREK_PG_PROBE_URL)
|
cd server && npm run probe:pg # dialect helpers + the repository statements it reaches against Postgres (CI job; needs TREK_PG_PROBE_URL)
|
||||||
|
cd server && npm run check:pg-baseline # the Postgres baseline in server/assets/postgres/ matches the entities and the migrations (CI gate)
|
||||||
cd server && npm run lint:tx # no new method writing twice outside one transaction (CI gate)
|
cd server && npm run lint:tx # no new method writing twice outside one transaction (CI gate)
|
||||||
cd server && npm run lint:test-sql # raw SQL fixtures in tests/ may only shrink; seed through tests/helpers/factories (CI gate)
|
cd server && npm run lint:test-sql # raw SQL fixtures in tests/ may only shrink; seed through tests/helpers/factories (CI gate)
|
||||||
cd server && npm run lint:test-mocks # vi.mock of config, realtime and db modules in tests/ may only shrink (CI gate)
|
cd server && npm run lint:test-mocks # vi.mock of config, realtime and db modules in tests/ may only shrink (CI gate)
|
||||||
@@ -134,13 +137,18 @@ These principles come out of a full-repo audit and shape all new code:
|
|||||||
|
|
||||||
## Quality gates in CI
|
## Quality gates in CI
|
||||||
|
|
||||||
`.github/workflows/test.yml` runs, per package: typecheck (server also `typecheck:tests`, client also the strict-mode ratchet `lint:strict`), lint (client and server through `lint:warnings`, which also holds the warning count per rule), `lint:pages`, `lint:rtl`, `lint:size` (client and server), the server's `lint:strict`, `lint:boundaries`, `lint:tx`, `lint:dialect`, `lint:test-sql`, `lint:test-mocks`, `lint:test-new-service`, `lint:query-api`, `lint:mcp-zod`, `lint:service-http` and `lint:response-contracts`, the client's and server's `lint:format`, `lint:layers`, `lint:offline`, `lint:dup`, `lint:pairs`, `lint:skips`, `lint:i18n-keys` and `theme:lint`, shared's `contracts:open`, the repo-wide `lint:knip` (in server-lint-checks), `check:plugin-facts`, `i18n:parity:strict` (with the untranslated-strings ratchet), the S3 contract suite, the Postgres probe (`postgres-probe`: every dialect helper on SQLite and Postgres, and the statements every repository method reaches with sample arguments against a Postgres service; the SQL errors per method and the list of methods it cannot measure are held to a baseline that only shrinks and fails while it is still unmeasured; see `server/CLAUDE.md`), the browser end-to-end flows (Chromium and WebKit), a client build with `check:gl-split`, coverage for all four packages, then a SonarCloud scan. It also builds the Docker image and boots it until `/api/health/ready` answers (`docker-image`), and lints and renders the Helm chart against the Kubernetes schemas and runs `docker compose config` on every compose file (`deploy-manifests`). `lint-prettier.yml` additionally runs `lint` + `lint:format` on `shared/`, both check-only. `plugin-sdk` has no lint script and is outside the eslint gates. **Not in CI**: the screenshot and help-media Playwright projects; run them locally. There are no git hooks; nothing runs before a commit except you. Other workflows build Docker images, scan them, and publish `trek-plugin-sdk` on `plugin-sdk-v*` tags.
|
`.github/workflows/test.yml` runs, per package: typecheck (server also `typecheck:tests`, client also the strict-mode ratchet `lint:strict`), lint (client and server through `lint:warnings`, which also holds the warning count per rule), `lint:pages`, `lint:rtl`, `lint:size` (client and server), the server's `lint:strict`, `lint:boundaries`, `lint:tx`, `lint:dialect`, `lint:engine-dispatch`, `lint:test-sql`, `lint:test-mocks`, `lint:test-new-service`, `lint:query-api`, `lint:mcp-zod`, `lint:service-http` and `lint:response-contracts`, the client's and server's `lint:format`, `lint:layers`, `lint:offline`, `lint:dup`, `lint:pairs`, `lint:skips`, `lint:i18n-keys` and `theme:lint`, shared's `contracts:open`, the repo-wide `lint:knip` (in `server-lint`), `check:plugin-facts`, `i18n:parity:strict` (with the untranslated-strings ratchet), the S3 contract suite, TREK on Postgres (`server-postgres`, once per supported major, 14 and 18, each in three slices: first the Postgres probe (in the first slice), every dialect helper on SQLite and Postgres and the statements every repository method reaches with sample arguments, its SQL errors per method and the methods it cannot measure held to a baseline that only shrinks and fails while it is still unmeasured; then the Postgres lane, every suite that boots the app on the real database module, found by `server/tests/postgres/lane.ts` rather than listed, plus PARITY-PG and the write lock; see `server/CLAUDE.md`), the browser end-to-end flows (Chromium and WebKit, in the Playwright container, in two slices), a client build with `check:gl-split`, coverage for all four packages, then a SonarCloud scan. It also builds the Docker image and boots it until `/api/health/ready` answers, on SQLite and on Postgres 18, and lints and renders the Helm chart against the Kubernetes schemas and runs `docker compose config` on every compose file (both in `docker`, each part when its area changed). `lint-prettier.yml` additionally runs `lint` + `lint:format` on `shared/`, both check-only. `plugin-sdk` has no lint script and is outside the eslint gates. **Not in CI**: the screenshot and help-media Playwright projects; run them locally. There are no git hooks; nothing runs before a commit except you. Other workflows build Docker images, scan them, and publish `trek-plugin-sdk` on `plugin-sdk-v*` tags.
|
||||||
|
|
||||||
- **Job names read "package: what"** (`Server: Types`, `Client: Tests 3/7`), and the list at the top of `test.yml` says what each job holds. A new job follows the scheme and joins that list, and the job-count note there says when a long job needs a slot freed first.
|
- **Job names read "<Area> <what>[ <variant>][ i/n]"** (`Server tests 3/10`, `Server Postgres 14 2/3`, `Docker and Helm`): the area first, one of Changes, Shared, Server, Client, Docker or Sonar, then lower case, with no colon, no parentheses and no middle dot, and a slice only at the end, so the checks list sorts by area. The workflow is named `CI`, so a check reads `CI / Server tests 3/10`. Job ids are the names in kebab-case (`server-tests`), the jobs stand in `test.yml` in area order, and the list at the top of `test.yml` says what each job holds. A new job follows the scheme and joins that list; `scripts/ci/workflow-jobs.test.mjs` fails on a name outside it. `ci-ok`, `lint` and `check-target` keep their names: the ruleset requires them by name.
|
||||||
- **Tests run beside the gates, in shards.** The client and server suites run in slices on parallel runners (`client-tests`, `server-tests`, through each package's `vitest.shard.config.ts`), and `client-coverage`/`server-coverage` merge their blob reports and check the thresholds against the whole. A red slice is usually a failing test, a red merge job usually a threshold.
|
- **What the folded jobs hold.** `Shared tests` is the plugin SDK's typecheck and coverage, run before the root install so the SDK resolves only its own dependencies, then i18n parity and shared's coverage. `Client types` is the typecheck and the strict ratchet; `Client checks` the source ratchets, then the production build with `check:gl-split`. `Docker and Helm` builds and boots the image when the image area changed and checks the chart and compose files when the deploy area changed. Inside a folded job each group of steps runs after a failure in another, so one red check shows every gate that failed; the step names say which.
|
||||||
- **`ci-ok` is the required check.** The branch ruleset requires `ci-ok` (plus `lint` and `check-target` from their own workflows), and `ci-ok` needs every job above except the scan. It fails if any of them failed or was cancelled and passes if they passed or were skipped. A new gate job counts only once it is listed in `ci-ok`'s `needs:`.
|
- **Tests run beside the gates, in shards.** The client and server suites run in ten slices each on parallel runners (`client-tests`, `server-tests`, through each package's `vitest.shard.config.ts`), the Postgres lane in three per major, and the end-to-end flows in two, and `client-coverage`/`server-coverage` merge their blob reports and check the thresholds against the whole. A red slice is usually a failing test, a red merge job usually a threshold. A sliced job states its slice count in its matrix's shard axis, the `i/n` in its name and its `--shard=i/n`; `scripts/ci/workflow-jobs.test.mjs` fails until all three agree, and on any job naming `matrix.shard` or `--shard` whose axis is not the one-line `shard: [1, ..., n]` it reads.
|
||||||
|
- **`ci-ok` is the required check.** The branch ruleset requires `ci-ok` (plus `lint` and `check-target` from their own workflows), and `ci-ok` needs every job above except the scan. It fails if any of them failed or was cancelled and passes if they passed or were skipped. A new gate job counts only once it is listed in `ci-ok`'s `needs:`, and `scripts/ci/workflow-jobs.test.mjs` (in `test:ci-scripts`) fails while a job other than the scan is missing there.
|
||||||
|
- **The release pull request mirrors the push run.** On the pull request from `dev` into `main` (head branch in this repository), `changes` sets `mirror` and turns every area off (`scripts/ci/changed-areas.mjs`), so no test, gate or scan job runs, and `ci-ok` runs `scripts/ci/mirror-push-run.mjs`: it waits for the `ci-ok` of the push run of `test.yml` on `dev` for exactly the PR's head commit and passes or fails with it. No such push run, one that ended without a verdict, or a wait past 17 minutes fails with a re-run hint, never passes. A push to `dev` lists its changes against the merge base with `main`, not against the previous push, so the run it mirrors covers every area the pull request brings in, even when an earlier push's run was cancelled or red. Testing that commit twice doubled the jobs past the 60 slots.
|
||||||
- **Guides name paths that exist**: the `changes` job runs `scripts/ci/doc-paths.mjs`, which resolves every backtick path in the CLAUDE.md files, `README.md`, `server/src/nest/README.md` and the wiki against the tracked files; the missing ones are listed in `scripts/ci/doc-paths-baseline.json`, which only shrinks (`--update` after a fix).
|
- **Guides name paths that exist**: the `changes` job runs `scripts/ci/doc-paths.mjs`, which resolves every backtick path in the CLAUDE.md files, `README.md`, `server/src/nest/README.md` and the wiki against the tracked files; the missing ones are listed in `scripts/ci/doc-paths-baseline.json`, which only shrinks (`--update` after a fix).
|
||||||
- **What runs is decided by `changes`, not by `on.paths`**: `scripts/ci/changed-areas.mjs` maps the changed files to the `code`, `image` and `deploy` areas (tests: `npm run test:ci-scripts`). A path filter on the workflow would leave `ci-ok` unreported on a docs-only PR and block it. Add a new top-level file the build reads to the right area there.
|
- **What runs is decided by `changes`, not by `on.paths`**: `scripts/ci/changed-areas.mjs` maps the changed files to the `code`, `image` and `deploy` areas (tests: `npm run test:ci-scripts`). A path filter on the workflow would leave `ci-ok` unreported on a docs-only PR and block it. Add a new top-level file the build reads to the right area there. A change to `test.yml`, to `scripts/ci/` or to a local action under `.github/actions/` runs everything.
|
||||||
|
- **Setup goes through one local action.** Every job that installs dependencies uses `.github/actions/setup/action.yml` (`scope` full, client or shared; `build-shared`) instead of its own `npm ci`; `workflow-jobs.test.mjs` fails on a job that installs on its own (plugin-sdk's own install in its directory excepted). The action restores node_modules on an exact key (runner image, scope, Node ABI, `.nvmrc`, the lockfile and every workspace `package.json`, so npm ci still refuses a `package.json` out of step with the lockfile; no restore-keys) and shared/dist on a key over shared's sources and build config, and runs `npm ci` or the shared build on a miss. Only pushes to dev and main save, the npm download cache included; pull requests only read.
|
||||||
|
- **End-to-end runs in the Playwright container**, `mcr.microsoft.com/playwright:v<version>-noble` pinned by digest, so no step installs browsers or system libraries. Dependabot bumps only the lockfile: on every Playwright PR move the tag and its digest in `client-e2e` by hand (`docker buildx imagetools inspect mcr.microsoft.com/playwright:v<version>-noble`); `workflow-jobs.test.mjs` fails until the tag names the lockfile's `@playwright/test` version.
|
||||||
|
- **Budget: `ci-ok` within ten minutes.** One code run starts at most about 35 long jobs (gates, slices, Postgres, e2e, Docker), so two PR runs fit in the organisation's 60 concurrent jobs. Every job sets `timeout-minutes` of at most 20 (15 for the long ones, 10 for the short ones), which `workflow-jobs.test.mjs` holds. A new long job, slice or shard needs a reason that outweighs its slot; the job-count note at the top of `test.yml` has the numbers.
|
||||||
- **Runners and Node**: jobs run on `ubuntu-24.04`, not `ubuntu-latest`, and every `setup-node` reads `.nvmrc`. Third-party actions (anything outside `actions/*`) are pinned by commit SHA with the tag in a comment; Dependabot keeps both current.
|
- **Runners and Node**: jobs run on `ubuntu-24.04`, not `ubuntu-latest`, and every `setup-node` reads `.nvmrc`. Third-party actions (anything outside `actions/*`) are pinned by commit SHA with the tag in a comment; Dependabot keeps both current.
|
||||||
- **Security scans are advisory.** `security.yml` runs `npm audit` (what the image installs, plus `plugin-sdk`) on every PR and push into dev and main, and Docker Scout on the built image for main. Neither is required: a newly published advisory would turn every open PR red at once. Fixes are held as floors in the root `package.json` `overrides`; npm ignores an `overrides` block in a workspace `package.json`, so never put one there.
|
- **Security scans are advisory.** `security.yml` runs `npm audit` (what the image installs, plus `plugin-sdk`) on every PR and push into dev and main, and Docker Scout on the built image for main. Neither is required: a newly published advisory would turn every open PR red at once. Fixes are held as floors in the root `package.json` `overrides`; npm ignores an `overrides` block in a workspace `package.json`, so never put one there.
|
||||||
- **Releases** are dispatched by hand and refuse a commit whose `ci-ok` is not green. `docker-dev.yml` (any branch, usually dev) is the canary: it builds the dispatched commit as the next minor or major `-pre.N` and moves only `:latest-pre` and `:<major>-pre`. `docker.yml` (main only) bumps the version, commits and tags it, builds both platforms from exactly that commit and moves `:latest`, `:<major>`, `:<major>.<minor>` and `:<version>`. Its `bump=auto` only finalizes a prerelease in flight; without one it stops and asks for patch, minor or major. Ship a release that migrates or changes a lot as a prerelease first, and as a minor, so installs pinned to `:<major>.<minor>` can wait it out.
|
- **Releases** are dispatched by hand and refuse a commit whose `ci-ok` is not green. `docker-dev.yml` (any branch, usually dev) is the canary: it builds the dispatched commit as the next minor or major `-pre.N` and moves only `:latest-pre` and `:<major>-pre`. `docker.yml` (main only) bumps the version, commits and tags it, builds both platforms from exactly that commit and moves `:latest`, `:<major>`, `:<major>.<minor>` and `:<version>`. Its `bump=auto` only finalizes a prerelease in flight; without one it stops and asks for patch, minor or major. Ship a release that migrates or changes a lot as a prerelease first, and as a minor, so installs pinned to `:<major>.<minor>` can wait it out.
|
||||||
|
|||||||
+23
-6
@@ -70,9 +70,25 @@ COPY server/package.json ./server/
|
|||||||
# gypfile:false (npm/cli#9837). The only other install scripts among the runtime
|
# gypfile:false (npm/cli#9837). The only other install scripts among the runtime
|
||||||
# deps are esbuild's binary check, redundant next to its optional platform
|
# deps are esbuild's binary check, redundant next to its optional platform
|
||||||
# package, and a telemetry ping.
|
# package, and a telemetry ping.
|
||||||
RUN apt-get update && \
|
# The upgrade takes the Debian security fixes the base image was built before
|
||||||
|
# (zlib, 11/2026, failed the image scan until node:24-trixie-slim caught up).
|
||||||
|
#
|
||||||
|
# postgresql-client-18 brings pg_dump, pg_restore and psql to
|
||||||
|
# /usr/lib/postgresql/18/bin, which back up and restore an install on Postgres
|
||||||
|
# (TREK_DB_URL). A client handles every server up to its own major and refuses
|
||||||
|
# a newer one, so the image carries the newest major TREK supports (14 to 18).
|
||||||
|
# Debian 13 ships 17 only, so it comes from the PostgreSQL project's apt
|
||||||
|
# repository (PGDG): the `18` component lists that major's packages and no
|
||||||
|
# other, and the repository's signing key (fingerprint B97B 0AFC AA1A 47F0 44F2
|
||||||
|
# 44A0 7FCC 7D46 ACCC 4CF8) is kept beside the entrypoint instead of fetched at
|
||||||
|
# build time. Raise both together when TREK supports a newer major.
|
||||||
|
COPY server/scripts/pgdg-apt-key.asc /etc/apt/keyrings/pgdg.asc
|
||||||
|
RUN echo 'deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt trixie-pgdg main 18' \
|
||||||
|
> /etc/apt/sources.list.d/pgdg.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get upgrade -y --no-install-recommends && \
|
||||||
apt-get install -y --no-install-recommends tzdata dumb-init wget ca-certificates \
|
apt-get install -y --no-install-recommends tzdata dumb-init wget ca-certificates \
|
||||||
libkitinerary-bin libsqlite3-0 && \
|
libkitinerary-bin libsqlite3-0 postgresql-client-18 && \
|
||||||
npm ci --workspace=server --omit=dev --ignore-scripts && \
|
npm ci --workspace=server --omit=dev --ignore-scripts && \
|
||||||
{ ln -sf "$(find /usr/lib -name kitinerary-extractor -type f | head -1)" /usr/local/bin/kitinerary-extractor || true; } && \
|
{ ln -sf "$(find /usr/lib -name kitinerary-extractor -type f | head -1)" /usr/local/bin/kitinerary-extractor || true; } && \
|
||||||
rm -rf /var/lib/apt/lists/* /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx && \
|
rm -rf /var/lib/apt/lists/* /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx && \
|
||||||
@@ -91,8 +107,9 @@ ENV KITINERARY_EXTRACTOR_PATH=/usr/local/bin/kitinerary-extractor
|
|||||||
|
|
||||||
COPY --chown=node:node --from=server-builder /app/server/dist ./server/dist
|
COPY --chown=node:node --from=server-builder /app/server/dist ./server/dist
|
||||||
# Runtime data assets read from server/assets at runtime: airports.json (flight
|
# Runtime data assets read from server/assets at runtime: airports.json (flight
|
||||||
# transport search) and atlas/*.geojson.gz + atlas/admin1/*.geojson.gz (Atlas
|
# transport search), atlas/*.geojson.gz + atlas/admin1/*.geojson.gz (Atlas
|
||||||
# country/region map). The build
|
# country/region map) and postgres/baseline.* (the schema a fresh Postgres
|
||||||
|
# database starts from). The build
|
||||||
# only emits dist, so these must be copied explicitly or the features silently
|
# only emits dist, so these must be copied explicitly or the features silently
|
||||||
# degrade to empty in the image.
|
# degrade to empty in the image.
|
||||||
COPY --chown=node:node --from=server-builder /app/server/assets ./server/assets
|
COPY --chown=node:node --from=server-builder /app/server/assets ./server/assets
|
||||||
@@ -103,9 +120,9 @@ COPY --chown=node:node wiki ./wiki
|
|||||||
# tsconfig-paths/register reads this at runtime to resolve MCP SDK paths.
|
# tsconfig-paths/register reads this at runtime to resolve MCP SDK paths.
|
||||||
COPY --chown=node:node server/tsconfig.json ./server/
|
COPY --chown=node:node server/tsconfig.json ./server/
|
||||||
# Encryption-key rotation is run on demand via tsx (a prod dep) straight from the
|
# Encryption-key rotation is run on demand via tsx (a prod dep) straight from the
|
||||||
# raw .ts source — it never enters dist, so it must be copied in explicitly or
|
# raw .ts source (the command and its stores module). They never enter dist, so they must be copied in explicitly or
|
||||||
# `node --import tsx scripts/migrate-encryption.ts` fails with module-not-found.
|
# `node --import tsx scripts/migrate-encryption.ts` fails with module-not-found.
|
||||||
COPY --chown=node:node server/scripts/migrate-encryption.ts ./server/scripts/migrate-encryption.ts
|
COPY --chown=node:node server/scripts/migrate-encryption.ts server/scripts/migrate-encryption-stores.ts ./server/scripts/
|
||||||
# Admin recovery script (node server/reset-admin.js) for locked-out installs.
|
# Admin recovery script (node server/reset-admin.js) for locked-out installs.
|
||||||
COPY --chown=node:node server/reset-admin.js ./server/reset-admin.js
|
COPY --chown=node:node server/reset-admin.js ./server/reset-admin.js
|
||||||
COPY --chown=node:node --from=shared-builder /app/shared/dist ./shared/dist
|
COPY --chown=node:node --from=shared-builder /app/shared/dist ./shared/dist
|
||||||
|
|||||||
@@ -20,7 +20,23 @@ geoBoundaries is licensed under **CC BY 4.0**
|
|||||||
The bundled files are simplified (coordinate-quantized) and re-tagged with the
|
The bundled files are simplified (coordinate-quantized) and re-tagged with the
|
||||||
property names TREK consumes. Country borders (`admin0`) derive from the geoBoundaries
|
property names TREK consumes. Country borders (`admin0`) derive from the geoBoundaries
|
||||||
CGAZ composite; sub-national regions (`admin1`) derive from the per-country open
|
CGAZ composite; sub-national regions (`admin1`) derive from the per-country open
|
||||||
(gbOpen) release.
|
(gbOpen) release, except for Ireland (below).
|
||||||
|
|
||||||
|
## Tailte Éireann — counties of Ireland
|
||||||
|
|
||||||
|
Ireland's regions in the same files (`admin1/IE.geojson.gz`, and its features in
|
||||||
|
`admin1.geojson.gz`) are the 26 counties from Tailte Éireann's *Counties - National
|
||||||
|
Statutory Boundaries - 2019 - Generalised 20m*, because geoBoundaries has no county
|
||||||
|
layer for Ireland.
|
||||||
|
|
||||||
|
Contains Tailte Éireann data, © Tailte Éireann, licensed under **CC BY 4.0**
|
||||||
|
(https://creativecommons.org/licenses/by/4.0/). Source:
|
||||||
|
https://data-osi.opendata.arcgis.com/
|
||||||
|
|
||||||
|
The outlines are simplified, coordinate-quantized and re-tagged with ISO 3166-2:IE
|
||||||
|
codes by `server/scripts/build-atlas-geo.mjs`. Tailte Éireann publishes the
|
||||||
|
generalised boundaries for reference only; they may not match the statutory
|
||||||
|
boundaries exactly.
|
||||||
|
|
||||||
## OpenStreetMap — geocoding, place details & descriptions
|
## OpenStreetMap — geocoding, place details & descriptions
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ Most of what follows is an addon an admin switches on or off. Lists, Costs, Docu
|
|||||||
#### 🗺️ Atlas, Vacay and Collections
|
#### 🗺️ Atlas, Vacay and Collections
|
||||||
|
|
||||||
- **Atlas**: countries and regions visited on [geoBoundaries](https://www.geoboundaries.org/) outlines, a bucket list, travel stats, and a tour activities tab with planned against recorded totals
|
- **Atlas**: countries and regions visited on [geoBoundaries](https://www.geoboundaries.org/) outlines, a bucket list, travel stats, and a tour activities tab with planned against recorded totals
|
||||||
- **Vacay**: leave calendar with half days, public holidays from date.nager.at, school holidays for 16 European countries, company holidays, carry-over between years, and joint or read-only sharing
|
- **Vacay**: leave calendar with half days, public holidays from [nagerholidays.com](https://nagerholidays.com), school holidays for 16 European countries, company holidays, carry-over between years, and joint or read-only sharing
|
||||||
- **Collections** (off by default): a place library outside any trip with lists, labels, ratings, a status per place, cover images, GPX and file export, copy into a trip, and sharing by invite
|
- **Collections** (off by default): a place library outside any trip with lists, labels, ratings, a status per place, cover images, GPX and file export, copy into a trip, and sharing by invite
|
||||||
- **Dawarich** (off by default): link a Dawarich instance for recorded tracks, suggested stays and countries for the Atlas
|
- **Dawarich** (off by default): link a Dawarich instance for recorded tracks, suggested stays and countries for the Atlas
|
||||||
|
|
||||||
@@ -276,6 +276,8 @@ Open `http://localhost:3000`, or `http://<server-ip>:3000` from another machine.
|
|||||||
|
|
||||||
`COOKIE_SECURE=false` is only for trying TREK over plain HTTP: without it the browser drops the session cookie and the login does not stick. Once TREK sits behind HTTPS (see [Reverse Proxy](#reverse-proxy)), remove it.
|
`COOKIE_SECURE=false` is only for trying TREK over plain HTTP: without it the browser drops the session cookie and the login does not stick. Once TREK sits behind HTTPS (see [Reverse Proxy](#reverse-proxy)), remove it.
|
||||||
|
|
||||||
|
**TrueNAS SCALE:** Install TREK directly from the Community catalog. See the [TrueNAS SCALE installation guide](https://github.com/liketrek/TREK/wiki/Install-TrueNAS-SCALE).
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> **No server yet?** TREK's own public services run on [**dataforest cloud**](https://cloud.dataforest.net/en?mtm_campaign=trek), our infrastructure sponsor. A small seed is plenty for a TREK instance and is ready within a minute.
|
> **No server yet?** TREK's own public services run on [**dataforest cloud**](https://cloud.dataforest.net/en?mtm_campaign=trek), our infrastructure sponsor. A small seed is plenty for a TREK instance and is ready within a minute.
|
||||||
|
|
||||||
@@ -319,6 +321,11 @@ docker compose up -d
|
|||||||
See [Install with Docker Compose](https://github.com/liketrek/TREK/wiki/Install-Docker-Compose)
|
See [Install with Docker Compose](https://github.com/liketrek/TREK/wiki/Install-Docker-Compose)
|
||||||
for the full walkthrough.
|
for the full walkthrough.
|
||||||
|
|
||||||
|
TREK stores its data in SQLite by default. Set `TREK_DB_URL` to run it on a PostgreSQL 14 to 18 database instead. The
|
||||||
|
[`docker-compose.postgres.yml`](docker-compose.postgres.yml) example starts one beside TREK, and the
|
||||||
|
[Postgres guide](https://github.com/liketrek/TREK/wiki/Database-Postgres) covers the requirements, the backups and
|
||||||
|
how to move an existing SQLite install to Postgres with the command TREK ships for it.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<h2 id="helm-kubernetes">Helm (Kubernetes)</h2>
|
<h2 id="helm-kubernetes">Helm (Kubernetes)</h2>
|
||||||
@@ -348,7 +355,7 @@ TREK then launches fullscreen with its own icon, just like a native app.
|
|||||||
## Updating
|
## Updating
|
||||||
|
|
||||||
See [Updating](https://github.com/liketrek/TREK/wiki/Updating) — Docker Compose,
|
See [Updating](https://github.com/liketrek/TREK/wiki/Updating) — Docker Compose,
|
||||||
Docker run, Helm, Portainer, Unraid and Proxmox, plus the encryption-key note.
|
Docker run, Helm, Portainer, Unraid, TrueNAS SCALE and Proxmox, plus the encryption-key note.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@@ -437,8 +444,9 @@ Every variable, its default and what it does: see
|
|||||||
|
|
||||||
The Atlas map's country and sub-national (province/county) boundaries come from
|
The Atlas map's country and sub-national (province/county) boundaries come from
|
||||||
[**geoBoundaries**](https://www.geoboundaries.org/) (Runfola et al., 2020), licensed
|
[**geoBoundaries**](https://www.geoboundaries.org/) (Runfola et al., 2020), licensed
|
||||||
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). See [NOTICE.md](NOTICE.md)
|
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); Ireland's counties come from
|
||||||
for full third-party attributions.
|
[**Tailte Éireann**](https://data-osi.opendata.arcgis.com/), also CC BY 4.0. See
|
||||||
|
[NOTICE.md](NOTICE.md) for full third-party attributions.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -43,8 +43,10 @@ See `values.yaml` for more options.
|
|||||||
## Notes
|
## Notes
|
||||||
- Ingress is off by default. Enable and configure hosts for your domain.
|
- Ingress is off by default. Enable and configure hosts for your domain.
|
||||||
- PVCs use the cluster's default StorageClass. Set `persistence.data.storageClassName` and/or `persistence.uploads.storageClassName` to bind a specific class.
|
- PVCs use the cluster's default StorageClass. Set `persistence.data.storageClassName` and/or `persistence.uploads.storageClassName` to bind a specific class.
|
||||||
- To use your own PVCs, set `persistence.data.existingClaim` and/or `persistence.uploads.existingClaim`. The other values for that volume (size, storageClassName, annotations) are then ignored.
|
- Both PVCs are `ReadWriteOnce`. Set `persistence.data.accessModes` and/or `persistence.uploads.accessModes` to override, for example `[ReadWriteMany]` so a backup pod can mount the volume. On the data volume such a pod may only read: SQLite corrupts `travel.db` when a second process writes it over a network filesystem.
|
||||||
|
- To use your own PVCs, set `persistence.data.existingClaim` and/or `persistence.uploads.existingClaim`. The other values for that volume (size, storageClassName, accessModes, annotations) are then ignored.
|
||||||
- With `persistence.enabled: false`, the data and uploads volumes use an `emptyDir` — storage is ephemeral and lost on pod restart. Intended for testing only.
|
- With `persistence.enabled: false`, the data and uploads volumes use an `emptyDir` — storage is ephemeral and lost on pod restart. Intended for testing only.
|
||||||
|
- `database.url` runs TREK on a PostgreSQL database instead of the SQLite file. The chart writes it into its Secret as `TREK_DB_URL`; `database.existingSecret` and `database.existingSecretKey` read it from a Secret you manage. Leave both empty for SQLite. Keep `replicas: 1` either way. See the wiki page `Database-Postgres`.
|
||||||
- `JWT_SECRET` is managed entirely by the server — auto-generated into the data PVC on first start and rotatable via the admin panel (Settings → Danger Zone). No Helm configuration needed.
|
- `JWT_SECRET` is managed entirely by the server — auto-generated into the data PVC on first start and rotatable via the admin panel (Settings → Danger Zone). No Helm configuration needed.
|
||||||
- `ENCRYPTION_KEY` encrypts stored secrets (API keys, MFA, SMTP, OIDC) at rest. Recommended: set via `secretEnv.ENCRYPTION_KEY` or `existingSecret`. If left empty, the server falls back automatically: existing installs use `data/.jwt_secret` (no action needed on upgrade); fresh installs auto-generate a key persisted to the data PVC.
|
- `ENCRYPTION_KEY` encrypts stored secrets (API keys, MFA, SMTP, OIDC) at rest. Recommended: set via `secretEnv.ENCRYPTION_KEY` or `existingSecret`. If left empty, the server falls back automatically: existing installs use `data/.jwt_secret` (no action needed on upgrade); fresh installs auto-generate a key persisted to the data PVC.
|
||||||
- Liveness and readiness probes are configurable under `probes`. Overrides are merged over the defaults, so `--set probes.liveness.initialDelaySeconds=60` keeps the `httpGet` handler. When switching to `exec` or `tcpSocket`, clear `httpGet` in the same override. Set `probes.liveness: null` to remove a probe.
|
- Liveness and readiness probes are configurable under `probes`. Overrides are merged over the defaults, so `--set probes.liveness.initialDelaySeconds=60` keeps the `httpGet` handler. When switching to `exec` or `tcpSocket`, clear `httpGet` in the same override. Set `probes.liveness: null` to remove a probe.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: trek
|
name: trek
|
||||||
version: 5.1.0
|
version: 5.1.4
|
||||||
description: Minimal Helm chart for TREK app
|
description: Minimal Helm chart for TREK app
|
||||||
appVersion: "5.1.0"
|
appVersion: "5.1.4"
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
{{- if and .Values.database.url (not .Values.database.existingSecret) .Values.existingSecret }}
|
||||||
|
{{- fail "database.url is written into the chart's own Secret, which existingSecret replaces. Put TREK_DB_URL in your Secret and set database.existingSecret instead." }}
|
||||||
|
{{- end }}
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@@ -5,11 +8,13 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
app: {{ include "trek.name" . }}
|
app: {{ include "trek.name" . }}
|
||||||
spec:
|
spec:
|
||||||
|
# One replica. Its rate limits, pending codes, permission cache and WebSocket
|
||||||
|
# connections live in the process's memory, so a second pod would not share them. That
|
||||||
|
# holds with database.url (PostgreSQL) too; see updateStrategy in values.yaml.
|
||||||
replicas: 1
|
replicas: 1
|
||||||
# TREK is a single-writer SQLite app on a ReadWriteOnce PVC, so the default
|
# The default RollingUpdate would start a second pod on the same ReadWriteOnce PVC
|
||||||
# RollingUpdate would start a second pod holding the same volume before the old one
|
# before the old one exits: a Multi-Attach deadlock, or two processes on one travel.db.
|
||||||
# exits — a Multi-Attach deadlock, or two processes on one travel.db. Recreate tears
|
# Recreate tears the old pod down first. Keep it, see updateStrategy in values.yaml.
|
||||||
# the old pod down first. Keep it, see updateStrategy in values.yaml.
|
|
||||||
strategy:
|
strategy:
|
||||||
type: {{ .Values.updateStrategy | default "Recreate" }}
|
type: {{ .Values.updateStrategy | default "Recreate" }}
|
||||||
selector:
|
selector:
|
||||||
@@ -61,6 +66,14 @@ spec:
|
|||||||
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.existingSecret }}
|
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.existingSecret }}
|
||||||
key: {{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}
|
key: {{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}
|
||||||
optional: true
|
optional: true
|
||||||
|
{{- if or .Values.database.url .Values.database.existingSecret }}
|
||||||
|
# Required when set: a missing key stops the pod rather than starting it on SQLite.
|
||||||
|
- name: TREK_DB_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.database.existingSecret }}
|
||||||
|
key: {{ if .Values.database.existingSecret }}{{ .Values.database.existingSecretKey | default "TREK_DB_URL" }}{{ else }}TREK_DB_URL{{ end }}
|
||||||
|
{{- end }}
|
||||||
- name: ADMIN_EMAIL
|
- name: ADMIN_EMAIL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
{{- toYaml (.Values.persistence.data.accessModes | default (list "ReadWriteOnce")) | nindent 4 }}
|
||||||
{{- with .Values.persistence.data.storageClassName }}
|
{{- with .Values.persistence.data.storageClassName }}
|
||||||
storageClassName: {{ . | quote }}
|
storageClassName: {{ . | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -33,7 +33,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
{{- toYaml (.Values.persistence.uploads.accessModes | default (list "ReadWriteOnce")) | nindent 4 }}
|
||||||
{{- with .Values.persistence.uploads.storageClassName }}
|
{{- with .Values.persistence.uploads.storageClassName }}
|
||||||
storageClassName: {{ . | quote }}
|
storageClassName: {{ . | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ metadata:
|
|||||||
type: Opaque
|
type: Opaque
|
||||||
data:
|
data:
|
||||||
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ .Values.secretEnv.ENCRYPTION_KEY | b64enc | quote }}
|
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ .Values.secretEnv.ENCRYPTION_KEY | b64enc | quote }}
|
||||||
|
{{- if .Values.database.url }}
|
||||||
|
TREK_DB_URL: {{ .Values.database.url | b64enc | quote }}
|
||||||
|
{{- end }}
|
||||||
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
||||||
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | b64enc | quote }}
|
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | b64enc | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -65,6 +68,9 @@ stringData:
|
|||||||
{{- else }}
|
{{- else }}
|
||||||
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ randAlphaNum 32 | quote }}
|
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ randAlphaNum 32 | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if .Values.database.url }}
|
||||||
|
TREK_DB_URL: {{ .Values.database.url | quote }}
|
||||||
|
{{- end }}
|
||||||
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
||||||
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | quote }}
|
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
+33
-5
@@ -4,10 +4,13 @@ image:
|
|||||||
# tag: latest
|
# tag: latest
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
# Deployment update strategy. Keep Recreate: TREK is a single-writer SQLite app, and
|
# Deployment update strategy. Keep Recreate. The new pod migrates the database when it
|
||||||
# during a RollingUpdate the new pod migrates the database while the old one still
|
# starts, and during a RollingUpdate it would do that while the old pod still writes to
|
||||||
# writes to it. A ReadWriteMany volume does not make that safe; SQLite's WAL needs both
|
# it. Recreate stops the old pod first. On SQLite two processes on one travel.db are
|
||||||
# processes on one host, which network filesystems do not provide.
|
# unsafe, and a ReadWriteOnce volume cannot be attached to both pods at once.
|
||||||
|
# With database.url the database is PostgreSQL, but the reason for one replica stays: TREK
|
||||||
|
# keeps rate limits, pending codes, the permission cache and WebSocket connections in
|
||||||
|
# memory, so a second pod would not share them. Postgres does not make more replicas safe.
|
||||||
updateStrategy: Recreate
|
updateStrategy: Recreate
|
||||||
|
|
||||||
# Pod-level security context. fsGroup gives the node user (uid/gid 1000) group access
|
# Pod-level security context. fsGroup gives the node user (uid/gid 1000) group access
|
||||||
@@ -178,6 +181,22 @@ env:
|
|||||||
# address is sent unless you set one here.
|
# address is sent unless you set one here.
|
||||||
|
|
||||||
|
|
||||||
|
# Database. Empty (the default) keeps TREK on its SQLite file in the data volume. Set url to
|
||||||
|
# run TREK on a PostgreSQL database instead (see the wiki page Database-Postgres). The URL
|
||||||
|
# carries the password, so it is never a plain env value: with url, the chart writes it into
|
||||||
|
# its own Secret as TREK_DB_URL; with existingSecret, TREK reads TREK_DB_URL from that Secret
|
||||||
|
# under existingSecretKey and the chart writes nothing. existingSecret wins over url. The
|
||||||
|
# variable is required when either is set: a missing Secret key stops the pod instead of
|
||||||
|
# starting it on SQLite. The role in the URL owns TREK's database and must not be a superuser
|
||||||
|
# (nor a member of one, nor hold a right that reaches the server's files or programs): a
|
||||||
|
# restore runs the backup's SQL as that role and refuses one that could reach the database host. The wiki page shows the
|
||||||
|
# SQL that creates such a role. PostgreSQL 14 to 18 is supported.
|
||||||
|
# url: "postgres://trek:<password>@postgres.example.internal:5432/trek?sslmode=require"
|
||||||
|
database:
|
||||||
|
url: ""
|
||||||
|
existingSecret: ""
|
||||||
|
existingSecretKey: TREK_DB_URL
|
||||||
|
|
||||||
# Secret environment variables stored in a Kubernetes Secret.
|
# Secret environment variables stored in a Kubernetes Secret.
|
||||||
# JWT_SECRET is managed entirely by the server (auto-generated into the data PVC,
|
# JWT_SECRET is managed entirely by the server (auto-generated into the data PVC,
|
||||||
# rotatable via the admin panel) — it is not configured here.
|
# rotatable via the admin panel) — it is not configured here.
|
||||||
@@ -247,12 +266,21 @@ persistence:
|
|||||||
size: 1Gi
|
size: 1Gi
|
||||||
# Leave empty to use the cluster's default StorageClass; set to bind a specific class.
|
# Leave empty to use the cluster's default StorageClass; set to bind a specific class.
|
||||||
storageClassName: ""
|
storageClassName: ""
|
||||||
# Bind an existing PVC. The other values (size, storageClassName, annotations) are then ignored.
|
# Access modes of the claim. ReadWriteMany lets another pod mount the volume, for
|
||||||
|
# example a backup sidecar, but only for reading: SQLite needs every writer on one
|
||||||
|
# host, so two pods writing travel.db over a network filesystem corrupt it.
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
# Bind an existing PVC. The other values (size, storageClassName, accessModes,
|
||||||
|
# annotations) are then ignored.
|
||||||
existingClaim: ""
|
existingClaim: ""
|
||||||
annotations: {}
|
annotations: {}
|
||||||
uploads:
|
uploads:
|
||||||
size: 1Gi
|
size: 1Gi
|
||||||
storageClassName: ""
|
storageClassName: ""
|
||||||
|
# Access modes of the claim; ReadWriteMany lets other pods read or add uploads.
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
# Specify an existing PVC to bind. The other values are then ignored.
|
# Specify an existing PVC to bind. The other values are then ignored.
|
||||||
existingClaim: ""
|
existingClaim: ""
|
||||||
annotations: {}
|
annotations: {}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ Scope: the **`@trek/client`** workspace (React 19 + Vite + Zustand + Tailwind PW
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev # Vite dev server; proxies the API/ws/uploads/MCP/OAuth paths → http://localhost:3001
|
npm run dev # Vite dev server; proxies the API/ws/uploads/MCP/OAuth paths → http://localhost:3001
|
||||||
npm run build # prebuild generates PWA icons, then vite build
|
npm run build # prebuild generates PWA icons, then vite build; postbuild writes a Brotli copy beside each hashed asset for the server to hand out
|
||||||
npm run typecheck # tsc --noEmit (CI)
|
npm run typecheck # tsc --noEmit (CI)
|
||||||
npm run lint:strict # tsc over tsconfig.strict.json (strictNullChecks + noImplicitAny): errors per file may only shrink against scripts/strict-baseline.json, a new file starts at zero (CI gate; --list shows them, --update lowers it)
|
npm run lint:strict # tsc over tsconfig.strict.json (strictNullChecks + noImplicitAny): errors per file may only shrink against scripts/strict-baseline.json, a new file starts at zero (CI gate; --list shows them, --update lowers it)
|
||||||
npm run lint # eslint . (CI runs lint:warnings instead, which fails on the same errors)
|
npm run lint # eslint . (CI runs lint:warnings instead, which fails on the same errors)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ android {
|
|||||||
|
|
||||||
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(':capacitor-action-sheet')
|
||||||
implementation project(':capacitor-app')
|
implementation project(':capacitor-app')
|
||||||
|
implementation project(':capacitor-dialog')
|
||||||
implementation project(':capacitor-filesystem')
|
implementation project(':capacitor-filesystem')
|
||||||
implementation project(':capacitor-haptics')
|
implementation project(':capacitor-haptics')
|
||||||
implementation project(':capacitor-keyboard')
|
implementation project(':capacitor-keyboard')
|
||||||
|
|||||||
+9
@@ -36,3 +36,12 @@
|
|||||||
@android.webkit.JavascriptInterface <methods>;
|
@android.webkit.JavascriptInterface <methods>;
|
||||||
}
|
}
|
||||||
-keep public class * extends com.getcapacitor.Plugin
|
-keep public class * extends com.getcapacitor.Plugin
|
||||||
|
|
||||||
|
# The stored copy of the server's UI gets Capacitor's bridge the way the
|
||||||
|
# server's own page does (TrekOfflineShell.withBridge reads it by reflection).
|
||||||
|
-keepclassmembers class com.getcapacitor.Bridge {
|
||||||
|
private com.getcapacitor.JSInjector getJSInjector();
|
||||||
|
}
|
||||||
|
-keep class com.getcapacitor.JSInjector {
|
||||||
|
public java.io.InputStream getInjectedStream(java.io.InputStream);
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import androidx.glance.appwidget.GlanceRemoteViews
|
|||||||
import com.liketrek.trek.tripday.TripDayNotification
|
import com.liketrek.trek.tripday.TripDayNotification
|
||||||
import com.liketrek.trek.widget.AtlasWidget
|
import com.liketrek.trek.widget.AtlasWidget
|
||||||
import com.liketrek.trek.widget.BookingsWidget
|
import com.liketrek.trek.widget.BookingsWidget
|
||||||
|
import com.liketrek.trek.widget.FlightWidget
|
||||||
import com.liketrek.trek.widget.CollabWidget
|
import com.liketrek.trek.widget.CollabWidget
|
||||||
import com.liketrek.trek.widget.PackingWidget
|
import com.liketrek.trek.widget.PackingWidget
|
||||||
import com.liketrek.trek.widget.TodayWidget
|
import com.liketrek.trek.widget.TodayWidget
|
||||||
@@ -74,6 +75,7 @@ class WidgetGalleryActivity : Activity() {
|
|||||||
"trip" to TripWidget(),
|
"trip" to TripWidget(),
|
||||||
"today" to TodayWidget(),
|
"today" to TodayWidget(),
|
||||||
"bookings" to BookingsWidget(),
|
"bookings" to BookingsWidget(),
|
||||||
|
"flight" to FlightWidget(),
|
||||||
"todos" to TodosWidget(),
|
"todos" to TodosWidget(),
|
||||||
"packing" to PackingWidget(),
|
"packing" to PackingWidget(),
|
||||||
"atlas" to AtlasWidget(),
|
"atlas" to AtlasWidget(),
|
||||||
|
|||||||
@@ -142,6 +142,15 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_bookings" />
|
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_bookings" />
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<receiver
|
||||||
|
android:name=".widget.FlightWidgetReceiver"
|
||||||
|
android:label="@string/widget_flight_name"
|
||||||
|
android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_flight" />
|
||||||
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".widget.TodosWidgetReceiver"
|
android:name=".widget.TodosWidgetReceiver"
|
||||||
android:label="@string/widget_todos_name"
|
android:label="@string/widget_todos_name"
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
package com.liketrek.trek;
|
package com.liketrek.trek;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.KeyboardShortcutGroup;
|
import android.view.KeyboardShortcutGroup;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import com.getcapacitor.BridgeActivity;
|
import com.getcapacitor.BridgeActivity;
|
||||||
import com.liketrek.trek.screen.TrekKeyCommands;
|
import com.liketrek.trek.screen.TrekKeyCommands;
|
||||||
import com.liketrek.trek.tiles.TrekTileStore;
|
import com.liketrek.trek.tiles.TrekTileStore;
|
||||||
@@ -26,6 +35,19 @@ public class MainActivity extends BridgeActivity {
|
|||||||
// runs and on its own origin. BridgeActivity reads `config` while it
|
// runs and on its own origin. BridgeActivity reads `config` while it
|
||||||
// builds the bridge inside super.onCreate().
|
// builds the bridge inside super.onCreate().
|
||||||
boolean restarting = TrekServerStore.consumeRestart(this);
|
boolean restarting = TrekServerStore.consumeRestart(this);
|
||||||
|
// Without a network the server cannot answer: with a copy of its UI the
|
||||||
|
// app starts on that at once (TrekOfflineShell), as it does when the
|
||||||
|
// address screen found the server out of reach. The check an update asks
|
||||||
|
// for waits for a launch that can reach the server.
|
||||||
|
boolean offlineStart = TrekServerStore.consumeOfflineStart(this)
|
||||||
|
|| (!TrekOfflineShell.hasNetwork(this) && TrekOfflineShell.hasCopy(this, TrekServerStore.getUrlOrPrevious(this)));
|
||||||
|
if (offlineStart && TrekOfflineShell.hasCopy(this, TrekServerStore.getUrlOrPrevious(this))) {
|
||||||
|
TrekServerStore.restoreForOffline(this);
|
||||||
|
TrekOfflineShell.activate(TrekServerStore.getUrl(this));
|
||||||
|
} else {
|
||||||
|
TrekOfflineShell.deactivate();
|
||||||
|
TrekServerStore.recheckAfterUpdate(this);
|
||||||
|
}
|
||||||
String server = TrekServerStore.getUrl(this);
|
String server = TrekServerStore.getUrl(this);
|
||||||
boolean onServer = server != null && !TrekServerStore.consumeShellOnce(this);
|
boolean onServer = server != null && !TrekServerStore.consumeShellOnce(this);
|
||||||
config = TrekServerStore.configFor(this, onServer ? server : null, restarting);
|
config = TrekServerStore.configFor(this, onServer ? server : null, restarting);
|
||||||
@@ -36,7 +58,17 @@ public class MainActivity extends BridgeActivity {
|
|||||||
// scroller natively. It scales the whole view, top bar and bottom dock included.
|
// scroller natively. It scales the whole view, top bar and bottom dock included.
|
||||||
bridge.getWebView().setOverScrollMode(View.OVER_SCROLL_NEVER);
|
bridge.getWebView().setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||||
// Set before any WebView callback can run: they are posted to this thread.
|
// Set before any WebView callback can run: they are posted to this thread.
|
||||||
if (onServer) bridge.setWebViewClient(new TrekWebViewClient(bridge, this::showAddressScreen));
|
if (onServer) {
|
||||||
|
bridge.setWebViewClient(
|
||||||
|
new TrekWebViewClient(
|
||||||
|
bridge,
|
||||||
|
this::showAddressScreen,
|
||||||
|
this::showSignInBar,
|
||||||
|
this::showErrorPageBar,
|
||||||
|
TrekServerStore.getSignInHosts(this)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
TrekSharedFiles.receive(this, getIntent());
|
TrekSharedFiles.receive(this, getIntent());
|
||||||
// Android 15's widget picker draws the widgets live from a sample trip.
|
// Android 15's widget picker draws the widgets live from a sample trip.
|
||||||
TrekWidgetUpdater.publishPreviews(this);
|
TrekWidgetUpdater.publishPreviews(this);
|
||||||
@@ -60,6 +92,18 @@ public class MainActivity extends BridgeActivity {
|
|||||||
if (group != null) data.add(group);
|
if (group != null) data.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The web view keeps new cookies in memory and writes them to disk on its
|
||||||
|
* own schedule, about half a minute later. An app Android ends in that time
|
||||||
|
* (swiped away, or reclaimed for memory) forgets the sign-in it just had, so
|
||||||
|
* the session is written down whenever the app leaves the screen.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
CookieManager.getInstance().flush();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewIntent(Intent intent) {
|
public void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
@@ -68,6 +112,122 @@ public class MainActivity extends BridgeActivity {
|
|||||||
|
|
||||||
private boolean leavingServer;
|
private boolean leavingServer;
|
||||||
|
|
||||||
|
private View signInBar;
|
||||||
|
/** Whether the page is a proxy's sign-in page, and whether the keyboard is up over it. */
|
||||||
|
private boolean onSignInPage;
|
||||||
|
/** Whether the page is an error page in place of the server's (TrekWebViewClient.onReceivedHttpError). */
|
||||||
|
private boolean onErrorPage;
|
||||||
|
private boolean keyboardUp;
|
||||||
|
private TextView signInHint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Over a proxy's sign-in page (Pangolin, authentik, ...): the server's UI is
|
||||||
|
* not there, so nothing else would lead back to the address screen, and a
|
||||||
|
* passkey cannot work in a web view for a domain the app is not tied to.
|
||||||
|
* The bar says so and offers to change the server.
|
||||||
|
*/
|
||||||
|
private void showSignInBar(boolean show) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
onSignInPage = show;
|
||||||
|
if (show && signInBar == null) signInBar = buildSignInBar();
|
||||||
|
updateSignInBar();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The same bar over an error page in place of the server's, with words for that. */
|
||||||
|
private void showErrorPageBar(boolean show) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
onErrorPage = show;
|
||||||
|
if (show && signInBar == null) signInBar = buildSignInBar();
|
||||||
|
updateSignInBar();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Out of the way while the keyboard is up: the form needs the room, and the bar is there again once it closes. */
|
||||||
|
private void updateSignInBar() {
|
||||||
|
if (signInBar == null) return;
|
||||||
|
if (signInHint != null) {
|
||||||
|
signInHint.setText(onSignInPage ? TrekServerStore.signInHintLabel(this) : TrekServerStore.errorPageHintLabel(this));
|
||||||
|
}
|
||||||
|
signInBar.setVisibility((onSignInPage || onErrorPage) && !keyboardUp ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View buildSignInBar() {
|
||||||
|
float dp = getResources().getDisplayMetrics().density;
|
||||||
|
LinearLayout bar = new LinearLayout(this);
|
||||||
|
bar.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
bar.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
bar.setPaddingRelative(Math.round(16 * dp), Math.round(10 * dp), Math.round(10 * dp), Math.round(10 * dp));
|
||||||
|
// The look of the app's own first screens: a white card with a sand edge,
|
||||||
|
// warm grey text and a dark button, over whatever page the proxy shows.
|
||||||
|
GradientDrawable background = new GradientDrawable();
|
||||||
|
background.setColor(0xF7FFFFFF);
|
||||||
|
background.setCornerRadius(18 * dp);
|
||||||
|
background.setStroke(Math.max(1, Math.round(dp)), 0xFFEFE4D8);
|
||||||
|
bar.setBackground(background);
|
||||||
|
bar.setElevation(8 * dp);
|
||||||
|
|
||||||
|
TextView hint = new TextView(this);
|
||||||
|
signInHint = hint;
|
||||||
|
hint.setText(TrekServerStore.signInHintLabel(this));
|
||||||
|
hint.setTextColor(0xFF6B5F57);
|
||||||
|
hint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.5f);
|
||||||
|
bar.addView(hint, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
|
|
||||||
|
Button change = new Button(this, null, android.R.attr.borderlessButtonStyle);
|
||||||
|
change.setText(TrekServerStore.changeServerLabel(this));
|
||||||
|
change.setAllCaps(false);
|
||||||
|
change.setTextColor(0xFFFFFFFF);
|
||||||
|
GradientDrawable pill = new GradientDrawable();
|
||||||
|
pill.setColor(0xFF111827);
|
||||||
|
pill.setCornerRadius(12 * dp);
|
||||||
|
change.setBackground(pill);
|
||||||
|
change.setMinHeight(0);
|
||||||
|
change.setMinimumHeight(0);
|
||||||
|
change.setPaddingRelative(Math.round(14 * dp), Math.round(9 * dp), Math.round(14 * dp), Math.round(9 * dp));
|
||||||
|
LinearLayout.LayoutParams changeParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
changeParams.setMarginStart(Math.round(10 * dp));
|
||||||
|
change.setOnClickListener((v) -> {
|
||||||
|
TrekServerStore.setUrl(this, null);
|
||||||
|
TrekServerStore.markRestart(this);
|
||||||
|
recreate();
|
||||||
|
});
|
||||||
|
bar.addView(change, changeParams);
|
||||||
|
|
||||||
|
int margin = Math.round(12 * dp);
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.BOTTOM
|
||||||
|
);
|
||||||
|
params.setMargins(margin, 0, margin, margin);
|
||||||
|
FrameLayout root = findViewById(android.R.id.content);
|
||||||
|
root.addView(bar, params);
|
||||||
|
// Above the gesture bar, and above the keyboard while it is up.
|
||||||
|
bar.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||||
|
// Read off the window's own insets: Capacitor hands the views below the
|
||||||
|
// decor a copy with the system bars zeroed, and before Android 11 that
|
||||||
|
// takes the keyboard with it.
|
||||||
|
androidx.core.view.WindowInsetsCompat window = androidx.core.view.ViewCompat.getRootWindowInsets(getWindow().getDecorView());
|
||||||
|
int bottom = window != null
|
||||||
|
? window.getInsets(androidx.core.view.WindowInsetsCompat.Type.navigationBars()).bottom
|
||||||
|
: insets.getStableInsetBottom();
|
||||||
|
boolean imeVisible = window != null && window.isVisible(androidx.core.view.WindowInsetsCompat.Type.ime());
|
||||||
|
if (imeVisible != keyboardUp) {
|
||||||
|
keyboardUp = imeVisible;
|
||||||
|
updateSignInBar();
|
||||||
|
}
|
||||||
|
FrameLayout.LayoutParams p = (FrameLayout.LayoutParams) v.getLayoutParams();
|
||||||
|
if (p.bottomMargin != margin + bottom) {
|
||||||
|
p.bottomMargin = margin + bottom;
|
||||||
|
v.setLayoutParams(p);
|
||||||
|
}
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
bar.requestApplyInsets();
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server did not load: back to the address screen, which offers retry
|
* The server did not load: back to the address screen, which offers retry
|
||||||
* and change. A fresh task rather than recreate(), because this usually
|
* and change. A fresh task rather than recreate(), because this usually
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.liketrek.trek;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A sign-in page in front of the server that the address screen never saw.
|
||||||
|
* A proxy can let the app's check through (an Authelia or Authentik rule that
|
||||||
|
* bypasses /api) and still send the page itself to its sign-in. Handed to the
|
||||||
|
* browser, that sign-in leaves its session there and the app stays blank on
|
||||||
|
* every launch. So a redirect away from the server, while the server's first
|
||||||
|
* page is still loading, is taken as the proxy's sign-in: it loads in the web
|
||||||
|
* view and its host is kept, the way the address screen keeps the ones it saw.
|
||||||
|
* A link the user follows is no redirect, and once a page of the server has
|
||||||
|
* shown, nothing is learned any more.
|
||||||
|
*/
|
||||||
|
final class SignInRedirect {
|
||||||
|
|
||||||
|
private SignInRedirect() {}
|
||||||
|
|
||||||
|
/** The host (host:port with an explicit port) to keep as a sign-in host, or null. */
|
||||||
|
static String learnedHost(String server, String target, boolean mainFrame, boolean redirect, boolean serverShown) {
|
||||||
|
if (!mainFrame || !redirect || serverShown || server == null || target == null) return null;
|
||||||
|
URI from;
|
||||||
|
URI to;
|
||||||
|
try {
|
||||||
|
from = new URI(server);
|
||||||
|
to = new URI(target);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String fromHost = lower(from.getHost());
|
||||||
|
String toHost = lower(to.getHost());
|
||||||
|
String toScheme = lower(to.getScheme());
|
||||||
|
if (fromHost == null || toHost == null) return null;
|
||||||
|
if (!"https".equals(toScheme) && !"http".equals(toScheme)) return null;
|
||||||
|
// Never from https down to plain http: the sign-in would send a password in the clear.
|
||||||
|
if ("https".equals(lower(from.getScheme())) && !"https".equals(toScheme)) return null;
|
||||||
|
if (toHost.equals(fromHost)) return null;
|
||||||
|
return to.getPort() == -1 ? toHost : toHost + ":" + to.getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether `url` is on the server's host, where the app's own pages come from. */
|
||||||
|
static boolean onServer(String server, String url) {
|
||||||
|
if (server == null || url == null) return false;
|
||||||
|
try {
|
||||||
|
String serverHost = lower(new URI(server).getHost());
|
||||||
|
return serverHost != null && serverHost.equals(lower(new URI(url).getHost()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String lower(String value) {
|
||||||
|
return value == null ? null : value.toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,330 @@
|
|||||||
|
package com.liketrek.trek;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebResourceResponse;
|
||||||
|
import com.getcapacitor.Bridge;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server's UI kept on the device, so the app starts without its server: on
|
||||||
|
* a trip without reception, or away from home with a server on the home
|
||||||
|
* network. The web view runs no service worker on a plain-http server, the
|
||||||
|
* usual address of a server at home, so the app keeps the start page and every
|
||||||
|
* file of the build itself (refreshed by native/offlineShell.ts while the
|
||||||
|
* server is reachable) and serves them under the server's own origin while it
|
||||||
|
* is not. The data comes from the UI's own offline store; the API is tried as
|
||||||
|
* usual and answers again once the server is back.
|
||||||
|
*/
|
||||||
|
final class TrekOfflineShell {
|
||||||
|
|
||||||
|
private static final String DIR = "offline-shell";
|
||||||
|
private static final String PAGE = "index.html";
|
||||||
|
private static final String STAMP = "server.txt";
|
||||||
|
private static final String FILES = "files";
|
||||||
|
/** A path of the build: no "..", no query, nothing outside the copy's folder. */
|
||||||
|
private static final Pattern SAFE_PATH = Pattern.compile("^[A-Za-z0-9._@\\-]+(?:/[A-Za-z0-9._@\\-]+)*$");
|
||||||
|
private static final Map<String, String> TYPES = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
TYPES.put("js", "text/javascript");
|
||||||
|
TYPES.put("mjs", "text/javascript");
|
||||||
|
TYPES.put("css", "text/css");
|
||||||
|
TYPES.put("json", "application/json");
|
||||||
|
TYPES.put("webmanifest", "application/manifest+json");
|
||||||
|
TYPES.put("svg", "image/svg+xml");
|
||||||
|
TYPES.put("png", "image/png");
|
||||||
|
TYPES.put("jpg", "image/jpeg");
|
||||||
|
TYPES.put("jpeg", "image/jpeg");
|
||||||
|
TYPES.put("webp", "image/webp");
|
||||||
|
TYPES.put("ico", "image/x-icon");
|
||||||
|
TYPES.put("woff", "font/woff");
|
||||||
|
TYPES.put("woff2", "font/woff2");
|
||||||
|
TYPES.put("ttf", "font/ttf");
|
||||||
|
TYPES.put("wasm", "application/wasm");
|
||||||
|
TYPES.put("html", "text/html");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server whose copy the UI comes from in this run: it did not answer
|
||||||
|
* when the app started. Null while the UI comes from the server itself.
|
||||||
|
* Bound to the server, so a copy never answers for another one.
|
||||||
|
*/
|
||||||
|
private static volatile String activeServer;
|
||||||
|
/** Capacitor's JSInjector (package-private there) and its getInjectedStream, found once. */
|
||||||
|
private static volatile Object injector;
|
||||||
|
private static volatile Method injectMethod;
|
||||||
|
private static volatile boolean injectorLooked;
|
||||||
|
|
||||||
|
private TrekOfflineShell() {}
|
||||||
|
|
||||||
|
static boolean isActive() {
|
||||||
|
return activeServer != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void activate(String server) {
|
||||||
|
activeServer = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A start that goes to the server. The flag lives in the process, and
|
||||||
|
* restart() recreates the activity in that same process (another server
|
||||||
|
* picked, the address screen, a reload once the server is back), so each
|
||||||
|
* start sets it anew instead of keeping the last run's copy in front.
|
||||||
|
*/
|
||||||
|
static void deactivate() {
|
||||||
|
activeServer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the copy stands in for this server in this run. */
|
||||||
|
static boolean isActiveFor(String server) {
|
||||||
|
String current = activeServer;
|
||||||
|
return current != null && current.equals(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File root(Context context) {
|
||||||
|
return new File(context.getFilesDir(), DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether there is a copy of this server's UI to start from. */
|
||||||
|
static boolean hasCopy(Context context, String server) {
|
||||||
|
return hasCopy(root(context), server);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasCopy(File root, String server) {
|
||||||
|
if (server == null) return false;
|
||||||
|
File page = new File(root, PAGE);
|
||||||
|
return page.isFile() && server.equals(readStamp(root));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the device has a network at all; with none, the server cannot answer and the copy starts at once. */
|
||||||
|
static boolean hasNetwork(Context context) {
|
||||||
|
try {
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (cm == null) return true;
|
||||||
|
Network network = cm.getActiveNetwork();
|
||||||
|
if (network == null) return false;
|
||||||
|
NetworkCapabilities caps = cm.getNetworkCapabilities(network);
|
||||||
|
return caps != null && caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before a refresh fetches the files of a build: a copy of another server
|
||||||
|
* is thrown away, one of this server stays as it is until savePage.
|
||||||
|
*/
|
||||||
|
static boolean beginRefresh(Context context, String server) {
|
||||||
|
return beginRefresh(root(context), server);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean beginRefresh(File root, String server) {
|
||||||
|
if (!server.equals(readStamp(root))) deleteTree(root);
|
||||||
|
return root.isDirectory() || root.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the start page, and only once every file it names is stored: the
|
||||||
|
* page points at the build's files by their hashes, so a refresh cut off
|
||||||
|
* halfway (no reception, the app ended) keeps the previous page with its
|
||||||
|
* complete build instead of a new page whose scripts are missing.
|
||||||
|
*/
|
||||||
|
static boolean savePage(Context context, String server, byte[] html) {
|
||||||
|
return savePage(root(context), server, html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean savePage(File root, String server, byte[] html) {
|
||||||
|
if (!root.isDirectory() && !root.mkdirs()) return false;
|
||||||
|
return write(new File(root, STAMP), server.getBytes(StandardCharsets.UTF_8)) && write(new File(root, PAGE), html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasFile(Context context, String path) {
|
||||||
|
return hasFile(root(context), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasFile(File root, String path) {
|
||||||
|
File file = fileFor(root, path);
|
||||||
|
return file != null && file.isFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean saveFile(Context context, String path, byte[] data) {
|
||||||
|
return saveFile(root(context), path, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean saveFile(File root, String path, byte[] data) {
|
||||||
|
File file = fileFor(root, path);
|
||||||
|
if (file == null) return false;
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
if (parent != null && !parent.isDirectory() && !parent.mkdirs()) return false;
|
||||||
|
return write(file, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Drops the files of older builds once the current one is complete. */
|
||||||
|
static void prune(Context context, Set<String> keep) {
|
||||||
|
prune(root(context), keep);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void prune(File root, Set<String> keep) {
|
||||||
|
File base = new File(root, FILES);
|
||||||
|
pruneDir(base, base, keep);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The copy's answer for a request of the server's UI while it is active:
|
||||||
|
* the start page for any page of the app (it routes itself), with
|
||||||
|
* Capacitor's bridge injected as into the server's own page, and a file of
|
||||||
|
* the build by its path. Null for anything else, which goes on as usual.
|
||||||
|
*/
|
||||||
|
static WebResourceResponse serve(Context context, Bridge bridge, String server, WebResourceRequest request) {
|
||||||
|
if (!isActiveFor(server) || !"GET".equalsIgnoreCase(request.getMethod())) return null;
|
||||||
|
Uri url = request.getUrl();
|
||||||
|
Uri origin = Uri.parse(server);
|
||||||
|
if (!sameOrigin(url, origin)) return null;
|
||||||
|
try {
|
||||||
|
if (request.isForMainFrame()) {
|
||||||
|
File page = new File(root(context), PAGE);
|
||||||
|
if (!page.isFile()) return null;
|
||||||
|
InputStream html = withBridge(bridge, new FileInputStream(page));
|
||||||
|
return response("text/html", html);
|
||||||
|
}
|
||||||
|
String path = url.getPath();
|
||||||
|
if (path == null) return null;
|
||||||
|
File file = fileFor(root(context), path);
|
||||||
|
if (file == null || !file.isFile()) return null;
|
||||||
|
return response(typeOf(path), new FileInputStream(file));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w("TrekShell", "Offline copy could not answer " + url, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WebResourceResponse response(String type, InputStream body) {
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Cache-Control", "no-store");
|
||||||
|
String charset = type.startsWith("text/") || type.endsWith("json") ? "utf-8" : null;
|
||||||
|
return new WebResourceResponse(type, charset, 200, "OK", headers, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capacitor injects its bridge into the server's page as it passes through;
|
||||||
|
* the copy gets the same script. Its builder is internal to Capacitor, hence
|
||||||
|
* the reflection on both (kept in proguard-rules.pro). Without it the UI still runs,
|
||||||
|
* as it would in a browser, just without the app's native parts.
|
||||||
|
*/
|
||||||
|
private static InputStream withBridge(Bridge bridge, InputStream html) {
|
||||||
|
if (!injectorLooked) {
|
||||||
|
injectorLooked = true;
|
||||||
|
try {
|
||||||
|
Method method = Bridge.class.getDeclaredMethod("getJSInjector");
|
||||||
|
method.setAccessible(true);
|
||||||
|
Object built = method.invoke(bridge);
|
||||||
|
if (built != null) {
|
||||||
|
Method inject = built.getClass().getDeclaredMethod("getInjectedStream", InputStream.class);
|
||||||
|
inject.setAccessible(true);
|
||||||
|
injectMethod = inject;
|
||||||
|
injector = built;
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
Log.w("TrekShell", "No bridge for the offline copy", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object current = injector;
|
||||||
|
Method inject = injectMethod;
|
||||||
|
if (current == null || inject == null) return html;
|
||||||
|
try {
|
||||||
|
Object injected = inject.invoke(current, html);
|
||||||
|
return injected instanceof InputStream ? (InputStream) injected : html;
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
Log.w("TrekShell", "Bridge not injected into the offline copy", e);
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean sameOrigin(Uri a, Uri b) {
|
||||||
|
if (a.getScheme() == null || b.getScheme() == null || a.getHost() == null || b.getHost() == null) return false;
|
||||||
|
return a.getScheme().equalsIgnoreCase(b.getScheme())
|
||||||
|
&& a.getHost().equalsIgnoreCase(b.getHost())
|
||||||
|
&& port(a) == port(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int port(Uri uri) {
|
||||||
|
if (uri.getPort() != -1) return uri.getPort();
|
||||||
|
return "https".equalsIgnoreCase(uri.getScheme()) ? 443 : 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File fileFor(File root, String path) {
|
||||||
|
String clean = path.startsWith("/") ? path.substring(1) : path;
|
||||||
|
if (clean.isEmpty() || clean.contains("..") || !SAFE_PATH.matcher(clean).matches()) return null;
|
||||||
|
return new File(new File(root, FILES), clean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String typeOf(String path) {
|
||||||
|
int dot = path.lastIndexOf('.');
|
||||||
|
String ext = dot < 0 ? "" : path.substring(dot + 1).toLowerCase(Locale.ROOT);
|
||||||
|
String type = TYPES.get(ext);
|
||||||
|
return type == null ? "application/octet-stream" : type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readStamp(File root) {
|
||||||
|
File stamp = new File(root, STAMP);
|
||||||
|
if (!stamp.isFile()) return null;
|
||||||
|
try (FileInputStream in = new FileInputStream(stamp)) {
|
||||||
|
byte[] data = new byte[(int) Math.min(stamp.length(), 4096)];
|
||||||
|
int read = in.read(data);
|
||||||
|
return read <= 0 ? null : new String(data, 0, read, StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Written beside the target and moved over it, so a cut-off write never leaves half a file. */
|
||||||
|
private static boolean write(File target, byte[] data) {
|
||||||
|
File temp = new File(target.getPath() + ".part");
|
||||||
|
try (FileOutputStream out = new FileOutputStream(temp)) {
|
||||||
|
out.write(data);
|
||||||
|
out.getFD().sync();
|
||||||
|
} catch (IOException e) {
|
||||||
|
temp.delete();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return temp.renameTo(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void pruneDir(File base, File dir, Set<String> keep) {
|
||||||
|
File[] children = dir.listFiles();
|
||||||
|
if (children == null) return;
|
||||||
|
for (File child : children) {
|
||||||
|
if (child.isDirectory()) {
|
||||||
|
pruneDir(base, child, keep);
|
||||||
|
String[] left = child.list();
|
||||||
|
if (left != null && left.length == 0) child.delete();
|
||||||
|
} else {
|
||||||
|
String relative = base.toURI().relativize(child.toURI()).getPath();
|
||||||
|
if (!keep.contains(relative)) child.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deleteTree(File file) {
|
||||||
|
File[] children = file.listFiles();
|
||||||
|
if (children != null) for (File child : children) deleteTree(child);
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,10 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -18,27 +22,159 @@ final class TrekServerStore {
|
|||||||
|
|
||||||
private static final String PREFS = "trek_shell";
|
private static final String PREFS = "trek_shell";
|
||||||
private static final String KEY_URL = "server_url";
|
private static final String KEY_URL = "server_url";
|
||||||
|
private static final String KEY_PREVIOUS_URL = "previous_server_url";
|
||||||
|
private static final String KEY_SERVER_CHECK = "server_check";
|
||||||
|
private static final String KEY_LABEL_SIGN_IN_HINT = "label_sign_in_hint";
|
||||||
|
private static final String KEY_LABEL_CHANGE_SERVER = "label_change_server";
|
||||||
|
private static final String KEY_LABEL_ERROR_PAGE_HINT = "label_error_page_hint";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server API this build needs (MIN_NATIVE_API in serverAddress.ts). A
|
||||||
|
* server remembered under a lower value is checked once more: the first
|
||||||
|
* launch after an update that raised it puts the address screen back up,
|
||||||
|
* filled in with that server (getPreviousUrl). Raise both together.
|
||||||
|
*/
|
||||||
|
private static final int SERVER_CHECK = 3;
|
||||||
|
private static final String KEY_SIGN_IN_HOSTS = "sign_in_hosts";
|
||||||
private static final String KEY_SHELL_ONCE = "shell_once";
|
private static final String KEY_SHELL_ONCE = "shell_once";
|
||||||
private static final String KEY_RESTART = "restart";
|
private static final String KEY_RESTART = "restart";
|
||||||
|
private static final String KEY_OFFLINE_START = "offline_start";
|
||||||
|
private static final String KEY_WELCOME = "welcome";
|
||||||
private static final String CONFIG_DIR = "trek-server-config";
|
private static final String CONFIG_DIR = "trek-server-config";
|
||||||
|
|
||||||
private TrekServerStore() {}
|
private TrekServerStore() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The one-time code of a TREK Cloud purchase (setServer's `welcome`). The
|
||||||
|
* server's first page opens its welcome page with it once, which signs the
|
||||||
|
* buyer in (TrekWebViewClient). Kept only until the restart has loaded.
|
||||||
|
*/
|
||||||
|
static void setWelcome(Context context, String code) {
|
||||||
|
SharedPreferences.Editor editor = prefs(context).edit();
|
||||||
|
if (code == null) editor.remove(KEY_WELCOME);
|
||||||
|
else editor.putString(KEY_WELCOME, code);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The welcome page for the pending code, handed out once; null when there is none. */
|
||||||
|
static String takeWelcomeUrl(Context context) {
|
||||||
|
String code = prefs(context).getString(KEY_WELCOME, null);
|
||||||
|
String server = getUrl(context);
|
||||||
|
if (code == null) return null;
|
||||||
|
prefs(context).edit().remove(KEY_WELCOME).commit();
|
||||||
|
if (server == null) return null;
|
||||||
|
return (server.endsWith("/") ? server : server + "/") + "api/managed/welcome#" + code;
|
||||||
|
}
|
||||||
|
|
||||||
static String getUrl(Context context) {
|
static String getUrl(Context context) {
|
||||||
return prefs(context).getString(KEY_URL, null);
|
return prefs(context).getString(KEY_URL, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Runs before the bridge is built, so a server picked under an older minimum is not loaded unchecked. */
|
||||||
|
static void recheckAfterUpdate(Context context) {
|
||||||
|
SharedPreferences prefs = prefs(context);
|
||||||
|
if (prefs.getInt(KEY_SERVER_CHECK, 0) >= SERVER_CHECK) return;
|
||||||
|
String server = getUrl(context);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit().putInt(KEY_SERVER_CHECK, SERVER_CHECK);
|
||||||
|
if (server != null) editor.remove(KEY_URL).remove(KEY_SIGN_IN_HOSTS).putString(KEY_PREVIOUS_URL, server);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The words of the bar over a proxy's sign-in page, in the user's language,
|
||||||
|
* as the address screen passed them (setServer's `labels`): the server's UI
|
||||||
|
* is not there to say them. Null keeps the English fallback.
|
||||||
|
*/
|
||||||
|
static void setLabels(Context context, String signInHint, String changeServer, String errorPageHint) {
|
||||||
|
SharedPreferences.Editor editor = prefs(context).edit();
|
||||||
|
if (signInHint != null) editor.putString(KEY_LABEL_SIGN_IN_HINT, signInHint);
|
||||||
|
if (changeServer != null) editor.putString(KEY_LABEL_CHANGE_SERVER, changeServer);
|
||||||
|
if (errorPageHint != null) editor.putString(KEY_LABEL_ERROR_PAGE_HINT, errorPageHint);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String errorPageHintLabel(Context context) {
|
||||||
|
return prefs(context).getString(
|
||||||
|
KEY_LABEL_ERROR_PAGE_HINT,
|
||||||
|
"This page is not from TREK: the server or a proxy in front of it refused the app. Check your proxy or certificate, or change the server."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String signInHintLabel(Context context) {
|
||||||
|
return prefs(context).getString(
|
||||||
|
KEY_LABEL_SIGN_IN_HINT,
|
||||||
|
"Passkeys and security keys do not work on this page in the app. Sign in with a password, or let the app through your proxy."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String changeServerLabel(Context context) {
|
||||||
|
return prefs(context).getString(KEY_LABEL_CHANGE_SERVER, "Change server");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The server an update asked to check again, until a server is set. */
|
||||||
|
static String getPreviousUrl(Context context) {
|
||||||
|
return prefs(context).getString(KEY_PREVIOUS_URL, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remembers the server; its sign-in hosts go with it and are replaced or dropped too. */
|
||||||
static void setUrl(Context context, String url) {
|
static void setUrl(Context context, String url) {
|
||||||
|
setServer(context, url, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setServer(Context context, String url, Set<String> signInHosts) {
|
||||||
SharedPreferences.Editor editor = prefs(context).edit();
|
SharedPreferences.Editor editor = prefs(context).edit();
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
editor.remove(KEY_URL);
|
editor.remove(KEY_URL);
|
||||||
} else {
|
} else {
|
||||||
editor.putString(KEY_URL, url);
|
editor.putString(KEY_URL, url).remove(KEY_PREVIOUS_URL);
|
||||||
|
}
|
||||||
|
if (signInHosts == null || signInHosts.isEmpty()) {
|
||||||
|
editor.remove(KEY_SIGN_IN_HOSTS);
|
||||||
|
} else {
|
||||||
|
Set<String> lower = new HashSet<>();
|
||||||
|
for (String host : signInHosts) lower.add(host.toLowerCase(Locale.ROOT));
|
||||||
|
editor.putStringSet(KEY_SIGN_IN_HOSTS, lower);
|
||||||
}
|
}
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hosts of a sign-in page that stands in front of the server (a proxy
|
||||||
|
* such as Cloudflare Access or Pangolin), as the address screen found them.
|
||||||
|
* Only these may load inside the web view besides the server itself, so
|
||||||
|
* the proxy's session lands where the app can use it (TrekWebViewClient).
|
||||||
|
*/
|
||||||
|
static Set<String> getSignInHosts(Context context) {
|
||||||
|
Set<String> hosts = prefs(context).getStringSet(KEY_SIGN_IN_HOSTS, null);
|
||||||
|
return hosts == null ? Collections.emptySet() : Collections.unmodifiableSet(new HashSet<>(hosts));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keeps one more sign-in host for the remembered server, as the web view met it (SignInRedirect). */
|
||||||
|
static void addSignInHost(Context context, String host) {
|
||||||
|
Set<String> hosts = new HashSet<>(getSignInHosts(context));
|
||||||
|
if (!hosts.add(host.toLowerCase(Locale.ROOT))) return;
|
||||||
|
prefs(context).edit().putStringSet(KEY_SIGN_IN_HOSTS, hosts).commit();
|
||||||
|
}
|
||||||
|
|
||||||
/** Start the next launch on the bundled address screen, even with a server remembered. */
|
/** Start the next launch on the bundled address screen, even with a server remembered. */
|
||||||
|
private static final String KEY_FAILURE = "last_failure";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Why the server's page did not load, in the WebView's own terms
|
||||||
|
* ("net::ERR_NAME_NOT_RESOLVED (-2)", "HTTP 503"): the address screen shows
|
||||||
|
* it small under its message, so a report carries the cause.
|
||||||
|
*/
|
||||||
|
static void setFailure(Context context, String failure) {
|
||||||
|
prefs(context).edit().putString(KEY_FAILURE, failure).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The failure behind this address screen, once. */
|
||||||
|
static String takeFailure(Context context) {
|
||||||
|
String failure = prefs(context).getString(KEY_FAILURE, null);
|
||||||
|
if (failure != null) prefs(context).edit().remove(KEY_FAILURE).commit();
|
||||||
|
return failure;
|
||||||
|
}
|
||||||
|
|
||||||
static void showShellOnce(Context context) {
|
static void showShellOnce(Context context) {
|
||||||
prefs(context).edit().putBoolean(KEY_SHELL_ONCE, true).commit();
|
prefs(context).edit().putBoolean(KEY_SHELL_ONCE, true).commit();
|
||||||
}
|
}
|
||||||
@@ -56,6 +192,37 @@ final class TrekServerStore {
|
|||||||
return consume(context, KEY_RESTART);
|
return consume(context, KEY_RESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The next onCreate starts on the stored copy of the server's UI (TrekOfflineShell). */
|
||||||
|
static void markOfflineStart(Context context) {
|
||||||
|
prefs(context).edit().putBoolean(KEY_OFFLINE_START, true).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean consumeOfflineStart(Context context) {
|
||||||
|
return consume(context, KEY_OFFLINE_START);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The remembered server, or the one an update asked to check again: the
|
||||||
|
* server the stored copy of the UI belongs to.
|
||||||
|
*/
|
||||||
|
static String getUrlOrPrevious(Context context) {
|
||||||
|
String url = getUrl(context);
|
||||||
|
return url != null ? url : getPreviousUrl(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starting on the stored copy while the check an update asked for could not
|
||||||
|
* run: the server goes back in place, unchecked for now, and the check runs
|
||||||
|
* again on the next launch, which reaches the server.
|
||||||
|
*/
|
||||||
|
static void restoreForOffline(Context context) {
|
||||||
|
SharedPreferences prefs = prefs(context);
|
||||||
|
if (prefs.getString(KEY_URL, null) != null) return;
|
||||||
|
String previous = prefs.getString(KEY_PREVIOUS_URL, null);
|
||||||
|
if (previous == null) return;
|
||||||
|
prefs.edit().putString(KEY_URL, previous).remove(KEY_PREVIOUS_URL).putInt(KEY_SERVER_CHECK, 0).commit();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean consume(Context context, String key) {
|
private static boolean consume(Context context, String key) {
|
||||||
boolean set = prefs(context).getBoolean(key, false);
|
boolean set = prefs(context).getBoolean(key, false);
|
||||||
if (set) prefs(context).edit().remove(key).commit();
|
if (set) prefs(context).edit().remove(key).commit();
|
||||||
|
|||||||
@@ -83,6 +83,12 @@ final class TrekSharedFiles {
|
|||||||
file.put("mimeType", meta.optString("mimeType", "application/octet-stream"));
|
file.put("mimeType", meta.optString("mimeType", "application/octet-stream"));
|
||||||
file.put("data", Base64.encodeToString(item.getSecond(), Base64.NO_WRAP));
|
file.put("data", Base64.encodeToString(item.getSecond(), Base64.NO_WRAP));
|
||||||
if (meta.has("tripId")) file.put("tripId", meta.optLong("tripId"));
|
if (meta.has("tripId")) file.put("tripId", meta.optLong("tripId"));
|
||||||
|
// A page or a link: where it came from, so the UI can keep it among the trip's links.
|
||||||
|
String url = meta.optString("url", "");
|
||||||
|
if (url.startsWith("https://") || url.startsWith("http://")) {
|
||||||
|
file.put("url", url);
|
||||||
|
file.put("title", meta.optString("title", url));
|
||||||
|
}
|
||||||
pending = file;
|
pending = file;
|
||||||
if (listener != null) listener.onFile(file);
|
if (listener != null) listener.onFile(file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,32 @@
|
|||||||
package com.liketrek.trek;
|
package com.liketrek.trek;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
import androidx.activity.result.ActivityResult;
|
||||||
|
import com.liketrek.trek.clientcert.ClientCertActions;
|
||||||
|
import com.liketrek.trek.clientcert.TrekClientIdentity;
|
||||||
import androidx.browser.customtabs.CustomTabsIntent;
|
import androidx.browser.customtabs.CustomTabsIntent;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
import com.getcapacitor.JSArray;
|
||||||
import com.getcapacitor.JSObject;
|
import com.getcapacitor.JSObject;
|
||||||
import com.getcapacitor.PermissionState;
|
import com.getcapacitor.PermissionState;
|
||||||
import com.getcapacitor.Plugin;
|
import com.getcapacitor.Plugin;
|
||||||
import com.getcapacitor.PluginCall;
|
import com.getcapacitor.PluginCall;
|
||||||
import com.getcapacitor.PluginMethod;
|
import com.getcapacitor.PluginMethod;
|
||||||
|
import com.getcapacitor.annotation.ActivityCallback;
|
||||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||||
import com.getcapacitor.annotation.Permission;
|
import com.getcapacitor.annotation.Permission;
|
||||||
import com.getcapacitor.annotation.PermissionCallback;
|
import com.getcapacitor.annotation.PermissionCallback;
|
||||||
import com.google.firebase.messaging.FirebaseMessaging;
|
import com.google.firebase.messaging.FirebaseMessaging;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/** The native half of client/src/native/trekShell.ts. */
|
/** The native half of client/src/native/trekShell.ts. */
|
||||||
@@ -29,6 +39,8 @@ import org.json.JSONObject;
|
|||||||
)
|
)
|
||||||
public class TrekShellPlugin extends Plugin {
|
public class TrekShellPlugin extends Plugin {
|
||||||
|
|
||||||
|
private static final String TAG = "TrekShell";
|
||||||
|
|
||||||
/** How long to wait after returning from the browser for the redirect to land. */
|
/** How long to wait after returning from the browser for the redirect to land. */
|
||||||
private static final long CANCEL_GRACE_MS = 600;
|
private static final long CANCEL_GRACE_MS = 600;
|
||||||
|
|
||||||
@@ -59,6 +71,8 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
"googleWallet",
|
"googleWallet",
|
||||||
"keyCommands",
|
"keyCommands",
|
||||||
"windowLayout",
|
"windowLayout",
|
||||||
|
"clientCertificate",
|
||||||
|
"filePreview",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** liketrek's push relay: the endpoint for this device's FCM token (trek-hosted push-relay.ts). */
|
/** liketrek's push relay: the endpoint for this device's FCM token (trek-hosted push-relay.ts). */
|
||||||
@@ -256,11 +270,53 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
call.resolve();
|
call.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a file the UI wrote to the cache in the app that views it, a PDF in
|
||||||
|
* the system's PDF viewer, instead of the share sheet. "unsupported" where no
|
||||||
|
* app on the device views the type; the UI then hands it to the share sheet.
|
||||||
|
*/
|
||||||
|
@PluginMethod
|
||||||
|
public void previewFile(PluginCall call) {
|
||||||
|
String path = call.getString("path");
|
||||||
|
Uri parsed = path == null ? null : Uri.parse(path);
|
||||||
|
java.io.File file = parsed != null && "file".equals(parsed.getScheme()) && parsed.getPath() != null ? new java.io.File(parsed.getPath()) : null;
|
||||||
|
java.io.File cache = getContext().getCacheDir();
|
||||||
|
boolean inCache;
|
||||||
|
try {
|
||||||
|
inCache = file != null && file.getCanonicalPath().startsWith(cache.getCanonicalPath() + java.io.File.separator);
|
||||||
|
} catch (java.io.IOException e) {
|
||||||
|
inCache = false;
|
||||||
|
}
|
||||||
|
if (!inCache || !file.isFile()) {
|
||||||
|
call.reject("a file in the app's cache is required", "INVALID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String type = call.getString("mimeType", "application/octet-stream");
|
||||||
|
Uri content = androidx.core.content.FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".fileprovider", file);
|
||||||
|
Intent view = new Intent(Intent.ACTION_VIEW)
|
||||||
|
.setDataAndType(content, type)
|
||||||
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
try {
|
||||||
|
getActivity().startActivity(view);
|
||||||
|
result.put("result", "shown");
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
result.put("result", "unsupported");
|
||||||
|
}
|
||||||
|
call.resolve(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void getServer(PluginCall call) {
|
public void getServer(PluginCall call) {
|
||||||
String url = TrekServerStore.getUrl(getContext());
|
String url = TrekServerStore.getUrl(getContext());
|
||||||
|
String previous = TrekServerStore.getPreviousUrl(getContext());
|
||||||
JSObject result = new JSObject();
|
JSObject result = new JSObject();
|
||||||
result.put("url", url == null ? JSONObject.NULL : url);
|
result.put("url", url == null ? JSONObject.NULL : url);
|
||||||
|
result.put("previousUrl", previous == null ? JSONObject.NULL : previous);
|
||||||
|
String failure = TrekServerStore.takeFailure(getContext());
|
||||||
|
result.put("failure", failure == null ? JSONObject.NULL : failure);
|
||||||
call.resolve(result);
|
call.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,11 +328,35 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
call.reject("A http(s) URL is required");
|
call.reject("A http(s) URL is required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TrekServerStore.setUrl(getContext(), url);
|
TrekServerStore.setServer(getContext(), url, signInHostsOf(call));
|
||||||
|
JSObject labels = call.getObject("labels");
|
||||||
|
if (labels != null) {
|
||||||
|
TrekServerStore.setLabels(
|
||||||
|
getContext(),
|
||||||
|
labels.getString("signInHint"),
|
||||||
|
labels.getString("changeServer"),
|
||||||
|
labels.getString("errorPageHint")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// A TREK Cloud purchase: the code that signs the buyer in, opened once after the first page.
|
||||||
|
String welcome = call.getString("welcome");
|
||||||
|
TrekServerStore.setWelcome(getContext(), welcome != null && welcome.matches("[A-Za-z0-9_-]{43}") ? welcome : null);
|
||||||
call.resolve();
|
call.resolve();
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The sign-in hosts the address screen passes along, plain host names only. */
|
||||||
|
private static Set<String> signInHostsOf(PluginCall call) {
|
||||||
|
Set<String> hosts = new HashSet<>();
|
||||||
|
JSArray list = call.getArray("signInHosts");
|
||||||
|
if (list == null) return hosts;
|
||||||
|
for (int i = 0; i < list.length(); i++) {
|
||||||
|
String host = list.optString(i, "");
|
||||||
|
if (host.matches("[A-Za-z0-9.-]+(:[0-9]+)?")) hosts.add(host);
|
||||||
|
}
|
||||||
|
return hosts;
|
||||||
|
}
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void resetServer(PluginCall call) {
|
public void resetServer(PluginCall call) {
|
||||||
TrekServerStore.setUrl(getContext(), null);
|
TrekServerStore.setUrl(getContext(), null);
|
||||||
@@ -315,7 +395,32 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
// A Custom Tab shares the browser's cookies, so a running SSO session at
|
// A Custom Tab shares the browser's cookies, so a running SSO session at
|
||||||
// the identity provider carries over. The redirect back to the app's
|
// the identity provider carries over. The redirect back to the app's
|
||||||
// scheme arrives through the intent-filter in AndroidManifest.xml.
|
// scheme arrives through the intent-filter in AndroidManifest.xml.
|
||||||
new CustomTabsIntent.Builder().build().launchUrl(getActivity(), Uri.parse(url));
|
Uri target = Uri.parse(url);
|
||||||
|
getActivity().runOnUiThread(() -> openSignIn(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the sign-in in a Custom Tab, or in the browser itself where no
|
||||||
|
* Custom Tab can come up. Launched on the UI thread: some devices dropped a
|
||||||
|
* launch from the bridge's thread without a word, and the sign-in then
|
||||||
|
* looked cancelled. A browser that cannot open at all is reported as such.
|
||||||
|
*/
|
||||||
|
private void openSignIn(Uri target) {
|
||||||
|
try {
|
||||||
|
new CustomTabsIntent.Builder().build().launchUrl(getActivity(), target);
|
||||||
|
return;
|
||||||
|
} catch (RuntimeException tabFailed) {
|
||||||
|
Log.w(TAG, "No Custom Tab for the sign-in, trying the browser", tabFailed);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, target).addCategory(Intent.CATEGORY_BROWSABLE));
|
||||||
|
} catch (RuntimeException browserFailed) {
|
||||||
|
Log.w(TAG, "No browser for the sign-in", browserFailed);
|
||||||
|
PluginCall call = pendingAuthCall();
|
||||||
|
if (call == null) return;
|
||||||
|
call.reject("No browser could open the sign-in", "NO_BROWSER");
|
||||||
|
finishAuth(call);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -331,7 +436,11 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
PluginCall call = pendingAuthCall();
|
PluginCall call = pendingAuthCall();
|
||||||
if (call == null || data == null || !authScheme.equals(data.getScheme())) return;
|
if (call == null) {
|
||||||
|
keepOrphanAuthReturn(intent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data == null || !authScheme.equals(data.getScheme())) return;
|
||||||
JSObject result = new JSObject();
|
JSObject result = new JSObject();
|
||||||
result.put("url", data.toString());
|
result.put("url", data.toString());
|
||||||
call.resolve(result);
|
call.resolve(result);
|
||||||
@@ -357,6 +466,48 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
}, CANCEL_GRACE_MS);
|
}, CANCEL_GRACE_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTH_PREFS = "trek_auth_return";
|
||||||
|
/** As long as the server keeps the code it carries (NATIVE_HANDOFF_CODE_TTL_MS), with room to spare. */
|
||||||
|
private static final long ORPHAN_AUTH_TTL_MS = 2 * 60 * 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A return to the sign-in scheme with no call waiting for it: Android ended
|
||||||
|
* the app while the browser was in front, and the browser's return started
|
||||||
|
* it anew (the launch intent comes through here as well). Kept on disk, as
|
||||||
|
* the process may be new too, until the sign-in page takes it. The return
|
||||||
|
* is then taken off the activity's intent: Capacitor hands the launch intent
|
||||||
|
* in again whenever the activity is created, and Android does as well when
|
||||||
|
* it rebuilds the task from the recent apps.
|
||||||
|
*/
|
||||||
|
private void keepOrphanAuthReturn(Intent intent) {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (data == null || !"auth".equals(data.getHost())) return;
|
||||||
|
if (!getContext().getString(R.string.custom_url_scheme).equals(data.getScheme())) return;
|
||||||
|
if (getActivity() != null && getActivity().getIntent() != null && getActivity().getIntent().getData() != null
|
||||||
|
&& data.equals(getActivity().getIntent().getData())) {
|
||||||
|
getActivity().setIntent(new Intent(getActivity().getIntent()).setData(null));
|
||||||
|
}
|
||||||
|
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) return;
|
||||||
|
getContext().getSharedPreferences(AUTH_PREFS, Context.MODE_PRIVATE)
|
||||||
|
.edit()
|
||||||
|
.putString("url", data.toString())
|
||||||
|
.putLong("at", System.currentTimeMillis())
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The kept return of a sign-in (keepOrphanAuthReturn), once and while fresh; null otherwise. */
|
||||||
|
@PluginMethod
|
||||||
|
public void takeAuthCallback(PluginCall call) {
|
||||||
|
android.content.SharedPreferences prefs = getContext().getSharedPreferences(AUTH_PREFS, Context.MODE_PRIVATE);
|
||||||
|
String url = prefs.getString("url", null);
|
||||||
|
long at = prefs.getLong("at", 0);
|
||||||
|
prefs.edit().clear().commit();
|
||||||
|
boolean fresh = url != null && System.currentTimeMillis() - at <= ORPHAN_AUTH_TTL_MS;
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
result.put("url", fresh ? url : JSONObject.NULL);
|
||||||
|
call.resolve(result);
|
||||||
|
}
|
||||||
|
|
||||||
private PluginCall pendingAuthCall() {
|
private PluginCall pendingAuthCall() {
|
||||||
return authCallId == null ? null : getBridge().getSavedCall(authCallId);
|
return authCallId == null ? null : getBridge().getSavedCall(authCallId);
|
||||||
}
|
}
|
||||||
@@ -375,19 +526,98 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
authBrowserOpen = false;
|
authBrowserOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** iOS only: Android keeps the service worker, which already starts TREK offline. */
|
/**
|
||||||
|
* Keeps the server's UI on the device for a start without the server
|
||||||
|
* (TrekOfflineShell): the start page, and each file of the build that
|
||||||
|
* native/offlineShell.ts lists from the server's manifest and the copy does
|
||||||
|
* not hold yet. Once all of them are there, files of older builds go. A web
|
||||||
|
* view runs no service worker on a plain-http server, the usual address of a
|
||||||
|
* server at home, so without this the app could not start away from it.
|
||||||
|
*/
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void refreshOfflineCopy(PluginCall call) {
|
public void refreshOfflineCopy(PluginCall call) {
|
||||||
JSObject result = new JSObject();
|
Context context = getContext();
|
||||||
result.put("saved", false);
|
String server = TrekServerStore.getUrl(context);
|
||||||
call.resolve(result);
|
JSArray listed = call.getArray("files");
|
||||||
|
if (server == null || TrekOfflineShell.isActive()) {
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
result.put("saved", false);
|
||||||
|
call.resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new Thread(() -> {
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
byte[] page = download(server, "", "text/html");
|
||||||
|
boolean complete = page != null && TrekOfflineShell.beginRefresh(context, server);
|
||||||
|
Set<String> keep = new HashSet<>();
|
||||||
|
if (complete && listed != null) {
|
||||||
|
for (int i = 0; i < listed.length(); i++) {
|
||||||
|
String path = listed.optString(i, null);
|
||||||
|
if (path == null || path.isEmpty()) continue;
|
||||||
|
String clean = path.startsWith("/") ? path.substring(1) : path;
|
||||||
|
keep.add(clean);
|
||||||
|
if (TrekOfflineShell.hasFile(context, clean)) continue;
|
||||||
|
byte[] data = download(server, clean, null);
|
||||||
|
if (data == null || !TrekOfflineShell.saveFile(context, clean, data)) complete = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The new page goes in last: until all its files are there the
|
||||||
|
// stored page stays the previous one, whose build is still whole.
|
||||||
|
boolean saved = complete && TrekOfflineShell.savePage(context, server, page);
|
||||||
|
complete = saved;
|
||||||
|
if (saved && listed != null) TrekOfflineShell.prune(context, keep);
|
||||||
|
result.put("saved", saved);
|
||||||
|
result.put("complete", complete);
|
||||||
|
call.resolve(result);
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A file of the server's UI, or null: only a 200 counts, and the page only as HTML. */
|
||||||
|
private static byte[] download(String server, String path, String wantType) {
|
||||||
|
java.net.HttpURLConnection connection = null;
|
||||||
|
try {
|
||||||
|
java.net.URL base = new java.net.URL(server.endsWith("/") ? server : server + "/");
|
||||||
|
java.net.URL url = new java.net.URL(base, path);
|
||||||
|
connection = (java.net.HttpURLConnection) url.openConnection();
|
||||||
|
connection.setConnectTimeout(15000);
|
||||||
|
connection.setReadTimeout(30000);
|
||||||
|
connection.setInstanceFollowRedirects(true);
|
||||||
|
if (wantType != null) connection.setRequestProperty("Accept", wantType);
|
||||||
|
if (connection.getResponseCode() != 200) return null;
|
||||||
|
String type = connection.getContentType();
|
||||||
|
if (wantType != null && (type == null || !type.startsWith(wantType))) return null;
|
||||||
|
try (java.io.InputStream in = connection.getInputStream()) {
|
||||||
|
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[16384];
|
||||||
|
for (int n = in.read(buffer); n > 0; n = in.read(buffer)) out.write(buffer, 0, n);
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
} catch (java.io.IOException | RuntimeException e) {
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
if (connection != null) connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address screen found the server out of reach: with a copy of its UI
|
||||||
|
* the app restarts on that instead (TrekOfflineShell), the same way it
|
||||||
|
* leaves the server for the address screen. Also for the server an update
|
||||||
|
* asked to check again, whose check then waits for the next launch.
|
||||||
|
*/
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void openOfflineCopy(PluginCall call) {
|
public void openOfflineCopy(PluginCall call) {
|
||||||
|
Context context = getContext();
|
||||||
JSObject result = new JSObject();
|
JSObject result = new JSObject();
|
||||||
result.put("opened", false);
|
if (!TrekOfflineShell.hasCopy(context, TrekServerStore.getUrlOrPrevious(context)) || getActivity() == null) {
|
||||||
|
result.put("opened", false);
|
||||||
|
call.resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrekServerStore.markOfflineStart(context);
|
||||||
|
result.put("opened", true);
|
||||||
call.resolve(result);
|
call.resolve(result);
|
||||||
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Widgets, shortcuts and the travel day ----
|
// ---- Widgets, shortcuts and the travel day ----
|
||||||
@@ -582,6 +812,12 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
com.liketrek.trek.billing.TrekBilling.INSTANCE.restore(getContext(), call);
|
com.liketrek.trek.billing.TrekBilling.INSTANCE.restore(getContext(), call);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether this Google account already holds a delivered cloud subscription. */
|
||||||
|
@PluginMethod
|
||||||
|
public void storeHeld(PluginCall call) {
|
||||||
|
com.liketrek.trek.billing.TrekBilling.INSTANCE.held(getContext(), call);
|
||||||
|
}
|
||||||
|
|
||||||
/** A paid subscription never delivered (it cleared while the app was closed), for the shell to redeem. */
|
/** A paid subscription never delivered (it cleared while the app was closed), for the shell to redeem. */
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void storeUnfinished(PluginCall call) {
|
public void storeUnfinished(PluginCall call) {
|
||||||
@@ -630,4 +866,129 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
// The last layout WindowManager reported, posture and hinge included; the bare window before the first.
|
// The last layout WindowManager reported, posture and hinge included; the bare window before the first.
|
||||||
getActivity().runOnUiThread(() -> call.resolve(com.liketrek.trek.screen.TrekWindowLayout.INSTANCE.current(getActivity())));
|
getActivity().runOnUiThread(() -> call.resolve(com.liketrek.trek.screen.TrekWindowLayout.INSTANCE.current(getActivity())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Client certificates (mutual TLS) ----
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address screen's check of a server, made natively so it notices
|
||||||
|
* whether the server asks for a client certificate and can show the stored
|
||||||
|
* one (clientcert/ClientCertActions.request).
|
||||||
|
*/
|
||||||
|
@PluginMethod
|
||||||
|
public void requestServer(PluginCall call) {
|
||||||
|
String url = call.getString("url");
|
||||||
|
Uri parsed = url == null ? null : Uri.parse(url);
|
||||||
|
if (parsed == null || parsed.getHost() == null || !("https".equals(parsed.getScheme()) || "http".equals(parsed.getScheme()))) {
|
||||||
|
call.reject("A http(s) URL is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int timeout = Math.max(1000, Math.min(call.getInt("timeoutMs", 10000), 30000));
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
call.resolve(ClientCertActions.request(getContext(), url, timeout));
|
||||||
|
} catch (Exception e) {
|
||||||
|
call.reject(e.getMessage() == null ? "request failed" : e.getMessage());
|
||||||
|
}
|
||||||
|
}, "trek-request-server").start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The stored certificate's details, or none. */
|
||||||
|
@PluginMethod
|
||||||
|
public void clientCertificate(PluginCall call) {
|
||||||
|
TrekClientIdentity.Info info = TrekClientIdentity.info(getContext());
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
result.put("certificate", info == null ? JSONObject.NULL : ClientCertActions.infoObject(info));
|
||||||
|
TrekClientIdentity.Request asked = TrekClientIdentity.INSTANCE.getLastRequest();
|
||||||
|
if (asked != null) {
|
||||||
|
JSObject request = new JSObject();
|
||||||
|
request.put("host", asked.getHost());
|
||||||
|
request.put("port", asked.getPort());
|
||||||
|
request.put("served", asked.getServed());
|
||||||
|
result.put("request", request);
|
||||||
|
}
|
||||||
|
call.resolve(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PluginMethod
|
||||||
|
public void removeClientCertificate(PluginCall call) {
|
||||||
|
TrekClientIdentity.remove(getContext());
|
||||||
|
forgetCertificateAnswers();
|
||||||
|
call.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The WebView keeps its answer to a certificate request per host; a changed certificate needs a fresh one. */
|
||||||
|
private void forgetCertificateAnswers() {
|
||||||
|
com.liketrek.trek.clientcert.ClientCertWatch.reset();
|
||||||
|
getActivity().runOnUiThread(() -> android.webkit.WebView.clearClientCertPreferences(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Picks a .p12/.pfx file, asks for its password until it opens or the user
|
||||||
|
* gives up, and keeps it for the server at host and port. Resolves with
|
||||||
|
* result "imported" (and the certificate), "cancelled", or "failed" and why.
|
||||||
|
*/
|
||||||
|
@PluginMethod
|
||||||
|
public void importClientCertificate(PluginCall call) {
|
||||||
|
String host = call.getString("host");
|
||||||
|
if (host == null || !host.matches("[A-Za-z0-9.-]+")) {
|
||||||
|
call.reject("A host is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Intent pick = new Intent(Intent.ACTION_OPEN_DOCUMENT).addCategory(Intent.CATEGORY_OPENABLE).setType("*/*");
|
||||||
|
pick.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "application/x-pkcs12", "application/pkcs12", "application/octet-stream" });
|
||||||
|
startActivityForResult(call, pick, "clientCertificatePicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ActivityCallback
|
||||||
|
private void clientCertificatePicked(PluginCall call, ActivityResult picked) {
|
||||||
|
if (call == null) return;
|
||||||
|
Uri uri = picked.getData() == null ? null : picked.getData().getData();
|
||||||
|
if (picked.getResultCode() != android.app.Activity.RESULT_OK || uri == null) {
|
||||||
|
resolveImport(call, "cancelled", null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new Thread(() -> {
|
||||||
|
byte[] bytes = ClientCertActions.readFile(getContext(), uri);
|
||||||
|
if (bytes == null) resolveImport(call, "failed", TrekClientIdentity.Failure.FORMAT.name());
|
||||||
|
else askPasswordFor(call, bytes, false);
|
||||||
|
}, "trek-client-cert").start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void askPasswordFor(PluginCall call, byte[] bytes, boolean wrong) {
|
||||||
|
JSObject labels = call.getObject("labels", new JSObject());
|
||||||
|
ClientCertActions.askPassword(getActivity(), labels, wrong, password -> {
|
||||||
|
if (password == null) {
|
||||||
|
resolveImport(call, "cancelled", null);
|
||||||
|
return kotlin.Unit.INSTANCE;
|
||||||
|
}
|
||||||
|
new Thread(() -> openWith(call, bytes, password), "trek-client-cert").start();
|
||||||
|
return kotlin.Unit.INSTANCE;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openWith(PluginCall call, byte[] bytes, char[] password) {
|
||||||
|
try {
|
||||||
|
TrekClientIdentity.Identity identity = TrekClientIdentity.read(bytes, password);
|
||||||
|
TrekClientIdentity.save(getContext(), identity, call.getString("host"), call.getInt("port", 443));
|
||||||
|
forgetCertificateAnswers();
|
||||||
|
resolveImport(call, "imported", null);
|
||||||
|
} catch (TrekClientIdentity.ImportException e) {
|
||||||
|
if (e.getReason() == TrekClientIdentity.Failure.PASSWORD) askPasswordFor(call, bytes, true);
|
||||||
|
else resolveImport(call, "failed", e.getReason().name());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.w(TAG, "client certificate not kept", e);
|
||||||
|
resolveImport(call, "failed", "STORE");
|
||||||
|
} finally {
|
||||||
|
java.util.Arrays.fill(password, '\0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resolveImport(PluginCall call, String result, String failure) {
|
||||||
|
JSObject out = new JSObject();
|
||||||
|
out.put("result", result);
|
||||||
|
if (failure != null) out.put("failure", failure.toLowerCase(java.util.Locale.ROOT));
|
||||||
|
TrekClientIdentity.Info info = TrekClientIdentity.info(getContext());
|
||||||
|
if ("imported".equals(result) && info != null) out.put("certificate", ClientCertActions.infoObject(info));
|
||||||
|
call.resolve(out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
package com.liketrek.trek;
|
package com.liketrek.trek;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.webkit.ClientCertRequest;
|
||||||
import android.webkit.WebResourceError;
|
import android.webkit.WebResourceError;
|
||||||
import android.webkit.WebResourceRequest;
|
import android.webkit.WebResourceRequest;
|
||||||
import android.webkit.WebResourceResponse;
|
import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import com.getcapacitor.Bridge;
|
import com.getcapacitor.Bridge;
|
||||||
import com.getcapacitor.BridgeWebViewClient;
|
import com.getcapacitor.BridgeWebViewClient;
|
||||||
|
import com.liketrek.trek.clientcert.TrekClientIdentity;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used while the WebView shows the user's server. When that server cannot be
|
* Used while the WebView shows the user's server. When that server cannot be
|
||||||
@@ -18,15 +27,105 @@ import com.getcapacitor.BridgeWebViewClient;
|
|||||||
class TrekWebViewClient extends BridgeWebViewClient {
|
class TrekWebViewClient extends BridgeWebViewClient {
|
||||||
|
|
||||||
private final Runnable onUnreachable;
|
private final Runnable onUnreachable;
|
||||||
|
/** Told whether the page now shown is a proxy's sign-in page, for the bar with the way out. */
|
||||||
|
private final Consumer<Boolean> onSignInPage;
|
||||||
|
/** Told whether the page now shown is an error page in place of the server's, for the same bar. */
|
||||||
|
private final Consumer<Boolean> onErrorPage;
|
||||||
|
/** The main-frame address that last came back as a 4xx page nobody else handled. */
|
||||||
|
private String errorPageUrl;
|
||||||
|
private final Set<String> signInHosts;
|
||||||
|
/** A page of the server has shown since launch; from then on no sign-in host is learned (SignInRedirect). */
|
||||||
|
private boolean serverShown;
|
||||||
|
/** The page itself failed on the network once already; the next failure goes to the address screen. */
|
||||||
|
private boolean retriedMainFrame;
|
||||||
|
/** The page loaded again after a network error, until that load starts: its error page counts for nothing. */
|
||||||
|
private String retryUrl;
|
||||||
|
private final Bridge bridge;
|
||||||
|
|
||||||
TrekWebViewClient(Bridge bridge, Runnable onUnreachable) {
|
TrekWebViewClient(
|
||||||
|
Bridge bridge,
|
||||||
|
Runnable onUnreachable,
|
||||||
|
Consumer<Boolean> onSignInPage,
|
||||||
|
Consumer<Boolean> onErrorPage,
|
||||||
|
Set<String> signInHosts
|
||||||
|
) {
|
||||||
super(bridge);
|
super(bridge);
|
||||||
|
this.bridge = bridge;
|
||||||
this.onUnreachable = onUnreachable;
|
this.onUnreachable = onUnreachable;
|
||||||
|
this.onSignInPage = onSignInPage;
|
||||||
|
this.onErrorPage = onErrorPage;
|
||||||
|
this.signInHosts = new HashSet<>(signInHosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mapbox's map resources go through the app's own store (tiles/TrekTileStore.kt). */
|
/**
|
||||||
|
* The sign-in page of a proxy in front of the server loads here rather than
|
||||||
|
* in the browser, so its session cookie is the web view's and every request
|
||||||
|
* of the app carries it, as in a browser. Only the hosts the address screen
|
||||||
|
* saw that proxy send it to (TrekServerStore.getSignInHosts), and only as a
|
||||||
|
* page: Capacitor injects its bridge into the server's origin alone, so the
|
||||||
|
* proxy's page gets no access to the app. Everything else goes on to
|
||||||
|
* Capacitor, which opens a foreign page in the browser.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||||
|
if (request.isForMainFrame() && isSignInHost(request.getUrl())) return false;
|
||||||
|
String learned = SignInRedirect.learnedHost(
|
||||||
|
TrekServerStore.getUrl(view.getContext()),
|
||||||
|
request.getUrl().toString(),
|
||||||
|
request.isForMainFrame(),
|
||||||
|
request.isRedirect(),
|
||||||
|
serverShown
|
||||||
|
);
|
||||||
|
if (learned != null) {
|
||||||
|
signInHosts.add(learned);
|
||||||
|
TrekServerStore.addSignInHost(view.getContext(), learned);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.shouldOverrideUrlLoading(view, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Every page the main frame shows, pushState included: is it a proxy's sign-in page? */
|
||||||
|
@Override
|
||||||
|
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
|
||||||
|
super.doUpdateVisitedHistory(view, url, isReload);
|
||||||
|
if (retryUrl != null) return;
|
||||||
|
onSignInPage.accept(url != null && isSignInHost(Uri.parse(url)));
|
||||||
|
// The 4xx answer arrives before this commit or after it; either way the
|
||||||
|
// flag is read once here, so the next page clears the bar again.
|
||||||
|
boolean error = url != null && url.equals(errorPageUrl);
|
||||||
|
errorPageUrl = null;
|
||||||
|
onErrorPage.accept(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** After the server's first page, a pending welcome code opens the welcome page once (TrekServerStore.takeWelcomeUrl). */
|
||||||
|
@Override
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
super.onPageFinished(view, url);
|
||||||
|
// The error page of a load that is about to be retried: not the server's
|
||||||
|
// first page, so no welcome page and no learning of sign-in hosts yet.
|
||||||
|
if (retryUrl != null) return;
|
||||||
|
if (SignInRedirect.onServer(TrekServerStore.getUrl(view.getContext()), url)) serverShown = true;
|
||||||
|
String welcome = TrekServerStore.takeWelcomeUrl(view.getContext());
|
||||||
|
if (welcome != null) view.loadUrl(welcome);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSignInHost(Uri url) {
|
||||||
|
String scheme = url.getScheme();
|
||||||
|
String host = url.getHost();
|
||||||
|
if (host == null || !("https".equals(scheme) || "http".equals(scheme))) return false;
|
||||||
|
String key = host.toLowerCase(Locale.ROOT);
|
||||||
|
return signInHosts.contains(key) || (url.getPort() != -1 && signInHosts.contains(key + ":" + url.getPort()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapbox's map resources go through the app's own store (tiles/TrekTileStore.kt),
|
||||||
|
* and while the server is out of reach the UI comes from its stored copy
|
||||||
|
* (TrekOfflineShell).
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||||
|
WebResourceResponse copy = TrekOfflineShell.serve(view.getContext(), bridge, TrekServerStore.getUrl(view.getContext()), request);
|
||||||
|
if (copy != null) return copy;
|
||||||
if (com.liketrek.trek.tiles.TrekTileStore.INSTANCE.handles(request)) {
|
if (com.liketrek.trek.tiles.TrekTileStore.INSTANCE.handles(request)) {
|
||||||
WebResourceResponse stored = com.liketrek.trek.tiles.TrekTileStore.INSTANCE.serve(request);
|
WebResourceResponse stored = com.liketrek.trek.tiles.TrekTileStore.INSTANCE.serve(request);
|
||||||
if (stored != null) return stored;
|
if (stored != null) return stored;
|
||||||
@@ -34,9 +133,62 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
return super.shouldInterceptRequest(view, request);
|
return super.shouldInterceptRequest(view, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A proxy in front of the server asks for a client certificate (mutual TLS).
|
||||||
|
* The stored one goes only to the host and port it was imported for; every
|
||||||
|
* other site that asks is told there is none, as a browser without a
|
||||||
|
* matching certificate would. The WebView remembers either answer for the
|
||||||
|
* host until the app restarts, which a new certificate always brings along.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
|
||||||
|
TrekClientIdentity.Identity identity = TrekClientIdentity.identityFor(view.getContext(), request.getHost(), request.getPort());
|
||||||
|
TrekClientIdentity.noteRequest(request.getHost(), request.getPort(), identity != null);
|
||||||
|
if (identity != null) request.proceed(identity.getKey(), identity.getChain());
|
||||||
|
else request.ignore();
|
||||||
|
// The page may still come from the service worker's cache while every
|
||||||
|
// request fails: check natively whether the server lets the app in.
|
||||||
|
String server = TrekServerStore.getUrl(view.getContext());
|
||||||
|
Uri serverUri = server == null ? null : Uri.parse(server);
|
||||||
|
if (serverUri != null && TrekClientIdentity.matches(String.valueOf(serverUri.getHost()), serverUri.getPort() > 0 ? serverUri.getPort() : 443, request.getHost(), request.getPort())) {
|
||||||
|
com.liketrek.trek.clientcert.ClientCertWatch.serverAsked(view.getContext(), server, () -> {
|
||||||
|
TrekServerStore.setFailure(view.getContext(), "client certificate requested");
|
||||||
|
onUnreachable.run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A page that failed on the network is loaded once more before the app says
|
||||||
|
* the server is unreachable. Started from the background, as when the
|
||||||
|
* browser hands a sign-in back to an app Android had ended, a Samsung phone
|
||||||
|
* may hold its network back for a moment, and the first load fails with the
|
||||||
|
* server there all along. The error is logged, as a report has nothing else.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||||
if (request.isForMainFrame()) {
|
if (request.isForMainFrame()) {
|
||||||
|
Log.w("TrekShell", "Page failed: " + error.getErrorCode() + " " + error.getDescription());
|
||||||
|
if (!retriedMainFrame && isNetworkError(error.getErrorCode())) {
|
||||||
|
retriedMainFrame = true;
|
||||||
|
retryUrl = request.getUrl().toString();
|
||||||
|
view.postDelayed(() -> {
|
||||||
|
String url = retryUrl;
|
||||||
|
retryUrl = null;
|
||||||
|
view.loadUrl(url);
|
||||||
|
}, 1500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Out of reach for good (a trip without reception, a server at home):
|
||||||
|
// the stored copy of the UI takes over, with the app's own offline data.
|
||||||
|
String server = TrekServerStore.getUrl(view.getContext());
|
||||||
|
if (isNetworkError(error.getErrorCode()) && !TrekOfflineShell.isActive() && TrekOfflineShell.hasCopy(view.getContext(), server)) {
|
||||||
|
TrekOfflineShell.activate(server);
|
||||||
|
String url = request.getUrl().toString();
|
||||||
|
view.post(() -> view.loadUrl(url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrekServerStore.setFailure(view.getContext(), error.getDescription() + " (" + error.getErrorCode() + ")");
|
||||||
onUnreachable.run();
|
onUnreachable.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -45,15 +197,37 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Only a 5xx on the page itself means the server is down (a proxy's 502 or
|
* Only a 5xx on the page itself means the server is down (a proxy's 502 or
|
||||||
* 503 while TREK restarts). A 4xx page is left alone: the server answered,
|
* 503 while TREK restarts). A 4xx page is not TREK's, which serves its UI for
|
||||||
* and TREK serves its UI for every other path.
|
* every path: a proxy that asked this page for a client certificate and got
|
||||||
|
* none, as Cloudflare does with a 403, sends the app to the address screen,
|
||||||
|
* which says so and offers to add one. Any other 4xx page (a proxy's block
|
||||||
|
* page, a certificate it refused) stays up with the bar and its way out, so
|
||||||
|
* the app is never stuck on a page without TREK's UI.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||||
|
int status = errorResponse.getStatusCode();
|
||||||
if (!request.isForMainFrame()) {
|
if (!request.isForMainFrame()) {
|
||||||
super.onReceivedHttpError(view, request, errorResponse);
|
super.onReceivedHttpError(view, request, errorResponse);
|
||||||
} else if (errorResponse.getStatusCode() >= 500) {
|
} else if (status >= 500 || (status >= 400 && wantedCertificate(request.getUrl()))) {
|
||||||
|
TrekServerStore.setFailure(view.getContext(), "HTTP " + status);
|
||||||
onUnreachable.run();
|
onUnreachable.run();
|
||||||
|
} else if (status >= 400) {
|
||||||
|
errorPageUrl = request.getUrl().toString();
|
||||||
|
onErrorPage.accept(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isNetworkError(int code) {
|
||||||
|
return code == WebViewClient.ERROR_HOST_LOOKUP
|
||||||
|
|| code == WebViewClient.ERROR_CONNECT
|
||||||
|
|| code == WebViewClient.ERROR_TIMEOUT
|
||||||
|
|| code == WebViewClient.ERROR_IO
|
||||||
|
|| code == WebViewClient.ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean wantedCertificate(Uri url) {
|
||||||
|
TrekClientIdentity.Request asked = TrekClientIdentity.INSTANCE.getLastRequest();
|
||||||
|
return asked != null && !asked.getServed() && TrekClientIdentity.matches(asked.getHost(), asked.getPort(), url.getHost(), url.getPort());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,23 +119,38 @@ object TrekBilling {
|
|||||||
val id = call.getString("productId") ?: return call.reject("productId is required")
|
val id = call.getString("productId") ?: return call.reject("productId is required")
|
||||||
ready(activity) { ok ->
|
ready(activity) { ok ->
|
||||||
if (!ok) return@ready call.resolve(JSObject().put("kind", "failed"))
|
if (!ok) return@ready call.resolve(JSObject().put("kind", "failed"))
|
||||||
details(activity, listOf(id)) { found ->
|
// One subscription per Google account: a second plan would run beside the first.
|
||||||
val product = found.firstOrNull()
|
// A delivered one stops the purchase here; one that was paid but never set up is
|
||||||
val offer = product?.let(::baseOffer)
|
// handed back as bought, so its instance is set up now.
|
||||||
if (product == null || offer == null) return@details call.resolve(JSObject().put("kind", "failed"))
|
val params = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.SUBS).build()
|
||||||
pendingPurchase?.resolve(JSObject().put("kind", "cancelled"))
|
client(activity).queryPurchasesAsync(params) { result, purchases ->
|
||||||
pendingPurchase = call
|
val held = if (result.responseCode == BillingClient.BillingResponseCode.OK) newest(purchases, PREFIX) else null
|
||||||
pendingProduct = id
|
when {
|
||||||
val params = BillingFlowParams.newBuilder()
|
held == null -> launchPurchase(activity, call, id)
|
||||||
.setProductDetailsParamsList(
|
held.isAcknowledged -> call.resolve(JSObject().put("kind", "subscribed"))
|
||||||
listOf(BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(product).setOfferToken(offer.offerToken).build()),
|
else -> call.resolve(receipt(held).put("kind", "bought"))
|
||||||
)
|
}
|
||||||
.build()
|
}
|
||||||
activity.runOnUiThread {
|
}
|
||||||
val launch = client(activity).launchBillingFlow(activity, params)
|
}
|
||||||
if (launch.responseCode != BillingClient.BillingResponseCode.OK) {
|
|
||||||
settle(if (launch.responseCode == BillingClient.BillingResponseCode.USER_CANCELED) "cancelled" else "failed", null)
|
private fun launchPurchase(activity: Activity, call: PluginCall, id: String) {
|
||||||
}
|
details(activity, listOf(id)) { found ->
|
||||||
|
val product = found.firstOrNull()
|
||||||
|
val offer = product?.let(::baseOffer)
|
||||||
|
if (product == null || offer == null) return@details call.resolve(JSObject().put("kind", "failed"))
|
||||||
|
pendingPurchase?.resolve(JSObject().put("kind", "cancelled"))
|
||||||
|
pendingPurchase = call
|
||||||
|
pendingProduct = id
|
||||||
|
val params = BillingFlowParams.newBuilder()
|
||||||
|
.setProductDetailsParamsList(
|
||||||
|
listOf(BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(product).setOfferToken(offer.offerToken).build()),
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
activity.runOnUiThread {
|
||||||
|
val launch = client(activity).launchBillingFlow(activity, params)
|
||||||
|
if (launch.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||||
|
settle(if (launch.responseCode == BillingClient.BillingResponseCode.USER_CANCELED) "cancelled" else "failed", null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,6 +223,19 @@ object TrekBilling {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether this Google account holds a delivered subscription under `prefix`; while one runs, the shell offers no purchase. */
|
||||||
|
fun held(context: Context, call: PluginCall) {
|
||||||
|
val prefix = call.getString("prefix") ?: PREFIX
|
||||||
|
ready(context) { ok ->
|
||||||
|
if (!ok) return@ready call.resolve(JSObject().put("held", false))
|
||||||
|
val params = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.SUBS).build()
|
||||||
|
client(context).queryPurchasesAsync(params) { result, purchases ->
|
||||||
|
val found = if (result.responseCode == BillingClient.BillingResponseCode.OK) newest(purchases, prefix) else null
|
||||||
|
call.resolve(JSObject().put("held", found?.isAcknowledged == true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The newest active subscription under `prefix` on this Google account, if any. */
|
/** The newest active subscription under `prefix` on this Google account, if any. */
|
||||||
fun restore(context: Context, call: PluginCall) {
|
fun restore(context: Context, call: PluginCall) {
|
||||||
val prefix = call.getString("prefix") ?: "cloud."
|
val prefix = call.getString("prefix") ?: "cloud."
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package com.liketrek.trek.clientcert
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import android.text.InputType
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import com.getcapacitor.JSObject
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
import javax.net.ssl.HttpsURLConnection
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What TrekShellPlugin does for client certificates (TrekClientIdentity):
|
||||||
|
* check a server while noticing whether it asks for one, read a picked file,
|
||||||
|
* and ask for its password.
|
||||||
|
*/
|
||||||
|
object ClientCertActions {
|
||||||
|
|
||||||
|
private const val MAX_BODY_BYTES = 512 * 1024
|
||||||
|
private const val MAX_FILE_BYTES = 256 * 1024
|
||||||
|
private const val MAX_REDIRECTS = 5
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A GET against the user's server for the address screen: status, body, final
|
||||||
|
* URL and headers, plus whether the server asked for a client certificate and
|
||||||
|
* whether one was shown. A failed connection answers status 0 instead of
|
||||||
|
* throwing, so a handshake the server broke off for want of a certificate
|
||||||
|
* still reports that it asked.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun request(context: Context, url: String, timeoutMs: Int): JSObject {
|
||||||
|
var asked: Triple<String, Int, Boolean>? = null
|
||||||
|
val factory = TrekClientIdentity.socketFactory(context) { host, port, served -> asked = Triple(host, port, served) }
|
||||||
|
val result = JSObject()
|
||||||
|
var current = URL(url)
|
||||||
|
try {
|
||||||
|
for (hop in 0..MAX_REDIRECTS) {
|
||||||
|
val connection = current.openConnection() as HttpURLConnection
|
||||||
|
if (connection is HttpsURLConnection) connection.sslSocketFactory = factory
|
||||||
|
connection.instanceFollowRedirects = false
|
||||||
|
connection.connectTimeout = timeoutMs
|
||||||
|
connection.readTimeout = timeoutMs
|
||||||
|
connection.setRequestProperty("Accept", "application/json, text/html;q=0.9, */*;q=0.8")
|
||||||
|
try {
|
||||||
|
val status = connection.responseCode
|
||||||
|
val location = connection.getHeaderField("Location")
|
||||||
|
if (status in 300..399 && location != null && hop < MAX_REDIRECTS) {
|
||||||
|
current = URL(current, location)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val stream = if (status >= 400) connection.errorStream else connection.inputStream
|
||||||
|
result.put("status", status)
|
||||||
|
result.put("data", stream?.use { readCapped(it, MAX_BODY_BYTES) }?.toString(Charsets.UTF_8) ?: "")
|
||||||
|
result.put("url", current.toString())
|
||||||
|
val headers = JSObject()
|
||||||
|
for ((name, values) in connection.headerFields) if (name != null && values.isNotEmpty()) headers.put(name, values.first())
|
||||||
|
result.put("headers", headers)
|
||||||
|
} finally {
|
||||||
|
connection.disconnect()
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
result.put("status", 0)
|
||||||
|
result.put("data", "")
|
||||||
|
result.put("url", current.toString())
|
||||||
|
result.put("error", e.javaClass.simpleName)
|
||||||
|
}
|
||||||
|
val seen = asked
|
||||||
|
result.put("certRequested", seen != null)
|
||||||
|
result.put("certSent", seen?.third == true)
|
||||||
|
if (seen != null) result.put("certHost", "${seen.first}:${seen.second}")
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The bytes of a picked file, or null when it cannot be read or is far too big for a certificate. */
|
||||||
|
@JvmStatic
|
||||||
|
fun readFile(context: Context, uri: Uri): ByteArray? = try {
|
||||||
|
context.contentResolver.openInputStream(uri)?.use { readCapped(it, MAX_FILE_BYTES + 1) }?.takeIf { it.size <= MAX_FILE_BYTES }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The password prompt, with the UI's own words (`labels`: title, message,
|
||||||
|
* placeholder, ok, cancel, wrongPassword). `wrong` shows that the last try
|
||||||
|
* did not open the file. `done` gets the password, or null when cancelled.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun askPassword(activity: Activity, labels: JSObject, wrong: Boolean, done: (CharArray?) -> Unit) {
|
||||||
|
activity.runOnUiThread {
|
||||||
|
val input = EditText(activity).apply {
|
||||||
|
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||||
|
hint = labels.getString("placeholder") ?: ""
|
||||||
|
}
|
||||||
|
val frame = FrameLayout(activity).apply {
|
||||||
|
val pad = (20 * activity.resources.displayMetrics.density).toInt()
|
||||||
|
setPadding(pad, pad / 2, pad, 0)
|
||||||
|
addView(input, FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
||||||
|
}
|
||||||
|
val message = if (wrong) labels.getString("wrongPassword") else labels.getString("message")
|
||||||
|
var answered = false
|
||||||
|
val dialog = AlertDialog.Builder(activity)
|
||||||
|
.setTitle(labels.getString("title"))
|
||||||
|
.setMessage(message)
|
||||||
|
.setView(frame)
|
||||||
|
.setPositiveButton(labels.getString("ok") ?: "OK") { _, _ ->
|
||||||
|
answered = true
|
||||||
|
val text = input.text
|
||||||
|
val password = CharArray(text.length) { text[it] }
|
||||||
|
done(password)
|
||||||
|
}
|
||||||
|
.setNegativeButton(labels.getString("cancel") ?: "Cancel") { _, _ ->
|
||||||
|
answered = true
|
||||||
|
done(null)
|
||||||
|
}
|
||||||
|
.setOnDismissListener { if (!answered) done(null) }
|
||||||
|
.create()
|
||||||
|
dialog.show()
|
||||||
|
input.requestFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The settings' view of the stored certificate. */
|
||||||
|
@JvmStatic
|
||||||
|
fun infoObject(info: TrekClientIdentity.Info): JSObject = JSObject().apply {
|
||||||
|
put("host", info.host)
|
||||||
|
put("port", info.port)
|
||||||
|
put("subject", info.subject)
|
||||||
|
put("issuer", info.issuer)
|
||||||
|
put("notAfter", info.notAfter)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun readCapped(stream: InputStream, max: Int): ByteArray {
|
||||||
|
val out = ByteArrayOutputStream()
|
||||||
|
val buffer = ByteArray(8192)
|
||||||
|
while (out.size() < max) {
|
||||||
|
val n = stream.read(buffer, 0, minOf(buffer.size, max - out.size()))
|
||||||
|
if (n < 0) break
|
||||||
|
out.write(buffer, 0, n)
|
||||||
|
}
|
||||||
|
return out.toByteArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.liketrek.trek.clientcert
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notices when the user's server stops letting the app in for want of a
|
||||||
|
* client certificate: one removed, expired, or no longer trusted by the proxy.
|
||||||
|
*
|
||||||
|
* The page alone does not show it. The service worker serves TREK's start page
|
||||||
|
* from its cache, so the page loads and only its requests fail, and the UI
|
||||||
|
* reports a server it cannot reach with no way to add a certificate. So when
|
||||||
|
* the server asks for one, the app checks once natively whether TREK answers
|
||||||
|
* with what it holds. Only a check that fails at the certificate (the handshake
|
||||||
|
* broke off, or the proxy answered with its own 4xx) sends the app to the
|
||||||
|
* address screen, which says so and offers to add one. A server that merely
|
||||||
|
* asks and lets everyone in answers TREK's 200, and nothing happens.
|
||||||
|
*/
|
||||||
|
object ClientCertWatch {
|
||||||
|
|
||||||
|
private const val MIN_INTERVAL_MS = 60_000L
|
||||||
|
private const val FEATURES_PATH = "/api/health/features"
|
||||||
|
private const val TIMEOUT_MS = 8000
|
||||||
|
|
||||||
|
private val lastCheck = AtomicLong(0)
|
||||||
|
|
||||||
|
/** Called where the server asked for a certificate; `onRefused` runs at most once a minute, on a background thread. */
|
||||||
|
@JvmStatic
|
||||||
|
fun serverAsked(context: Context, serverUrl: String?, onRefused: Runnable) {
|
||||||
|
if (serverUrl == null) return
|
||||||
|
val now = System.currentTimeMillis()
|
||||||
|
val last = lastCheck.get()
|
||||||
|
if (now - last < MIN_INTERVAL_MS || !lastCheck.compareAndSet(last, now)) return
|
||||||
|
val appContext = context.applicationContext
|
||||||
|
Thread({
|
||||||
|
val result = ClientCertActions.request(appContext, serverUrl.trimEnd('/') + FEATURES_PATH, TIMEOUT_MS)
|
||||||
|
if (refused(result.optBoolean("certRequested"), result.optInt("status"))) onRefused.run()
|
||||||
|
}, "trek-client-cert-watch").start()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A new or removed certificate is worth a check of its own, whenever the last one ran. */
|
||||||
|
@JvmStatic
|
||||||
|
fun reset() {
|
||||||
|
lastCheck.set(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The server asked for a certificate and did not answer with TREK. */
|
||||||
|
@JvmStatic
|
||||||
|
fun refused(certRequested: Boolean, status: Int): Boolean = certRequested && (status == 0 || status in 400..499)
|
||||||
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package com.liketrek.trek.clientcert
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.security.keystore.KeyGenParameterSpec
|
||||||
|
import android.security.keystore.KeyProperties
|
||||||
|
import android.util.Base64
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
|
import java.io.IOException
|
||||||
|
import java.net.Socket
|
||||||
|
import java.security.KeyFactory
|
||||||
|
import java.security.KeyStore
|
||||||
|
import java.security.Principal
|
||||||
|
import java.security.PrivateKey
|
||||||
|
import java.security.UnrecoverableKeyException
|
||||||
|
import java.security.cert.CertificateFactory
|
||||||
|
import java.security.cert.X509Certificate
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
import javax.crypto.Cipher
|
||||||
|
import javax.crypto.KeyGenerator
|
||||||
|
import javax.crypto.SecretKey
|
||||||
|
import javax.crypto.spec.GCMParameterSpec
|
||||||
|
import javax.net.ssl.SSLContext
|
||||||
|
import javax.net.ssl.SSLEngine
|
||||||
|
import javax.net.ssl.SSLSocket
|
||||||
|
import javax.net.ssl.SSLSocketFactory
|
||||||
|
import javax.net.ssl.X509ExtendedKeyManager
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client certificate a user's TREK server asks for (mutual TLS): a proxy
|
||||||
|
* such as Cloudflare, nginx, Caddy or Traefik in front of TREK lets through only
|
||||||
|
* devices that show one. The app holds at most one, for one server.
|
||||||
|
*
|
||||||
|
* It comes in as a PKCS#12 file (.p12, .pfx) and its password. Neither is kept:
|
||||||
|
* the private key is sealed with an AES key of the Android keystore, which
|
||||||
|
* never leaves it, and stored with the certificate chain in the app's private
|
||||||
|
* preferences. In memory the key is an ordinary one, which TLS 1.2 and 1.3 and
|
||||||
|
* the WebView all take, whatever its kind; a key imported into the keystore
|
||||||
|
* itself would be refused by some of them for its padding or digest rules.
|
||||||
|
*
|
||||||
|
* Only the host and port it was imported for ever see it (`identityFor`), so a
|
||||||
|
* login page, a map tile provider or liketrek.com never learns of it.
|
||||||
|
*/
|
||||||
|
object TrekClientIdentity {
|
||||||
|
|
||||||
|
private const val PREFS = "trek_client_identity"
|
||||||
|
private const val WRAP_ALIAS = "trek-client-identity-wrap"
|
||||||
|
private const val KEYMANAGER_ALIAS = "trek-client-identity"
|
||||||
|
private const val GCM_TAG_BITS = 128
|
||||||
|
|
||||||
|
/** Why a file could not be taken. */
|
||||||
|
enum class Failure { PASSWORD, FORMAT, NO_KEY, EXPIRED, NOT_YET_VALID }
|
||||||
|
|
||||||
|
class ImportException(val reason: Failure) : Exception(reason.name)
|
||||||
|
|
||||||
|
class Identity(val key: PrivateKey, val chain: Array<X509Certificate>)
|
||||||
|
|
||||||
|
/** What the settings show: who the certificate names, who issued it, until when, and for which server. */
|
||||||
|
data class Info(val host: String, val port: Int, val subject: String, val issuer: String, val notAfter: Long)
|
||||||
|
|
||||||
|
/** The opened identity, with the sealed key text it was opened from: opened once, not per request. */
|
||||||
|
@Volatile private var cached: Pair<String, Identity>? = null
|
||||||
|
|
||||||
|
/** The last time a server asked for a certificate while the app showed it: for the address screen. */
|
||||||
|
@Volatile var lastRequest: Request? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
data class Request(val host: String, val port: Int, val served: Boolean)
|
||||||
|
|
||||||
|
private class Stored(val host: String, val port: Int, val algorithm: String, val sealedText: String, val iv: ByteArray, val chain: List<ByteArray>)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a PKCS#12 file: the first entry that holds a private key, with its chain.
|
||||||
|
* Throws ImportException naming what is wrong with it.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
@Throws(ImportException::class)
|
||||||
|
fun read(bytes: ByteArray, password: CharArray, now: Date = Date()): Identity {
|
||||||
|
val store = KeyStore.getInstance("PKCS12")
|
||||||
|
try {
|
||||||
|
store.load(ByteArrayInputStream(bytes), password)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw ImportException(if (isPasswordFailure(e)) Failure.PASSWORD else Failure.FORMAT)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw ImportException(Failure.FORMAT)
|
||||||
|
}
|
||||||
|
val alias = store.aliases().toList().firstOrNull { store.isKeyEntry(it) } ?: throw ImportException(Failure.NO_KEY)
|
||||||
|
val key = try {
|
||||||
|
store.getKey(alias, password) as? PrivateKey
|
||||||
|
} catch (e: UnrecoverableKeyException) {
|
||||||
|
throw ImportException(Failure.PASSWORD)
|
||||||
|
} ?: throw ImportException(Failure.NO_KEY)
|
||||||
|
val chain = store.getCertificateChain(alias)?.mapNotNull { it as? X509Certificate }?.toTypedArray()
|
||||||
|
if (chain.isNullOrEmpty()) throw ImportException(Failure.NO_KEY)
|
||||||
|
val leaf = chain[0]
|
||||||
|
if (now.after(leaf.notAfter)) throw ImportException(Failure.EXPIRED)
|
||||||
|
if (now.before(leaf.notBefore)) throw ImportException(Failure.NOT_YET_VALID)
|
||||||
|
return Identity(key, chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A wrong password shows up as a failed MAC check or an unrecoverable key, wrapped in an IOException. */
|
||||||
|
private fun isPasswordFailure(e: Throwable): Boolean {
|
||||||
|
var cause: Throwable? = e
|
||||||
|
while (cause != null) {
|
||||||
|
if (cause is UnrecoverableKeyException || cause is javax.crypto.BadPaddingException) return true
|
||||||
|
if (cause.message?.lowercase(Locale.ROOT)?.contains("password") == true) return true
|
||||||
|
cause = cause.cause
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keeps the identity for this host and port, replacing any other. */
|
||||||
|
@JvmStatic
|
||||||
|
fun save(context: Context, identity: Identity, host: String, port: Int) {
|
||||||
|
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, wrapKey())
|
||||||
|
val sealed = cipher.doFinal(identity.key.encoded)
|
||||||
|
prefs(context).edit()
|
||||||
|
.putString("host", host.lowercase(Locale.ROOT))
|
||||||
|
.putInt("port", port)
|
||||||
|
.putString("algorithm", identity.key.algorithm)
|
||||||
|
.putString("key", encode(sealed))
|
||||||
|
.putString("iv", encode(cipher.iv))
|
||||||
|
.putString("chain", identity.chain.joinToString(",") { encode(it.encoded) })
|
||||||
|
.apply()
|
||||||
|
cached = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun remove(context: Context) {
|
||||||
|
prefs(context).edit().clear().apply()
|
||||||
|
cached = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun info(context: Context): Info? {
|
||||||
|
val stored = stored(context) ?: return null
|
||||||
|
val leaf = runCatching { certificate(stored.chain.first()) }.getOrNull() ?: return null
|
||||||
|
return Info(stored.host, stored.port, commonName(leaf.subjectX500Principal), commonName(leaf.issuerX500Principal), leaf.notAfter.time)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The identity for a server at this host and port, or null when there is none for it. */
|
||||||
|
@JvmStatic
|
||||||
|
fun identityFor(context: Context, host: String?, port: Int): Identity? {
|
||||||
|
val stored = stored(context) ?: return null
|
||||||
|
if (!matches(stored.host, stored.port, host, port)) return null
|
||||||
|
return opened(stored)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun opened(stored: Stored): Identity? {
|
||||||
|
cached?.let { (from, identity) -> if (from == stored.sealedText) return identity }
|
||||||
|
val identity = runCatching { open(stored) }.getOrNull() ?: return null
|
||||||
|
cached = stored.sealedText to identity
|
||||||
|
return identity
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether a request to host and port (-1 or 0 for the scheme's default) goes to the server the identity is for. */
|
||||||
|
@JvmStatic
|
||||||
|
fun matches(storedHost: String, storedPort: Int, host: String?, port: Int): Boolean {
|
||||||
|
if (host == null || !host.equals(storedHost, ignoreCase = true)) return false
|
||||||
|
val effective = if (port <= 0) 443 else port
|
||||||
|
return effective == storedPort
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called where a server asked for a certificate, so the address screen can offer one. */
|
||||||
|
@JvmStatic
|
||||||
|
fun noteRequest(host: String?, port: Int, served: Boolean) {
|
||||||
|
if (host == null) return
|
||||||
|
lastRequest = Request(host.lowercase(Locale.ROOT), if (port <= 0) 443 else port, served)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A socket factory for the app's own requests (the server check, map tiles).
|
||||||
|
* It offers the identity only when the server it is talking to asks for one
|
||||||
|
* and is the one the identity is for, and tells `onAsked` about every ask.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun socketFactory(context: Context, onAsked: ((host: String, port: Int, served: Boolean) -> Unit)? = null): SSLSocketFactory {
|
||||||
|
val appContext = context.applicationContext
|
||||||
|
val manager = object : X509ExtendedKeyManager() {
|
||||||
|
// Decided per handshake in choose(); the key and chain are then read for
|
||||||
|
// the one alias, so parallel connections never see each other's choice.
|
||||||
|
private fun choose(host: String?, port: Int): String? {
|
||||||
|
val identity = identityFor(appContext, host, port)
|
||||||
|
if (host != null) {
|
||||||
|
noteRequest(host, port, identity != null)
|
||||||
|
onAsked?.invoke(host.lowercase(Locale.ROOT), if (port <= 0) 443 else port, identity != null)
|
||||||
|
}
|
||||||
|
return if (identity != null) KEYMANAGER_ALIAS else null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun chooseClientAlias(keyType: Array<out String>?, issuers: Array<out Principal>?, socket: Socket?): String? {
|
||||||
|
val session = (socket as? SSLSocket)?.handshakeSession
|
||||||
|
return choose(session?.peerHost, session?.peerPort ?: -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun chooseEngineClientAlias(keyType: Array<out String>?, issuers: Array<out Principal>?, engine: SSLEngine?): String? =
|
||||||
|
choose(engine?.peerHost, engine?.peerPort ?: -1)
|
||||||
|
|
||||||
|
override fun getCertificateChain(alias: String?): Array<X509Certificate>? =
|
||||||
|
if (alias == KEYMANAGER_ALIAS) stored(appContext)?.let { opened(it) }?.chain else null
|
||||||
|
override fun getPrivateKey(alias: String?): PrivateKey? =
|
||||||
|
if (alias == KEYMANAGER_ALIAS) stored(appContext)?.let { opened(it) }?.key else null
|
||||||
|
override fun getClientAliases(keyType: String?, issuers: Array<out Principal>?): Array<String>? = null
|
||||||
|
override fun getServerAliases(keyType: String?, issuers: Array<out Principal>?): Array<String>? = null
|
||||||
|
override fun chooseServerAlias(keyType: String?, issuers: Array<out Principal>?, socket: Socket?): String? = null
|
||||||
|
}
|
||||||
|
val tls = SSLContext.getInstance("TLS")
|
||||||
|
tls.init(arrayOf(manager), null, null)
|
||||||
|
return tls.socketFactory
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun open(stored: Stored): Identity {
|
||||||
|
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, wrapKey(), GCMParameterSpec(GCM_TAG_BITS, stored.iv))
|
||||||
|
val key = KeyFactory.getInstance(stored.algorithm).generatePrivate(PKCS8EncodedKeySpec(cipher.doFinal(decode(stored.sealedText))))
|
||||||
|
return Identity(key, stored.chain.map { certificate(it) }.toTypedArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stored(context: Context): Stored? {
|
||||||
|
val p = prefs(context)
|
||||||
|
val host = p.getString("host", null) ?: return null
|
||||||
|
val algorithm = p.getString("algorithm", null) ?: return null
|
||||||
|
val key = p.getString("key", null) ?: return null
|
||||||
|
val iv = p.getString("iv", null) ?: return null
|
||||||
|
val chain = p.getString("chain", null)?.split(",")?.filter { it.isNotEmpty() }?.map { decode(it) } ?: return null
|
||||||
|
if (chain.isEmpty()) return null
|
||||||
|
return Stored(host, p.getInt("port", 443), algorithm, key, decode(iv), chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The keystore's AES key that seals the private key; made once, never leaves the keystore. */
|
||||||
|
private fun wrapKey(): SecretKey {
|
||||||
|
val keystore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }
|
||||||
|
(keystore.getKey(WRAP_ALIAS, null) as? SecretKey)?.let { return it }
|
||||||
|
val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore")
|
||||||
|
generator.init(
|
||||||
|
KeyGenParameterSpec.Builder(WRAP_ALIAS, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
|
||||||
|
.setBlockModes(KeyProperties.BLOCK_MODE_GCM)
|
||||||
|
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
|
||||||
|
.setKeySize(256)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
return generator.generateKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun certificate(der: ByteArray): X509Certificate =
|
||||||
|
CertificateFactory.getInstance("X.509").generateCertificate(ByteArrayInputStream(der)) as X509Certificate
|
||||||
|
|
||||||
|
/** The CN of a name, or the whole name when it has none. */
|
||||||
|
@JvmStatic
|
||||||
|
fun commonName(principal: javax.security.auth.x500.X500Principal): String {
|
||||||
|
val name = principal.getName(javax.security.auth.x500.X500Principal.RFC2253)
|
||||||
|
return Regex("(?:^|,)CN=((?:\\\\.|[^,])*)").find(name)?.groupValues?.get(1)?.replace("\\", "") ?: name
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prefs(context: Context) = context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||||
|
private fun encode(bytes: ByteArray) = Base64.encodeToString(bytes, Base64.NO_WRAP)
|
||||||
|
private fun decode(text: String) = Base64.decode(text, Base64.NO_WRAP)
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@ object ShareHandoff {
|
|||||||
fun store(context: Context, item: ShareItem, tripId: Long?): Boolean = runCatching {
|
fun store(context: Context, item: ShareItem, tripId: Long?): Boolean = runCatching {
|
||||||
val meta = JSONObject().put("name", item.name).put("mimeType", item.mimeType)
|
val meta = JSONObject().put("name", item.name).put("mimeType", item.mimeType)
|
||||||
if (tripId != null) meta.put("tripId", tripId)
|
if (tripId != null) meta.put("tripId", tripId)
|
||||||
|
if (item.url != null) meta.put("url", item.url).put("title", item.title)
|
||||||
File(dir(context), "pending.data").writeBytes(item.data)
|
File(dir(context), "pending.data").writeBytes(item.data)
|
||||||
File(dir(context), "pending.json").writeText(meta.toString())
|
File(dir(context), "pending.json").writeText(meta.toString())
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ data class ShareItem(
|
|||||||
val title: String,
|
val title: String,
|
||||||
/** A host, for a page. */
|
/** A host, for a page. */
|
||||||
val source: String? = null,
|
val source: String? = null,
|
||||||
|
/**
|
||||||
|
* The web address it came from, when it is a page or a link: the app offers to
|
||||||
|
* keep it among the trip's links as well as to read a booking out of it.
|
||||||
|
*/
|
||||||
|
val url: String? = null,
|
||||||
) {
|
) {
|
||||||
enum class Kind { PASS, PDF, MAIL, CALENDAR, PAGE, TEXT, IMAGE, FILE }
|
enum class Kind { PASS, PDF, MAIL, CALENDAR, PAGE, TEXT, IMAGE, FILE }
|
||||||
|
|
||||||
@@ -90,11 +95,16 @@ object ShareLoader {
|
|||||||
return checked(ShareItem(kind, withExtension(name, kind), normalized, data, name.substringBeforeLast('.').ifBlank { name }))
|
return checked(ShareItem(kind, withExtension(name, kind), normalized, data, name.substringBeforeLast('.').ifBlank { name }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A link becomes the page it points at; anything else, a text file the import reads. */
|
/**
|
||||||
|
* A link becomes the page it points at, or the bare link when the page cannot be
|
||||||
|
* read (a sign-in wall, an app-only page, no network), which the app can still
|
||||||
|
* keep among the trip's links. Anything else, a text file the import reads.
|
||||||
|
*/
|
||||||
internal fun fromText(text: String, subject: String?): ShareItem {
|
internal fun fromText(text: String, subject: String?): ShareItem {
|
||||||
val link = firstLink(text)
|
val link = firstLink(text)
|
||||||
if (link != null) {
|
if (link != null) {
|
||||||
runCatching { return page(link, subject) }
|
runCatching { return page(link, subject) }
|
||||||
|
return linkOnly(link, subject)
|
||||||
}
|
}
|
||||||
val firstLine = text.lineSequence().firstOrNull { it.isNotBlank() }?.trim() ?: text
|
val firstLine = text.lineSequence().firstOrNull { it.isNotBlank() }?.trim() ?: text
|
||||||
return checked(ShareItem(ShareItem.Kind.TEXT, "shared-text.txt", "text/plain", text.toByteArray(), (subject ?: firstLine).take(80)))
|
return checked(ShareItem(ShareItem.Kind.TEXT, "shared-text.txt", "text/plain", text.toByteArray(), (subject ?: firstLine).take(80)))
|
||||||
@@ -121,12 +131,19 @@ object ShareLoader {
|
|||||||
val html = String(data, Charsets.UTF_8)
|
val html = String(data, Charsets.UTF_8)
|
||||||
val host = runCatching { Uri.parse(link).host }.getOrNull()
|
val host = runCatching { Uri.parse(link).host }.getOrNull()
|
||||||
val title = pageTitle(html) ?: subject ?: host ?: "Page"
|
val title = pageTitle(html) ?: subject ?: host ?: "Page"
|
||||||
return checked(ShareItem(ShareItem.Kind.PAGE, "${slug(title)}.html", "text/html", data, title, host))
|
return checked(ShareItem(ShareItem.Kind.PAGE, "${slug(title)}.html", "text/html", data, title, host, link))
|
||||||
} finally {
|
} finally {
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The link alone, as a text/uri-list the app recognises as nothing to read a booking from. */
|
||||||
|
internal fun linkOnly(link: String, subject: String?): ShareItem {
|
||||||
|
// java.net.URI rather than android.net.Uri: the same host, and readable in a JVM unit test.
|
||||||
|
val host = runCatching { java.net.URI(link).host }.getOrNull()
|
||||||
|
return ShareItem(ShareItem.Kind.PAGE, "link.url", "text/uri-list", link.toByteArray(), subject ?: host ?: link, host, link)
|
||||||
|
}
|
||||||
|
|
||||||
/** The kind and the MIME type the import should see, from the name when the type is vague. */
|
/** The kind and the MIME type the import should see, from the name when the type is vague. */
|
||||||
internal fun classify(name: String, mime: String): Pair<ShareItem.Kind, String> {
|
internal fun classify(name: String, mime: String): Pair<ShareItem.Kind, String> {
|
||||||
val ext = name.substringAfterLast('.', "").lowercase()
|
val ext = name.substringAfterLast('.', "").lowercase()
|
||||||
|
|||||||
@@ -100,13 +100,13 @@ object TrekTileStore {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** HttpURLConnection has already undone any gzip, so no Content-Encoding goes along. */
|
|
||||||
/** Headers that are the request's own; the connection sets the hop-by-hop ones itself. */
|
/** Headers that are the request's own; the connection sets the hop-by-hop ones itself. */
|
||||||
private val HOP_BY_HOP = setOf("connection", "keep-alive", "transfer-encoding", "te", "upgrade", "host", "content-length", "accept-encoding")
|
private val HOP_BY_HOP = setOf("connection", "keep-alive", "transfer-encoding", "te", "upgrade", "host", "content-length", "accept-encoding")
|
||||||
|
|
||||||
internal fun forwardedHeaders(headers: Map<String, String>?): Map<String, String> =
|
internal fun forwardedHeaders(headers: Map<String, String>?): Map<String, String> =
|
||||||
headers.orEmpty().filterKeys { it.lowercase() !in HOP_BY_HOP }
|
headers.orEmpty().filterKeys { it.lowercase() !in HOP_BY_HOP }
|
||||||
|
|
||||||
|
/** HttpURLConnection has already undone any gzip, so no Content-Encoding goes along. */
|
||||||
private fun response(bytes: ByteArray, type: String): WebResourceResponse {
|
private fun response(bytes: ByteArray, type: String): WebResourceResponse {
|
||||||
val mime = type.substringBefore(';').trim()
|
val mime = type.substringBefore(';').trim()
|
||||||
val charset = Regex("charset=([^;]+)").find(type)?.groupValues?.get(1)
|
val charset = Regex("charset=([^;]+)").find(type)?.groupValues?.get(1)
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ class BookingsWidgetReceiver : TrekWidgetReceiver() {
|
|||||||
override val glanceAppWidget: GlanceAppWidget = BookingsWidget()
|
override val glanceAppWidget: GlanceAppWidget = BookingsWidget()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FlightWidgetReceiver : TrekWidgetReceiver() {
|
||||||
|
override val glanceAppWidget: GlanceAppWidget = FlightWidget()
|
||||||
|
}
|
||||||
|
|
||||||
class TodosWidgetReceiver : TrekWidgetReceiver() {
|
class TodosWidgetReceiver : TrekWidgetReceiver() {
|
||||||
override val glanceAppWidget: GlanceAppWidget = TodosWidget()
|
override val glanceAppWidget: GlanceAppWidget = TodosWidget()
|
||||||
}
|
}
|
||||||
@@ -56,6 +60,7 @@ object TrekWidgetUpdater {
|
|||||||
TripWidgetReceiver::class,
|
TripWidgetReceiver::class,
|
||||||
TodayWidgetReceiver::class,
|
TodayWidgetReceiver::class,
|
||||||
BookingsWidgetReceiver::class,
|
BookingsWidgetReceiver::class,
|
||||||
|
FlightWidgetReceiver::class,
|
||||||
TodosWidgetReceiver::class,
|
TodosWidgetReceiver::class,
|
||||||
PackingWidgetReceiver::class,
|
PackingWidgetReceiver::class,
|
||||||
AtlasWidgetReceiver::class,
|
AtlasWidgetReceiver::class,
|
||||||
|
|||||||
@@ -82,10 +82,12 @@ abstract class TrekWidget : GlanceAppWidget() {
|
|||||||
// Read inside the composition: a session outlives one update, and every
|
// Read inside the composition: a session outlives one update, and every
|
||||||
// write (the dashboard's, then each trip's) must reach it.
|
// write (the dashboard's, then each trip's) must reach it.
|
||||||
val version by WidgetStore.version.collectAsState()
|
val version by WidgetStore.version.collectAsState()
|
||||||
val snapshot = remember(version) {
|
val stored = remember(version) {
|
||||||
val tripId = if (perTrip && appWidgetId >= 0) WidgetStore.tripFor(context, appWidgetId) else WidgetStore.AUTO
|
val tripId = if (perTrip && appWidgetId >= 0) WidgetStore.tripFor(context, appWidgetId) else WidgetStore.AUTO
|
||||||
WidgetStore.load(context, tripId)
|
WidgetStore.load(context, tripId)
|
||||||
}
|
}
|
||||||
|
// The day of the trip is today's on every update, not the one the app last wrote.
|
||||||
|
val snapshot = stored?.on(LocalDate.now())
|
||||||
TrekWidgetTheme.Themed { Content(snapshot) }
|
TrekWidgetTheme.Themed { Content(snapshot) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -448,6 +450,173 @@ private fun BookingRow(booking: WidgetSnapshot.Booking, labels: WidgetSnapshot.L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Flight ----
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where a flight stands now (as FlightMoment on iOS). What the feed saw wins: a
|
||||||
|
* flight still at the gate past its planned departure is not flown along the
|
||||||
|
* arc, and it is only landed once confirmed. Only a flight the feed never heard
|
||||||
|
* of moves on by its schedule alone; a lost one stops two hours after arrival.
|
||||||
|
*/
|
||||||
|
private class FlightMoment(f: WidgetSnapshot.Flight, nowSeconds: Long) {
|
||||||
|
val start: Long = f.depActual ?: f.depExpected ?: f.dep
|
||||||
|
val end: Long = maxOf(f.arrExpected ?: f.arr, start + 60)
|
||||||
|
private val heard = f.seen != null
|
||||||
|
val landed = f.landed || (!heard && nowSeconds >= end) || nowSeconds >= end + 7200
|
||||||
|
val airborne = !landed && (f.airborne || f.depActual != null || (!heard && nowSeconds >= start))
|
||||||
|
val ready = !landed && !airborne && nowSeconds >= start
|
||||||
|
val progress: Float = when {
|
||||||
|
landed -> 1f
|
||||||
|
airborne -> ((nowSeconds - start).toFloat() / (end - start)).coerceIn(0f, 0.98f)
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A duration in the app's words: "2 d 4 h", "1 h 5 min", "12 min". */
|
||||||
|
private fun durationText(seconds: Long, labels: WidgetSnapshot.Labels): String {
|
||||||
|
val minutes = ((seconds + 59) / 60).coerceAtLeast(1)
|
||||||
|
val days = minutes / 1440
|
||||||
|
val hours = (minutes % 1440) / 60
|
||||||
|
val rest = minutes % 60
|
||||||
|
return when {
|
||||||
|
days > 0 -> labels.durDaysHours.replace("{d}", "$days").replace("{h}", "$hours")
|
||||||
|
hours > 0 -> labels.durHoursMinutes.replace("{h}", "$hours").replace("{m}", "$rest")
|
||||||
|
else -> labels.durMinutes.replace("{m}", "$rest")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Departs in 2 h 10 min", "Lands in 1 h 5 min", "Landed". */
|
||||||
|
private fun momentText(m: FlightMoment, labels: WidgetSnapshot.Labels, nowSeconds: Long): String = when {
|
||||||
|
m.landed -> labels.flightLanded
|
||||||
|
m.ready -> labels.flightReady
|
||||||
|
m.airborne -> labels.flightLands.replace("{time}", durationText(m.end - nowSeconds, labels))
|
||||||
|
else -> labels.flightDeparts.replace("{time}", durationText(m.start - nowSeconds, labels))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The delay as a chip's text and colour; nothing to say without data. */
|
||||||
|
private fun delayChip(delay: Int?, labels: WidgetSnapshot.Labels): Pair<String, ColorProvider>? = when {
|
||||||
|
delay == null -> null
|
||||||
|
delay > 5 -> labels.flightLate.replace("{m}", "$delay") to (if (delay >= 30) TrekStatus.danger else TrekStatus.pending)
|
||||||
|
delay < -5 -> labels.flightEarly.replace("{m}", "${-delay}") to TrekStatus.confirmed
|
||||||
|
else -> labels.flightOnTime to TrekStatus.confirmed
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val FLIGHT_BLUE = 0xFF4A7DDB.toInt()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trip's next flight, or the one in the air: both airports large, the
|
||||||
|
* route as an arc with the aircraft on it, the moment in words and the delay.
|
||||||
|
* The arc and the words follow the clock each time the widget is drawn.
|
||||||
|
*/
|
||||||
|
class FlightWidget : TrekWidget() {
|
||||||
|
@Composable
|
||||||
|
override fun Content(snapshot: WidgetSnapshot?) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val size = LocalSize.current
|
||||||
|
val labels = snapshot?.labels ?: return EmptyWidget(WidgetSamples.emptyText(context))
|
||||||
|
val flight = snapshot.flight
|
||||||
|
WidgetFrame(onClick = openPath(context, flight?.path ?: snapshot.trip?.path ?: "/")) {
|
||||||
|
Column(modifier = GlanceModifier.fillMaxSize()) {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = GlanceModifier.fillMaxWidth()) {
|
||||||
|
Icon(Icons.Rounded.Flight, GlanceTheme.colors.primary, 14.dp)
|
||||||
|
Spacer(GlanceModifier.width(5.dp))
|
||||||
|
Eyebrow(flight?.number ?: labels.flight, GlanceTheme.colors.primary, GlanceModifier.defaultWeight())
|
||||||
|
flight?.let { f ->
|
||||||
|
delayChip(f.delay, labels)?.let { (text, color) ->
|
||||||
|
if (size.isWide || (f.delay ?: 0) > 5) Chip(text, GlanceTheme.colors.surfaceVariant, color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flight == null) {
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
Line(labels.noFlight, 14.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Medium, maxLines = 2)
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
} else {
|
||||||
|
FlightBody(flight, labels, size.isWide, size.isTall)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The origin stands on the right in a right-to-left layout, so the drawn arc is
|
||||||
|
* mirrored with it. Read from the locale the widget speaks, not from the
|
||||||
|
* Configuration, which a composition may not read directly.
|
||||||
|
*/
|
||||||
|
private fun isRtl(): Boolean =
|
||||||
|
android.text.TextUtils.getLayoutDirectionFromLocale(java.util.Locale.getDefault()) == android.view.View.LAYOUT_DIRECTION_RTL
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ColumnScope.FlightBody(f: WidgetSnapshot.Flight, labels: WidgetSnapshot.Labels, wide: Boolean, tall: Boolean) {
|
||||||
|
val now = System.currentTimeMillis() / 1000
|
||||||
|
val m = FlightMoment(f, now)
|
||||||
|
val arrival = f.arrTimeExpected ?: f.arrTime
|
||||||
|
val momentColor = if (m.airborne) GlanceTheme.colors.primary else GlanceTheme.colors.onSurface
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
if (!wide) Line(momentText(m, labels, now), 13.sp, momentColor, FontWeight.Bold, maxLines = 2)
|
||||||
|
Spacer(GlanceModifier.height(6.dp))
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = GlanceModifier.fillMaxWidth()) {
|
||||||
|
Column(modifier = GlanceModifier.defaultWeight()) {
|
||||||
|
Line(f.from, if (wide) 26.sp else 22.sp, weight = FontWeight.Bold)
|
||||||
|
if (wide) f.fromCity?.let { Line(it, 11.sp, GlanceTheme.colors.onSurfaceVariant) }
|
||||||
|
}
|
||||||
|
if (wide) {
|
||||||
|
Image(
|
||||||
|
provider = ImageProvider(WidgetArt.flightArc(m.progress, FLIGHT_BLUE, android.graphics.Color.argb(90, 120, 120, 130), rtl = isRtl())),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Fit,
|
||||||
|
modifier = GlanceModifier.width(120.dp).height(26.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(modifier = GlanceModifier.defaultWeight(), horizontalAlignment = Alignment.End) {
|
||||||
|
Line(f.to, if (wide) 26.sp else 22.sp, weight = FontWeight.Bold)
|
||||||
|
if (wide) f.toCity?.let { Line(it, 11.sp, GlanceTheme.colors.onSurfaceVariant) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!wide) {
|
||||||
|
Image(
|
||||||
|
provider = ImageProvider(WidgetArt.flightArc(m.progress, FLIGHT_BLUE, android.graphics.Color.argb(90, 120, 120, 130), rtl = isRtl())),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.FillBounds,
|
||||||
|
modifier = GlanceModifier.fillMaxWidth().height(22.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(GlanceModifier.height(4.dp))
|
||||||
|
Row(modifier = GlanceModifier.fillMaxWidth()) {
|
||||||
|
Line(f.depTime, 12.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Bold, modifier = GlanceModifier.defaultWeight())
|
||||||
|
Line(arrival, 12.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Bold)
|
||||||
|
}
|
||||||
|
if (wide) {
|
||||||
|
Spacer(GlanceModifier.height(8.dp))
|
||||||
|
Line(momentText(m, labels, now), 13.sp, momentColor, FontWeight.Bold)
|
||||||
|
if (m.airborne) {
|
||||||
|
Spacer(GlanceModifier.height(5.dp))
|
||||||
|
Bar(m.progress, GlanceTheme.colors.primary, GlanceTheme.colors.surfaceVariant, 5.dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tall) {
|
||||||
|
Spacer(GlanceModifier.height(10.dp))
|
||||||
|
f.aircraft?.let { FlightFact(it) }
|
||||||
|
f.fromCity?.let { from -> f.toCity?.let { to -> FlightFact("$from \u2192 $to") } }
|
||||||
|
}
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun FlightFact(text: String) {
|
||||||
|
Row(
|
||||||
|
modifier = GlanceModifier.fillMaxWidth().background(GlanceTheme.colors.surfaceVariant).cornerRadius(12.dp)
|
||||||
|
.padding(horizontal = 10.dp, vertical = 7.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(Icons.Rounded.Flight, GlanceTheme.colors.primary, 13.dp)
|
||||||
|
Spacer(GlanceModifier.width(7.dp))
|
||||||
|
Line(text, 12.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Medium)
|
||||||
|
}
|
||||||
|
Spacer(GlanceModifier.height(5.dp))
|
||||||
|
}
|
||||||
|
|
||||||
// ---- To-dos ----
|
// ---- To-dos ----
|
||||||
|
|
||||||
/** What is still open for the trip, and how far the packing has come. */
|
/** What is still open for the trip, and how far the packing has come. */
|
||||||
|
|||||||
@@ -149,4 +149,100 @@ object WidgetArt {
|
|||||||
}
|
}
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A flight's route as an arc: dashed ahead, solid where it has flown, a dot
|
||||||
|
* at either airport and an airliner riding the curve at its heading. White
|
||||||
|
* on a translucent track, like the ring; the widget tints nothing, so the
|
||||||
|
* caller passes the flight colour.
|
||||||
|
*/
|
||||||
|
fun flightArc(
|
||||||
|
progress: Float,
|
||||||
|
color: Int,
|
||||||
|
track: Int,
|
||||||
|
width: Int = 600,
|
||||||
|
height: Int = 120,
|
||||||
|
showPlane: Boolean = true,
|
||||||
|
rtl: Boolean = false,
|
||||||
|
): Bitmap {
|
||||||
|
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(bitmap)
|
||||||
|
// Right to left the origin stands on the right: the whole drawing is mirrored.
|
||||||
|
if (rtl) canvas.scale(-1f, 1f, width / 2f, height / 2f)
|
||||||
|
val p = progress.coerceIn(0f, 1f)
|
||||||
|
val inset = height * 0.14f
|
||||||
|
val sx = inset
|
||||||
|
val sy = height - inset
|
||||||
|
val ex = width - inset
|
||||||
|
val ey = height - inset
|
||||||
|
val cx = width / 2f
|
||||||
|
val cy = -height * 0.45f
|
||||||
|
val path = android.graphics.Path().apply {
|
||||||
|
moveTo(sx, sy)
|
||||||
|
quadTo(cx, cy, ex, ey)
|
||||||
|
}
|
||||||
|
val line = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
style = Paint.Style.STROKE
|
||||||
|
strokeCap = Paint.Cap.ROUND
|
||||||
|
strokeWidth = height * 0.035f
|
||||||
|
this.color = track
|
||||||
|
pathEffect = android.graphics.DashPathEffect(floatArrayOf(height * 0.02f, height * 0.07f), 0f)
|
||||||
|
}
|
||||||
|
canvas.drawPath(path, line)
|
||||||
|
val measure = android.graphics.PathMeasure(path, false)
|
||||||
|
if (p > 0f) {
|
||||||
|
val flown = android.graphics.Path()
|
||||||
|
measure.getSegment(0f, measure.length * p, flown, true)
|
||||||
|
line.pathEffect = null
|
||||||
|
line.strokeWidth = height * 0.045f
|
||||||
|
line.color = color
|
||||||
|
canvas.drawPath(flown, line)
|
||||||
|
}
|
||||||
|
val dot = Paint(Paint.ANTI_ALIAS_FLAG).apply { this.color = color }
|
||||||
|
canvas.drawCircle(sx, sy, height * 0.05f, dot)
|
||||||
|
val ring = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
style = if (p >= 1f) Paint.Style.FILL else Paint.Style.STROKE
|
||||||
|
strokeWidth = height * 0.03f
|
||||||
|
this.color = color
|
||||||
|
}
|
||||||
|
canvas.drawCircle(ex, ey, height * 0.06f, ring)
|
||||||
|
if (showPlane) {
|
||||||
|
val pos = FloatArray(2)
|
||||||
|
val tan = FloatArray(2)
|
||||||
|
measure.getPosTan(measure.length * p, pos, tan)
|
||||||
|
canvas.save()
|
||||||
|
canvas.translate(pos[0], pos[1])
|
||||||
|
canvas.rotate(Math.toDegrees(kotlin.math.atan2(tan[1].toDouble(), tan[0].toDouble())).toFloat())
|
||||||
|
val scale = height * 0.012f
|
||||||
|
canvas.scale(scale, scale)
|
||||||
|
canvas.drawCircle(0f, 0f, 13f, Paint(Paint.ANTI_ALIAS_FLAG).apply { this.color = Color.WHITE })
|
||||||
|
canvas.drawPath(airliner(), Paint(Paint.ANTI_ALIAS_FLAG).apply { this.color = color })
|
||||||
|
canvas.restore()
|
||||||
|
}
|
||||||
|
return bitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An airliner seen from above, nose along +x, about 18 units long, centred. */
|
||||||
|
private fun airliner(): android.graphics.Path = android.graphics.Path().apply {
|
||||||
|
moveTo(9f, 0f)
|
||||||
|
cubicTo(9f, -0.9f, 8.3f, -1.3f, 7.4f, -1.3f)
|
||||||
|
lineTo(3.2f, -1.3f)
|
||||||
|
lineTo(-1.6f, -7.6f)
|
||||||
|
lineTo(-3.7f, -7.6f)
|
||||||
|
lineTo(-1.4f, -1.3f)
|
||||||
|
lineTo(-5.5f, -1.3f)
|
||||||
|
lineTo(-7.2f, -3.7f)
|
||||||
|
lineTo(-8.8f, -3.7f)
|
||||||
|
lineTo(-7.8f, 0f)
|
||||||
|
lineTo(-8.8f, 3.7f)
|
||||||
|
lineTo(-7.2f, 3.7f)
|
||||||
|
lineTo(-5.5f, 1.3f)
|
||||||
|
lineTo(-1.4f, 1.3f)
|
||||||
|
lineTo(-3.7f, 7.6f)
|
||||||
|
lineTo(-1.6f, 7.6f)
|
||||||
|
lineTo(3.2f, 1.3f)
|
||||||
|
lineTo(7.4f, 1.3f)
|
||||||
|
cubicTo(8.3f, 1.3f, 9f, 0.9f, 9f, 0f)
|
||||||
|
close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,19 @@ import org.json.JSONObject
|
|||||||
* (WidgetSnapshot.sample in TrekFamily.swift).
|
* (WidgetSnapshot.sample in TrekFamily.swift).
|
||||||
*/
|
*/
|
||||||
object WidgetSamples {
|
object WidgetSamples {
|
||||||
|
/** In the air on a running trip, two days ahead before one: the same LH 716 as the iOS sample. */
|
||||||
|
private fun flightJson(running: Boolean): String {
|
||||||
|
val now = System.currentTimeMillis() / 1000
|
||||||
|
val dep = if (running) now - 4 * 3600 else now + 2 * 86_400 + 5 * 3600
|
||||||
|
val live = if (running) {
|
||||||
|
""""depActual": ${dep + 18 * 60}, "arrExpected": ${dep + 12 * 3600 + 41 * 60}, "arrTimeExpected": "08:46", "delay": 16, "aircraft": "A359 D-AIXA","""
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
return """{"number": "LH 716", "from": "FRA", "to": "HND", "fromCity": "Frankfurt", "toCity": "Tokyo Haneda",
|
||||||
|
"dep": $dep, "arr": ${dep + 12 * 3600 + 25 * 60}, $live "depTime": "13:05", "arrTime": "08:30", "path": "/trips/1?booking=1"}"""
|
||||||
|
}
|
||||||
|
|
||||||
fun emptyText(context: Context): String = context.getString(R.string.widget_empty)
|
fun emptyText(context: Context): String = context.getString(R.string.widget_empty)
|
||||||
|
|
||||||
fun snapshot(running: Boolean, now: LocalDate = LocalDate.now()): WidgetSnapshot = WidgetSnapshot.fromJson(JSONObject(json(running, now)))
|
fun snapshot(running: Boolean, now: LocalDate = LocalDate.now()): WidgetSnapshot = WidgetSnapshot.fromJson(JSONObject(json(running, now)))
|
||||||
@@ -37,6 +50,7 @@ object WidgetSamples {
|
|||||||
"place": "Kyoto, Japan", "dayCount": 9, "placeCount": 34, "memberCount": 3},
|
"place": "Kyoto, Japan", "dayCount": 9, "placeCount": 34, "memberCount": 3},
|
||||||
$today
|
$today
|
||||||
"weather": {"temp": 18, "high": 21, "low": 11, "main": "${if (running) "Clear" else "Clouds"}", "label": "Mostly sunny", "place": "Kyoto", "rain": 10},
|
"weather": {"temp": 18, "high": 21, "low": 11, "main": "${if (running) "Clear" else "Clouds"}", "label": "Mostly sunny", "place": "Kyoto", "rain": 10},
|
||||||
|
"flight": ${flightJson(running)},
|
||||||
"bookings": [
|
"bookings": [
|
||||||
{"title": "LH 716", "kind": "flight", "date": "${iso(if (running) 6 else 12)}", "time": "13:05", "detail": "FRA → HND", "confirmed": true, "path": "/trips/1"},
|
{"title": "LH 716", "kind": "flight", "date": "${iso(if (running) 6 else 12)}", "time": "13:05", "detail": "FRA → HND", "confirmed": true, "path": "/trips/1"},
|
||||||
{"title": "Shinkansen Nozomi 21", "kind": "train", "date": "${iso(if (running) 0 else 13)}", "time": "09:12", "detail": "Tokyo → Kyoto", "confirmed": true, "path": "/trips/1"},
|
{"title": "Shinkansen Nozomi 21", "kind": "train", "date": "${iso(if (running) 0 else 13)}", "time": "09:12", "detail": "Tokyo → Kyoto", "confirmed": true, "path": "/trips/1"},
|
||||||
|
|||||||
@@ -25,7 +25,30 @@ data class WidgetSnapshot(
|
|||||||
val atlas: Atlas?,
|
val atlas: Atlas?,
|
||||||
val collab: Collab?,
|
val collab: Collab?,
|
||||||
val labels: Labels,
|
val labels: Labels,
|
||||||
|
/** The trip's next flight or the one in the air; last and defaulted, so older callers keep compiling. */
|
||||||
|
val flight: Flight? = null,
|
||||||
|
/**
|
||||||
|
* The trip's days from the day the app wrote this on, each with its date, so
|
||||||
|
* the widget turns to the next day itself (see [on]); empty from an app
|
||||||
|
* that predates them.
|
||||||
|
*/
|
||||||
|
val days: List<Today> = emptyList(),
|
||||||
) {
|
) {
|
||||||
|
/**
|
||||||
|
* The snapshot as it reads on [date]: that date's trip day out of [days],
|
||||||
|
* none before or after the trip, and only the bookings from that date on.
|
||||||
|
* The app writes its snapshot only while it runs, so without this a widget
|
||||||
|
* showed the day it last ran. A snapshot without [days] reads as written.
|
||||||
|
*/
|
||||||
|
fun on(date: LocalDate): WidgetSnapshot {
|
||||||
|
if (days.isEmpty()) return this
|
||||||
|
val key = date.toString()
|
||||||
|
return copy(
|
||||||
|
today = days.firstOrNull { it.date == key },
|
||||||
|
bookings = bookings.filter { (it.date ?: key) >= key },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
data class Trip(
|
data class Trip(
|
||||||
val title: String,
|
val title: String,
|
||||||
val start: String,
|
val start: String,
|
||||||
@@ -50,7 +73,8 @@ data class WidgetSnapshot(
|
|||||||
val symbol: String?,
|
val symbol: String?,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Today(val dayLabel: String, val stops: List<Stop>, val index: Int?, val total: Int?)
|
/** A trip day; [date] (yyyy-MM-dd) is absent from an app that predates the days ahead. */
|
||||||
|
data class Today(val dayLabel: String, val stops: List<Stop>, val index: Int?, val total: Int?, val date: String? = null)
|
||||||
|
|
||||||
data class Weather(
|
data class Weather(
|
||||||
val temp: Int,
|
val temp: Int,
|
||||||
@@ -105,6 +129,39 @@ data class WidgetSnapshot(
|
|||||||
|
|
||||||
data class Collab(val members: List<Member>, val messages: List<Message>, val poll: Poll?, val path: String)
|
data class Collab(val members: List<Member>, val messages: List<Message>, val poll: Poll?, val path: String)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The flight widget's flight. Times are epoch seconds, so the widget moves on
|
||||||
|
* with the clock between two snapshots; the clock times at either airport
|
||||||
|
* come formatted, since the widget has no zone data.
|
||||||
|
*/
|
||||||
|
data class Flight(
|
||||||
|
val number: String,
|
||||||
|
val from: String,
|
||||||
|
val to: String,
|
||||||
|
val fromCity: String?,
|
||||||
|
val toCity: String?,
|
||||||
|
val dep: Long,
|
||||||
|
val arr: Long,
|
||||||
|
/** Observed take-off. */
|
||||||
|
val depActual: Long?,
|
||||||
|
/** Before take-off: the planned departure plus the delay seen so far. */
|
||||||
|
val depExpected: Long?,
|
||||||
|
/** The feed saw the aircraft in the air when the app last looked. */
|
||||||
|
val airborne: Boolean,
|
||||||
|
/** Touchdown once landed, else the estimate while in the air. */
|
||||||
|
val arrExpected: Long?,
|
||||||
|
val landed: Boolean,
|
||||||
|
val depTime: String,
|
||||||
|
val arrTime: String,
|
||||||
|
val arrTimeExpected: String?,
|
||||||
|
/** Minutes late against the schedule, negative when early. */
|
||||||
|
val delay: Int?,
|
||||||
|
val aircraft: String?,
|
||||||
|
/** When the feed last heard the aircraft; null for a flight it never heard of. */
|
||||||
|
val seen: Long?,
|
||||||
|
val path: String,
|
||||||
|
)
|
||||||
|
|
||||||
/** The labels, translated by the app. The optional ones fall back to English. */
|
/** The labels, translated by the app. The optional ones fall back to English. */
|
||||||
data class Labels(private val raw: JSONObject) {
|
data class Labels(private val raw: JSONObject) {
|
||||||
val nextTrip get() = text("nextTrip", "Next trip")
|
val nextTrip get() = text("nextTrip", "Next trip")
|
||||||
@@ -137,6 +194,23 @@ data class WidgetSnapshot(
|
|||||||
val votes get() = text("votes", "votes")
|
val votes get() = text("votes", "votes")
|
||||||
val noMessages get() = text("noMessages", "No messages yet")
|
val noMessages get() = text("noMessages", "No messages yet")
|
||||||
val departure get() = text("departure", "Departure")
|
val departure get() = text("departure", "Departure")
|
||||||
|
val flight get() = text("flight", "Flight")
|
||||||
|
/** Contains "{time}". */
|
||||||
|
val flightDeparts get() = text("flightDeparts", "Departs in {time}")
|
||||||
|
/** Contains "{time}". */
|
||||||
|
val flightLands get() = text("flightLands", "Lands in {time}")
|
||||||
|
val flightLanded get() = text("flightLanded", "Landed")
|
||||||
|
val flightReady get() = text("flightReady", "Ready for departure")
|
||||||
|
val noFlight get() = text("noFlight", "No flight ahead")
|
||||||
|
val flightOnTime get() = text("flightOnTime", "On time")
|
||||||
|
/** Contains "{m}". */
|
||||||
|
val flightLate get() = text("flightLate", "+{m} min")
|
||||||
|
/** Contains "{m}". */
|
||||||
|
val flightEarly get() = text("flightEarly", "{m} min early")
|
||||||
|
/** Contain "{d}" and "{h}", "{h}" and "{m}", and "{m}". */
|
||||||
|
val durDaysHours get() = text("durDaysHours", "{d} d {h} h")
|
||||||
|
val durHoursMinutes get() = text("durHoursMinutes", "{h} h {m} min")
|
||||||
|
val durMinutes get() = text("durMinutes", "{m} min")
|
||||||
|
|
||||||
private fun text(key: String, fallback: String): String = raw.optString(key).ifBlank { fallback }
|
private fun text(key: String, fallback: String): String = raw.optString(key).ifBlank { fallback }
|
||||||
}
|
}
|
||||||
@@ -160,6 +234,16 @@ data class WidgetSnapshot(
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun dayOf(t: JSONObject): Today = Today(
|
||||||
|
dayLabel = t.optString("dayLabel"),
|
||||||
|
stops = t.optJSONArray("stops").objects().map {
|
||||||
|
Stop(it.str("time"), it.optString("name"), it.int("minutes"), it.str("color"), it.str("symbol"))
|
||||||
|
},
|
||||||
|
index = t.int("index"),
|
||||||
|
total = t.int("total"),
|
||||||
|
date = t.str("date"),
|
||||||
|
)
|
||||||
|
|
||||||
fun fromJson(o: JSONObject): WidgetSnapshot = WidgetSnapshot(
|
fun fromJson(o: JSONObject): WidgetSnapshot = WidgetSnapshot(
|
||||||
trip = o.optJSONObject("trip")?.let {
|
trip = o.optJSONObject("trip")?.let {
|
||||||
Trip(
|
Trip(
|
||||||
@@ -174,16 +258,8 @@ data class WidgetSnapshot(
|
|||||||
memberCount = it.int("memberCount"),
|
memberCount = it.int("memberCount"),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
today = o.optJSONObject("today")?.let { t ->
|
today = o.optJSONObject("today")?.let(::dayOf),
|
||||||
Today(
|
days = o.optJSONArray("days").objects().map(::dayOf),
|
||||||
dayLabel = t.optString("dayLabel"),
|
|
||||||
stops = t.optJSONArray("stops").objects().map {
|
|
||||||
Stop(it.str("time"), it.optString("name"), it.int("minutes"), it.str("color"), it.str("symbol"))
|
|
||||||
},
|
|
||||||
index = t.int("index"),
|
|
||||||
total = t.int("total"),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
weather = o.optJSONObject("weather")?.let {
|
weather = o.optJSONObject("weather")?.let {
|
||||||
Weather(it.optInt("temp"), it.int("high"), it.int("low"), it.optString("main"), it.optString("label"), it.str("place"), it.int("rain"))
|
Weather(it.optInt("temp"), it.int("high"), it.int("low"), it.optString("main"), it.optString("label"), it.str("place"), it.int("rain"))
|
||||||
},
|
},
|
||||||
@@ -240,6 +316,29 @@ data class WidgetSnapshot(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
labels = Labels(o.optJSONObject("labels") ?: JSONObject()),
|
labels = Labels(o.optJSONObject("labels") ?: JSONObject()),
|
||||||
|
flight = o.optJSONObject("flight")?.let { f ->
|
||||||
|
Flight(
|
||||||
|
number = f.optString("number"),
|
||||||
|
from = f.optString("from"),
|
||||||
|
to = f.optString("to"),
|
||||||
|
fromCity = f.str("fromCity"),
|
||||||
|
toCity = f.str("toCity"),
|
||||||
|
dep = f.optLong("dep"),
|
||||||
|
arr = f.optLong("arr"),
|
||||||
|
depActual = f.long("depActual"),
|
||||||
|
depExpected = f.long("depExpected"),
|
||||||
|
airborne = f.optBoolean("airborne"),
|
||||||
|
arrExpected = f.long("arrExpected"),
|
||||||
|
landed = f.optBoolean("landed"),
|
||||||
|
depTime = f.optString("depTime"),
|
||||||
|
arrTime = f.optString("arrTime"),
|
||||||
|
arrTimeExpected = f.str("arrTimeExpected"),
|
||||||
|
delay = f.int("delay"),
|
||||||
|
aircraft = f.str("aircraft"),
|
||||||
|
seen = f.long("seen"),
|
||||||
|
path = f.optString("path", "/"),
|
||||||
|
)
|
||||||
|
}?.takeIf { it.dep > 0 && it.arr > 0 },
|
||||||
)
|
)
|
||||||
|
|
||||||
fun day(iso: String?): LocalDate? {
|
fun day(iso: String?): LocalDate? {
|
||||||
@@ -258,6 +357,8 @@ data class WidgetSnapshot(
|
|||||||
|
|
||||||
private fun JSONObject.int(key: String): Int? = if (has(key) && !isNull(key)) optInt(key) else null
|
private fun JSONObject.int(key: String): Int? = if (has(key) && !isNull(key)) optInt(key) else null
|
||||||
|
|
||||||
|
private fun JSONObject.long(key: String): Long? = if (has(key) && !isNull(key)) optLong(key) else null
|
||||||
|
|
||||||
private fun JSONArray?.objects(): List<JSONObject> =
|
private fun JSONArray?.objects(): List<JSONObject> =
|
||||||
if (this == null) emptyList() else (0 until length()).mapNotNull { optJSONObject(it) }
|
if (this == null) emptyList() else (0 until length()).mapNotNull { optJSONObject(it) }
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">خطة اليوم كخط زمني، مع الطقس والمحطة التالية.</string>
|
<string name="widget_today_description">خطة اليوم كخط زمني، مع الطقس والمحطة التالية.</string>
|
||||||
<string name="widget_bookings_name">الحجوزات</string>
|
<string name="widget_bookings_name">الحجوزات</string>
|
||||||
<string name="widget_bookings_description">رحلاتك وقطاراتك وفنادقك وحجوزات المطاعم القادمة ومواعيدها.</string>
|
<string name="widget_bookings_description">رحلاتك وقطاراتك وفنادقك وحجوزات المطاعم القادمة ومواعيدها.</string>
|
||||||
|
<string name="widget_flight_name">الرحلة</string>
|
||||||
|
<string name="widget_flight_description">رحلتك القادمة مباشرة: عد تنازلي للإقلاع، والطائرة في طريقها، والتأخير والوصول.</string>
|
||||||
<string name="widget_todos_name">المهام</string>
|
<string name="widget_todos_name">المهام</string>
|
||||||
<string name="widget_todos_description">ما تبقى للرحلة، ومدى تقدم تجهيز الأمتعة.</string>
|
<string name="widget_todos_description">ما تبقى للرحلة، ومدى تقدم تجهيز الأمتعة.</string>
|
||||||
<string name="widget_packing_name">قائمة الأمتعة</string>
|
<string name="widget_packing_name">قائمة الأمتعة</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Günün planı zaman xətti kimi, hava və növbəti dayanacaqla.</string>
|
<string name="widget_today_description">Günün planı zaman xətti kimi, hava və növbəti dayanacaqla.</string>
|
||||||
<string name="widget_bookings_name">Bronlar</string>
|
<string name="widget_bookings_name">Bronlar</string>
|
||||||
<string name="widget_bookings_description">Növbəti uçuşlar, qatarlar, otellər və restoranlar, nə vaxt olduqları ilə.</string>
|
<string name="widget_bookings_description">Növbəti uçuşlar, qatarlar, otellər və restoranlar, nə vaxt olduqları ilə.</string>
|
||||||
|
<string name="widget_flight_name">Uçuş</string>
|
||||||
|
<string name="widget_flight_description">Növbəti uçuşun canlı: uçuşa qədər geri sayım, yolda olan təyyarə, gecikmə və gəliş.</string>
|
||||||
<string name="widget_todos_name">Tapşırıqlar</string>
|
<string name="widget_todos_name">Tapşırıqlar</string>
|
||||||
<string name="widget_todos_description">Səyahət üçün hələ nəyin qaldığı və yığışmağın nə yerdə olduğu.</string>
|
<string name="widget_todos_description">Səyahət üçün hələ nəyin qaldığı və yığışmağın nə yerdə olduğu.</string>
|
||||||
<string name="widget_packing_name">Yük siyahısı</string>
|
<string name="widget_packing_name">Yük siyahısı</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">以时间线显示今天的计划,附带天气和下一站。</string>
|
<string name="widget_today_description">以时间线显示今天的计划,附带天气和下一站。</string>
|
||||||
<string name="widget_bookings_name">预订</string>
|
<string name="widget_bookings_name">预订</string>
|
||||||
<string name="widget_bookings_description">你接下来的航班、火车、酒店和餐厅,以及时间。</string>
|
<string name="widget_bookings_description">你接下来的航班、火车、酒店和餐厅,以及时间。</string>
|
||||||
|
<string name="widget_flight_name">航班</string>
|
||||||
|
<string name="widget_flight_description">实时查看下一班航班:起飞倒计时、飞行中的飞机、延误和到达。</string>
|
||||||
<string name="widget_todos_name">待办</string>
|
<string name="widget_todos_name">待办</string>
|
||||||
<string name="widget_todos_description">旅行还剩哪些事没做,以及行李收拾到哪一步。</string>
|
<string name="widget_todos_description">旅行还剩哪些事没做,以及行李收拾到哪一步。</string>
|
||||||
<string name="widget_packing_name">行李</string>
|
<string name="widget_packing_name">行李</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">以時間軸顯示今天的計畫,附上天氣與下一站。</string>
|
<string name="widget_today_description">以時間軸顯示今天的計畫,附上天氣與下一站。</string>
|
||||||
<string name="widget_bookings_name">預訂</string>
|
<string name="widget_bookings_name">預訂</string>
|
||||||
<string name="widget_bookings_description">你接下來的航班、火車、飯店與餐廳,以及時間。</string>
|
<string name="widget_bookings_description">你接下來的航班、火車、飯店與餐廳,以及時間。</string>
|
||||||
|
<string name="widget_flight_name">航班</string>
|
||||||
|
<string name="widget_flight_description">即時查看下一班航班:起飛倒數、飛行中的飛機、延誤和抵達。</string>
|
||||||
<string name="widget_todos_name">待辦</string>
|
<string name="widget_todos_name">待辦</string>
|
||||||
<string name="widget_todos_description">旅行還剩哪些事沒做,以及行李整理到哪一步。</string>
|
<string name="widget_todos_description">旅行還剩哪些事沒做,以及行李整理到哪一步。</string>
|
||||||
<string name="widget_packing_name">行李</string>
|
<string name="widget_packing_name">行李</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">El pla del dia com a línia de temps, amb el temps i la propera parada.</string>
|
<string name="widget_today_description">El pla del dia com a línia de temps, amb el temps i la propera parada.</string>
|
||||||
<string name="widget_bookings_name">Reserves</string>
|
<string name="widget_bookings_name">Reserves</string>
|
||||||
<string name="widget_bookings_description">Els teus propers vols, trens, hotels i taules, i quan toquen.</string>
|
<string name="widget_bookings_description">Els teus propers vols, trens, hotels i taules, i quan toquen.</string>
|
||||||
|
<string name="widget_flight_name">Vol</string>
|
||||||
|
<string name="widget_flight_description">El teu proper vol en directe: compte enrere de la sortida, l’avió en camí, retard i arribada.</string>
|
||||||
<string name="widget_todos_name">Tasques</string>
|
<string name="widget_todos_name">Tasques</string>
|
||||||
<string name="widget_todos_description">El que encara queda per al viatge i com va l\'equipatge.</string>
|
<string name="widget_todos_description">El que encara queda per al viatge i com va l\'equipatge.</string>
|
||||||
<string name="widget_packing_name">Equipatge</string>
|
<string name="widget_packing_name">Equipatge</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Plán dne jako časová osa, s počasím a další zastávkou.</string>
|
<string name="widget_today_description">Plán dne jako časová osa, s počasím a další zastávkou.</string>
|
||||||
<string name="widget_bookings_name">Rezervace</string>
|
<string name="widget_bookings_name">Rezervace</string>
|
||||||
<string name="widget_bookings_description">Tvoje další lety, vlaky, hotely a stoly, a kdy tě čekají.</string>
|
<string name="widget_bookings_description">Tvoje další lety, vlaky, hotely a stoly, a kdy tě čekají.</string>
|
||||||
|
<string name="widget_flight_name">Let</string>
|
||||||
|
<string name="widget_flight_description">Tvůj další let živě: odpočet do odletu, letadlo na cestě, zpoždění a přílet.</string>
|
||||||
<string name="widget_todos_name">Úkoly</string>
|
<string name="widget_todos_name">Úkoly</string>
|
||||||
<string name="widget_todos_description">Co ještě zbývá k cestě a jak daleko je balení.</string>
|
<string name="widget_todos_description">Co ještě zbývá k cestě a jak daleko je balení.</string>
|
||||||
<string name="widget_packing_name">Balení</string>
|
<string name="widget_packing_name">Balení</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Der Tagesplan als Zeitleiste, mit dem Wetter und dem nächsten Stopp.</string>
|
<string name="widget_today_description">Der Tagesplan als Zeitleiste, mit dem Wetter und dem nächsten Stopp.</string>
|
||||||
<string name="widget_bookings_name">Buchungen</string>
|
<string name="widget_bookings_name">Buchungen</string>
|
||||||
<string name="widget_bookings_description">Deine nächsten Flüge, Züge, Hotels und Tische, und wann sie anstehen.</string>
|
<string name="widget_bookings_description">Deine nächsten Flüge, Züge, Hotels und Tische, und wann sie anstehen.</string>
|
||||||
|
<string name="widget_flight_name">Flug</string>
|
||||||
|
<string name="widget_flight_description">Dein nächster Flug live: Countdown bis zum Abflug, die Maschine unterwegs, Verspätung und Ankunft.</string>
|
||||||
<string name="widget_todos_name">To-dos</string>
|
<string name="widget_todos_name">To-dos</string>
|
||||||
<string name="widget_todos_description">Was für die Reise noch offen ist und wie weit das Packen ist.</string>
|
<string name="widget_todos_description">Was für die Reise noch offen ist und wie weit das Packen ist.</string>
|
||||||
<string name="widget_packing_name">Packliste</string>
|
<string name="widget_packing_name">Packliste</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Το πρόγραμμα της ημέρας ως χρονολόγιο, με τον καιρό και την επόμενη στάση.</string>
|
<string name="widget_today_description">Το πρόγραμμα της ημέρας ως χρονολόγιο, με τον καιρό και την επόμενη στάση.</string>
|
||||||
<string name="widget_bookings_name">Κρατήσεις</string>
|
<string name="widget_bookings_name">Κρατήσεις</string>
|
||||||
<string name="widget_bookings_description">Οι επόμενες πτήσεις, τα τρένα, τα ξενοδοχεία και τα τραπέζια σου, και πότε είναι.</string>
|
<string name="widget_bookings_description">Οι επόμενες πτήσεις, τα τρένα, τα ξενοδοχεία και τα τραπέζια σου, και πότε είναι.</string>
|
||||||
|
<string name="widget_flight_name">Πτήση</string>
|
||||||
|
<string name="widget_flight_description">Η επόμενη πτήση σου ζωντανά: αντίστροφη μέτρηση για την αναχώρηση, το αεροσκάφος καθ’ οδόν, καθυστέρηση και άφιξη.</string>
|
||||||
<string name="widget_todos_name">Εκκρεμότητες</string>
|
<string name="widget_todos_name">Εκκρεμότητες</string>
|
||||||
<string name="widget_todos_description">Τι μένει ακόμα για το ταξίδι και πόσο έχει προχωρήσει το πακετάρισμα.</string>
|
<string name="widget_todos_description">Τι μένει ακόμα για το ταξίδι και πόσο έχει προχωρήσει το πακετάρισμα.</string>
|
||||||
<string name="widget_packing_name">Αποσκευές</string>
|
<string name="widget_packing_name">Αποσκευές</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">El plan del día como línea de tiempo, con el tiempo y la próxima parada.</string>
|
<string name="widget_today_description">El plan del día como línea de tiempo, con el tiempo y la próxima parada.</string>
|
||||||
<string name="widget_bookings_name">Reservas</string>
|
<string name="widget_bookings_name">Reservas</string>
|
||||||
<string name="widget_bookings_description">Tus próximos vuelos, trenes, hoteles y mesas, y cuándo tocan.</string>
|
<string name="widget_bookings_description">Tus próximos vuelos, trenes, hoteles y mesas, y cuándo tocan.</string>
|
||||||
|
<string name="widget_flight_name">Vuelo</string>
|
||||||
|
<string name="widget_flight_description">Tu próximo vuelo en directo: cuenta atrás de la salida, el avión en camino, retraso y llegada.</string>
|
||||||
<string name="widget_todos_name">Tareas</string>
|
<string name="widget_todos_name">Tareas</string>
|
||||||
<string name="widget_todos_description">Lo que aún queda para el viaje y cómo va la maleta.</string>
|
<string name="widget_todos_description">Lo que aún queda para el viaje y cómo va la maleta.</string>
|
||||||
<string name="widget_packing_name">Equipaje</string>
|
<string name="widget_packing_name">Equipaje</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Päeva plaan ajajoonena, koos ilma ja järgmise peatusega.</string>
|
<string name="widget_today_description">Päeva plaan ajajoonena, koos ilma ja järgmise peatusega.</string>
|
||||||
<string name="widget_bookings_name">Broneeringud</string>
|
<string name="widget_bookings_name">Broneeringud</string>
|
||||||
<string name="widget_bookings_description">Sinu järgmised lennud, rongid, hotellid ja lauad ning millal need on.</string>
|
<string name="widget_bookings_description">Sinu järgmised lennud, rongid, hotellid ja lauad ning millal need on.</string>
|
||||||
|
<string name="widget_flight_name">Lend</string>
|
||||||
|
<string name="widget_flight_description">Sinu järgmine lend otse: loendus väljumiseni, lennuk teel, hilinemine ja saabumine.</string>
|
||||||
<string name="widget_todos_name">Ülesanded</string>
|
<string name="widget_todos_name">Ülesanded</string>
|
||||||
<string name="widget_todos_description">Mis reisi jaoks veel tegemata on ja kui kaugel pakkimine on.</string>
|
<string name="widget_todos_description">Mis reisi jaoks veel tegemata on ja kui kaugel pakkimine on.</string>
|
||||||
<string name="widget_packing_name">Pakkimine</string>
|
<string name="widget_packing_name">Pakkimine</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Le programme du jour en frise, avec la météo et la prochaine étape.</string>
|
<string name="widget_today_description">Le programme du jour en frise, avec la météo et la prochaine étape.</string>
|
||||||
<string name="widget_bookings_name">Réservations</string>
|
<string name="widget_bookings_name">Réservations</string>
|
||||||
<string name="widget_bookings_description">Vos prochains vols, trains, hôtels et tables, et quand ils arrivent.</string>
|
<string name="widget_bookings_description">Vos prochains vols, trains, hôtels et tables, et quand ils arrivent.</string>
|
||||||
|
<string name="widget_flight_name">Vol</string>
|
||||||
|
<string name="widget_flight_description">Votre prochain vol en direct : compte à rebours du départ, l’avion en route, retard et arrivée.</string>
|
||||||
<string name="widget_todos_name">À faire</string>
|
<string name="widget_todos_name">À faire</string>
|
||||||
<string name="widget_todos_description">Ce qui reste à faire pour le voyage et où en sont les bagages.</string>
|
<string name="widget_todos_description">Ce qui reste à faire pour le voyage et où en sont les bagages.</string>
|
||||||
<string name="widget_packing_name">Bagages</string>
|
<string name="widget_packing_name">Bagages</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">A nap terve idővonalon, az időjárással és a következő megállóval.</string>
|
<string name="widget_today_description">A nap terve idővonalon, az időjárással és a következő megállóval.</string>
|
||||||
<string name="widget_bookings_name">Foglalások</string>
|
<string name="widget_bookings_name">Foglalások</string>
|
||||||
<string name="widget_bookings_description">A következő járataid, vonataid, szállásaid és asztalfoglalásaid, és hogy mikor esedékesek.</string>
|
<string name="widget_bookings_description">A következő járataid, vonataid, szállásaid és asztalfoglalásaid, és hogy mikor esedékesek.</string>
|
||||||
|
<string name="widget_flight_name">Járat</string>
|
||||||
|
<string name="widget_flight_description">A következő járatod élőben: visszaszámlálás az indulásig, a gép útközben, késés és érkezés.</string>
|
||||||
<string name="widget_todos_name">Teendők</string>
|
<string name="widget_todos_name">Teendők</string>
|
||||||
<string name="widget_todos_description">Ami még hátravan az utazáshoz, és hol tart a csomagolás.</string>
|
<string name="widget_todos_description">Ami még hátravan az utazáshoz, és hol tart a csomagolás.</string>
|
||||||
<string name="widget_packing_name">Csomagolás</string>
|
<string name="widget_packing_name">Csomagolás</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Rencana hari ini sebagai linimasa, dengan cuaca dan perhentian berikutnya.</string>
|
<string name="widget_today_description">Rencana hari ini sebagai linimasa, dengan cuaca dan perhentian berikutnya.</string>
|
||||||
<string name="widget_bookings_name">Pemesanan</string>
|
<string name="widget_bookings_name">Pemesanan</string>
|
||||||
<string name="widget_bookings_description">Penerbangan, kereta, hotel, dan meja berikutnya, beserta waktunya.</string>
|
<string name="widget_bookings_description">Penerbangan, kereta, hotel, dan meja berikutnya, beserta waktunya.</string>
|
||||||
|
<string name="widget_flight_name">Penerbangan</string>
|
||||||
|
<string name="widget_flight_description">Penerbangan berikutnya secara langsung: hitung mundur keberangkatan, pesawat dalam perjalanan, keterlambatan, dan kedatangan.</string>
|
||||||
<string name="widget_todos_name">Tugas</string>
|
<string name="widget_todos_name">Tugas</string>
|
||||||
<string name="widget_todos_description">Yang masih tersisa untuk perjalanan dan sejauh mana persiapan barang.</string>
|
<string name="widget_todos_description">Yang masih tersisa untuk perjalanan dan sejauh mana persiapan barang.</string>
|
||||||
<string name="widget_packing_name">Barang bawaan</string>
|
<string name="widget_packing_name">Barang bawaan</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Il programma del giorno come linea del tempo, con il meteo e la prossima tappa.</string>
|
<string name="widget_today_description">Il programma del giorno come linea del tempo, con il meteo e la prossima tappa.</string>
|
||||||
<string name="widget_bookings_name">Prenotazioni</string>
|
<string name="widget_bookings_name">Prenotazioni</string>
|
||||||
<string name="widget_bookings_description">I tuoi prossimi voli, treni, hotel e tavoli, e quando sono.</string>
|
<string name="widget_bookings_description">I tuoi prossimi voli, treni, hotel e tavoli, e quando sono.</string>
|
||||||
|
<string name="widget_flight_name">Volo</string>
|
||||||
|
<string name="widget_flight_description">Il tuo prossimo volo in tempo reale: conto alla rovescia per la partenza, l’aereo in viaggio, ritardo e arrivo.</string>
|
||||||
<string name="widget_todos_name">Da fare</string>
|
<string name="widget_todos_name">Da fare</string>
|
||||||
<string name="widget_todos_description">Cosa manca ancora per il viaggio e a che punto è la valigia.</string>
|
<string name="widget_todos_description">Cosa manca ancora per il viaggio e a che punto è la valigia.</string>
|
||||||
<string name="widget_packing_name">Bagagli</string>
|
<string name="widget_packing_name">Bagagli</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">תוכנית היום כציר זמן, עם מזג האוויר והעצירה הבאה.</string>
|
<string name="widget_today_description">תוכנית היום כציר זמן, עם מזג האוויר והעצירה הבאה.</string>
|
||||||
<string name="widget_bookings_name">הזמנות</string>
|
<string name="widget_bookings_name">הזמנות</string>
|
||||||
<string name="widget_bookings_description">הטיסות, הרכבות, המלונות והשולחנות הבאים שלך, ומתי הם.</string>
|
<string name="widget_bookings_description">הטיסות, הרכבות, המלונות והשולחנות הבאים שלך, ומתי הם.</string>
|
||||||
|
<string name="widget_flight_name">טיסה</string>
|
||||||
|
<string name="widget_flight_description">הטיסה הבאה שלך בזמן אמת: ספירה לאחור עד ההמראה, המטוס בדרך, עיכוב והגעה.</string>
|
||||||
<string name="widget_todos_name">משימות</string>
|
<string name="widget_todos_name">משימות</string>
|
||||||
<string name="widget_todos_description">מה עוד פתוח לטיול וכמה התקדמה האריזה.</string>
|
<string name="widget_todos_description">מה עוד פתוח לטיול וכמה התקדמה האריזה.</string>
|
||||||
<string name="widget_packing_name">אריזה</string>
|
<string name="widget_packing_name">אריזה</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">今日の予定をタイムラインで、天気と次の予定とともに表示します。</string>
|
<string name="widget_today_description">今日の予定をタイムラインで、天気と次の予定とともに表示します。</string>
|
||||||
<string name="widget_bookings_name">予約</string>
|
<string name="widget_bookings_name">予約</string>
|
||||||
<string name="widget_bookings_description">次のフライト、列車、ホテル、レストランとその日時。</string>
|
<string name="widget_bookings_description">次のフライト、列車、ホテル、レストランとその日時。</string>
|
||||||
|
<string name="widget_flight_name">フライト</string>
|
||||||
|
<string name="widget_flight_description">次のフライトをライブで:出発までのカウントダウン、飛行中の機体、遅延と到着。</string>
|
||||||
<string name="widget_todos_name">やること</string>
|
<string name="widget_todos_name">やること</string>
|
||||||
<string name="widget_todos_description">旅行のために残っていることと、荷造りの進み具合。</string>
|
<string name="widget_todos_description">旅行のために残っていることと、荷造りの進み具合。</string>
|
||||||
<string name="widget_packing_name">持ち物</string>
|
<string name="widget_packing_name">持ち物</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">오늘 일정을 타임라인으로, 날씨와 다음 장소와 함께 보여 줍니다.</string>
|
<string name="widget_today_description">오늘 일정을 타임라인으로, 날씨와 다음 장소와 함께 보여 줍니다.</string>
|
||||||
<string name="widget_bookings_name">예약</string>
|
<string name="widget_bookings_name">예약</string>
|
||||||
<string name="widget_bookings_description">다가오는 항공편, 기차, 호텔, 식당과 그 시간.</string>
|
<string name="widget_bookings_description">다가오는 항공편, 기차, 호텔, 식당과 그 시간.</string>
|
||||||
|
<string name="widget_flight_name">항공편</string>
|
||||||
|
<string name="widget_flight_description">다음 항공편을 실시간으로: 출발 카운트다운, 비행 중인 항공기, 지연과 도착.</string>
|
||||||
<string name="widget_todos_name">할 일</string>
|
<string name="widget_todos_name">할 일</string>
|
||||||
<string name="widget_todos_description">여행을 위해 남은 일과 짐 싸기 진행 상황.</string>
|
<string name="widget_todos_description">여행을 위해 남은 일과 짐 싸기 진행 상황.</string>
|
||||||
<string name="widget_packing_name">짐 싸기</string>
|
<string name="widget_packing_name">짐 싸기</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Het dagplan als tijdlijn, met het weer en de volgende stop.</string>
|
<string name="widget_today_description">Het dagplan als tijdlijn, met het weer en de volgende stop.</string>
|
||||||
<string name="widget_bookings_name">Boekingen</string>
|
<string name="widget_bookings_name">Boekingen</string>
|
||||||
<string name="widget_bookings_description">Je volgende vluchten, treinen, hotels en tafels, en wanneer ze zijn.</string>
|
<string name="widget_bookings_description">Je volgende vluchten, treinen, hotels en tafels, en wanneer ze zijn.</string>
|
||||||
|
<string name="widget_flight_name">Vlucht</string>
|
||||||
|
<string name="widget_flight_description">Je volgende vlucht live: aftellen tot vertrek, het toestel onderweg, vertraging en aankomst.</string>
|
||||||
<string name="widget_todos_name">Taken</string>
|
<string name="widget_todos_name">Taken</string>
|
||||||
<string name="widget_todos_description">Wat er nog openstaat voor de reis en hoe ver het inpakken is.</string>
|
<string name="widget_todos_description">Wat er nog openstaat voor de reis en hoe ver het inpakken is.</string>
|
||||||
<string name="widget_packing_name">Bagage</string>
|
<string name="widget_packing_name">Bagage</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Plan dnia jako oś czasu, z pogodą i kolejnym przystankiem.</string>
|
<string name="widget_today_description">Plan dnia jako oś czasu, z pogodą i kolejnym przystankiem.</string>
|
||||||
<string name="widget_bookings_name">Rezerwacje</string>
|
<string name="widget_bookings_name">Rezerwacje</string>
|
||||||
<string name="widget_bookings_description">Twoje najbliższe loty, pociągi, hotele i stoliki oraz ich terminy.</string>
|
<string name="widget_bookings_description">Twoje najbliższe loty, pociągi, hotele i stoliki oraz ich terminy.</string>
|
||||||
|
<string name="widget_flight_name">Lot</string>
|
||||||
|
<string name="widget_flight_description">Twój następny lot na żywo: odliczanie do odlotu, samolot w drodze, opóźnienie i przylot.</string>
|
||||||
<string name="widget_todos_name">Zadania</string>
|
<string name="widget_todos_name">Zadania</string>
|
||||||
<string name="widget_todos_description">Co jeszcze zostało do zrobienia przed podróżą i jak idzie pakowanie.</string>
|
<string name="widget_todos_description">Co jeszcze zostało do zrobienia przed podróżą i jak idzie pakowanie.</string>
|
||||||
<string name="widget_packing_name">Pakowanie</string>
|
<string name="widget_packing_name">Pakowanie</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">O plano do dia como linha do tempo, com o clima e a próxima parada.</string>
|
<string name="widget_today_description">O plano do dia como linha do tempo, com o clima e a próxima parada.</string>
|
||||||
<string name="widget_bookings_name">Reservas</string>
|
<string name="widget_bookings_name">Reservas</string>
|
||||||
<string name="widget_bookings_description">Seus próximos voos, trens, hotéis e mesas, e quando acontecem.</string>
|
<string name="widget_bookings_description">Seus próximos voos, trens, hotéis e mesas, e quando acontecem.</string>
|
||||||
|
<string name="widget_flight_name">Voo</string>
|
||||||
|
<string name="widget_flight_description">Seu próximo voo ao vivo: contagem regressiva para a partida, o avião a caminho, atraso e chegada.</string>
|
||||||
<string name="widget_todos_name">Tarefas</string>
|
<string name="widget_todos_name">Tarefas</string>
|
||||||
<string name="widget_todos_description">O que ainda falta para a viagem e quanto da mala já está pronto.</string>
|
<string name="widget_todos_description">O que ainda falta para a viagem e quanto da mala já está pronto.</string>
|
||||||
<string name="widget_packing_name">Bagagem</string>
|
<string name="widget_packing_name">Bagagem</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">План дня в виде ленты времени, с погодой и следующей остановкой.</string>
|
<string name="widget_today_description">План дня в виде ленты времени, с погодой и следующей остановкой.</string>
|
||||||
<string name="widget_bookings_name">Бронирования</string>
|
<string name="widget_bookings_name">Бронирования</string>
|
||||||
<string name="widget_bookings_description">Ближайшие рейсы, поезда, отели и столики и когда они.</string>
|
<string name="widget_bookings_description">Ближайшие рейсы, поезда, отели и столики и когда они.</string>
|
||||||
|
<string name="widget_flight_name">Рейс</string>
|
||||||
|
<string name="widget_flight_description">Ваш следующий рейс в реальном времени: отсчёт до вылета, самолёт в пути, задержка и прибытие.</string>
|
||||||
<string name="widget_todos_name">Задачи</string>
|
<string name="widget_todos_name">Задачи</string>
|
||||||
<string name="widget_todos_description">Что ещё осталось сделать к поездке и как идут сборы.</string>
|
<string name="widget_todos_description">Что ещё осталось сделать к поездке и как идут сборы.</string>
|
||||||
<string name="widget_packing_name">Сборы</string>
|
<string name="widget_packing_name">Сборы</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Plán dňa ako časová os, s počasím a ďalšou zastávkou.</string>
|
<string name="widget_today_description">Plán dňa ako časová os, s počasím a ďalšou zastávkou.</string>
|
||||||
<string name="widget_bookings_name">Rezervácie</string>
|
<string name="widget_bookings_name">Rezervácie</string>
|
||||||
<string name="widget_bookings_description">Tvoje ďalšie lety, vlaky, hotely a stoly a kedy ťa čakajú.</string>
|
<string name="widget_bookings_description">Tvoje ďalšie lety, vlaky, hotely a stoly a kedy ťa čakajú.</string>
|
||||||
|
<string name="widget_flight_name">Let</string>
|
||||||
|
<string name="widget_flight_description">Tvoj ďalší let naživo: odpočet do odletu, lietadlo na ceste, meškanie a prílet.</string>
|
||||||
<string name="widget_todos_name">Úlohy</string>
|
<string name="widget_todos_name">Úlohy</string>
|
||||||
<string name="widget_todos_description">Čo ešte zostáva na cestu a ako ďaleko je balenie.</string>
|
<string name="widget_todos_description">Čo ešte zostáva na cestu a ako ďaleko je balenie.</string>
|
||||||
<string name="widget_packing_name">Balenie</string>
|
<string name="widget_packing_name">Balenie</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Dagens plan som tidslinje, med vädret och nästa stopp.</string>
|
<string name="widget_today_description">Dagens plan som tidslinje, med vädret och nästa stopp.</string>
|
||||||
<string name="widget_bookings_name">Bokningar</string>
|
<string name="widget_bookings_name">Bokningar</string>
|
||||||
<string name="widget_bookings_description">Dina nästa flyg, tåg, hotell och bord, och när de är.</string>
|
<string name="widget_bookings_description">Dina nästa flyg, tåg, hotell och bord, och när de är.</string>
|
||||||
|
<string name="widget_flight_name">Flyg</string>
|
||||||
|
<string name="widget_flight_description">Ditt nästa flyg live: nedräkning till avgång, planet på väg, försening och ankomst.</string>
|
||||||
<string name="widget_todos_name">Att göra</string>
|
<string name="widget_todos_name">Att göra</string>
|
||||||
<string name="widget_todos_description">Vad som återstår inför resan och hur långt packningen har kommit.</string>
|
<string name="widget_todos_description">Vad som återstår inför resan och hur långt packningen har kommit.</string>
|
||||||
<string name="widget_packing_name">Packning</string>
|
<string name="widget_packing_name">Packning</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">แผนของวันนี้เป็นไทม์ไลน์ พร้อมสภาพอากาศและจุดหมายถัดไป</string>
|
<string name="widget_today_description">แผนของวันนี้เป็นไทม์ไลน์ พร้อมสภาพอากาศและจุดหมายถัดไป</string>
|
||||||
<string name="widget_bookings_name">การจอง</string>
|
<string name="widget_bookings_name">การจอง</string>
|
||||||
<string name="widget_bookings_description">เที่ยวบิน รถไฟ โรงแรม และร้านอาหารถัดไปของคุณ และเวลาของแต่ละรายการ</string>
|
<string name="widget_bookings_description">เที่ยวบิน รถไฟ โรงแรม และร้านอาหารถัดไปของคุณ และเวลาของแต่ละรายการ</string>
|
||||||
|
<string name="widget_flight_name">เที่ยวบิน</string>
|
||||||
|
<string name="widget_flight_description">เที่ยวบินถัดไปแบบสด: นับถอยหลังถึงเวลาออกเดินทาง เครื่องบินระหว่างทาง ความล่าช้า และเวลาถึง</string>
|
||||||
<string name="widget_todos_name">สิ่งที่ต้องทำ</string>
|
<string name="widget_todos_name">สิ่งที่ต้องทำ</string>
|
||||||
<string name="widget_todos_description">สิ่งที่ยังค้างอยู่สำหรับทริป และความคืบหน้าการจัดกระเป๋า</string>
|
<string name="widget_todos_description">สิ่งที่ยังค้างอยู่สำหรับทริป และความคืบหน้าการจัดกระเป๋า</string>
|
||||||
<string name="widget_packing_name">จัดกระเป๋า</string>
|
<string name="widget_packing_name">จัดกระเป๋า</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Günün planı zaman çizelgesi olarak, hava durumu ve sonraki durakla.</string>
|
<string name="widget_today_description">Günün planı zaman çizelgesi olarak, hava durumu ve sonraki durakla.</string>
|
||||||
<string name="widget_bookings_name">Rezervasyonlar</string>
|
<string name="widget_bookings_name">Rezervasyonlar</string>
|
||||||
<string name="widget_bookings_description">Sıradaki uçuşların, trenlerin, otellerin ve masaların, ne zaman oldukları ile.</string>
|
<string name="widget_bookings_description">Sıradaki uçuşların, trenlerin, otellerin ve masaların, ne zaman oldukları ile.</string>
|
||||||
|
<string name="widget_flight_name">Uçuş</string>
|
||||||
|
<string name="widget_flight_description">Bir sonraki uçuşun canlı: kalkışa geri sayım, yoldaki uçak, gecikme ve varış.</string>
|
||||||
<string name="widget_todos_name">Yapılacaklar</string>
|
<string name="widget_todos_name">Yapılacaklar</string>
|
||||||
<string name="widget_todos_description">Seyahat için hâlâ açık olanlar ve bavulun ne durumda olduğu.</string>
|
<string name="widget_todos_description">Seyahat için hâlâ açık olanlar ve bavulun ne durumda olduğu.</string>
|
||||||
<string name="widget_packing_name">Bavul</string>
|
<string name="widget_packing_name">Bavul</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">План дня у вигляді стрічки часу, з погодою і наступною зупинкою.</string>
|
<string name="widget_today_description">План дня у вигляді стрічки часу, з погодою і наступною зупинкою.</string>
|
||||||
<string name="widget_bookings_name">Бронювання</string>
|
<string name="widget_bookings_name">Бронювання</string>
|
||||||
<string name="widget_bookings_description">Найближчі рейси, поїзди, готелі й столики та коли вони.</string>
|
<string name="widget_bookings_description">Найближчі рейси, поїзди, готелі й столики та коли вони.</string>
|
||||||
|
<string name="widget_flight_name">Рейс</string>
|
||||||
|
<string name="widget_flight_description">Ваш наступний рейс наживо: відлік до вильоту, літак у дорозі, затримка й прибуття.</string>
|
||||||
<string name="widget_todos_name">Завдання</string>
|
<string name="widget_todos_name">Завдання</string>
|
||||||
<string name="widget_todos_description">Що ще лишилося зробити до подорожі і як просувається пакування.</string>
|
<string name="widget_todos_description">Що ще лишилося зробити до подорожі і як просувається пакування.</string>
|
||||||
<string name="widget_packing_name">Пакування</string>
|
<string name="widget_packing_name">Пакування</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Kế hoạch hôm nay dạng dòng thời gian, kèm thời tiết và điểm dừng tiếp theo.</string>
|
<string name="widget_today_description">Kế hoạch hôm nay dạng dòng thời gian, kèm thời tiết và điểm dừng tiếp theo.</string>
|
||||||
<string name="widget_bookings_name">Đặt chỗ</string>
|
<string name="widget_bookings_name">Đặt chỗ</string>
|
||||||
<string name="widget_bookings_description">Các chuyến bay, tàu, khách sạn và bàn sắp tới của bạn, cùng thời gian.</string>
|
<string name="widget_bookings_description">Các chuyến bay, tàu, khách sạn và bàn sắp tới của bạn, cùng thời gian.</string>
|
||||||
|
<string name="widget_flight_name">Chuyến bay</string>
|
||||||
|
<string name="widget_flight_description">Chuyến bay tiếp theo trực tiếp: đếm ngược giờ khởi hành, máy bay đang bay, độ trễ và giờ đến.</string>
|
||||||
<string name="widget_todos_name">Việc cần làm</string>
|
<string name="widget_todos_name">Việc cần làm</string>
|
||||||
<string name="widget_todos_description">Những gì còn lại cho chuyến đi và việc soạn hành lý đã tới đâu.</string>
|
<string name="widget_todos_description">Những gì còn lại cho chuyến đi và việc soạn hành lý đã tới đâu.</string>
|
||||||
<string name="widget_packing_name">Hành lý</string>
|
<string name="widget_packing_name">Hành lý</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Today\'s plan as a timeline, with the weather and what is next.</string>
|
<string name="widget_today_description">Today\'s plan as a timeline, with the weather and what is next.</string>
|
||||||
<string name="widget_bookings_name">Bookings</string>
|
<string name="widget_bookings_name">Bookings</string>
|
||||||
<string name="widget_bookings_description">Your next flights, trains, hotels and tables, and when they are due.</string>
|
<string name="widget_bookings_description">Your next flights, trains, hotels and tables, and when they are due.</string>
|
||||||
|
<string name="widget_flight_name">Flight</string>
|
||||||
|
<string name="widget_flight_description">Your next flight live: departure countdown, the aircraft on its way, delay and arrival.</string>
|
||||||
<string name="widget_todos_name">To-dos</string>
|
<string name="widget_todos_name">To-dos</string>
|
||||||
<string name="widget_todos_description">What is still open for the trip, and how far the packing has come.</string>
|
<string name="widget_todos_description">What is still open for the trip, and how far the packing has come.</string>
|
||||||
<string name="widget_packing_name">Packing</string>
|
<string name="widget_packing_name">Packing</string>
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- The flight widget (widget/TrekWidgets.kt). Sizes in cells for Android 12+, dp before.
|
||||||
|
No previewImage: Glance draws the picker preview from the sample trip (providePreview). -->
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:description="@string/widget_flight_description"
|
||||||
|
android:initialLayout="@layout/glance_default_loading_layout"
|
||||||
|
android:minWidth="110dp"
|
||||||
|
android:minHeight="110dp"
|
||||||
|
android:minResizeWidth="110dp"
|
||||||
|
android:minResizeHeight="110dp"
|
||||||
|
android:maxResizeWidth="530dp"
|
||||||
|
android:maxResizeHeight="450dp"
|
||||||
|
android:targetCellWidth="4"
|
||||||
|
android:targetCellHeight="2"
|
||||||
|
android:resizeMode="horizontal|vertical"
|
||||||
|
android:updatePeriodMillis="1800000"
|
||||||
|
android:widgetCategory="home_screen"
|
||||||
|
android:configure="com.liketrek.trek.widget.WidgetConfigActivity"
|
||||||
|
android:widgetFeatures="reconfigurable|configuration_optional" />
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package com.liketrek.trek
|
||||||
|
|
||||||
|
import com.liketrek.trek.clientcert.ClientCertWatch
|
||||||
|
import com.liketrek.trek.clientcert.TrekClientIdentity
|
||||||
|
import com.liketrek.trek.clientcert.TrekClientIdentity.Failure
|
||||||
|
import java.util.Date
|
||||||
|
import javax.security.auth.x500.X500Principal
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Assert.fail
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reading a client certificate file (TrekClientIdentity.read) and the rule for
|
||||||
|
* which server sees it. The files in test/resources/clientcert are test-only:
|
||||||
|
* a throwaway CA, password "trek-test". valid.p12 has OpenSSL 3's default
|
||||||
|
* encryption (AES-256, PBKDF2), valid-legacy.p12 the older RC2/3DES one that
|
||||||
|
* many routers and NAS systems still export.
|
||||||
|
*/
|
||||||
|
class ClientIdentityTest {
|
||||||
|
private val password = "trek-test".toCharArray()
|
||||||
|
private val inside = Date(1_800_000_000_000L) // 2027-01-15, inside every valid test certificate
|
||||||
|
|
||||||
|
private fun file(name: String): ByteArray =
|
||||||
|
requireNotNull(javaClass.classLoader?.getResourceAsStream("clientcert/$name")) { name }.use { it.readBytes() }
|
||||||
|
|
||||||
|
private fun failure(name: String, pass: CharArray = password, now: Date = inside): Failure {
|
||||||
|
try {
|
||||||
|
TrekClientIdentity.read(file(name), pass, now)
|
||||||
|
} catch (e: TrekClientIdentity.ImportException) {
|
||||||
|
return e.reason
|
||||||
|
}
|
||||||
|
fail("$name opened")
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun opensModernAndLegacyFiles() {
|
||||||
|
for (name in listOf("valid.p12", "valid-legacy.p12")) {
|
||||||
|
val identity = TrekClientIdentity.read(file(name), password, inside)
|
||||||
|
assertEquals("trek-test-valid", TrekClientIdentity.commonName(identity.chain[0].subjectX500Principal))
|
||||||
|
assertEquals("TREK mTLS Test CA", TrekClientIdentity.commonName(identity.chain[0].issuerX500Principal))
|
||||||
|
assertEquals("RSA", identity.key.algorithm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun namesWhatIsWrongWithAFile() {
|
||||||
|
assertEquals(Failure.PASSWORD, failure("valid.p12", "wrong".toCharArray()))
|
||||||
|
assertEquals(Failure.PASSWORD, failure("valid-legacy.p12", "wrong".toCharArray()))
|
||||||
|
assertEquals(Failure.EXPIRED, failure("expired.p12"))
|
||||||
|
assertEquals(Failure.NOT_YET_VALID, failure("future.p12"))
|
||||||
|
assertEquals(Failure.NO_KEY, failure("cert-only.p12"))
|
||||||
|
try {
|
||||||
|
TrekClientIdentity.read("not a certificate".toByteArray(), password, inside)
|
||||||
|
fail("text opened")
|
||||||
|
} catch (e: TrekClientIdentity.ImportException) {
|
||||||
|
assertEquals(Failure.FORMAT, e.reason)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun showsTheCertificateOnlyToItsHostAndPort() {
|
||||||
|
assertTrue(TrekClientIdentity.matches("trek.example.com", 443, "Trek.Example.com", -1))
|
||||||
|
assertTrue(TrekClientIdentity.matches("trek.example.com", 443, "trek.example.com", 443))
|
||||||
|
assertTrue(TrekClientIdentity.matches("nas.local", 8443, "nas.local", 8443))
|
||||||
|
assertFalse(TrekClientIdentity.matches("trek.example.com", 443, "auth.example.com", 443))
|
||||||
|
assertFalse(TrekClientIdentity.matches("trek.example.com", 443, "trek.example.com", 8443))
|
||||||
|
assertFalse(TrekClientIdentity.matches("nas.local", 8443, "nas.local", -1))
|
||||||
|
assertFalse(TrekClientIdentity.matches("trek.example.com", 443, null, 443))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun leavesForTheAddressScreenOnlyWhenTheCertificateIsWhatFails() {
|
||||||
|
assertTrue(ClientCertWatch.refused(true, 0)) // handshake broken off: nginx, Caddy, Traefik
|
||||||
|
assertTrue(ClientCertWatch.refused(true, 403)) // Cloudflare's block page
|
||||||
|
assertTrue(ClientCertWatch.refused(true, 400)) // nginx without a valid certificate
|
||||||
|
assertFalse(ClientCertWatch.refused(true, 200)) // asks, but lets everyone in
|
||||||
|
assertFalse(ClientCertWatch.refused(true, 502)) // TREK restarting behind the proxy
|
||||||
|
assertFalse(ClientCertWatch.refused(false, 0)) // simply offline
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun readsTheCommonNameOrFallsBackToTheWholeName() {
|
||||||
|
assertEquals("Phone, home", TrekClientIdentity.commonName(X500Principal("CN=Phone\\, home,O=Family")))
|
||||||
|
assertEquals("O=Family", TrekClientIdentity.commonName(X500Principal("O=Family")))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,11 +13,33 @@ import java.time.LocalDate
|
|||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertNull
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
/** The native side's own decisions, apart from the views. */
|
/** The native side's own decisions, apart from the views. */
|
||||||
class NativeLogicTest {
|
class NativeLogicTest {
|
||||||
|
@Test
|
||||||
|
fun aRedirectAwayWhileTheServerLoadsIsTakenAsItsSignIn() {
|
||||||
|
val server = "https://trek.example.com"
|
||||||
|
// Authelia in front of the page, its check let through on /api.
|
||||||
|
assertEquals("auth.example.com", SignInRedirect.learnedHost(server, "https://auth.example.com/?rd=https%3A%2F%2Ftrek.example.com%2F", true, true, false))
|
||||||
|
assertEquals("auth.example.com:9091", SignInRedirect.learnedHost(server, "https://Auth.example.com:9091/", true, true, false))
|
||||||
|
// A link the user follows, a frame, or anything after the server's page has shown: the browser, as before.
|
||||||
|
assertNull(SignInRedirect.learnedHost(server, "https://auth.example.com/", true, false, false))
|
||||||
|
assertNull(SignInRedirect.learnedHost(server, "https://auth.example.com/", false, true, false))
|
||||||
|
assertNull(SignInRedirect.learnedHost(server, "https://auth.example.com/", true, true, true))
|
||||||
|
// The server's own host, another scheme, or a step down to plain http.
|
||||||
|
assertNull(SignInRedirect.learnedHost(server, "https://trek.example.com/login", true, true, false))
|
||||||
|
assertNull(SignInRedirect.learnedHost(server, "intent://auth.example.com/", true, true, false))
|
||||||
|
assertNull(SignInRedirect.learnedHost(server, "http://auth.example.com/", true, true, false))
|
||||||
|
assertEquals("auth.lan", SignInRedirect.learnedHost("http://trek.lan:3000", "http://auth.lan/", true, true, false))
|
||||||
|
assertNull(SignInRedirect.learnedHost(null, "https://auth.example.com/", true, true, false))
|
||||||
|
assertTrue(SignInRedirect.onServer(server, "https://TREK.example.com/dashboard"))
|
||||||
|
assertFalse(SignInRedirect.onServer(server, "https://auth.example.com/"))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun pushesLandInTheChannelOfTheirEvent() {
|
fun pushesLandInTheChannelOfTheirEvent() {
|
||||||
assertEquals(TrekPushService.CHANNEL_CHAT, TrekPushService.channelFor("collab_message"))
|
assertEquals(TrekPushService.CHANNEL_CHAT, TrekPushService.channelFor("collab_message"))
|
||||||
@@ -49,6 +71,16 @@ class NativeLogicTest {
|
|||||||
assertEquals("page", ShareLoader.slug("!!!"))
|
assertEquals("page", ShareLoader.slug("!!!"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aLinkWhosePageCannotBeReadIsHandedOverAsTheLinkItself() {
|
||||||
|
val item = ShareLoader.linkOnly("https://www.instagram.com/p/abc", null)
|
||||||
|
assertEquals("text/uri-list", item.mimeType)
|
||||||
|
assertEquals("https://www.instagram.com/p/abc", item.url)
|
||||||
|
assertEquals("https://www.instagram.com/p/abc", String(item.data))
|
||||||
|
assertEquals("www.instagram.com", item.title)
|
||||||
|
assertEquals("Ramen place", ShareLoader.linkOnly("https://maps.app.goo.gl/x", "Ramen place").title)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun theShareSheetOffersComingTripsFirstThenRecentPastOnes() {
|
fun theShareSheetOffersComingTripsFirstThenRecentPastOnes() {
|
||||||
val today = LocalDate.of(2026, 11, 7)
|
val today = LocalDate.of(2026, 11, 7)
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package com.liketrek.trek
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Assert.assertArrayEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/** The stored copy of the server's UI (TrekOfflineShell), on a plain folder. */
|
||||||
|
class TrekOfflineShellTest {
|
||||||
|
private val root: File = Files.createTempDirectory("offline-shell").toFile()
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun cleanUp() {
|
||||||
|
TrekOfflineShell.deactivate()
|
||||||
|
root.deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theCopyAnswersOnlyForTheServerItWasStartedFor() {
|
||||||
|
TrekOfflineShell.activate("https://a.example.com")
|
||||||
|
assertTrue(TrekOfflineShell.isActive())
|
||||||
|
assertTrue(TrekOfflineShell.isActiveFor("https://a.example.com"))
|
||||||
|
// Another server picked in the same process: its pages come from the server.
|
||||||
|
assertFalse(TrekOfflineShell.isActiveFor("https://b.example.com"))
|
||||||
|
assertFalse(TrekOfflineShell.isActiveFor(null))
|
||||||
|
// A start that reaches the server leaves the copy behind.
|
||||||
|
TrekOfflineShell.deactivate()
|
||||||
|
assertFalse(TrekOfflineShell.isActive())
|
||||||
|
assertFalse(TrekOfflineShell.isActiveFor("https://a.example.com"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aRefreshCutOffHalfwayKeepsThePreviousBuildWhole() {
|
||||||
|
val server = "https://a.example.com"
|
||||||
|
val oldPage = "<script src=/assets/index-old.js>".toByteArray()
|
||||||
|
assertTrue(TrekOfflineShell.beginRefresh(root, server))
|
||||||
|
assertTrue(TrekOfflineShell.saveFile(root, "assets/index-old.js", byteArrayOf(1)))
|
||||||
|
assertTrue(TrekOfflineShell.savePage(root, server, oldPage))
|
||||||
|
assertTrue(TrekOfflineShell.hasCopy(root, server))
|
||||||
|
|
||||||
|
// The next build: one file arrives, then the connection drops before the page is taken over.
|
||||||
|
assertTrue(TrekOfflineShell.beginRefresh(root, server))
|
||||||
|
assertTrue(TrekOfflineShell.saveFile(root, "assets/index-new.js", byteArrayOf(2)))
|
||||||
|
|
||||||
|
assertTrue(TrekOfflineShell.hasCopy(root, server))
|
||||||
|
assertArrayEquals(oldPage, File(root, "index.html").readBytes())
|
||||||
|
assertTrue(TrekOfflineShell.hasFile(root, "assets/index-old.js"))
|
||||||
|
// The file already fetched stays for the next try.
|
||||||
|
assertTrue(TrekOfflineShell.hasFile(root, "assets/index-new.js"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aCompleteRefreshTakesTheNewPageAndDropsTheOldBuild() {
|
||||||
|
val server = "https://a.example.com"
|
||||||
|
TrekOfflineShell.beginRefresh(root, server)
|
||||||
|
TrekOfflineShell.saveFile(root, "assets/index-old.js", byteArrayOf(1))
|
||||||
|
TrekOfflineShell.savePage(root, server, "old".toByteArray())
|
||||||
|
|
||||||
|
TrekOfflineShell.beginRefresh(root, server)
|
||||||
|
TrekOfflineShell.saveFile(root, "assets/index-new.js", byteArrayOf(2))
|
||||||
|
assertTrue(TrekOfflineShell.savePage(root, server, "new".toByteArray()))
|
||||||
|
TrekOfflineShell.prune(root, setOf("assets/index-new.js"))
|
||||||
|
|
||||||
|
assertArrayEquals("new".toByteArray(), File(root, "index.html").readBytes())
|
||||||
|
assertTrue(TrekOfflineShell.hasFile(root, "assets/index-new.js"))
|
||||||
|
assertFalse(TrekOfflineShell.hasFile(root, "assets/index-old.js"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aRefreshForAnotherServerThrowsTheOldCopyAwayFirst() {
|
||||||
|
TrekOfflineShell.beginRefresh(root, "https://a.example.com")
|
||||||
|
TrekOfflineShell.saveFile(root, "assets/index-a.js", byteArrayOf(1))
|
||||||
|
TrekOfflineShell.savePage(root, "https://a.example.com", "a".toByteArray())
|
||||||
|
|
||||||
|
assertTrue(TrekOfflineShell.beginRefresh(root, "https://b.example.com"))
|
||||||
|
|
||||||
|
assertFalse(TrekOfflineShell.hasCopy(root, "https://a.example.com"))
|
||||||
|
assertFalse(TrekOfflineShell.hasCopy(root, "https://b.example.com"))
|
||||||
|
assertFalse(TrekOfflineShell.hasFile(root, "assets/index-a.js"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun pathsOutsideTheCopyAreRefused() {
|
||||||
|
assertFalse(TrekOfflineShell.saveFile(root, "../escape.js", byteArrayOf(1)))
|
||||||
|
assertFalse(TrekOfflineShell.saveFile(root, "assets/index.js?v=1", byteArrayOf(1)))
|
||||||
|
assertFalse(TrekOfflineShell.hasFile(root, ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,4 +99,34 @@ class WidgetSnapshotTest {
|
|||||||
assertEquals("ferry.fill", TrekIcons.booking("cruise").first)
|
assertEquals("ferry.fill", TrekIcons.booking("cruise").first)
|
||||||
assertEquals("bookmark.fill", TrekIcons.booking("something").first)
|
assertEquals("bookmark.fill", TrekIcons.booking("something").first)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun turnsToTheDayOfTheDateItIsReadOn() {
|
||||||
|
val json = """{"trip":{"title":"T","start":"2026-11-06","end":"2026-11-08","path":"/trips/1"},
|
||||||
|
"today":{"date":"2026-11-06","dayLabel":"Day 1 of 3","stops":[{"time":"09:00","name":"Museum","minutes":540}]},
|
||||||
|
"days":[
|
||||||
|
{"date":"2026-11-06","dayLabel":"Day 1 of 3","stops":[{"time":"09:00","name":"Museum","minutes":540}]},
|
||||||
|
{"date":"2026-11-07","dayLabel":"Day 2 of 3","stops":[{"time":"10:00","name":"Harbour","minutes":600}]}
|
||||||
|
],
|
||||||
|
"bookings":[
|
||||||
|
{"title":"Hotel","kind":"hotel","date":"2026-11-06","confirmed":true,"path":"/trips/1"},
|
||||||
|
{"title":"Train","kind":"train","date":"2026-11-07","confirmed":true,"path":"/trips/1"}
|
||||||
|
],
|
||||||
|
"labels":{}}"""
|
||||||
|
val snapshot = WidgetSnapshot.parse(json)!!
|
||||||
|
assertEquals("Day 1 of 3", snapshot.on(LocalDate.of(2026, 11, 6)).today!!.dayLabel)
|
||||||
|
val second = snapshot.on(LocalDate.of(2026, 11, 7))
|
||||||
|
assertEquals("Day 2 of 3", second.today!!.dayLabel)
|
||||||
|
assertEquals("Harbour", second.today!!.stops.single().name)
|
||||||
|
assertEquals(listOf("Train"), second.bookings.map { it.title })
|
||||||
|
// A day the app wrote nothing for (the trip is over) shows no day.
|
||||||
|
assertNull(snapshot.on(LocalDate.of(2026, 11, 9)).today)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aSnapshotWithoutDaysReadsAsWritten() {
|
||||||
|
val snapshot = WidgetSnapshot.parse(WidgetSamples.json(running = true, now = today))!!
|
||||||
|
assertTrue(snapshot.days.isEmpty())
|
||||||
|
assertEquals(snapshot, snapshot.on(today.plusDays(3)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,9 +2,15 @@
|
|||||||
include ':capacitor-android'
|
include ':capacitor-android'
|
||||||
project(':capacitor-android').projectDir = new File('../../node_modules/@capacitor/android/capacitor')
|
project(':capacitor-android').projectDir = new File('../../node_modules/@capacitor/android/capacitor')
|
||||||
|
|
||||||
|
include ':capacitor-action-sheet'
|
||||||
|
project(':capacitor-action-sheet').projectDir = new File('../../node_modules/@capacitor/action-sheet/android')
|
||||||
|
|
||||||
include ':capacitor-app'
|
include ':capacitor-app'
|
||||||
project(':capacitor-app').projectDir = new File('../../node_modules/@capacitor/app/android')
|
project(':capacitor-app').projectDir = new File('../../node_modules/@capacitor/app/android')
|
||||||
|
|
||||||
|
include ':capacitor-dialog'
|
||||||
|
project(':capacitor-dialog').projectDir = new File('../../node_modules/@capacitor/dialog/android')
|
||||||
|
|
||||||
include ':capacitor-filesystem'
|
include ':capacitor-filesystem'
|
||||||
project(':capacitor-filesystem').projectDir = new File('../../node_modules/@capacitor/filesystem/android')
|
project(':capacitor-filesystem').projectDir = new File('../../node_modules/@capacitor/filesystem/android')
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
only(p => section(p, 'Authentication Methods').getByText('Password Login', { exact: true }).locator('xpath=../..')),
|
only(p => section(p, 'Authentication Methods').getByText('Password Login', { exact: true }).locator('xpath=../..')),
|
||||||
// The SSO rows exist only once OIDC is configured; the run shows where that happens.
|
// The SSO rows exist only once OIDC is configured; the run shows where that happens.
|
||||||
only(p => section(p, 'Single Sign-On (OIDC)')),
|
only(p => section(p, 'Single Sign-On (OIDC)')),
|
||||||
only(p => section(p, 'Require two-factor authentication (2FA)')),
|
only(p => section(p, 'Require 2FA')),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'admin-passkeys': {
|
'admin-passkeys': {
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ SIGNED_TARGETS = {
|
|||||||
"NotificationService" => "com.liketrek.trek.notifications",
|
"NotificationService" => "com.liketrek.trek.notifications",
|
||||||
"TREKWidgets" => "com.liketrek.trek.widgets",
|
"TREKWidgets" => "com.liketrek.trek.widgets",
|
||||||
"ShareExtension" => "com.liketrek.trek.share",
|
"ShareExtension" => "com.liketrek.trek.share",
|
||||||
|
"TREKWatch" => "com.liketrek.trek.watchkitapp",
|
||||||
|
"TREKWatchWidgets" => "com.liketrek.trek.watchkitapp.widgets",
|
||||||
}
|
}
|
||||||
|
|
||||||
platform :ios do
|
platform :ios do
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// The chunk group that holds the lucide icons the app loads at startup (vite.config.js).
|
||||||
|
//
|
||||||
|
// Every lucide icon is a module of its own, and the plugin icon lookup
|
||||||
|
// (src/components/shared/PluginIcon.tsx) reaches all of them by name, from the navigation
|
||||||
|
// every page renders. Left to itself the bundler puts each icon that some other chunk
|
||||||
|
// also uses into a chunk of its own, so that neither side holds a copy: 187 files of a few
|
||||||
|
// hundred bytes each, every one a request of its own on a first visit and an entry of its
|
||||||
|
// own in the service worker's precache. In one group they are one file, whose hash changes
|
||||||
|
// only when lucide-react does.
|
||||||
|
//
|
||||||
|
// `tags: ['$initial']` for the reason the other groups carry it: without it the group would
|
||||||
|
// also take icons that today sit behind a lazy route and make them part of the first load.
|
||||||
|
export const ICON_CHUNK = {
|
||||||
|
name: 'vendor-icons',
|
||||||
|
priority: 20,
|
||||||
|
tags: ['$initial'],
|
||||||
|
test: /[\\/]node_modules[\\/]lucide-react[\\/]/,
|
||||||
|
};
|
||||||
@@ -10,11 +10,19 @@
|
|||||||
01FD437981FC32C2C2C5BDCE /* TREKWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 702D0DF4A7E323CEA94CA03F /* TREKWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
01FD437981FC32C2C2C5BDCE /* TREKWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 702D0DF4A7E323CEA94CA03F /* TREKWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
0520A7C30D8D3FACCBB784BE /* ShareItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2A15008B5664C48B639F94 /* ShareItem.swift */; };
|
0520A7C30D8D3FACCBB784BE /* ShareItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2A15008B5664C48B639F94 /* ShareItem.swift */; };
|
||||||
0C2D60A4950D7293E1F282CB /* TripDayAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 337775CD9091673D0ADDF325 /* TripDayAttributes.swift */; };
|
0C2D60A4950D7293E1F282CB /* TripDayAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 337775CD9091673D0ADDF325 /* TripDayAttributes.swift */; };
|
||||||
|
0D801738BB09A41A62E9B57F /* TrekStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CAD7E43FE81EA6E2DD2585 /* TrekStyle.swift */; };
|
||||||
|
1091DAAC693DAE3E1CBB7D69 /* WatchStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8850ACF43C79E9D879ACC44 /* WatchStore.swift */; };
|
||||||
|
11B5B80E66AB03C92B0EADBD /* TREKWatchApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CE3377B458EDD77B809F61 /* TREKWatchApp.swift */; };
|
||||||
157A7B737E3FFB610A218D47 /* AtlasContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D004544572B0E85DE29A7B8 /* AtlasContent.swift */; };
|
157A7B737E3FFB610A218D47 /* AtlasContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D004544572B0E85DE29A7B8 /* AtlasContent.swift */; };
|
||||||
1A0A6E71365C0A1178B85CB8 /* TrekStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CAD7E43FE81EA6E2DD2585 /* TrekStyle.swift */; };
|
1A0A6E71365C0A1178B85CB8 /* TrekStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CAD7E43FE81EA6E2DD2585 /* TrekStyle.swift */; };
|
||||||
|
1F8D58E1B4FD9BB84172527A /* WatchSample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10FB55D221F4BA18795F33B5 /* WatchSample.swift */; };
|
||||||
2162CD349AFFDF070C16A58A /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E901288FC198E4D33BE754F /* SwiftUI.framework */; };
|
2162CD349AFFDF070C16A58A /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E901288FC198E4D33BE754F /* SwiftUI.framework */; };
|
||||||
|
228EA0E0270314581194EC3A /* TREKWatchWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D88ABD8284E0A39E7586BE /* TREKWatchWidgets.swift */; };
|
||||||
|
239FC886F02275957A1D449A /* FacesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787A9D6B7D9EB7FED319C1B5 /* FacesView.swift */; };
|
||||||
2CFE220A73ACB585F3D4CB8F /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2EE43D236E661AA975612A4B /* UserNotifications.framework */; };
|
2CFE220A73ACB585F3D4CB8F /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2EE43D236E661AA975612A4B /* UserNotifications.framework */; };
|
||||||
2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; };
|
2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; };
|
||||||
|
2FB9B214E9DA5C7A25BE0EA1 /* TrekStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CAD7E43FE81EA6E2DD2585 /* TrekStyle.swift */; };
|
||||||
|
318BBC653A438E6D1D493F50 /* DemoMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B6357E3FBBA4D9CDD1C7A3 /* DemoMode.swift */; };
|
||||||
32797E66C09CF7579AC323FD /* TREKWidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C2E47D0B005674C2B4ADA56 /* TREKWidgetsBundle.swift */; };
|
32797E66C09CF7579AC323FD /* TREKWidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C2E47D0B005674C2B4ADA56 /* TREKWidgetsBundle.swift */; };
|
||||||
3FB1872A25267A8E88FCBE3C /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC64330AC19625949E8DC05A /* WidgetKit.framework */; };
|
3FB1872A25267A8E88FCBE3C /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC64330AC19625949E8DC05A /* WidgetKit.framework */; };
|
||||||
45B990B86488D5CC2B5222B5 /* WorldGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AC751335E0136865E08990 /* WorldGrid.swift */; };
|
45B990B86488D5CC2B5222B5 /* WorldGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AC751335E0136865E08990 /* WorldGrid.swift */; };
|
||||||
@@ -29,32 +37,60 @@
|
|||||||
512499AF65E091B2BBC9A7BB /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */; };
|
512499AF65E091B2BBC9A7BB /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */; };
|
||||||
5480CCC12F42E9605044AB6B /* ShareHandoff.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56050CCA8DE4BEB4680D9E0B /* ShareHandoff.swift */; };
|
5480CCC12F42E9605044AB6B /* ShareHandoff.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56050CCA8DE4BEB4680D9E0B /* ShareHandoff.swift */; };
|
||||||
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */; };
|
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */; };
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A01 /* FlightContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = F11E0C0A9B7D4E2A8C3F5A02 /* FlightContent.swift */; };
|
||||||
5BBE9EE02A47EC67C31F5E21 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0A4B2C6C93971E884561CFA /* Localizable.strings */; };
|
5BBE9EE02A47EC67C31F5E21 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0A4B2C6C93971E884561CFA /* Localizable.strings */; };
|
||||||
612BB9680DC27BB8BF553060 /* TrekFamily.swift in Sources */ = {isa = PBXBuildFile; fileRef = A030A06726542A2D7F61C54B /* TrekFamily.swift */; };
|
612BB9680DC27BB8BF553060 /* TrekFamily.swift in Sources */ = {isa = PBXBuildFile; fileRef = A030A06726542A2D7F61C54B /* TrekFamily.swift */; };
|
||||||
|
634F4E63DC7C2A0027F0D118 /* Details.swift in Sources */ = {isa = PBXBuildFile; fileRef = F406A4A31BD875A880A7CA14 /* Details.swift */; };
|
||||||
|
661AEED37F1F278677F4F306 /* WatchStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B991C938B24A275550C15977 /* WatchStyle.swift */; };
|
||||||
|
6680B5C572AA37E6E3DFC3A2 /* ComplicationViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F0323803613DBCB2ADEF2F /* ComplicationViews.swift */; };
|
||||||
|
6EB76B1C6AB4AC78FF021994 /* WatchStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8850ACF43C79E9D879ACC44 /* WatchStore.swift */; };
|
||||||
|
7060F9DB820849A45ECE0507 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3C3D5E2482AC7D20D2054623 /* Assets.xcassets */; };
|
||||||
7A1E00032C0000000000A003 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 7A1E00022C0000000000A002 /* PrivacyInfo.xcprivacy */; };
|
7A1E00032C0000000000A003 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 7A1E00022C0000000000A002 /* PrivacyInfo.xcprivacy */; };
|
||||||
7A1E00052C0000000000A005 /* TrekBridgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E00042C0000000000A004 /* TrekBridgeViewController.swift */; };
|
7A1E00052C0000000000A005 /* TrekBridgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E00042C0000000000A004 /* TrekBridgeViewController.swift */; };
|
||||||
7A1E00072C0000000000A007 /* TrekShellPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E00062C0000000000A006 /* TrekShellPlugin.swift */; };
|
7A1E00072C0000000000A007 /* TrekShellPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E00062C0000000000A006 /* TrekShellPlugin.swift */; };
|
||||||
7FB730DC35C234816EAE65AF /* WidgetSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D74B7888714BF264E0E6 /* WidgetSnapshot.swift */; };
|
7FB730DC35C234816EAE65AF /* WidgetSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D74B7888714BF264E0E6 /* WidgetSnapshot.swift */; };
|
||||||
|
81E4582AD7514CA1AF373E48 /* WatchSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842D54F96D80A1D1C4C21457 /* WatchSnapshot.swift */; };
|
||||||
84EB79E4B677229481809933 /* NotificationService.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = A03A384FE54FAD1ED68E12DC /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
84EB79E4B677229481809933 /* NotificationService.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = A03A384FE54FAD1ED68E12DC /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
|
8925D4B7322D6930F3C02959 /* TrekWatchLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125A1BB381BBF7E58B8902FD /* TrekWatchLink.swift */; };
|
||||||
|
A1C3E5F70913B5D7F9E1A301 /* TrekClientIdentity.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C3E5F70913B5D7F9E1A302 /* TrekClientIdentity.swift */; };
|
||||||
|
896952F864B35C647FF6910A /* WatchSample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10FB55D221F4BA18795F33B5 /* WatchSample.swift */; };
|
||||||
8FC5873BE6A8CB2AFB31A46A /* TripContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */; };
|
8FC5873BE6A8CB2AFB31A46A /* TripContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */; };
|
||||||
|
8FFB2B488E43AD339D0BB450 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3A6054202DCC03D83C2C9602 /* Localizable.strings */; };
|
||||||
|
91B14997828BEF884E1239B4 /* Pages.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB5322D218E340690F499CA2 /* Pages.swift */; };
|
||||||
9582B6832FE993A70072D4E8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9582B6822FE993A50072D4E8 /* SceneDelegate.swift */; };
|
9582B6832FE993A70072D4E8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9582B6822FE993A50072D4E8 /* SceneDelegate.swift */; };
|
||||||
96DBDCE4766AC9F13F100A06 /* SharePage.js in Resources */ = {isa = PBXBuildFile; fileRef = 9DC696E1A1FD3A1A1695F9EA /* SharePage.js */; };
|
96DBDCE4766AC9F13F100A06 /* SharePage.js in Resources */ = {isa = PBXBuildFile; fileRef = 9DC696E1A1FD3A1A1695F9EA /* SharePage.js */; };
|
||||||
9A175689CFCC630BE9BB9EE1 /* TodayContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24B175DE91E1E6E850DB0285 /* TodayContent.swift */; };
|
9A175689CFCC630BE9BB9EE1 /* TodayContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24B175DE91E1E6E850DB0285 /* TodayContent.swift */; };
|
||||||
A0E8821CA7CF51AF2D6D8422 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 248A72D1C511B4969D89333A /* Localizable.strings */; };
|
A0E8821CA7CF51AF2D6D8422 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 248A72D1C511B4969D89333A /* Localizable.strings */; };
|
||||||
A2B048E183B19BB17E264FDE /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED561D7B7219D23A99FAEB11 /* ShareViewController.swift */; };
|
A2B048E183B19BB17E264FDE /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED561D7B7219D23A99FAEB11 /* ShareViewController.swift */; };
|
||||||
A8FDD4DBE3F078BF935CC4B9 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFA8802204810ED580DE46F3 /* NotificationService.swift */; };
|
A8FDD4DBE3F078BF935CC4B9 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFA8802204810ED580DE46F3 /* NotificationService.swift */; };
|
||||||
|
AAE5F2A3903F1E241C395BB8 /* WatchModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42EBD981456D3493C3947441 /* WatchModel.swift */; };
|
||||||
|
AEE032DFFB63C7BEB8AFABBF /* TREKWatch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = CF4BA0BDDABFBDB24394025D /* TREKWatch.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
B4C0FC386F71D849E141C91E /* NextTripWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7064A9DA92FCC8ACAA4F22A /* NextTripWidget.swift */; };
|
B4C0FC386F71D849E141C91E /* NextTripWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7064A9DA92FCC8ACAA4F22A /* NextTripWidget.swift */; };
|
||||||
B65B7CFC62EEFF443491EA64 /* ActivityKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 192E69C7E66646BC39566925 /* ActivityKit.framework */; };
|
B65B7CFC62EEFF443491EA64 /* ActivityKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 192E69C7E66646BC39566925 /* ActivityKit.framework */; };
|
||||||
B8D1816D155C8D52DFCAE25B /* ShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6831E849332626BE8D54CEF /* ShareView.swift */; };
|
B8D1816D155C8D52DFCAE25B /* ShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6831E849332626BE8D54CEF /* ShareView.swift */; };
|
||||||
BE2DBB926DB04D6CEEFD8B43 /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 694631A1018DCE5678F29930 /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
BE2DBB926DB04D6CEEFD8B43 /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 694631A1018DCE5678F29930 /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
|
C109B48C5A072AF9BE685BE4 /* ComplicationViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F0323803613DBCB2ADEF2F /* ComplicationViews.swift */; };
|
||||||
|
C3959ACB55B495F7A86F89A9 /* WatchStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B991C938B24A275550C15977 /* WatchStyle.swift */; };
|
||||||
|
D0983EB4FB8015F96E232919 /* WatchSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842D54F96D80A1D1C4C21457 /* WatchSnapshot.swift */; };
|
||||||
D3C699E2258FBA6A11C1DDE4 /* TripIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8442B4B8988AF5D1BFA3ADE3 /* TripIntent.swift */; };
|
D3C699E2258FBA6A11C1DDE4 /* TripIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8442B4B8988AF5D1BFA3ADE3 /* TripIntent.swift */; };
|
||||||
|
DE14C398EAFA594CB32ABBF2 /* WidgetSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D74B7888714BF264E0E6 /* WidgetSnapshot.swift */; };
|
||||||
DF633789F2F667C4CF264C9E /* TripDayLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3259F6C40216CECEBAC6F307 /* TripDayLiveActivity.swift */; };
|
DF633789F2F667C4CF264C9E /* TripDayLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3259F6C40216CECEBAC6F307 /* TripDayLiveActivity.swift */; };
|
||||||
EA5EDDD4E5F9BC9BC46C563F /* CollabContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D5041DDDAFF5B491B053999 /* CollabContent.swift */; };
|
EA5EDDD4E5F9BC9BC46C563F /* CollabContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D5041DDDAFF5B491B053999 /* CollabContent.swift */; };
|
||||||
F1E29B18C5B1E75A5BC01B57 /* TodosContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */; };
|
F1E29B18C5B1E75A5BC01B57 /* TodosContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */; };
|
||||||
|
F30AA6CFFE04035E7D6AC546 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3A6054202DCC03D83C2C9602 /* Localizable.strings */; };
|
||||||
|
F9947489F5B9323E519D3903 /* WidgetSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D74B7888714BF264E0E6 /* WidgetSnapshot.swift */; };
|
||||||
FEB91385917AC44D5CDAA59C /* PackingContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C0771C8582246A26E0C98E /* PackingContent.swift */; };
|
FEB91385917AC44D5CDAA59C /* PackingContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C0771C8582246A26E0C98E /* PackingContent.swift */; };
|
||||||
|
FECB6034B17C07C879908CEF /* TREKWatchWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 0DA9D9714D1E594A44A3569F /* TREKWatchWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
201AA9320B6C5DCBCC3429BF /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 504EC2FC1FED79650016851F /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 59A840D13C3074A09FCCC7CB;
|
||||||
|
remoteInfo = TREKWatch;
|
||||||
|
};
|
||||||
3BB8A38B2B2C8614B24CF2AD /* PBXContainerItemProxy */ = {
|
3BB8A38B2B2C8614B24CF2AD /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
containerPortal = 504EC2FC1FED79650016851F /* Project object */;
|
containerPortal = 504EC2FC1FED79650016851F /* Project object */;
|
||||||
@@ -76,9 +112,38 @@
|
|||||||
remoteGlobalIDString = A3BE5653156025C97CA62C68;
|
remoteGlobalIDString = A3BE5653156025C97CA62C68;
|
||||||
remoteInfo = TREKWidgets;
|
remoteInfo = TREKWidgets;
|
||||||
};
|
};
|
||||||
|
EA68232794738AB11E866FA3 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 504EC2FC1FED79650016851F /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 5B5EA8FB8F58C6BFA3B77661;
|
||||||
|
remoteInfo = TREKWatchWidgets;
|
||||||
|
};
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
9545786868FF757328C69E1E /* Embed Foundation Extensions */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 13;
|
||||||
|
files = (
|
||||||
|
FECB6034B17C07C879908CEF /* TREKWatchWidgets.appex in Embed Foundation Extensions */,
|
||||||
|
);
|
||||||
|
name = "Embed Foundation Extensions";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
986D3C6100A1AB6BE603CF1C /* Embed Watch Content */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "$(CONTENTS_FOLDER_PATH)/Watch";
|
||||||
|
dstSubfolderSpec = 16;
|
||||||
|
files = (
|
||||||
|
AEE032DFFB63C7BEB8AFABBF /* TREKWatch.app in Embed Watch Content */,
|
||||||
|
);
|
||||||
|
name = "Embed Watch Content";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
A8F12B42B22FCA041C6AA0DA /* Embed Foundation Extensions */ = {
|
A8F12B42B22FCA041C6AA0DA /* Embed Foundation Extensions */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -95,14 +160,23 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
00B7BB68930D45D35C9AD54A /* az */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = az; path = az.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
037DA05706AE051CEFCA7D75 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
037DA05706AE051CEFCA7D75 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
04C0771C8582246A26E0C98E /* PackingContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PackingContent.swift; sourceTree = "<group>"; };
|
04C0771C8582246A26E0C98E /* PackingContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PackingContent.swift; sourceTree = "<group>"; };
|
||||||
|
07C00C53BA5641B009E40EF1 /* zh-Hans */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
|
07DF720DA5E63F842526A075 /* vi */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
090D74588DA8436DEC275567 /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
090D74588DA8436DEC275567 /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
095A4E5D36F6E22070842EC1 /* nl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
095A4E5D36F6E22070842EC1 /* nl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
0A7C4491A7ABDDBEBE00E5BF /* sk */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
0A7C4491A7ABDDBEBE00E5BF /* sk */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
0BA66BF6D1F4FB57EFF31981 /* ShareExtension.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = "<group>"; };
|
0BA66BF6D1F4FB57EFF31981 /* ShareExtension.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = "<group>"; };
|
||||||
|
0CC4BCF06E7719280549FFF1 /* el */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
0DA9D9714D1E594A44A3569F /* TREKWatchWidgets.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TREKWatchWidgets.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
10FB55D221F4BA18795F33B5 /* WatchSample.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WatchSample.swift; sourceTree = "<group>"; };
|
||||||
114C13FB91B554AE8DC4372B /* et */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = "<group>"; };
|
114C13FB91B554AE8DC4372B /* et */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
125A1BB381BBF7E58B8902FD /* TrekWatchLink.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TrekWatchLink.swift; sourceTree = "<group>"; };
|
||||||
|
A1C3E5F70913B5D7F9E1A302 /* TrekClientIdentity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TrekClientIdentity.swift; sourceTree = "<group>"; };
|
||||||
12DE24E0B7E2E5F3564D952B /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = "<group>"; };
|
12DE24E0B7E2E5F3564D952B /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
1335F1EEB49D744B27A00F31 /* th */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
15884CA899CAD3FFD98BA927 /* hu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
15884CA899CAD3FFD98BA927 /* hu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
15CAD7E43FE81EA6E2DD2585 /* TrekStyle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TrekStyle.swift; sourceTree = "<group>"; };
|
15CAD7E43FE81EA6E2DD2585 /* TrekStyle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TrekStyle.swift; sourceTree = "<group>"; };
|
||||||
192E69C7E66646BC39566925 /* ActivityKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ActivityKit.framework; path = System/Library/Frameworks/ActivityKit.framework; sourceTree = SDKROOT; };
|
192E69C7E66646BC39566925 /* ActivityKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ActivityKit.framework; path = System/Library/Frameworks/ActivityKit.framework; sourceTree = SDKROOT; };
|
||||||
@@ -111,19 +185,27 @@
|
|||||||
1E7522315D47F086145DC4B8 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
1E7522315D47F086145DC4B8 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
1ED347C91E03E51FDF8ABC1A /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
1ED347C91E03E51FDF8ABC1A /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
22A904A2E55946892F488B1A /* th */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
|
22A904A2E55946892F488B1A /* th */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
230D9B2E5898FCEC3EC4FB44 /* pl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
23AE662FD3762641A2047F72 /* ja */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
241C37D114DDD53C7E915CB8 /* id */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = id; path = id.lproj/Localizable.strings; sourceTree = "<group>"; };
|
241C37D114DDD53C7E915CB8 /* id */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = id; path = id.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
24B175DE91E1E6E850DB0285 /* TodayContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TodayContent.swift; sourceTree = "<group>"; };
|
24B175DE91E1E6E850DB0285 /* TodayContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TodayContent.swift; sourceTree = "<group>"; };
|
||||||
|
2D75538DBBAA6B2366CD8B69 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
2EE43D236E661AA975612A4B /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
|
2EE43D236E661AA975612A4B /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
|
||||||
2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = "<group>"; };
|
2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = "<group>"; };
|
||||||
|
2FD81D4601E9EB8744171B09 /* zh-Hant */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
3259F6C40216CECEBAC6F307 /* TripDayLiveActivity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripDayLiveActivity.swift; sourceTree = "<group>"; };
|
3259F6C40216CECEBAC6F307 /* TripDayLiveActivity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripDayLiveActivity.swift; sourceTree = "<group>"; };
|
||||||
32A62EE30F8AD514D7DB2CAA /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
32A62EE30F8AD514D7DB2CAA /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
337775CD9091673D0ADDF325 /* TripDayAttributes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripDayAttributes.swift; sourceTree = "<group>"; };
|
337775CD9091673D0ADDF325 /* TripDayAttributes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripDayAttributes.swift; sourceTree = "<group>"; };
|
||||||
|
37FA9D6C0C247EC699CF326C /* TREKWatchWidgets.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = TREKWatchWidgets.entitlements; sourceTree = "<group>"; };
|
||||||
38C632E7EE9C0DF1CA0BF0A0 /* cs */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
|
38C632E7EE9C0DF1CA0BF0A0 /* cs */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
3C3D5E2482AC7D20D2054623 /* Assets.xcassets */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
3CB565FC61AB5AEA87A3F615 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
|
3CB565FC61AB5AEA87A3F615 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
3DF4F4305878F949DD09193F /* NotificationService.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = NotificationService.entitlements; sourceTree = "<group>"; };
|
3DF4F4305878F949DD09193F /* NotificationService.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = NotificationService.entitlements; sourceTree = "<group>"; };
|
||||||
405B04DFF3A978D1046147C6 /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Localizable.strings; sourceTree = "<group>"; };
|
405B04DFF3A978D1046147C6 /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
408F0E543D49BFCCF6B19194 /* es */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
408F0E543D49BFCCF6B19194 /* es */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
4167040E2C29E44D55580916 /* ru */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
4167040E2C29E44D55580916 /* ru */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
42EBD981456D3493C3947441 /* WatchModel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WatchModel.swift; sourceTree = "<group>"; };
|
||||||
|
467929A8EB65D22F8FA91588 /* ca */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
4D004544572B0E85DE29A7B8 /* AtlasContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AtlasContent.swift; sourceTree = "<group>"; };
|
4D004544572B0E85DE29A7B8 /* AtlasContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AtlasContent.swift; sourceTree = "<group>"; };
|
||||||
50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
|
50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
|
||||||
504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@@ -134,6 +216,7 @@
|
|||||||
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
|
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
|
||||||
56050CCA8DE4BEB4680D9E0B /* ShareHandoff.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareHandoff.swift; sourceTree = "<group>"; };
|
56050CCA8DE4BEB4680D9E0B /* ShareHandoff.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareHandoff.swift; sourceTree = "<group>"; };
|
||||||
|
57DF93CD1B88A7135481BF03 /* de */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
5C0109EA628FA897B7BFDD3E /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
|
5C0109EA628FA897B7BFDD3E /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = th; path = th.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
608F00CBD96957EEA888E50A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
608F00CBD96957EEA888E50A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
60EB00F3670B41B898765DF9 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
60EB00F3670B41B898765DF9 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
@@ -143,24 +226,34 @@
|
|||||||
683725459244601B71D92E2D /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
683725459244601B71D92E2D /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
6932A417DC4BC05BF07D80E2 /* it */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
|
6932A417DC4BC05BF07D80E2 /* it */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
694631A1018DCE5678F29930 /* ShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
694631A1018DCE5678F29930 /* ShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
697E5726770333015DDD444D /* TREKWatch.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = TREKWatch.entitlements; sourceTree = "<group>"; };
|
||||||
6E901288FC198E4D33BE754F /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
|
6E901288FC198E4D33BE754F /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
|
||||||
702D0DF4A7E323CEA94CA03F /* TREKWidgets.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TREKWidgets.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
702D0DF4A7E323CEA94CA03F /* TREKWidgets.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = TREKWidgets.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
7328217E23761C22814FEC25 /* az */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = az; path = az.lproj/Localizable.strings; sourceTree = "<group>"; };
|
7328217E23761C22814FEC25 /* az */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = az; path = az.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
772816394C94096090C2F8FE /* ar */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
77A0112CA76E5C1787073AEB /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
77A0112CA76E5C1787073AEB /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
77C217524DA98A6A92F422F4 /* zh-Hant */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
77C217524DA98A6A92F422F4 /* zh-Hant */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
|
787A9D6B7D9EB7FED319C1B5 /* FacesView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = FacesView.swift; sourceTree = "<group>"; };
|
||||||
|
7887877A91D6C782111A8388 /* it */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
7A1E00012C0000000000A001 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };
|
7A1E00012C0000000000A001 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };
|
||||||
7A1E00022C0000000000A002 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
|
7A1E00022C0000000000A002 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
|
||||||
7A1E00042C0000000000A004 /* TrekBridgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrekBridgeViewController.swift; sourceTree = "<group>"; };
|
7A1E00042C0000000000A004 /* TrekBridgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrekBridgeViewController.swift; sourceTree = "<group>"; };
|
||||||
7A1E00062C0000000000A006 /* TrekShellPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrekShellPlugin.swift; sourceTree = "<group>"; };
|
7A1E00062C0000000000A006 /* TrekShellPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrekShellPlugin.swift; sourceTree = "<group>"; };
|
||||||
7D5041DDDAFF5B491B053999 /* CollabContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CollabContent.swift; sourceTree = "<group>"; };
|
7D5041DDDAFF5B491B053999 /* CollabContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CollabContent.swift; sourceTree = "<group>"; };
|
||||||
7D525040492AFBC121FD4CC6 /* ar */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
7D525040492AFBC121FD4CC6 /* ar */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
842D54F96D80A1D1C4C21457 /* WatchSnapshot.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WatchSnapshot.swift; sourceTree = "<group>"; };
|
||||||
8442B4B8988AF5D1BFA3ADE3 /* TripIntent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripIntent.swift; sourceTree = "<group>"; };
|
8442B4B8988AF5D1BFA3ADE3 /* TripIntent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripIntent.swift; sourceTree = "<group>"; };
|
||||||
|
849A85B6008760CCD7D9AE6A /* id */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = id; path = id.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
84CB5C3B6BD4E1DE1A8BD2B4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
84CB5C3B6BD4E1DE1A8BD2B4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
889DA33D98BC601268861D54 /* fr */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
8A0289CB321AE008D8815A19 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
|
8A0289CB321AE008D8815A19 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
8C2E47D0B005674C2B4ADA56 /* TREKWidgetsBundle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TREKWidgetsBundle.swift; sourceTree = "<group>"; };
|
8C2E47D0B005674C2B4ADA56 /* TREKWidgetsBundle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TREKWidgetsBundle.swift; sourceTree = "<group>"; };
|
||||||
|
8CBB0E5B9BE05CE82C8DA7F4 /* sv */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
8D361F7B14AE9F5ACE3BFE78 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = "<group>"; };
|
8D361F7B14AE9F5ACE3BFE78 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
91F0DD852C0D6D4578449977 /* en */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
9582B6822FE993A50072D4E8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
9582B6822FE993A50072D4E8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||||
958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; };
|
958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||||
|
96CE3377B458EDD77B809F61 /* TREKWatchApp.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TREKWatchApp.swift; sourceTree = "<group>"; };
|
||||||
9A3FAA9DBC67D12389EEF0CF /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
9A3FAA9DBC67D12389EEF0CF /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
9D673E1909A5B750376ECB41 /* en */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
9D673E1909A5B750376ECB41 /* en */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
9DC696E1A1FD3A1A1695F9EA /* SharePage.js */ = {isa = PBXFileReference; includeInIndex = 1; path = SharePage.js; sourceTree = "<group>"; };
|
9DC696E1A1FD3A1A1695F9EA /* SharePage.js */ = {isa = PBXFileReference; includeInIndex = 1; path = SharePage.js; sourceTree = "<group>"; };
|
||||||
@@ -172,35 +265,57 @@
|
|||||||
A479036A85683EFF2922D096 /* el */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
|
A479036A85683EFF2922D096 /* el */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
A5C182FC253CBEE8D5439536 /* ca */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Localizable.strings; sourceTree = "<group>"; };
|
A5C182FC253CBEE8D5439536 /* ca */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
AA02F5CBC22E08415CC1C9BE /* pl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
AA02F5CBC22E08415CC1C9BE /* pl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
AB5322D218E340690F499CA2 /* Pages.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Pages.swift; sourceTree = "<group>"; };
|
||||||
AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TodosContent.swift; sourceTree = "<group>"; };
|
AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TodosContent.swift; sourceTree = "<group>"; };
|
||||||
B0450E66BFCF00CC4097330A /* he */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = "<group>"; };
|
B0450E66BFCF00CC4097330A /* he */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
B680CBF1268D2EE1982B165C /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
|
B680CBF1268D2EE1982B165C /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
B7F33B7A5C27C126DF29DCA4 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
|
B7F33B7A5C27C126DF29DCA4 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
B8850ACF43C79E9D879ACC44 /* WatchStore.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WatchStore.swift; sourceTree = "<group>"; };
|
||||||
|
B991C938B24A275550C15977 /* WatchStyle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WatchStyle.swift; sourceTree = "<group>"; };
|
||||||
|
B9F0323803613DBCB2ADEF2F /* ComplicationViews.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ComplicationViews.swift; sourceTree = "<group>"; };
|
||||||
BB2A15008B5664C48B639F94 /* ShareItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareItem.swift; sourceTree = "<group>"; };
|
BB2A15008B5664C48B639F94 /* ShareItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareItem.swift; sourceTree = "<group>"; };
|
||||||
BBB2E19CD540AB30B44BECCA /* TREKWidgets.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = TREKWidgets.entitlements; sourceTree = "<group>"; };
|
BBB2E19CD540AB30B44BECCA /* TREKWidgets.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = TREKWidgets.entitlements; sourceTree = "<group>"; };
|
||||||
BC64330AC19625949E8DC05A /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
|
BC64330AC19625949E8DC05A /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
|
||||||
BE41D7212DCB0C78E00A8462 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
BE41D7212DCB0C78E00A8462 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
BF10C31D56A1C10C6BF62046 /* pt-BR */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
|
C24CDF14EBF4CF52CBF3DDD0 /* he */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
C333CDB6CAD048E3F9242222 /* ru */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
C6A6008115A85C9AAE181C5E /* sk */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
C7064A9DA92FCC8ACAA4F22A /* NextTripWidget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NextTripWidget.swift; sourceTree = "<group>"; };
|
C7064A9DA92FCC8ACAA4F22A /* NextTripWidget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NextTripWidget.swift; sourceTree = "<group>"; };
|
||||||
|
C73847E8A007B21B8AD1DCD4 /* tr */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
C996A3060A2D20A4B5C9C377 /* ko */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
|
C996A3060A2D20A4B5C9C377 /* ko */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
C9B6357E3FBBA4D9CDD1C7A3 /* DemoMode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = DemoMode.swift; sourceTree = "<group>"; };
|
||||||
CC077989456FB9DB5F4FF676 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
CC077989456FB9DB5F4FF676 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
CD6763B965A87DDB6FCC2D05 /* de */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
|
CD6763B965A87DDB6FCC2D05 /* de */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
CD83ADB6D661D6F7A64CDAB6 /* es */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
CE79157F1170A47CF7FC6FE0 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
CE79157F1170A47CF7FC6FE0 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
CF4BA0BDDABFBDB24394025D /* TREKWatch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TREKWatch.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D0AC751335E0136865E08990 /* WorldGrid.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WorldGrid.swift; sourceTree = "<group>"; };
|
D0AC751335E0136865E08990 /* WorldGrid.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WorldGrid.swift; sourceTree = "<group>"; };
|
||||||
D84D92C18CC022646692CB9B /* sv */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
|
D84D92C18CC022646692CB9B /* sv */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
D863C8994C9DAA79D236401C /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
DBF6D74B7888714BF264E0E6 /* WidgetSnapshot.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WidgetSnapshot.swift; sourceTree = "<group>"; };
|
DBF6D74B7888714BF264E0E6 /* WidgetSnapshot.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = WidgetSnapshot.swift; sourceTree = "<group>"; };
|
||||||
DC0C9AB4D77D77A7BC2BA85B /* ja */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
|
DC0C9AB4D77D77A7BC2BA85B /* ja */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
DD341749E47B7DF89BA9A46D /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
|
DD341749E47B7DF89BA9A46D /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
DE0046E6067251CB0D61EC7A /* et */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripContent.swift; sourceTree = "<group>"; };
|
DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TripContent.swift; sourceTree = "<group>"; };
|
||||||
DE8B592FE52EC6FFB589751E /* fr */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
DE8B592FE52EC6FFB589751E /* fr */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
E2CFBDBCC474A7A72E053A8E /* uk */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
E2CFBDBCC474A7A72E053A8E /* uk */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; };
|
E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; };
|
||||||
|
E47D5FF1A217D5F77B3C7548 /* uk */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
E4AA747C2B20D0CDA0A9538A /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
E5800E4ECECED54A47CDABAA /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
E5800E4ECECED54A47CDABAA /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
E6831E849332626BE8D54CEF /* ShareView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareView.swift; sourceTree = "<group>"; };
|
E6831E849332626BE8D54CEF /* ShareView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareView.swift; sourceTree = "<group>"; };
|
||||||
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BookingsContent.swift; sourceTree = "<group>"; };
|
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BookingsContent.swift; sourceTree = "<group>"; };
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A02 /* FlightContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = FlightContent.swift; sourceTree = "<group>"; };
|
||||||
EAFBDD97043B34E4B64FDA86 /* pt-BR */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
EAFBDD97043B34E4B64FDA86 /* pt-BR */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
|
EC8D1292C9FC6430C059960A /* nl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
ECC80E1314B31ED2D2347411 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
ECC80E1314B31ED2D2347411 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
ED561D7B7219D23A99FAEB11 /* ShareViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
|
ED561D7B7219D23A99FAEB11 /* ShareViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
|
||||||
EE30A6DF943052C6ADE92D63 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
|
EE30A6DF943052C6ADE92D63 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
F406A4A31BD875A880A7CA14 /* Details.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Details.swift; sourceTree = "<group>"; };
|
||||||
|
F410423B093EBD2DD11C0FFC /* ko */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
F4D88ABD8284E0A39E7586BE /* TREKWatchWidgets.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TREKWatchWidgets.swift; sourceTree = "<group>"; };
|
||||||
|
FB2D9CFF5AC22AEB8CA3D7BD /* cs */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
FFA8802204810ED580DE46F3 /* NotificationService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
|
FFA8802204810ED580DE46F3 /* NotificationService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@@ -223,6 +338,20 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
622430061CE31239E1D64FB8 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
69112BCF6652B92DFA2AE6BB /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
C9AA4ADC0D397C620A35B6A3 /* Frameworks */ = {
|
C9AA4ADC0D397C620A35B6A3 /* Frameworks */ = {
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -259,6 +388,9 @@
|
|||||||
74C1FC6022E562372A71EEC9 /* NotificationService */,
|
74C1FC6022E562372A71EEC9 /* NotificationService */,
|
||||||
FB9226BC82835538BCE3DC0A /* TREKWidgets */,
|
FB9226BC82835538BCE3DC0A /* TREKWidgets */,
|
||||||
DFD2010504102AC0E682D00F /* ShareExtension */,
|
DFD2010504102AC0E682D00F /* ShareExtension */,
|
||||||
|
A5731FDC6B43DF41413C28A6 /* TREKWatch */,
|
||||||
|
83BCA52D4B145E66DC1B0111 /* TREKWatchKit */,
|
||||||
|
F3ECD357918C4A98B023F65F /* TREKWatchWidgets */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -269,6 +401,8 @@
|
|||||||
A03A384FE54FAD1ED68E12DC /* NotificationService.appex */,
|
A03A384FE54FAD1ED68E12DC /* NotificationService.appex */,
|
||||||
702D0DF4A7E323CEA94CA03F /* TREKWidgets.appex */,
|
702D0DF4A7E323CEA94CA03F /* TREKWidgets.appex */,
|
||||||
694631A1018DCE5678F29930 /* ShareExtension.appex */,
|
694631A1018DCE5678F29930 /* ShareExtension.appex */,
|
||||||
|
CF4BA0BDDABFBDB24394025D /* TREKWatch.app */,
|
||||||
|
0DA9D9714D1E594A44A3569F /* TREKWatchWidgets.appex */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -289,6 +423,8 @@
|
|||||||
7A1E00022C0000000000A002 /* PrivacyInfo.xcprivacy */,
|
7A1E00022C0000000000A002 /* PrivacyInfo.xcprivacy */,
|
||||||
2FAD9762203C412B000D30F8 /* config.xml */,
|
2FAD9762203C412B000D30F8 /* config.xml */,
|
||||||
50B271D01FEDC1A000F3C39B /* public */,
|
50B271D01FEDC1A000F3C39B /* public */,
|
||||||
|
125A1BB381BBF7E58B8902FD /* TrekWatchLink.swift */,
|
||||||
|
A1C3E5F70913B5D7F9E1A302 /* TrekClientIdentity.swift */,
|
||||||
);
|
);
|
||||||
path = App;
|
path = App;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -302,6 +438,7 @@
|
|||||||
6E901288FC198E4D33BE754F /* SwiftUI.framework */,
|
6E901288FC198E4D33BE754F /* SwiftUI.framework */,
|
||||||
192E69C7E66646BC39566925 /* ActivityKit.framework */,
|
192E69C7E66646BC39566925 /* ActivityKit.framework */,
|
||||||
E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */,
|
E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */,
|
||||||
|
DC1BBE9AA7035B32D3653122 /* watchOS */,
|
||||||
);
|
);
|
||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -317,6 +454,44 @@
|
|||||||
path = NotificationService;
|
path = NotificationService;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
83BCA52D4B145E66DC1B0111 /* TREKWatchKit */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
B9F0323803613DBCB2ADEF2F /* ComplicationViews.swift */,
|
||||||
|
10FB55D221F4BA18795F33B5 /* WatchSample.swift */,
|
||||||
|
842D54F96D80A1D1C4C21457 /* WatchSnapshot.swift */,
|
||||||
|
B8850ACF43C79E9D879ACC44 /* WatchStore.swift */,
|
||||||
|
B991C938B24A275550C15977 /* WatchStyle.swift */,
|
||||||
|
);
|
||||||
|
name = TREKWatchKit;
|
||||||
|
path = TREKWatchKit;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
A5731FDC6B43DF41413C28A6 /* TREKWatch */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3C3D5E2482AC7D20D2054623 /* Assets.xcassets */,
|
||||||
|
C9B6357E3FBBA4D9CDD1C7A3 /* DemoMode.swift */,
|
||||||
|
F406A4A31BD875A880A7CA14 /* Details.swift */,
|
||||||
|
787A9D6B7D9EB7FED319C1B5 /* FacesView.swift */,
|
||||||
|
D863C8994C9DAA79D236401C /* Info.plist */,
|
||||||
|
AB5322D218E340690F499CA2 /* Pages.swift */,
|
||||||
|
697E5726770333015DDD444D /* TREKWatch.entitlements */,
|
||||||
|
96CE3377B458EDD77B809F61 /* TREKWatchApp.swift */,
|
||||||
|
42EBD981456D3493C3947441 /* WatchModel.swift */,
|
||||||
|
3A6054202DCC03D83C2C9602 /* Localizable.strings */,
|
||||||
|
);
|
||||||
|
name = TREKWatch;
|
||||||
|
path = TREKWatch;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
DC1BBE9AA7035B32D3653122 /* watchOS */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = watchOS;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
DFD2010504102AC0E682D00F /* ShareExtension */ = {
|
DFD2010504102AC0E682D00F /* ShareExtension */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -333,6 +508,17 @@
|
|||||||
path = ShareExtension;
|
path = ShareExtension;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
F3ECD357918C4A98B023F65F /* TREKWatchWidgets */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
2D75538DBBAA6B2366CD8B69 /* Info.plist */,
|
||||||
|
37FA9D6C0C247EC699CF326C /* TREKWatchWidgets.entitlements */,
|
||||||
|
F4D88ABD8284E0A39E7586BE /* TREKWatchWidgets.swift */,
|
||||||
|
);
|
||||||
|
name = TREKWatchWidgets;
|
||||||
|
path = TREKWatchWidgets;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
FB9226BC82835538BCE3DC0A /* TREKWidgets */ = {
|
FB9226BC82835538BCE3DC0A /* TREKWidgets */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -354,6 +540,7 @@
|
|||||||
DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */,
|
DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */,
|
||||||
24B175DE91E1E6E850DB0285 /* TodayContent.swift */,
|
24B175DE91E1E6E850DB0285 /* TodayContent.swift */,
|
||||||
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */,
|
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */,
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A02 /* FlightContent.swift */,
|
||||||
AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */,
|
AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */,
|
||||||
);
|
);
|
||||||
name = TREKWidgets;
|
name = TREKWidgets;
|
||||||
@@ -388,6 +575,7 @@
|
|||||||
504EC3011FED79650016851F /* Frameworks */,
|
504EC3011FED79650016851F /* Frameworks */,
|
||||||
504EC3021FED79650016851F /* Resources */,
|
504EC3021FED79650016851F /* Resources */,
|
||||||
A8F12B42B22FCA041C6AA0DA /* Embed Foundation Extensions */,
|
A8F12B42B22FCA041C6AA0DA /* Embed Foundation Extensions */,
|
||||||
|
986D3C6100A1AB6BE603CF1C /* Embed Watch Content */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
@@ -395,6 +583,7 @@
|
|||||||
E23A0A46599B8EE7A5B74F45 /* PBXTargetDependency */,
|
E23A0A46599B8EE7A5B74F45 /* PBXTargetDependency */,
|
||||||
4CD7F5AF02CB806E4189489A /* PBXTargetDependency */,
|
4CD7F5AF02CB806E4189489A /* PBXTargetDependency */,
|
||||||
855AE76937B942D62DFFD7E2 /* PBXTargetDependency */,
|
855AE76937B942D62DFFD7E2 /* PBXTargetDependency */,
|
||||||
|
DC6A321F5C3C7D5EF0973677 /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = App;
|
name = App;
|
||||||
packageProductDependencies = (
|
packageProductDependencies = (
|
||||||
@@ -404,6 +593,42 @@
|
|||||||
productReference = 504EC3041FED79650016851F /* App.app */;
|
productReference = 504EC3041FED79650016851F /* App.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
|
59A840D13C3074A09FCCC7CB /* TREKWatch */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = DF9244A5B1D6A7560CB92D4E /* Build configuration list for PBXNativeTarget "TREKWatch" */;
|
||||||
|
buildPhases = (
|
||||||
|
B3023E0FD7245E6465981AC5 /* Sources */,
|
||||||
|
622430061CE31239E1D64FB8 /* Frameworks */,
|
||||||
|
E46DCC12600D7B9D1381FBCE /* Resources */,
|
||||||
|
9545786868FF757328C69E1E /* Embed Foundation Extensions */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
5D0E9608BF309D8A27F5C4B6 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = TREKWatch;
|
||||||
|
productName = TREKWatch;
|
||||||
|
productReference = CF4BA0BDDABFBDB24394025D /* TREKWatch.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
5B5EA8FB8F58C6BFA3B77661 /* TREKWatchWidgets */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C24DF86369B92FC86F735AEE /* Build configuration list for PBXNativeTarget "TREKWatchWidgets" */;
|
||||||
|
buildPhases = (
|
||||||
|
068381E1E877C97A3390DE57 /* Sources */,
|
||||||
|
69112BCF6652B92DFA2AE6BB /* Frameworks */,
|
||||||
|
F36545081C7270E279639BF4 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = TREKWatchWidgets;
|
||||||
|
productName = TREKWatchWidgets;
|
||||||
|
productReference = 0DA9D9714D1E594A44A3569F /* TREKWatchWidgets.appex */;
|
||||||
|
productType = "com.apple.product-type.app-extension";
|
||||||
|
};
|
||||||
9480DFBC2C2A112973DA468A /* NotificationService */ = {
|
9480DFBC2C2A112973DA468A /* NotificationService */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 4E3E5FA93A15425251E22D48 /* Build configuration list for PBXNativeTarget "NotificationService" */;
|
buildConfigurationList = 4E3E5FA93A15425251E22D48 /* Build configuration list for PBXNativeTarget "NotificationService" */;
|
||||||
@@ -506,6 +731,8 @@
|
|||||||
9480DFBC2C2A112973DA468A /* NotificationService */,
|
9480DFBC2C2A112973DA468A /* NotificationService */,
|
||||||
A3BE5653156025C97CA62C68 /* TREKWidgets */,
|
A3BE5653156025C97CA62C68 /* TREKWidgets */,
|
||||||
01A63CD6CFBC1463CAA8FFF0 /* ShareExtension */,
|
01A63CD6CFBC1463CAA8FFF0 /* ShareExtension */,
|
||||||
|
59A840D13C3074A09FCCC7CB /* TREKWatch */,
|
||||||
|
5B5EA8FB8F58C6BFA3B77661 /* TREKWatchWidgets */,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
@@ -540,6 +767,15 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
E46DCC12600D7B9D1381FBCE /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
7060F9DB820849A45ECE0507 /* Assets.xcassets in Resources */,
|
||||||
|
8FFB2B488E43AD339D0BB450 /* Localizable.strings in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
EB430D4F409D7961AF5603C9 /* Resources */ = {
|
EB430D4F409D7961AF5603C9 /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -549,9 +785,32 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
F36545081C7270E279639BF4 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
F30AA6CFFE04035E7D6AC546 /* Localizable.strings in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
068381E1E877C97A3390DE57 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
228EA0E0270314581194EC3A /* TREKWatchWidgets.swift in Sources */,
|
||||||
|
C109B48C5A072AF9BE685BE4 /* ComplicationViews.swift in Sources */,
|
||||||
|
896952F864B35C647FF6910A /* WatchSample.swift in Sources */,
|
||||||
|
81E4582AD7514CA1AF373E48 /* WatchSnapshot.swift in Sources */,
|
||||||
|
6EB76B1C6AB4AC78FF021994 /* WatchStore.swift in Sources */,
|
||||||
|
661AEED37F1F278677F4F306 /* WatchStyle.swift in Sources */,
|
||||||
|
0D801738BB09A41A62E9B57F /* TrekStyle.swift in Sources */,
|
||||||
|
DE14C398EAFA594CB32ABBF2 /* WidgetSnapshot.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
1EA0B85A2E70AC56F83C09C9 /* Sources */ = {
|
1EA0B85A2E70AC56F83C09C9 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -569,6 +828,8 @@
|
|||||||
7A1E00052C0000000000A005 /* TrekBridgeViewController.swift in Sources */,
|
7A1E00052C0000000000A005 /* TrekBridgeViewController.swift in Sources */,
|
||||||
7A1E00072C0000000000A007 /* TrekShellPlugin.swift in Sources */,
|
7A1E00072C0000000000A007 /* TrekShellPlugin.swift in Sources */,
|
||||||
0C2D60A4950D7293E1F282CB /* TripDayAttributes.swift in Sources */,
|
0C2D60A4950D7293E1F282CB /* TripDayAttributes.swift in Sources */,
|
||||||
|
8925D4B7322D6930F3C02959 /* TrekWatchLink.swift in Sources */,
|
||||||
|
A1C3E5F70913B5D7F9E1A301 /* TrekClientIdentity.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -591,10 +852,31 @@
|
|||||||
8FC5873BE6A8CB2AFB31A46A /* TripContent.swift in Sources */,
|
8FC5873BE6A8CB2AFB31A46A /* TripContent.swift in Sources */,
|
||||||
9A175689CFCC630BE9BB9EE1 /* TodayContent.swift in Sources */,
|
9A175689CFCC630BE9BB9EE1 /* TodayContent.swift in Sources */,
|
||||||
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */,
|
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */,
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A01 /* FlightContent.swift in Sources */,
|
||||||
F1E29B18C5B1E75A5BC01B57 /* TodosContent.swift in Sources */,
|
F1E29B18C5B1E75A5BC01B57 /* TodosContent.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
B3023E0FD7245E6465981AC5 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
318BBC653A438E6D1D493F50 /* DemoMode.swift in Sources */,
|
||||||
|
634F4E63DC7C2A0027F0D118 /* Details.swift in Sources */,
|
||||||
|
239FC886F02275957A1D449A /* FacesView.swift in Sources */,
|
||||||
|
91B14997828BEF884E1239B4 /* Pages.swift in Sources */,
|
||||||
|
11B5B80E66AB03C92B0EADBD /* TREKWatchApp.swift in Sources */,
|
||||||
|
AAE5F2A3903F1E241C395BB8 /* WatchModel.swift in Sources */,
|
||||||
|
6680B5C572AA37E6E3DFC3A2 /* ComplicationViews.swift in Sources */,
|
||||||
|
1F8D58E1B4FD9BB84172527A /* WatchSample.swift in Sources */,
|
||||||
|
D0983EB4FB8015F96E232919 /* WatchSnapshot.swift in Sources */,
|
||||||
|
1091DAAC693DAE3E1CBB7D69 /* WatchStore.swift in Sources */,
|
||||||
|
C3959ACB55B495F7A86F89A9 /* WatchStyle.swift in Sources */,
|
||||||
|
2FB9B214E9DA5C7A25BE0EA1 /* TrekStyle.swift in Sources */,
|
||||||
|
F9947489F5B9323E519D3903 /* WidgetSnapshot.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
E0B13DA0CF9C1103058FE869 /* Sources */ = {
|
E0B13DA0CF9C1103058FE869 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -615,12 +897,24 @@
|
|||||||
target = A3BE5653156025C97CA62C68 /* TREKWidgets */;
|
target = A3BE5653156025C97CA62C68 /* TREKWidgets */;
|
||||||
targetProxy = B8BBE7F7A64678D780A7F3D1 /* PBXContainerItemProxy */;
|
targetProxy = B8BBE7F7A64678D780A7F3D1 /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
5D0E9608BF309D8A27F5C4B6 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
name = TREKWatchWidgets;
|
||||||
|
target = 5B5EA8FB8F58C6BFA3B77661 /* TREKWatchWidgets */;
|
||||||
|
targetProxy = EA68232794738AB11E866FA3 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
855AE76937B942D62DFFD7E2 /* PBXTargetDependency */ = {
|
855AE76937B942D62DFFD7E2 /* PBXTargetDependency */ = {
|
||||||
isa = PBXTargetDependency;
|
isa = PBXTargetDependency;
|
||||||
name = ShareExtension;
|
name = ShareExtension;
|
||||||
target = 01A63CD6CFBC1463CAA8FFF0 /* ShareExtension */;
|
target = 01A63CD6CFBC1463CAA8FFF0 /* ShareExtension */;
|
||||||
targetProxy = 64B91219C04CABCE204C7CCC /* PBXContainerItemProxy */;
|
targetProxy = 64B91219C04CABCE204C7CCC /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
DC6A321F5C3C7D5EF0973677 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
name = TREKWatch;
|
||||||
|
target = 59A840D13C3074A09FCCC7CB /* TREKWatch */;
|
||||||
|
targetProxy = 201AA9320B6C5DCBCC3429BF /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
E23A0A46599B8EE7A5B74F45 /* PBXTargetDependency */ = {
|
E23A0A46599B8EE7A5B74F45 /* PBXTargetDependency */ = {
|
||||||
isa = PBXTargetDependency;
|
isa = PBXTargetDependency;
|
||||||
name = NotificationService;
|
name = NotificationService;
|
||||||
@@ -665,6 +959,41 @@
|
|||||||
name = Localizable.strings;
|
name = Localizable.strings;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
3A6054202DCC03D83C2C9602 /* Localizable.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
772816394C94096090C2F8FE /* ar */,
|
||||||
|
00B7BB68930D45D35C9AD54A /* az */,
|
||||||
|
467929A8EB65D22F8FA91588 /* ca */,
|
||||||
|
FB2D9CFF5AC22AEB8CA3D7BD /* cs */,
|
||||||
|
57DF93CD1B88A7135481BF03 /* de */,
|
||||||
|
0CC4BCF06E7719280549FFF1 /* el */,
|
||||||
|
91F0DD852C0D6D4578449977 /* en */,
|
||||||
|
CD83ADB6D661D6F7A64CDAB6 /* es */,
|
||||||
|
DE0046E6067251CB0D61EC7A /* et */,
|
||||||
|
889DA33D98BC601268861D54 /* fr */,
|
||||||
|
C24CDF14EBF4CF52CBF3DDD0 /* he */,
|
||||||
|
E4AA747C2B20D0CDA0A9538A /* hu */,
|
||||||
|
849A85B6008760CCD7D9AE6A /* id */,
|
||||||
|
7887877A91D6C782111A8388 /* it */,
|
||||||
|
23AE662FD3762641A2047F72 /* ja */,
|
||||||
|
F410423B093EBD2DD11C0FFC /* ko */,
|
||||||
|
EC8D1292C9FC6430C059960A /* nl */,
|
||||||
|
230D9B2E5898FCEC3EC4FB44 /* pl */,
|
||||||
|
BF10C31D56A1C10C6BF62046 /* pt-BR */,
|
||||||
|
C333CDB6CAD048E3F9242222 /* ru */,
|
||||||
|
C6A6008115A85C9AAE181C5E /* sk */,
|
||||||
|
8CBB0E5B9BE05CE82C8DA7F4 /* sv */,
|
||||||
|
1335F1EEB49D744B27A00F31 /* th */,
|
||||||
|
C73847E8A007B21B8AD1DCD4 /* tr */,
|
||||||
|
E47D5FF1A217D5F77B3C7548 /* uk */,
|
||||||
|
07DF720DA5E63F842526A075 /* vi */,
|
||||||
|
07C00C53BA5641B009E40EF1 /* zh-Hans */,
|
||||||
|
2FD81D4601E9EB8744171B09 /* zh-Hant */,
|
||||||
|
);
|
||||||
|
name = Localizable.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
504EC30B1FED79650016851F /* Main.storyboard */ = {
|
504EC30B1FED79650016851F /* Main.storyboard */ = {
|
||||||
isa = PBXVariantGroup;
|
isa = PBXVariantGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -719,6 +1048,33 @@
|
|||||||
/* End PBXVariantGroup section */
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
|
1F7D993B412B63E918648BA1 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = TREKWatch/TREKWatch.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
|
INFOPLIST_FILE = TREKWatch/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.liketrek.trek.watchkitapp;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SDKROOT = watchos;
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
WATCHOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
31CC9E868E52D06AD12E83D6 /* Debug */ = {
|
31CC9E868E52D06AD12E83D6 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
@@ -950,6 +1306,32 @@
|
|||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
57D289EF9468E358528F5FBB /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = TREKWatch/TREKWatch.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
|
INFOPLIST_FILE = TREKWatch/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.liketrek.trek.watchkitapp;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SDKROOT = watchos;
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
|
WATCHOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
686FA31AEC6FE5BA3EF95E99 /* Debug */ = {
|
686FA31AEC6FE5BA3EF95E99 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
@@ -1001,6 +1383,30 @@
|
|||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
C04A1F63D9298FA52E6C727E /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_ENTITLEMENTS = TREKWatchWidgets/TREKWatchWidgets.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
|
INFOPLIST_FILE = TREKWatchWidgets/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
"@executable_path/../../Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.liketrek.trek.watchkitapp.widgets;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SDKROOT = watchos;
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
|
WATCHOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
C5621F5D75100AAEBB1BD22A /* Release */ = {
|
C5621F5D75100AAEBB1BD22A /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
@@ -1027,6 +1433,31 @@
|
|||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
DF4816365A7D101A9EA8A0C7 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_ENTITLEMENTS = TREKWatchWidgets/TREKWatchWidgets.entitlements;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = NO;
|
||||||
|
INFOPLIST_FILE = TREKWatchWidgets/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
"@executable_path/../../Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.liketrek.trek.watchkitapp.widgets;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SDKROOT = watchos;
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
WATCHOS_DEPLOYMENT_TARGET = 11.0;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
@@ -1075,6 +1506,24 @@
|
|||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
|
C24DF86369B92FC86F735AEE /* Build configuration list for PBXNativeTarget "TREKWatchWidgets" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
DF4816365A7D101A9EA8A0C7 /* Release */,
|
||||||
|
C04A1F63D9298FA52E6C727E /* Debug */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
DF9244A5B1D6A7560CB92D4E /* Build configuration list for PBXNativeTarget "TREKWatch" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
1F7D993B412B63E918648BA1 /* Release */,
|
||||||
|
57D289EF9468E358528F5FBB /* Debug */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
/* Begin XCLocalSwiftPackageReference section */
|
/* Begin XCLocalSwiftPackageReference section */
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
// Taps on a TREK notification, and banners while the app is open.
|
// Taps on a TREK notification, and banners while the app is open.
|
||||||
UNUserNotificationCenter.current().delegate = self
|
UNUserNotificationCenter.current().delegate = self
|
||||||
|
// Early, so ticks the watch sent while the app was closed arrive with this launch.
|
||||||
|
TrekWatchLink.shared.activate()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +25,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
TrekPush.shared.didFail(error)
|
TrekPush.shared.didFail(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A silent push from the TREK server: a list of a trip changed, so the Apple
|
||||||
|
/// Watch is brought up to date (TrekWatchRefresher). Nothing else arrives this way.
|
||||||
|
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
|
||||||
|
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||||
|
guard userInfo["trek"] as? String == "watch-sync" else { return completionHandler(.noData) }
|
||||||
|
TrekWatchRefresher.refresh(completion: completionHandler)
|
||||||
|
}
|
||||||
|
|
||||||
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification,
|
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification,
|
||||||
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||||
completionHandler([.banner, .list, .sound])
|
completionHandler([.banner, .list, .sound])
|
||||||
@@ -58,6 +68,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Hardware keyboard
|
||||||
|
|
||||||
|
/// The UI's shortcuts for the screen on show (TrekKeyCommands), in the app's
|
||||||
|
/// menu: the overlay a held Command key brings up lists them there.
|
||||||
|
override func buildMenu(with builder: UIMenuBuilder) {
|
||||||
|
super.buildMenu(with: builder)
|
||||||
|
guard builder.system == .main, !TrekKeyCommands.current.isEmpty else { return }
|
||||||
|
let parent: UIMenu.Identifier = builder.menu(for: .application) != nil ? .application : .root
|
||||||
|
builder.insertChild(TrekKeyCommands.menu(), atStartOfMenu: parent)
|
||||||
|
}
|
||||||
|
|
||||||
func application(_ application: UIApplication,
|
func application(_ application: UIApplication,
|
||||||
configurationForConnecting connectingSceneSession: UISceneSession,
|
configurationForConnecting connectingSceneSession: UISceneSession,
|
||||||
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>$(PRODUCT_NAME)</string>
|
<string>TREK</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
@@ -120,6 +120,10 @@
|
|||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
<key>UIBackgroundModes</key>
|
||||||
|
<array>
|
||||||
|
<string>remote-notification</string>
|
||||||
|
</array>
|
||||||
<key>UIApplicationSceneManifest</key>
|
<key>UIApplicationSceneManifest</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>UIApplicationSupportsMultipleScenes</key>
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
@@ -160,6 +164,8 @@
|
|||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
|
<true/>
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
|
|
||||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||||
guard let windowScene = scene as? UIWindowScene else { return }
|
guard let windowScene = scene as? UIWindowScene else { return }
|
||||||
|
// Launched by a quick action on the app icon: held until the UI asks for it.
|
||||||
|
if let item = connectionOptions.shortcutItem { _ = TrekQuickActions.open(item) }
|
||||||
|
|
||||||
window = UIWindow(windowScene: windowScene)
|
window = UIWindow(windowScene: windowScene)
|
||||||
window?.rootViewController = TrekBridgeViewController()
|
window?.rootViewController = TrekBridgeViewController()
|
||||||
@@ -15,6 +17,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
for context in connectionOptions.urlContexts where context.url.isFileURL {
|
for context in connectionOptions.urlContexts where context.url.isFileURL {
|
||||||
TrekSharedFiles.receive(context.url)
|
TrekSharedFiles.receive(context.url)
|
||||||
}
|
}
|
||||||
|
// Launched by a tap on a widget or a Live Activity: held like a quick action.
|
||||||
|
// Capacitor still hears of the link, the UI ignores it there (feature appLinks).
|
||||||
|
for context in connectionOptions.urlContexts {
|
||||||
|
if let path = TrekQuickActions.appLinkPath(context.url) { TrekQuickActions.open(path: path) }
|
||||||
|
}
|
||||||
SceneDelegateProxy.shared.scene(scene, willConnectTo: session, options: connectionOptions)
|
SceneDelegateProxy.shared.scene(scene, willConnectTo: session, options: connectionOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,13 +45,101 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
// com.liketrek.trek://share: the share sheet left an item for the import.
|
// com.liketrek.trek://share: the share sheet left an item for the import.
|
||||||
let handoffs = URLContexts.filter { $0.url.scheme == "com.liketrek.trek" && $0.url.host == "share" }
|
let handoffs = URLContexts.filter { $0.url.scheme == "com.liketrek.trek" && $0.url.host == "share" }
|
||||||
if !handoffs.isEmpty { TrekSharedFiles.receiveFromShareExtension() }
|
if !handoffs.isEmpty { TrekSharedFiles.receiveFromShareExtension() }
|
||||||
let others = URLContexts.subtracting(files).subtracting(handoffs)
|
// com.liketrek.trek://navigate/<path>: a widget or Live Activity tap. Through
|
||||||
|
// Capacitor it was an event a page reloading after the system ended its process
|
||||||
|
// never heard, and that page then took the same link for one already followed.
|
||||||
|
let appLinks = URLContexts.filter { TrekQuickActions.appLinkPath($0.url) != nil }
|
||||||
|
for context in appLinks {
|
||||||
|
if let path = TrekQuickActions.appLinkPath(context.url) { TrekQuickActions.open(path: path) }
|
||||||
|
}
|
||||||
|
let others = URLContexts.subtracting(files).subtracting(handoffs).subtracting(appLinks)
|
||||||
if !others.isEmpty { SceneDelegateProxy.shared.scene(scene, openURLContexts: others) }
|
if !others.isEmpty { SceneDelegateProxy.shared.scene(scene, openURLContexts: others) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
||||||
SceneDelegateProxy.shared.scene(scene, continue: userActivity)
|
SceneDelegateProxy.shared.scene(scene, continue: userActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A quick action on the app icon while the app was running in the background.
|
||||||
|
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem,
|
||||||
|
completionHandler: @escaping (Bool) -> Void) {
|
||||||
|
completionHandler(TrekQuickActions.open(shortcutItem))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The quick actions on the app icon (a long press on it): "New trip" and the
|
||||||
|
/// trip coming up, set by the UI in its language (TrekShell.setQuickActions).
|
||||||
|
/// Each carries the path it opens; a tap goes to the UI as that path, at once
|
||||||
|
/// when it listens, or held for it to take when the tap launched the app.
|
||||||
|
enum TrekQuickActions {
|
||||||
|
private static let pathKey = "path"
|
||||||
|
private static var pending: String?
|
||||||
|
static var onOpen: ((String) -> Void)?
|
||||||
|
|
||||||
|
struct Item {
|
||||||
|
let type: String
|
||||||
|
let title: String
|
||||||
|
let subtitle: String?
|
||||||
|
let icon: String
|
||||||
|
let path: String
|
||||||
|
|
||||||
|
init?(raw: JSObject) {
|
||||||
|
guard let type = raw["type"] as? String, let title = raw["title"] as? String,
|
||||||
|
let path = raw["path"] as? String, path.hasPrefix("/") else { return nil }
|
||||||
|
self.type = type
|
||||||
|
self.title = title
|
||||||
|
self.subtitle = raw["subtitle"] as? String
|
||||||
|
self.icon = raw["icon"] as? String ?? ""
|
||||||
|
self.path = path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func set(_ items: [Item]) {
|
||||||
|
UIApplication.shared.shortcutItems = items.prefix(4).map { item in
|
||||||
|
UIApplicationShortcutItem(
|
||||||
|
type: "com.liketrek.trek.\(item.type)",
|
||||||
|
localizedTitle: item.title,
|
||||||
|
localizedSubtitle: item.subtitle,
|
||||||
|
icon: icon(item.icon),
|
||||||
|
userInfo: [pathKey: item.path as NSString]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func icon(_ name: String) -> UIApplicationShortcutIcon {
|
||||||
|
switch name {
|
||||||
|
case "add": return UIApplicationShortcutIcon(type: .add)
|
||||||
|
case "trip": return UIApplicationShortcutIcon(systemImageName: "suitcase")
|
||||||
|
default: return UIApplicationShortcutIcon(type: .compose)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func open(_ item: UIApplicationShortcutItem) -> Bool {
|
||||||
|
guard let path = item.userInfo?[pathKey] as? String, path.hasPrefix("/") else { return false }
|
||||||
|
open(path: path)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A path to open: at once when the UI listens, else held for it to take.
|
||||||
|
/// Widget and Live Activity taps come this way too, so each is followed once.
|
||||||
|
static func open(path: String) {
|
||||||
|
if let onOpen { onOpen(path) } else { pending = path }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The path in com.liketrek.trek://navigate/<path>, the link widgets and Live Activities open.
|
||||||
|
static func appLinkPath(_ url: URL) -> String? {
|
||||||
|
let prefix = "com.liketrek.trek://navigate"
|
||||||
|
guard url.absoluteString.hasPrefix(prefix) else { return nil }
|
||||||
|
let path = String(url.absoluteString.dropFirst(prefix.count))
|
||||||
|
if path.isEmpty { return "/" }
|
||||||
|
return path.hasPrefix("/") ? path : nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The action the app was launched with, once.
|
||||||
|
static func take() -> String? {
|
||||||
|
defer { pending = nil }
|
||||||
|
return pending
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The blur over the app while it sits in the app switcher, when the app lock
|
/// The blur over the app while it sits in the app switcher, when the app lock
|
||||||
@@ -110,6 +205,11 @@ enum TrekSharedFiles {
|
|||||||
"data": data.base64EncodedString(),
|
"data": data.base64EncodedString(),
|
||||||
]
|
]
|
||||||
if let tripId = info["tripId"] as? Int { file["tripId"] = tripId }
|
if let tripId = info["tripId"] as? Int { file["tripId"] = tripId }
|
||||||
|
// A page or a link: where it came from, so the UI can keep it among the trip's links.
|
||||||
|
if let url = info["url"] as? String, url.hasPrefix("https://") || url.hasPrefix("http://") {
|
||||||
|
file["url"] = url
|
||||||
|
if let title = info["title"] as? String { file["title"] = title }
|
||||||
|
}
|
||||||
pending = file
|
pending = file
|
||||||
onReceive?(file)
|
onReceive?(file)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import WebKit
|
|||||||
class TrekBridgeViewController: CAPBridgeViewController {
|
class TrekBridgeViewController: CAPBridgeViewController {
|
||||||
override func instanceDescriptor() -> InstanceDescriptor {
|
override func instanceDescriptor() -> InstanceDescriptor {
|
||||||
let descriptor = super.instanceDescriptor()
|
let descriptor = super.instanceDescriptor()
|
||||||
|
TrekServerStore.recheckAfterUpdate()
|
||||||
if let server = TrekServerStore.url {
|
if let server = TrekServerStore.url {
|
||||||
// The trailing slash matters: Capacitor treats every URL that starts
|
// The trailing slash matters: Capacitor treats every URL that starts
|
||||||
// with this string as the app's own, and without it that would take
|
// with this string as the app's own, and without it that would take
|
||||||
@@ -40,15 +41,399 @@ class TrekBridgeViewController: CAPBridgeViewController {
|
|||||||
// reachable" with a server that was there all along.
|
// reachable" with a server that was there all along.
|
||||||
if let webView, let inner = webView.navigationDelegate {
|
if let webView, let inner = webView.navigationDelegate {
|
||||||
let proxy = TrekNavigationProxy(inner: inner)
|
let proxy = TrekNavigationProxy(inner: inner)
|
||||||
|
proxy.onErrorPage = { [weak self] error in self?.errorPageChanged(error) }
|
||||||
|
proxy.onPageShown = { [weak self] in self?.publishSafeArea(force: true) }
|
||||||
navigationProxy = proxy
|
navigationProxy = proxy
|
||||||
webView.navigationDelegate = proxy
|
webView.navigationDelegate = proxy
|
||||||
}
|
}
|
||||||
|
guardBridgeMessages()
|
||||||
|
watchSignInPages()
|
||||||
bridge?.registerPluginInstance(TrekShellPlugin())
|
bridge?.registerPluginInstance(TrekShellPlugin())
|
||||||
// WebKit's own swipe back slides away a screenshot of the whole page,
|
// WebKit's own swipe back slides away a screenshot of the whole page,
|
||||||
// closes no sheet and takes every drag near the edge from the UI. The UI
|
// closes no sheet and takes every drag near the edge from the UI. The UI
|
||||||
// draws its own (mobile/components/MEdgeBack.tsx, feature "edgeBack"):
|
// draws its own (mobile/components/MEdgeBack.tsx, feature "edgeBack"):
|
||||||
// the page follows the finger and an open sheet closes first.
|
// the page follows the finger and an open sheet closes first.
|
||||||
webView?.allowsBackForwardNavigationGestures = false
|
webView?.allowsBackForwardNavigationGestures = false
|
||||||
|
// A long press on a link would lift a preview of the page it points to,
|
||||||
|
// which no native list does; the press means "drag" or nothing here.
|
||||||
|
webView?.allowsLinkPreview = false
|
||||||
|
paintBehindWebView()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - What shows where the web view does not reach
|
||||||
|
|
||||||
|
/// The UI reports its theme through StatusBar.setStyle (native/nativeApp.ts),
|
||||||
|
/// which lands here; the colour behind the web view follows it.
|
||||||
|
override func setNeedsStatusBarAppearanceUpdate() {
|
||||||
|
super.setNeedsStatusBarAppearanceUpdate()
|
||||||
|
paintBehindWebView()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Some iOS releases (27.0.x) lay the web view out below the status bar
|
||||||
|
/// instead of under it, and the strip above the page then showed this
|
||||||
|
/// view's black. It now carries the top colour of the screen background
|
||||||
|
/// (mobile.css --m-scr), so the strip reads as part of the page on every
|
||||||
|
/// release, and the rubber band at the ends shows the same colour.
|
||||||
|
private func paintBehindWebView() {
|
||||||
|
let dark: Bool
|
||||||
|
switch preferredStatusBarStyle {
|
||||||
|
case .lightContent: dark = true
|
||||||
|
case .darkContent: dark = false
|
||||||
|
default: dark = traitCollection.userInterfaceStyle == .dark
|
||||||
|
}
|
||||||
|
let color = dark
|
||||||
|
? UIColor(red: 0x17 / 255, green: 0x17 / 255, blue: 0x1C / 255, alpha: 1)
|
||||||
|
: UIColor(red: 0xFB / 255, green: 0xFA / 255, blue: 0xF7 / 255, alpha: 1)
|
||||||
|
view.backgroundColor = color
|
||||||
|
webView?.scrollView.backgroundColor = color
|
||||||
|
webView?.underPageBackgroundColor = color
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - The safe area the page keeps clear of
|
||||||
|
|
||||||
|
override func viewDidLayoutSubviews() {
|
||||||
|
super.viewDidLayoutSubviews()
|
||||||
|
publishSafeArea()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewSafeAreaInsetsDidChange() {
|
||||||
|
super.viewSafeAreaInsetsDidChange()
|
||||||
|
publishSafeArea()
|
||||||
|
}
|
||||||
|
|
||||||
|
private var publishedSafeArea: UIEdgeInsets?
|
||||||
|
|
||||||
|
/// WebKit's env(safe-area-inset-*) is the window's safe area only where the
|
||||||
|
/// web view overlaps it. Where a release lays the web view out below the
|
||||||
|
/// status bar it reports 0, yet a camera in a corner can still reach into
|
||||||
|
/// the page. The part of the window's safe area (and of the status bar) that
|
||||||
|
/// falls inside the web view goes to the page as --trek-native-safe-*, which
|
||||||
|
/// mobile.css takes as a floor under env(), never in its place.
|
||||||
|
func publishSafeArea(force: Bool = false) {
|
||||||
|
guard let webView, let window = view.window else { return }
|
||||||
|
let frame = webView.convert(webView.bounds, to: window)
|
||||||
|
let safe = window.safeAreaInsets
|
||||||
|
let statusBar = window.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
|
||||||
|
let insets = UIEdgeInsets(
|
||||||
|
top: max(0, max(safe.top, statusBar) - frame.minY),
|
||||||
|
left: max(0, safe.left - frame.minX),
|
||||||
|
bottom: max(0, safe.bottom - (window.bounds.maxY - frame.maxY)),
|
||||||
|
right: max(0, safe.right - (window.bounds.maxX - frame.maxX))
|
||||||
|
)
|
||||||
|
let corner = cornerElement(in: frame, window: window)
|
||||||
|
if !force, insets == publishedSafeArea, corner == publishedCorner { return }
|
||||||
|
publishedSafeArea = insets
|
||||||
|
publishedCorner = corner
|
||||||
|
let px = { (v: CGFloat) in "'\(Int(v.rounded(.up)))px'" }
|
||||||
|
let js = "(function(s){"
|
||||||
|
+ "s.setProperty('--trek-native-safe-top',\(px(insets.top)));"
|
||||||
|
+ "s.setProperty('--trek-native-safe-left',\(px(insets.left)));"
|
||||||
|
+ "s.setProperty('--trek-native-safe-right',\(px(insets.right)));"
|
||||||
|
+ "s.setProperty('--trek-native-safe-bottom',\(px(insets.bottom)));"
|
||||||
|
+ "s.setProperty('--trek-native-corner-bottom',\(px(corner.top)));"
|
||||||
|
+ "s.setProperty('--trek-native-corner-left',\(px(corner.left)));"
|
||||||
|
+ "s.setProperty('--trek-native-corner-right',\(px(corner.right)));"
|
||||||
|
+ "})(document.documentElement.style)"
|
||||||
|
webView.evaluateJavaScript(js, completionHandler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var publishedCorner: UIEdgeInsets?
|
||||||
|
|
||||||
|
/// An element in a top corner of the screen, such as the status capsule of
|
||||||
|
/// an iPhone Duo: how far down it reaches (top) and how wide it is on its
|
||||||
|
/// side (left/right), in the web view's coordinates; zero where there is
|
||||||
|
/// none. iOS 26 tells a corner apart from a whole edge: the safe area with
|
||||||
|
/// the corner avoided vertically reaches lower than the one avoiding it
|
||||||
|
/// horizontally, which in turn is wider on the corner's side. The page puts
|
||||||
|
/// its top bar beside the element and starts its content below it, using
|
||||||
|
/// the full width (mobile.css), instead of giving up a strip of the whole
|
||||||
|
/// height.
|
||||||
|
private func cornerElement(in frame: CGRect, window: UIWindow) -> UIEdgeInsets {
|
||||||
|
guard #available(iOS 26.0, *) else { return .zero }
|
||||||
|
let vertical = view.edgeInsets(for: .safeArea(cornerAdaptation: .vertical))
|
||||||
|
let horizontal = view.edgeInsets(for: .safeArea(cornerAdaptation: .horizontal))
|
||||||
|
guard vertical.top > horizontal.top + 1 else { return .zero }
|
||||||
|
return UIEdgeInsets(
|
||||||
|
top: max(0, vertical.top - frame.minY),
|
||||||
|
left: max(0, horizontal.left - vertical.left - frame.minX),
|
||||||
|
bottom: 0,
|
||||||
|
right: max(0, horizontal.right - vertical.right - (window.bounds.maxX - frame.maxX))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - A proxy's sign-in page
|
||||||
|
|
||||||
|
/// Over a proxy's sign-in page (Pangolin, authentik, ...) the server's UI is
|
||||||
|
/// not there, so nothing else leads back to the address screen, and a passkey
|
||||||
|
/// cannot work in a web view for a domain the app is not tied to. A bar says
|
||||||
|
/// so and offers to change the server; the keyboard gets room on that page,
|
||||||
|
/// which TREK's own script makes everywhere else (native/keepFieldInView.ts).
|
||||||
|
private var signInBar: UIView?
|
||||||
|
private var urlObservation: NSKeyValueObservation?
|
||||||
|
private var insetObservation: NSKeyValueObservation?
|
||||||
|
private var onSignInPage = false
|
||||||
|
/// Whether the main frame shows an error page in place of the server's (a 4xx
|
||||||
|
/// nobody else handled: a proxy's block page, a client certificate it refused).
|
||||||
|
private var onErrorPage = false
|
||||||
|
private var signInHint: UILabel?
|
||||||
|
private var keyboardUp = false
|
||||||
|
/// How far the keyboard reaches into the view while it is up.
|
||||||
|
private var keyboardRoom: CGFloat = 0
|
||||||
|
/// Whether the bottom inset is this controller's, so leaving the page puts it back.
|
||||||
|
private var ownsInset = false
|
||||||
|
private var bodyReset: DispatchWorkItem?
|
||||||
|
|
||||||
|
private func watchSignInPages() {
|
||||||
|
urlObservation = webView?.observe(\.url, options: [.initial, .new]) { [weak self] webView, _ in
|
||||||
|
let signIn = TrekServerStore.isSignInHost(webView.url)
|
||||||
|
DispatchQueue.main.async { self?.signInPageChanged(signIn) }
|
||||||
|
}
|
||||||
|
// The keyboard plugin zeroes the scroll inset on every frame change it
|
||||||
|
// makes, the last one a while after the keyboard is up. On a sign-in
|
||||||
|
// page the inset wanted here is put back each time.
|
||||||
|
insetObservation = webView?.scrollView.observe(\.contentInset, options: [.new]) { [weak self] _, _ in
|
||||||
|
DispatchQueue.main.async { self?.applyInset() }
|
||||||
|
}
|
||||||
|
let center = NotificationCenter.default
|
||||||
|
center.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||||
|
center.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func signInPageChanged(_ signIn: Bool) {
|
||||||
|
onSignInPage = signIn
|
||||||
|
if signIn && signInBar == nil { signInBar = makeSignInBar() }
|
||||||
|
updateSignInBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func errorPageChanged(_ error: Bool) {
|
||||||
|
onErrorPage = error
|
||||||
|
if error && signInBar == nil { signInBar = makeSignInBar() }
|
||||||
|
updateSignInBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Out of the way while the keyboard is up: the form needs the room.
|
||||||
|
private func updateSignInBar() {
|
||||||
|
let labels = TrekServerStore.labels
|
||||||
|
signInHint?.text = onSignInPage
|
||||||
|
? labels["signInHint"]
|
||||||
|
?? "Passkeys and security keys do not work on this page in the app. Sign in with a password, or let the app through your proxy."
|
||||||
|
: labels["errorPageHint"] ?? "This page is not from TREK: the server or a proxy in front of it refused the app. Check your proxy or certificate, or change the server."
|
||||||
|
signInBar?.isHidden = !((onSignInPage || onErrorPage) && !keyboardUp)
|
||||||
|
applyInset()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// On a sign-in page the page can scroll past what covers its end: the
|
||||||
|
/// keyboard while it is up, the bar otherwise. TREK's own pages are left alone.
|
||||||
|
private func applyInset() {
|
||||||
|
guard let scrollView = webView?.scrollView else { return }
|
||||||
|
let wanted: CGFloat
|
||||||
|
if onSignInPage || onErrorPage {
|
||||||
|
if keyboardUp {
|
||||||
|
wanted = keyboardRoom
|
||||||
|
} else if let bar = signInBar {
|
||||||
|
view.layoutIfNeeded()
|
||||||
|
wanted = max(0, view.bounds.height - bar.frame.minY)
|
||||||
|
} else {
|
||||||
|
wanted = 0
|
||||||
|
}
|
||||||
|
ownsInset = true
|
||||||
|
} else if ownsInset {
|
||||||
|
wanted = 0
|
||||||
|
ownsInset = false
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if scrollView.contentInset.bottom != wanted { scrollView.contentInset.bottom = wanted }
|
||||||
|
if scrollView.verticalScrollIndicatorInsets.bottom != wanted { scrollView.verticalScrollIndicatorInsets.bottom = wanted }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The keyboard plugin also sizes the body to the area above the keyboard,
|
||||||
|
/// after the keyboard's animation and a further 0.2 s. On a sign-in page the
|
||||||
|
/// body gets its height back once that has run, so the button under the
|
||||||
|
/// keyboard can be scrolled into view through the inset above.
|
||||||
|
@objc private func keyboardWillShow(_ note: Notification) {
|
||||||
|
keyboardUp = true
|
||||||
|
if let frame = note.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect {
|
||||||
|
keyboardRoom = max(0, view.bounds.height - view.convert(frame, from: nil).minY)
|
||||||
|
}
|
||||||
|
bodyReset?.cancel()
|
||||||
|
if onSignInPage {
|
||||||
|
let duration = note.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0.25
|
||||||
|
let reset = DispatchWorkItem { [weak self] in
|
||||||
|
guard let self, self.onSignInPage, self.keyboardUp, let webView = self.webView else { return }
|
||||||
|
webView.evaluateJavaScript("document.body.style.height = ''", completionHandler: nil)
|
||||||
|
self.applyInset()
|
||||||
|
}
|
||||||
|
bodyReset = reset
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + duration + 0.35, execute: reset)
|
||||||
|
}
|
||||||
|
updateSignInBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func keyboardWillHide() {
|
||||||
|
keyboardUp = false
|
||||||
|
bodyReset?.cancel()
|
||||||
|
updateSignInBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func makeSignInBar() -> UIView {
|
||||||
|
let labels = TrekServerStore.labels
|
||||||
|
// The look of the app's own first screens: a white card with a sand edge,
|
||||||
|
// warm grey text and a dark button, over whatever page the proxy shows.
|
||||||
|
let bar = UIView()
|
||||||
|
bar.backgroundColor = UIColor(white: 1, alpha: 0.97)
|
||||||
|
bar.layer.cornerRadius = 18
|
||||||
|
bar.layer.cornerCurve = .continuous
|
||||||
|
bar.layer.borderWidth = 1
|
||||||
|
bar.layer.borderColor = UIColor(red: 0xEF / 255, green: 0xE4 / 255, blue: 0xD8 / 255, alpha: 1).cgColor
|
||||||
|
bar.layer.shadowColor = UIColor(red: 0x1F / 255, green: 0x1A / 255, blue: 0x17 / 255, alpha: 1).cgColor
|
||||||
|
bar.layer.shadowOpacity = 0.18
|
||||||
|
bar.layer.shadowRadius = 18
|
||||||
|
bar.layer.shadowOffset = CGSize(width: 0, height: 10)
|
||||||
|
bar.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
let hint = UILabel()
|
||||||
|
hint.text = labels["signInHint"]
|
||||||
|
?? "Passkeys and security keys do not work on this page in the app. Sign in with a password, or let the app through your proxy."
|
||||||
|
hint.textColor = UIColor(red: 0x6B / 255, green: 0x5F / 255, blue: 0x57 / 255, alpha: 1)
|
||||||
|
hint.font = .preferredFont(forTextStyle: .footnote)
|
||||||
|
hint.adjustsFontForContentSizeCategory = true
|
||||||
|
hint.numberOfLines = 0
|
||||||
|
signInHint = hint
|
||||||
|
hint.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
var look = UIButton.Configuration.filled()
|
||||||
|
look.baseBackgroundColor = UIColor(red: 0x11 / 255, green: 0x18 / 255, blue: 0x27 / 255, alpha: 1)
|
||||||
|
look.baseForegroundColor = .white
|
||||||
|
look.cornerStyle = .fixed
|
||||||
|
look.background.cornerRadius = 12
|
||||||
|
look.contentInsets = NSDirectionalEdgeInsets(top: 9, leading: 14, bottom: 9, trailing: 14)
|
||||||
|
let change = UIButton(configuration: look)
|
||||||
|
change.setTitle(labels["changeServer"] ?? "Change server", for: .normal)
|
||||||
|
change.titleLabel?.font = .systemFont(ofSize: 15, weight: .semibold)
|
||||||
|
change.addTarget(self, action: #selector(changeServerFromSignIn), for: .touchUpInside)
|
||||||
|
change.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
change.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
|
change.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
|
|
||||||
|
bar.addSubview(hint)
|
||||||
|
bar.addSubview(change)
|
||||||
|
view.addSubview(bar)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
bar.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 12),
|
||||||
|
bar.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -12),
|
||||||
|
bar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -8),
|
||||||
|
hint.leadingAnchor.constraint(equalTo: bar.leadingAnchor, constant: 14),
|
||||||
|
hint.topAnchor.constraint(equalTo: bar.topAnchor, constant: 10),
|
||||||
|
hint.bottomAnchor.constraint(equalTo: bar.bottomAnchor, constant: -10),
|
||||||
|
change.leadingAnchor.constraint(equalTo: hint.trailingAnchor, constant: 8),
|
||||||
|
change.trailingAnchor.constraint(equalTo: bar.trailingAnchor, constant: -12),
|
||||||
|
change.centerYAnchor.constraint(equalTo: bar.centerYAnchor),
|
||||||
|
])
|
||||||
|
return bar
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What resetServer does from the UI: forget the server, back to the address screen.
|
||||||
|
@objc private func changeServerFromSignIn() {
|
||||||
|
TrekServerStore.url = nil
|
||||||
|
view.window?.rootViewController = TrekBridgeViewController()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Kept alive here: the content controller holds it, but only for as long as it is registered.
|
||||||
|
private var messageGuard: TrekBridgeMessageGuard?
|
||||||
|
|
||||||
|
/// Capacitor answers bridge messages from any page in the web view. With a
|
||||||
|
/// proxy's sign-in page loading there, its messages are dropped before they
|
||||||
|
/// reach the plugins. Always in place: a sign-in host can also be learned
|
||||||
|
/// while the app runs (TrekSignInRedirect).
|
||||||
|
private func guardBridgeMessages() {
|
||||||
|
guard let handler = (bridge as? CapacitorBridge)?.webViewDelegationHandler,
|
||||||
|
let controller = webView?.configuration.userContentController else { return }
|
||||||
|
let guarded = TrekBridgeMessageGuard(inner: handler)
|
||||||
|
controller.removeScriptMessageHandler(forName: TrekBridgeMessageGuard.name)
|
||||||
|
controller.add(guarded, name: TrekBridgeMessageGuard.name)
|
||||||
|
messageGuard = guarded
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A key command of the UI's (TrekKeyCommands) was pressed. The commands sit
|
||||||
|
/// in the main menu, which sends their action up the responder chain from
|
||||||
|
/// the web view, and this controller is the first stop that answers it.
|
||||||
|
@objc func trekKeyCommand(_ sender: UIKeyCommand) {
|
||||||
|
guard let id = sender.propertyList as? String else { return }
|
||||||
|
TrekKeyCommands.onPress?(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Hardware keyboard (TrekShell.setKeyCommands)
|
||||||
|
|
||||||
|
/// The UI's keyboard shortcuts as key commands in the app's main menu. There
|
||||||
|
/// they show in the overlay a held Command key brings up and, on iPadOS 26, in
|
||||||
|
/// the menu bar, under the names the UI gives them in its language. Each screen
|
||||||
|
/// replaces the list (mobile/keyboard/MKeyboardHost.tsx), and the menu is
|
||||||
|
/// rebuilt with it, so only what works here and now is ever offered.
|
||||||
|
enum TrekKeyCommands {
|
||||||
|
struct Command {
|
||||||
|
let id: String
|
||||||
|
let title: String
|
||||||
|
let input: String
|
||||||
|
let modifiers: UIKeyModifierFlags
|
||||||
|
|
||||||
|
init?(raw: JSObject) {
|
||||||
|
guard let id = raw["id"] as? String, let title = raw["title"] as? String,
|
||||||
|
let input = raw["input"] as? String, !input.isEmpty else { return nil }
|
||||||
|
var flags: UIKeyModifierFlags = []
|
||||||
|
for name in raw["modifiers"] as? [String] ?? [] {
|
||||||
|
switch name {
|
||||||
|
case "command": flags.insert(.command)
|
||||||
|
case "shift": flags.insert(.shift)
|
||||||
|
case "option": flags.insert(.alternate)
|
||||||
|
case "control": flags.insert(.control)
|
||||||
|
default: break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.id = id
|
||||||
|
self.title = title
|
||||||
|
self.input = Command.key(input)
|
||||||
|
self.modifiers = flags
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func key(_ name: String) -> String {
|
||||||
|
switch name {
|
||||||
|
case "left": return UIKeyCommand.inputLeftArrow
|
||||||
|
case "right": return UIKeyCommand.inputRightArrow
|
||||||
|
case "up": return UIKeyCommand.inputUpArrow
|
||||||
|
case "down": return UIKeyCommand.inputDownArrow
|
||||||
|
case "escape": return UIKeyCommand.inputEscape
|
||||||
|
default: return name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static let menuIdentifier = UIMenu.Identifier("com.liketrek.trek.shortcuts")
|
||||||
|
private(set) static var current: [Command] = []
|
||||||
|
static var onPress: ((String) -> Void)?
|
||||||
|
|
||||||
|
static func set(_ commands: [Command]) {
|
||||||
|
current = commands
|
||||||
|
UIMenuSystem.main.setNeedsRebuild()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The commands as one menu, without a title of its own: it joins the app's
|
||||||
|
/// menu, where iPadOS lists the shortcuts under the app's name.
|
||||||
|
static func menu() -> UIMenu {
|
||||||
|
let children = current.map { command -> UIKeyCommand in
|
||||||
|
let key = UIKeyCommand(
|
||||||
|
title: command.title,
|
||||||
|
action: #selector(TrekBridgeViewController.trekKeyCommand(_:)),
|
||||||
|
input: command.input,
|
||||||
|
modifierFlags: command.modifiers,
|
||||||
|
propertyList: command.id
|
||||||
|
)
|
||||||
|
// ⌘[ and ⌘, belong to the app here, not to the web view's editing.
|
||||||
|
key.wantsPriorityOverSystemBehavior = true
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
return UIMenu(title: "", identifier: menuIdentifier, options: .displayInline, children: children)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +441,136 @@ class TrekBridgeViewController: CAPBridgeViewController {
|
|||||||
enum TrekServerStore {
|
enum TrekServerStore {
|
||||||
private static let key = "TrekServerURL"
|
private static let key = "TrekServerURL"
|
||||||
|
|
||||||
|
private static let failureKey = "TrekLastFailure"
|
||||||
|
|
||||||
|
/// Why the server's page did not load ("NSURLErrorDomain -1003"): the
|
||||||
|
/// address screen shows it small under its message, so a report carries
|
||||||
|
/// the cause. Taken once.
|
||||||
|
static func noteFailure(_ error: Error) {
|
||||||
|
let ns = error as NSError
|
||||||
|
UserDefaults.standard.set("\(ns.domain) \(ns.code)", forKey: failureKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func takeFailure() -> String? {
|
||||||
|
let failure = UserDefaults.standard.string(forKey: failureKey)
|
||||||
|
UserDefaults.standard.removeObject(forKey: failureKey)
|
||||||
|
return failure
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let previousKey = "TrekPreviousServerURL"
|
||||||
|
|
||||||
|
private static let checkedKey = "TrekServerCheck"
|
||||||
|
|
||||||
|
private static let labelsKey = "TrekShellLabels"
|
||||||
|
|
||||||
|
/// The words of the bar over a proxy's sign-in page, in the user's language,
|
||||||
|
/// as the address screen passed them (setServer's `labels`): the server's UI
|
||||||
|
/// is not there to say them. Empty keeps the English fallback.
|
||||||
|
static var labels: [String: String] {
|
||||||
|
get { UserDefaults.standard.dictionary(forKey: labelsKey) as? [String: String] ?? [:] }
|
||||||
|
set { UserDefaults.standard.set(newValue, forKey: labelsKey) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The server API this build needs (MIN_NATIVE_API in serverAddress.ts).
|
||||||
|
/// A server remembered under a lower value is checked once more: the first
|
||||||
|
/// launch after an update that raised it puts the address screen back up,
|
||||||
|
/// filled in with that server (previousURL). Raise both together.
|
||||||
|
private static let serverCheck = 3
|
||||||
|
|
||||||
|
/// Runs before the first bridge is built, so a server picked under an older
|
||||||
|
/// minimum is not loaded unchecked.
|
||||||
|
static func recheckAfterUpdate() {
|
||||||
|
let defaults = UserDefaults.standard
|
||||||
|
guard defaults.integer(forKey: checkedKey) < serverCheck else { return }
|
||||||
|
defaults.set(serverCheck, forKey: checkedKey)
|
||||||
|
guard let server = url else { return }
|
||||||
|
// Not through `url`, which throws the offline copy away: it still belongs
|
||||||
|
// to this server, and is what the app starts on if the check cannot run.
|
||||||
|
defaults.removeObject(forKey: key)
|
||||||
|
defaults.removeObject(forKey: signInHostsKey)
|
||||||
|
defaults.set(server, forKey: previousKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The check an update asked for cannot run (the server is out of reach),
|
||||||
|
/// but there is a copy of its UI: the server goes back in place, unchecked
|
||||||
|
/// for now, and the check runs again on the next launch.
|
||||||
|
static func restoreForOffline() -> Bool {
|
||||||
|
let defaults = UserDefaults.standard
|
||||||
|
guard url == nil, let previous = previousURL,
|
||||||
|
FileManager.default.fileExists(atPath: offlineCopyURL.path) else { return false }
|
||||||
|
defaults.set(previous, forKey: key)
|
||||||
|
defaults.removeObject(forKey: previousKey)
|
||||||
|
defaults.set(0, forKey: checkedKey)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The server an update asked to check again, until a server is set.
|
||||||
|
static var previousURL: String? {
|
||||||
|
UserDefaults.standard.string(forKey: previousKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let signInHostsKey = "TrekServerSignInHosts"
|
||||||
|
|
||||||
|
/// Setting the server drops the sign-in hosts of the one before it.
|
||||||
static var url: String? {
|
static var url: String? {
|
||||||
get { UserDefaults.standard.string(forKey: key) }
|
get { UserDefaults.standard.string(forKey: key) }
|
||||||
set {
|
set {
|
||||||
if let newValue { UserDefaults.standard.set(newValue, forKey: key) } else { UserDefaults.standard.removeObject(forKey: key) }
|
if let newValue {
|
||||||
|
UserDefaults.standard.set(newValue, forKey: key)
|
||||||
|
UserDefaults.standard.removeObject(forKey: previousKey)
|
||||||
|
} else {
|
||||||
|
UserDefaults.standard.removeObject(forKey: key)
|
||||||
|
}
|
||||||
|
UserDefaults.standard.removeObject(forKey: signInHostsKey)
|
||||||
try? FileManager.default.removeItem(at: offlineCopyURL)
|
try? FileManager.default.removeItem(at: offlineCopyURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The hosts of a sign-in page in front of the server (a proxy such as
|
||||||
|
/// Cloudflare Access or Pangolin), as the address screen found them. Only
|
||||||
|
/// these load in the web view besides the server, so the proxy's session
|
||||||
|
/// cookie is the web view's (TrekNavigationProxy), and none of them may
|
||||||
|
/// talk to the app (TrekBridgeMessageGuard).
|
||||||
|
static var signInHosts: Set<String> {
|
||||||
|
get { Set((UserDefaults.standard.stringArray(forKey: signInHostsKey) ?? []).map { $0.lowercased() }) }
|
||||||
|
set {
|
||||||
|
if newValue.isEmpty {
|
||||||
|
UserDefaults.standard.removeObject(forKey: signInHostsKey)
|
||||||
|
} else {
|
||||||
|
UserDefaults.standard.set(Array(newValue).sorted(), forKey: signInHostsKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Keeps one more sign-in host for the remembered server, as the web view met it (TrekSignInRedirect).
|
||||||
|
static func addSignInHost(_ host: String) {
|
||||||
|
var hosts = signInHosts
|
||||||
|
guard hosts.insert(host.lowercased()).inserted else { return }
|
||||||
|
signInHosts = hosts
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `url` is one of the sign-in hosts, matched on host or host:port.
|
||||||
|
static func isSignInHost(_ url: URL?) -> Bool {
|
||||||
|
guard let url, ["https", "http"].contains(url.scheme?.lowercased() ?? ""), let host = url.host?.lowercased() else { return false }
|
||||||
|
let hosts = signInHosts
|
||||||
|
if hosts.contains(host) { return true }
|
||||||
|
if let port = url.port { return hosts.contains("\(host):\(port)") }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The one-time code of a TREK Cloud purchase (setServer's `welcome`). The
|
||||||
|
/// server's first page opens its welcome page with it once, which signs the
|
||||||
|
/// buyer in (TrekNavigationProxy). Kept in memory only, never on disk.
|
||||||
|
static var pendingWelcome: String?
|
||||||
|
|
||||||
|
/// The welcome page for the pending code, handed out once.
|
||||||
|
static func takeWelcomeURL() -> URL? {
|
||||||
|
guard let code = pendingWelcome, let server = url else { return nil }
|
||||||
|
pendingWelcome = nil
|
||||||
|
let base = server.hasSuffix("/") ? server : server + "/"
|
||||||
|
return URL(string: base + "api/managed/welcome#" + code)
|
||||||
|
}
|
||||||
|
|
||||||
static var offlineCopyURL: URL {
|
static var offlineCopyURL: URL {
|
||||||
let support = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
|
let support = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
|
||||||
return support.appendingPathComponent("offline-start-page.html")
|
return support.appendingPathComponent("offline-start-page.html")
|
||||||
@@ -285,12 +792,48 @@ final class TrekTileSchemeHandler: NSObject, WKURLSchemeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A sign-in page in front of the server that the address screen never saw.
|
||||||
|
/// A proxy can let the app's check through (an Authelia or Authentik rule that
|
||||||
|
/// bypasses /api) and still send the page itself to its sign-in. Handed to
|
||||||
|
/// Safari, that sign-in leaves its session there and the app stays blank on
|
||||||
|
/// every launch. So a redirect away from the server, while the server's first
|
||||||
|
/// page is still loading, is taken as the proxy's sign-in: it loads in the web
|
||||||
|
/// view and its host is kept, the way the address screen keeps the ones it saw.
|
||||||
|
/// A link the user taps is no redirect, and once a page of the server has
|
||||||
|
/// shown, nothing is learned any more.
|
||||||
|
enum TrekSignInRedirect {
|
||||||
|
/// The host (host:port with an explicit port) to keep as a sign-in host, or nil.
|
||||||
|
static func learnedHost(server: String?, target: URL?, mainFrame: Bool, redirect: Bool, serverShown: Bool) -> String? {
|
||||||
|
guard mainFrame, redirect, !serverShown,
|
||||||
|
let server, let from = URL(string: server), let fromHost = from.host?.lowercased(),
|
||||||
|
let target, let toHost = target.host?.lowercased(),
|
||||||
|
let toScheme = target.scheme?.lowercased(), ["https", "http"].contains(toScheme) else { return nil }
|
||||||
|
// Never from https down to plain http: the sign-in would send a password in the clear.
|
||||||
|
if from.scheme?.lowercased() == "https", toScheme != "https" { return nil }
|
||||||
|
guard toHost != fromHost else { return nil }
|
||||||
|
if let port = target.port { return "\(toHost):\(port)" }
|
||||||
|
return toHost
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `url` is on the server's host, where the app's own pages come from.
|
||||||
|
static func onServer(server: String?, url: URL?) -> Bool {
|
||||||
|
guard let server, let host = URL(string: server)?.host?.lowercased() else { return false }
|
||||||
|
return url?.host?.lowercased() == host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Stands in front of Capacitor's navigation delegate and hands it everything
|
/// Stands in front of Capacitor's navigation delegate and hands it everything
|
||||||
/// but the failures of a navigation that another one replaced: a cancelled
|
/// but the failures of a navigation that another one replaced: a cancelled
|
||||||
/// load (NSURLErrorCancelled) or an interrupted frame load (WebKit 102). Those
|
/// load (NSURLErrorCancelled) or an interrupted frame load (WebKit 102). Those
|
||||||
/// are no fault, and Capacitor would answer them with its error page.
|
/// are no fault, and Capacitor would answer them with its error page.
|
||||||
final class TrekNavigationProxy: NSObject, WKNavigationDelegate {
|
final class TrekNavigationProxy: NSObject, WKNavigationDelegate {
|
||||||
private let inner: WKNavigationDelegate
|
private let inner: WKNavigationDelegate
|
||||||
|
/// A page of the server has shown since launch; from then on no sign-in host is learned (TrekSignInRedirect).
|
||||||
|
private var serverShown = false
|
||||||
|
/// Told on the main thread whether the main frame now shows an error page in place of the server's.
|
||||||
|
var onErrorPage: ((Bool) -> Void)?
|
||||||
|
/// Told when a page has finished loading: a new document starts without the safe area the controller handed the last one.
|
||||||
|
var onPageShown: (() -> Void)?
|
||||||
|
|
||||||
init(inner: WKNavigationDelegate) {
|
init(inner: WKNavigationDelegate) {
|
||||||
self.inner = inner
|
self.inner = inner
|
||||||
@@ -310,13 +853,133 @@ final class TrekNavigationProxy: NSObject, WKNavigationDelegate {
|
|||||||
(inner as AnyObject).responds(to: aSelector) ? inner : nil
|
(inner as AnyObject).responds(to: aSelector) ? inner : nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The sign-in page of a proxy in front of the server loads here instead of
|
||||||
|
/// in Safari, so its session is the web view's and every request carries it.
|
||||||
|
/// Only the hosts the address screen saw (TrekServerStore.signInHosts), and
|
||||||
|
/// only in the main frame; everything else is Capacitor's decision as before.
|
||||||
|
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
|
if navigationAction.targetFrame?.isMainFrame == true, TrekServerStore.isSignInHost(navigationAction.request.url) {
|
||||||
|
decisionHandler(.allow)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// WebKit asks again for every server redirect, as a navigation of type .other.
|
||||||
|
if let host = TrekSignInRedirect.learnedHost(
|
||||||
|
server: TrekServerStore.url,
|
||||||
|
target: navigationAction.request.url,
|
||||||
|
mainFrame: navigationAction.targetFrame?.isMainFrame == true,
|
||||||
|
redirect: navigationAction.navigationType == .other,
|
||||||
|
serverShown: serverShown
|
||||||
|
) {
|
||||||
|
TrekServerStore.addSignInHost(host)
|
||||||
|
decisionHandler(.allow)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let selector = NSSelectorFromString("webView:decidePolicyForNavigationAction:decisionHandler:")
|
||||||
|
guard (inner as AnyObject).responds(to: selector) else {
|
||||||
|
decisionHandler(.allow)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inner.webView?(webView, decidePolicyFor: navigationAction, decisionHandler: decisionHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// After the server's first page, a pending welcome code opens the welcome
|
||||||
|
/// page once (TrekServerStore.takeWelcomeURL); it is on the server's origin.
|
||||||
|
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||||
|
inner.webView?(webView, didFinish: navigation)
|
||||||
|
onPageShown?()
|
||||||
|
if TrekSignInRedirect.onServer(server: TrekServerStore.url, url: webView.url) {
|
||||||
|
serverShown = true
|
||||||
|
// The server's page is up: an earlier failure is no cause any more.
|
||||||
|
_ = TrekServerStore.takeFailure()
|
||||||
|
}
|
||||||
|
if let welcome = TrekServerStore.takeWelcomeURL() {
|
||||||
|
webView.load(URLRequest(url: welcome))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A proxy in front of the server asks for a client certificate (mutual TLS):
|
||||||
|
/// the stored one goes to the host and port it was imported for and nowhere
|
||||||
|
/// else (TrekClientIdentity). Every other challenge is Capacitor's as before.
|
||||||
|
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge,
|
||||||
|
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||||
|
if TrekClientIdentity.answer(challenge, completionHandler) {
|
||||||
|
let space = challenge.protectionSpace
|
||||||
|
TrekClientCertWatch.serverAsked(host: space.host, port: space.port) { [weak self, weak webView] in
|
||||||
|
guard let self, let webView else { return }
|
||||||
|
// Capacitor's own answer to a failed load: the address screen (errorPath).
|
||||||
|
TrekServerStore.noteFailure(URLError(.clientCertificateRejected))
|
||||||
|
self.inner.webView?(webView, didFailProvisionalNavigation: nil, withError: URLError(.clientCertificateRejected))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let selector = NSSelectorFromString("webView:didReceiveAuthenticationChallenge:completionHandler:")
|
||||||
|
guard (inner as AnyObject).responds(to: selector) else {
|
||||||
|
completionHandler(.performDefaultHandling, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inner.webView?(webView, didReceive: challenge, completionHandler: completionHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A proxy that asked the page for a client certificate, got none and
|
||||||
|
/// answered with its own refusal (Cloudflare's 403, nginx's 400) sends the
|
||||||
|
/// app to the address screen, which says so and offers to add one, rather
|
||||||
|
/// than leaving the proxy's error page up. Any other 4xx page is not TREK's,
|
||||||
|
/// which serves its UI for every path (a proxy's block page, a certificate it
|
||||||
|
/// refused): it stays up with the bar and its way out to another server.
|
||||||
|
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse,
|
||||||
|
decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||||
|
if navigationResponse.isForMainFrame, let http = navigationResponse.response as? HTTPURLResponse,
|
||||||
|
http.statusCode >= 400, http.statusCode < 500, let asked = TrekClientIdentity.lastRequest, !asked.served,
|
||||||
|
let url = http.url, url.host?.lowercased() == asked.host, (url.port ?? 443) == asked.port {
|
||||||
|
decisionHandler(.cancel)
|
||||||
|
TrekServerStore.noteFailure(URLError(.clientCertificateRequired))
|
||||||
|
inner.webView?(webView, didFailProvisionalNavigation: nil, withError: URLError(.clientCertificateRequired))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if navigationResponse.isForMainFrame, let http = navigationResponse.response as? HTTPURLResponse {
|
||||||
|
let error = http.statusCode >= 400 && http.statusCode < 500
|
||||||
|
DispatchQueue.main.async { [weak self] in self?.onErrorPage?(error) }
|
||||||
|
}
|
||||||
|
let selector = NSSelectorFromString("webView:decidePolicyForNavigationResponse:decisionHandler:")
|
||||||
|
guard (inner as AnyObject).responds(to: selector) else {
|
||||||
|
decisionHandler(.allow)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inner.webView?(webView, decidePolicyFor: navigationResponse, decisionHandler: decisionHandler)
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
||||||
if Self.isReplaced(error) { return }
|
if Self.isReplaced(error) { return }
|
||||||
|
TrekServerStore.noteFailure(error)
|
||||||
inner.webView?(webView, didFail: navigation, withError: error)
|
inner.webView?(webView, didFail: navigation, withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
|
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
|
||||||
if Self.isReplaced(error) { return }
|
if Self.isReplaced(error) { return }
|
||||||
|
TrekServerStore.noteFailure(error)
|
||||||
inner.webView?(webView, didFailProvisionalNavigation: navigation, withError: error)
|
inner.webView?(webView, didFailProvisionalNavigation: navigation, withError: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stands in front of Capacitor's bridge message handler and drops what a
|
||||||
|
/// proxy's sign-in page posts: that page loads in the web view (see
|
||||||
|
/// TrekNavigationProxy), and Capacitor itself would hand its messages to the
|
||||||
|
/// plugins whatever page they come from.
|
||||||
|
final class TrekBridgeMessageGuard: NSObject, WKScriptMessageHandler {
|
||||||
|
static let name = "bridge"
|
||||||
|
private let inner: WKScriptMessageHandler
|
||||||
|
|
||||||
|
init(inner: WKScriptMessageHandler) {
|
||||||
|
self.inner = inner
|
||||||
|
}
|
||||||
|
|
||||||
|
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||||
|
let origin = message.frameInfo.securityOrigin
|
||||||
|
var components = URLComponents()
|
||||||
|
components.scheme = origin.protocol
|
||||||
|
components.host = origin.host
|
||||||
|
if origin.port != 0 { components.port = origin.port }
|
||||||
|
if TrekServerStore.isSignInHost(components.url) { return }
|
||||||
|
inner.userContentController(userContentController, didReceive: message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,393 @@
|
|||||||
|
import Foundation
|
||||||
|
import Security
|
||||||
|
import UIKit
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
|
/// The client certificate a user's TREK server asks for (mutual TLS): a proxy
|
||||||
|
/// such as Cloudflare, nginx, Caddy or Traefik in front of TREK lets through
|
||||||
|
/// only devices that show one. The app holds at most one, for one server.
|
||||||
|
///
|
||||||
|
/// It comes in as a PKCS#12 file (.p12, .pfx) and its password. The password is
|
||||||
|
/// never kept; the identity goes into the keychain, this device only, readable
|
||||||
|
/// after the first unlock (so a background refresh can show it too). Only the
|
||||||
|
/// host and port it was imported for ever see it (`identity(forHost:port:)`), so a
|
||||||
|
/// sign-in page, a map tile provider or liketrek.com never learns of it.
|
||||||
|
enum TrekClientIdentity {
|
||||||
|
private static let label = "trek-client-identity"
|
||||||
|
private static let hostKey = "TrekClientIdentityHost"
|
||||||
|
private static let portKey = "TrekClientIdentityPort"
|
||||||
|
|
||||||
|
enum Failure: String, Error {
|
||||||
|
case password, format, noKey = "no_key", expired, notYetValid = "not_yet_valid", store
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The last server that asked for a certificate while the app ran, and whether it got one.
|
||||||
|
struct Request {
|
||||||
|
let host: String
|
||||||
|
let port: Int
|
||||||
|
let served: Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let lock = NSLock()
|
||||||
|
private static var _lastRequest: Request?
|
||||||
|
static var lastRequest: Request? {
|
||||||
|
lock.lock(); defer { lock.unlock() }
|
||||||
|
return _lastRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
static func noteRequest(host: String, port: Int, served: Bool) {
|
||||||
|
lock.lock(); defer { lock.unlock() }
|
||||||
|
_lastRequest = Request(host: host.lowercased(), port: port > 0 ? port : 443, served: served)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Reading a file
|
||||||
|
|
||||||
|
/// Opens a PKCS#12 file: the identity and the rest of its chain.
|
||||||
|
static func read(_ data: Data, password: String, now: Date = Date()) -> Result<(SecIdentity, [SecCertificate]), Failure> {
|
||||||
|
var items: CFArray?
|
||||||
|
let status = SecPKCS12Import(data as CFData, [kSecImportExportPassphrase as String: password] as CFDictionary, &items)
|
||||||
|
switch status {
|
||||||
|
case errSecSuccess: break
|
||||||
|
case errSecAuthFailed, errSecPkcs12VerifyFailure: return .failure(.password)
|
||||||
|
default: return .failure(.format)
|
||||||
|
}
|
||||||
|
guard let first = (items as? [[String: Any]])?.first,
|
||||||
|
let value = first[kSecImportItemIdentity as String] else { return .failure(.noKey) }
|
||||||
|
let identity = value as! SecIdentity
|
||||||
|
var leaf: SecCertificate?
|
||||||
|
guard SecIdentityCopyCertificate(identity, &leaf) == errSecSuccess, let leaf else { return .failure(.noKey) }
|
||||||
|
if let validity = validity(of: leaf) {
|
||||||
|
if now > validity.notAfter { return .failure(.expired) }
|
||||||
|
if now < validity.notBefore { return .failure(.notYetValid) }
|
||||||
|
}
|
||||||
|
let leafData = SecCertificateCopyData(leaf) as Data
|
||||||
|
let chain = (first[kSecImportItemCertChain as String] as? [SecCertificate] ?? []).filter {
|
||||||
|
SecCertificateCopyData($0) as Data != leafData
|
||||||
|
}
|
||||||
|
return .success((identity, chain))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Keeping it
|
||||||
|
|
||||||
|
/// Keeps the identity for this host and port, replacing any other.
|
||||||
|
static func save(_ identity: SecIdentity, chain: [SecCertificate], host: String, port: Int) -> Bool {
|
||||||
|
remove()
|
||||||
|
let query: [String: Any] = [
|
||||||
|
kSecValueRef as String: identity,
|
||||||
|
kSecAttrLabel as String: label,
|
||||||
|
kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly,
|
||||||
|
]
|
||||||
|
guard SecItemAdd(query as CFDictionary, nil) == errSecSuccess else { return false }
|
||||||
|
// The chain's intermediates go along so a proxy that wants them gets them.
|
||||||
|
let encoded = chain.map { SecCertificateCopyData($0) as Data }
|
||||||
|
UserDefaults.standard.set(encoded, forKey: chainKey)
|
||||||
|
UserDefaults.standard.set(host.lowercased(), forKey: hostKey)
|
||||||
|
UserDefaults.standard.set(port, forKey: portKey)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let chainKey = "TrekClientIdentityChain"
|
||||||
|
|
||||||
|
static func remove() {
|
||||||
|
TrekClientCertWatch.reset()
|
||||||
|
for itemClass in [kSecClassIdentity, kSecClassCertificate, kSecClassKey] {
|
||||||
|
SecItemDelete([kSecClass as String: itemClass, kSecAttrLabel as String: label] as CFDictionary)
|
||||||
|
}
|
||||||
|
UserDefaults.standard.removeObject(forKey: hostKey)
|
||||||
|
UserDefaults.standard.removeObject(forKey: portKey)
|
||||||
|
UserDefaults.standard.removeObject(forKey: chainKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func storedIdentity() -> SecIdentity? {
|
||||||
|
var item: CFTypeRef?
|
||||||
|
let query: [String: Any] = [
|
||||||
|
kSecClass as String: kSecClassIdentity,
|
||||||
|
kSecAttrLabel as String: label,
|
||||||
|
kSecReturnRef as String: true,
|
||||||
|
]
|
||||||
|
guard SecItemCopyMatching(query as CFDictionary, &item) == errSecSuccess, let item else { return nil }
|
||||||
|
return (item as! SecIdentity)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether a request to host and port (0 or less for https' default) goes to the server the identity is for.
|
||||||
|
static func matches(host: String?, port: Int) -> Bool {
|
||||||
|
guard let host, let stored = UserDefaults.standard.string(forKey: hostKey) else { return false }
|
||||||
|
let storedPort = UserDefaults.standard.integer(forKey: portKey)
|
||||||
|
return host.lowercased() == stored && (port > 0 ? port : 443) == (storedPort > 0 ? storedPort : 443)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The credential for a server at host and port, or nil when the stored one is for another.
|
||||||
|
static func credential(forHost host: String, port: Int) -> URLCredential? {
|
||||||
|
guard matches(host: host, port: port), let identity = storedIdentity() else { return nil }
|
||||||
|
let chain = (UserDefaults.standard.array(forKey: chainKey) as? [Data] ?? []).compactMap {
|
||||||
|
SecCertificateCreateWithData(nil, $0 as CFData)
|
||||||
|
}
|
||||||
|
// Per session: a replaced certificate takes effect on the next connection.
|
||||||
|
return URLCredential(identity: identity, certificates: chain.isEmpty ? nil : chain, persistence: .forSession)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Answers a challenge if it asks for a client certificate; false leaves it to the caller.
|
||||||
|
static func answer(_ challenge: URLAuthenticationChallenge, _ completion: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> Bool {
|
||||||
|
guard challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate else { return false }
|
||||||
|
let space = challenge.protectionSpace
|
||||||
|
let credential = credential(forHost: space.host, port: space.port)
|
||||||
|
noteRequest(host: space.host, port: space.port, served: credential != nil)
|
||||||
|
if let credential {
|
||||||
|
completion(.useCredential, credential)
|
||||||
|
} else {
|
||||||
|
// As a browser without a matching certificate: go on without one.
|
||||||
|
completion(.performDefaultHandling, nil)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: What the settings show
|
||||||
|
|
||||||
|
static func info() -> [String: Any]? {
|
||||||
|
guard let host = UserDefaults.standard.string(forKey: hostKey), let identity = storedIdentity() else { return nil }
|
||||||
|
var leaf: SecCertificate?
|
||||||
|
guard SecIdentityCopyCertificate(identity, &leaf) == errSecSuccess, let leaf else { return nil }
|
||||||
|
let port = UserDefaults.standard.integer(forKey: portKey)
|
||||||
|
var result: [String: Any] = [
|
||||||
|
"host": host,
|
||||||
|
"port": port > 0 ? port : 443,
|
||||||
|
"subject": SecCertificateCopySubjectSummary(leaf) as String? ?? "",
|
||||||
|
"issuer": issuerName(of: leaf) ?? "",
|
||||||
|
]
|
||||||
|
if let validity = validity(of: leaf) { result["notAfter"] = Int(validity.notAfter.timeIntervalSince1970 * 1000) }
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Certificate fields
|
||||||
|
|
||||||
|
/// notBefore and notAfter from the DER: iOS has no public API for them.
|
||||||
|
static func validity(of certificate: SecCertificate) -> (notBefore: Date, notAfter: Date)? {
|
||||||
|
DER.validity(SecCertificateCopyData(certificate) as Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func issuerName(of certificate: SecCertificate) -> String? {
|
||||||
|
DER.issuerCommonName(SecCertificateCopyData(certificate) as Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Just enough DER to read an X.509 certificate's validity and a name's CN.
|
||||||
|
enum DER {
|
||||||
|
private struct Node {
|
||||||
|
let tag: UInt8
|
||||||
|
let body: Range<Int>
|
||||||
|
let end: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func node(_ bytes: [UInt8], at offset: Int) -> Node? {
|
||||||
|
guard offset + 2 <= bytes.count else { return nil }
|
||||||
|
let tag = bytes[offset]
|
||||||
|
var length = Int(bytes[offset + 1])
|
||||||
|
var start = offset + 2
|
||||||
|
if length & 0x80 != 0 {
|
||||||
|
let count = length & 0x7f
|
||||||
|
guard count > 0, count <= 4, start + count <= bytes.count else { return nil }
|
||||||
|
length = bytes[start..<start + count].reduce(0) { $0 << 8 | Int($1) }
|
||||||
|
start += count
|
||||||
|
}
|
||||||
|
guard start + length <= bytes.count else { return nil }
|
||||||
|
return Node(tag: tag, body: start..<start + length, end: start + length)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func children(_ bytes: [UInt8], in range: Range<Int>) -> [Node] {
|
||||||
|
var result: [Node] = []
|
||||||
|
var offset = range.lowerBound
|
||||||
|
while offset < range.upperBound, let child = node(bytes, at: offset) {
|
||||||
|
result.append(child)
|
||||||
|
offset = child.end
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The fields of the TBSCertificate after the version: serial, signature algorithm, issuer, validity, ...
|
||||||
|
private static func tbsFields(_ bytes: [UInt8]) -> [Node]? {
|
||||||
|
guard let certificate = node(bytes, at: 0), let tbs = children(bytes, in: certificate.body).first else { return nil }
|
||||||
|
var fields = children(bytes, in: tbs.body)
|
||||||
|
if fields.first?.tag == 0xa0 { fields.removeFirst() }
|
||||||
|
return fields.count > 3 ? fields : nil
|
||||||
|
}
|
||||||
|
|
||||||
|
static func validity(_ data: Data) -> (notBefore: Date, notAfter: Date)? {
|
||||||
|
let bytes = [UInt8](data)
|
||||||
|
guard let fields = tbsFields(bytes) else { return nil }
|
||||||
|
let times = children(bytes, in: fields[3].body)
|
||||||
|
guard times.count == 2, let from = time(bytes, times[0]), let to = time(bytes, times[1]) else { return nil }
|
||||||
|
return (from, to)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func time(_ bytes: [UInt8], _ node: Node) -> Date? {
|
||||||
|
guard let text = String(bytes: bytes[node.body], encoding: .ascii) else { return nil }
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||||
|
formatter.timeZone = TimeZone(identifier: "UTC")
|
||||||
|
formatter.dateFormat = node.tag == 0x17 ? "yyMMddHHmmss'Z'" : "yyyyMMddHHmmss'Z'"
|
||||||
|
return formatter.date(from: text)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The CN of the issuer's Name (a SEQUENCE of SETs of type and value), or nil.
|
||||||
|
static func issuerCommonName(_ data: Data) -> String? {
|
||||||
|
let bytes = [UInt8](data)
|
||||||
|
guard let fields = tbsFields(bytes) else { return nil }
|
||||||
|
for set in children(bytes, in: fields[2].body) {
|
||||||
|
for pair in children(bytes, in: set.body) {
|
||||||
|
let parts = children(bytes, in: pair.body)
|
||||||
|
guard parts.count == 2, Array(bytes[parts[0].body]) == [0x55, 0x04, 0x03] else { continue }
|
||||||
|
return String(bytes: bytes[parts[1].body], encoding: .utf8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Notices when the user's server stops letting the app in for want of a
|
||||||
|
/// client certificate (one removed, expired, or no longer trusted). The page can
|
||||||
|
/// still be the stored offline copy while every request fails, so when the server
|
||||||
|
/// asks for a certificate the app checks once natively whether TREK answers with
|
||||||
|
/// what it holds. Only a check that fails at the certificate (the handshake broke
|
||||||
|
/// off, or the proxy's own 4xx) calls `onRefused`; a server that merely asks and
|
||||||
|
/// lets everyone in answers TREK's 200. At most once a minute.
|
||||||
|
enum TrekClientCertWatch {
|
||||||
|
private static let lock = NSLock()
|
||||||
|
private static var lastCheck = Date.distantPast
|
||||||
|
|
||||||
|
/// A new or removed certificate is worth a check of its own, whenever the last one ran.
|
||||||
|
static func reset() {
|
||||||
|
lock.lock(); defer { lock.unlock() }
|
||||||
|
lastCheck = .distantPast
|
||||||
|
}
|
||||||
|
|
||||||
|
static func serverAsked(host: String, port: Int, onRefused: @escaping () -> Void) {
|
||||||
|
guard let raw = TrekServerStore.url, let server = URL(string: raw), server.scheme == "https",
|
||||||
|
server.host?.lowercased() == host.lowercased(), (server.port ?? 443) == (port > 0 ? port : 443),
|
||||||
|
let features = URL(string: raw.trimmingCharacters(in: CharacterSet(charactersIn: "/")) + "/api/health/features") else { return }
|
||||||
|
lock.lock()
|
||||||
|
let due = Date().timeIntervalSince(lastCheck) >= 60
|
||||||
|
if due { lastCheck = Date() }
|
||||||
|
lock.unlock()
|
||||||
|
guard due else { return }
|
||||||
|
var request = URLRequest(url: features, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 8)
|
||||||
|
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
||||||
|
var task: URLSessionDataTask?
|
||||||
|
task = TrekClientCertSessionDelegate.session.dataTask(with: request) { _, response, _ in
|
||||||
|
let asked = task.flatMap { TrekClientCertSessionDelegate.shared.ask(for: $0) } != nil
|
||||||
|
let status = (response as? HTTPURLResponse)?.statusCode ?? 0
|
||||||
|
if asked && (status == 0 || (400..<500).contains(status)) {
|
||||||
|
DispatchQueue.main.async(execute: onRefused)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task?.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A URLSession delegate for the app's own requests to the user's server: it
|
||||||
|
/// shows the client certificate where the server asks for it and notes the ask.
|
||||||
|
final class TrekClientCertSessionDelegate: NSObject, URLSessionTaskDelegate {
|
||||||
|
static let shared = TrekClientCertSessionDelegate()
|
||||||
|
|
||||||
|
/// The app's session for the user's server (offline copy, watch, address check).
|
||||||
|
static let session = URLSession(configuration: .default, delegate: shared, delegateQueue: nil)
|
||||||
|
|
||||||
|
/// Per task: whether the server asked, and whether it got a certificate (address check only).
|
||||||
|
private let lock = NSLock()
|
||||||
|
private var asks: [Int: Bool] = [:]
|
||||||
|
|
||||||
|
func ask(for task: URLSessionTask) -> Bool? {
|
||||||
|
lock.lock(); defer { lock.unlock() }
|
||||||
|
return asks.removeValue(forKey: task.taskIdentifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge,
|
||||||
|
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||||
|
let handled = TrekClientIdentity.answer(challenge) { disposition, credential in
|
||||||
|
self.lock.lock()
|
||||||
|
self.asks[task.taskIdentifier] = credential != nil
|
||||||
|
self.lock.unlock()
|
||||||
|
completionHandler(disposition, credential)
|
||||||
|
}
|
||||||
|
if !handled { completionHandler(.performDefaultHandling, nil) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The file picker and password prompt of an import, in the UI's words.
|
||||||
|
final class TrekClientCertImporter: NSObject, UIDocumentPickerDelegate {
|
||||||
|
private let presenter: UIViewController
|
||||||
|
private let labels: [String: String]
|
||||||
|
private let host: String
|
||||||
|
private let port: Int
|
||||||
|
private let done: ([String: Any]) -> Void
|
||||||
|
private var keepAlive: TrekClientCertImporter?
|
||||||
|
|
||||||
|
init(presenter: UIViewController, labels: [String: String], host: String, port: Int, done: @escaping ([String: Any]) -> Void) {
|
||||||
|
self.presenter = presenter
|
||||||
|
self.labels = labels
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.done = done
|
||||||
|
}
|
||||||
|
|
||||||
|
func start() {
|
||||||
|
keepAlive = self
|
||||||
|
let types = [UTType(filenameExtension: "p12"), UTType(filenameExtension: "pfx"), UTType("com.rsa.pkcs-12")].compactMap { $0 }
|
||||||
|
let picker = UIDocumentPickerViewController(forOpeningContentTypes: types.isEmpty ? [.data] : types, asCopy: true)
|
||||||
|
picker.delegate = self
|
||||||
|
presenter.present(picker, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
|
||||||
|
finish(["result": "cancelled"])
|
||||||
|
}
|
||||||
|
|
||||||
|
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
||||||
|
guard let url = urls.first,
|
||||||
|
let attributes = try? FileManager.default.attributesOfItem(atPath: url.path),
|
||||||
|
(attributes[.size] as? Int ?? 0) <= 256 * 1024,
|
||||||
|
let data = try? Data(contentsOf: url) else {
|
||||||
|
finish(["result": "failed", "failure": TrekClientIdentity.Failure.format.rawValue])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try? FileManager.default.removeItem(at: url)
|
||||||
|
askPassword(for: data, wrong: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func askPassword(for data: Data, wrong: Bool) {
|
||||||
|
let alert = UIAlertController(title: labels["title"], message: wrong ? labels["wrongPassword"] : labels["message"], preferredStyle: .alert)
|
||||||
|
alert.addTextField { field in
|
||||||
|
field.isSecureTextEntry = true
|
||||||
|
field.placeholder = self.labels["placeholder"]
|
||||||
|
field.textContentType = .password
|
||||||
|
}
|
||||||
|
alert.addAction(UIAlertAction(title: labels["cancel"] ?? "Cancel", style: .cancel) { _ in
|
||||||
|
self.finish(["result": "cancelled"])
|
||||||
|
})
|
||||||
|
alert.addAction(UIAlertAction(title: labels["ok"] ?? "OK", style: .default) { _ in
|
||||||
|
self.open(data, password: alert.textFields?.first?.text ?? "")
|
||||||
|
})
|
||||||
|
presenter.present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func open(_ data: Data, password: String) {
|
||||||
|
switch TrekClientIdentity.read(data, password: password) {
|
||||||
|
case .failure(.password):
|
||||||
|
askPassword(for: data, wrong: true)
|
||||||
|
case .failure(let failure):
|
||||||
|
finish(["result": "failed", "failure": failure.rawValue])
|
||||||
|
case .success(let (identity, chain)):
|
||||||
|
guard TrekClientIdentity.save(identity, chain: chain, host: host, port: port) else {
|
||||||
|
finish(["result": "failed", "failure": TrekClientIdentity.Failure.store.rawValue])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var result: [String: Any] = ["result": "imported"]
|
||||||
|
if let info = TrekClientIdentity.info() { result["certificate"] = info }
|
||||||
|
finish(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func finish(_ result: [String: Any]) {
|
||||||
|
done(result)
|
||||||
|
keepAlive = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import ActivityKit
|
|||||||
#endif
|
#endif
|
||||||
import LocalAuthentication
|
import LocalAuthentication
|
||||||
import PassKit
|
import PassKit
|
||||||
|
import QuickLook
|
||||||
import UIKit
|
import UIKit
|
||||||
import WebKit
|
import WebKit
|
||||||
|
|
||||||
@@ -45,7 +46,18 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
CAPPluginMethod(name: "storePurchase", returnType: CAPPluginReturnPromise),
|
CAPPluginMethod(name: "storePurchase", returnType: CAPPluginReturnPromise),
|
||||||
CAPPluginMethod(name: "storeFinish", returnType: CAPPluginReturnPromise),
|
CAPPluginMethod(name: "storeFinish", returnType: CAPPluginReturnPromise),
|
||||||
CAPPluginMethod(name: "storeRestore", returnType: CAPPluginReturnPromise),
|
CAPPluginMethod(name: "storeRestore", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "storeHeld", returnType: CAPPluginReturnPromise),
|
||||||
CAPPluginMethod(name: "addToWallet", returnType: CAPPluginReturnPromise),
|
CAPPluginMethod(name: "addToWallet", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "setWatchSnapshot", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "takeWatchActions", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "setKeyCommands", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "setQuickActions", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "takeQuickAction", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "requestServer", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "clientCertificate", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "importClientCertificate", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "removeClientCertificate", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "previewFile", returnType: CAPPluginReturnPromise),
|
||||||
]
|
]
|
||||||
|
|
||||||
/// What this binary offers the server's UI, raised with every native feature
|
/// What this binary offers the server's UI, raised with every native feature
|
||||||
@@ -53,7 +65,20 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
/// and a server can require a minimum (minNativeShellApi in /api/health/features).
|
/// and a server can require a minimum (minNativeShellApi in /api/health/features).
|
||||||
static let shellApi = 2
|
static let shellApi = 2
|
||||||
/// The native features by name, so the UI can turn each on by itself.
|
/// The native features by name, so the UI can turn each on by itself.
|
||||||
static let features: [String] = ["capabilities", "edgeBack", "tileCache", "biometricLock", "geolocation", "sharedFiles", "nativePush", "widgets", "liveActivity", "widgetTrips", "storeKit", "shareSheet", "wallet"]
|
/// "watch" only where WatchConnectivity is (an iPhone, not an iPad), so the UI never
|
||||||
|
/// builds a snapshot for nothing; "wallet" only where Wallet can take a pass (an
|
||||||
|
/// iPhone: an iPad has no Wallet app), so the UI offers no button that does nothing.
|
||||||
|
static var features: [String] {
|
||||||
|
var names = ["capabilities", "edgeBack", "tileCache", "biometricLock", "geolocation", "sharedFiles", "nativePush", "widgets", "liveActivity", "widgetTrips", "storeKit", "shareSheet", "keyCommands", "quickActions", "appLinks", "clientCertificate", "filePreview"]
|
||||||
|
if canAddWalletPasses { names.append("wallet") }
|
||||||
|
if TrekWatchLink.isAvailable { names.append("watch") }
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether this device can add a pass to Apple Wallet (an iPhone; not an iPad).
|
||||||
|
static var canAddWalletPasses: Bool {
|
||||||
|
PKPassLibrary.isPassLibraryAvailable() && PKAddPassesViewController.canAddPasses()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Shared booking documents
|
// MARK: - Shared booking documents
|
||||||
|
|
||||||
@@ -65,6 +90,49 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
DispatchQueue.main.async { self?.notifyListeners("pushOpened", data: ["url": url]) }
|
DispatchQueue.main.async { self?.notifyListeners("pushOpened", data: ["url": url]) }
|
||||||
}
|
}
|
||||||
TrekStore.watchUpdates()
|
TrekStore.watchUpdates()
|
||||||
|
TrekWatchLink.shared.onAction = { [weak self] in self?.notifyListeners("watchAction", data: [:]) }
|
||||||
|
TrekKeyCommands.onPress = { [weak self] id in
|
||||||
|
self?.notifyListeners("keyCommand", data: ["id": id])
|
||||||
|
}
|
||||||
|
// Kept until a listener takes it: a tap while the page reloads reaches the new page.
|
||||||
|
TrekQuickActions.onOpen = { [weak self] path in
|
||||||
|
DispatchQueue.main.async { self?.notifyListeners("quickAction", data: ["path": path], retainUntilConsumed: true) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Quick actions on the app icon
|
||||||
|
|
||||||
|
/// The app icon's quick actions, in the UI's language (TrekQuickActions).
|
||||||
|
@objc func setQuickActions(_ call: CAPPluginCall) {
|
||||||
|
let items = (call.getArray("items", JSObject.self) ?? []).compactMap { TrekQuickActions.Item(raw: $0) }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
TrekQuickActions.set(items)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The quick action the app was launched with, before the UI was there to hear of it.
|
||||||
|
@objc func takeQuickAction(_ call: CAPPluginCall) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
if let path = TrekQuickActions.take() {
|
||||||
|
call.resolve(["path": path])
|
||||||
|
} else {
|
||||||
|
call.resolve(["path": NSNull()])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Hardware keyboard
|
||||||
|
|
||||||
|
/// The UI's keyboard shortcuts for the screen it shows (mobile/keyboard),
|
||||||
|
/// named in its language, as key commands in the app's menu.
|
||||||
|
@objc func setKeyCommands(_ call: CAPPluginCall) {
|
||||||
|
let raw = call.getArray("commands", JSObject.self) ?? []
|
||||||
|
let commands = raw.compactMap { TrekKeyCommands.Command(raw: $0) }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
TrekKeyCommands.set(commands)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Widgets and the travel-day Live Activity
|
// MARK: - Widgets and the travel-day Live Activity
|
||||||
@@ -106,7 +174,8 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
nextName: nextName,
|
nextName: nextName,
|
||||||
nextTime: call.getString("nextTime"),
|
nextTime: call.getString("nextTime"),
|
||||||
done: call.getInt("done") ?? 0,
|
done: call.getInt("done") ?? 0,
|
||||||
total: call.getInt("total") ?? 0
|
total: call.getInt("total") ?? 0,
|
||||||
|
flight: TrekShellPlugin.activityFlight(call.getObject("flight"))
|
||||||
)
|
)
|
||||||
// Stale at the end of the day, so a forgotten one fades out on its own.
|
// Stale at the end of the day, so a forgotten one fades out on its own.
|
||||||
let stale = Calendar.current.startOfDay(for: Date().addingTimeInterval(86_400))
|
let stale = Calendar.current.startOfDay(for: Date().addingTimeInterval(86_400))
|
||||||
@@ -126,6 +195,19 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
call.resolve(["running": false])
|
call.resolve(["running": false])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The day's flight the UI sent along (native/widgets.ts tripDayState), when complete.
|
||||||
|
@available(iOS 16.1, *)
|
||||||
|
static func activityFlight(_ raw: JSObject?) -> TripDayAttributes.Flight? {
|
||||||
|
guard let raw, let number = raw["number"] as? String, let from = raw["from"] as? String, let to = raw["to"] as? String,
|
||||||
|
let dep = (raw["dep"] as? NSNumber)?.doubleValue, let arr = (raw["arr"] as? NSNumber)?.doubleValue, arr > dep,
|
||||||
|
let depTime = raw["depTime"] as? String, let arrTime = raw["arrTime"] as? String else { return nil }
|
||||||
|
return TripDayAttributes.Flight(
|
||||||
|
number: number, from: from, to: to, dep: dep, arr: arr, depTime: depTime, arrTime: arrTime,
|
||||||
|
delay: (raw["delay"] as? NSNumber)?.intValue,
|
||||||
|
airborne: (raw["airborne"] as? Bool) ?? false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@objc func endTripDay(_ call: CAPPluginCall) {
|
@objc func endTripDay(_ call: CAPPluginCall) {
|
||||||
#if canImport(ActivityKit)
|
#if canImport(ActivityKit)
|
||||||
if #available(iOS 16.2, *) {
|
if #available(iOS 16.2, *) {
|
||||||
@@ -137,6 +219,27 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
call.resolve()
|
call.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Apple Watch
|
||||||
|
|
||||||
|
/// Passes what the watch app shows (native/watch.ts builds it) on to the watch.
|
||||||
|
@objc func setWatchSnapshot(_ call: CAPPluginCall) {
|
||||||
|
guard TrekWatchLink.isAvailable else {
|
||||||
|
call.resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let json = call.getString("json"), let data = json.data(using: .utf8) else {
|
||||||
|
call.reject("json is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
TrekWatchLink.shared.publish(data)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The packing items and to-dos ticked on the watch since the last call, oldest first.
|
||||||
|
@objc func takeWatchActions(_ call: CAPPluginCall) {
|
||||||
|
call.resolve(["actions": TrekWatchLink.shared.takeActions()])
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Push
|
// MARK: - Push
|
||||||
|
|
||||||
/// Asks for permission, registers with APNs and answers with a Web Push
|
/// Asks for permission, registers with APNs and answers with a Web Push
|
||||||
@@ -261,7 +364,11 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
private var authSession: ASWebAuthenticationSession?
|
private var authSession: ASWebAuthenticationSession?
|
||||||
|
|
||||||
@objc func getServer(_ call: CAPPluginCall) {
|
@objc func getServer(_ call: CAPPluginCall) {
|
||||||
call.resolve(["url": TrekServerStore.url ?? NSNull()])
|
call.resolve([
|
||||||
|
"url": TrekServerStore.url ?? NSNull(),
|
||||||
|
"previousUrl": TrekServerStore.previousURL ?? NSNull(),
|
||||||
|
"failure": TrekServerStore.takeFailure() ?? NSNull(),
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func setServer(_ call: CAPPluginCall) {
|
@objc func setServer(_ call: CAPPluginCall) {
|
||||||
@@ -270,6 +377,14 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
TrekServerStore.url = raw
|
TrekServerStore.url = raw
|
||||||
|
let labels = (call.getObject("labels") ?? [:]).compactMapValues { $0 as? String }
|
||||||
|
if !labels.isEmpty { TrekServerStore.labels = labels }
|
||||||
|
// After the URL: setting it clears the hosts of the server before.
|
||||||
|
let hosts = (call.getArray("signInHosts", String.self) ?? []).filter { $0.range(of: "^[A-Za-z0-9.-]+(:[0-9]+)?$", options: .regularExpression) != nil }
|
||||||
|
TrekServerStore.signInHosts = Set(hosts.map { $0.lowercased() })
|
||||||
|
// A TREK Cloud purchase: the code that signs the buyer in, opened once after the first page.
|
||||||
|
let welcome = call.getString("welcome") ?? ""
|
||||||
|
TrekServerStore.pendingWelcome = welcome.range(of: "^[A-Za-z0-9_-]{43}$", options: .regularExpression) != nil ? welcome : nil
|
||||||
call.resolve()
|
call.resolve()
|
||||||
restartBridge()
|
restartBridge()
|
||||||
}
|
}
|
||||||
@@ -342,7 +457,8 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
}
|
}
|
||||||
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 15)
|
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 15)
|
||||||
request.setValue("text/html", forHTTPHeaderField: "Accept")
|
request.setValue("text/html", forHTTPHeaderField: "Accept")
|
||||||
URLSession.shared.dataTask(with: request) { data, response, _ in
|
// The app's session, so a server behind mutual TLS gets the client certificate.
|
||||||
|
TrekClientCertSessionDelegate.session.dataTask(with: request) { data, response, _ in
|
||||||
guard let data, let http = response as? HTTPURLResponse, http.statusCode == 200,
|
guard let data, let http = response as? HTTPURLResponse, http.statusCode == 200,
|
||||||
http.value(forHTTPHeaderField: "Content-Type")?.hasPrefix("text/html") == true,
|
http.value(forHTTPHeaderField: "Content-Type")?.hasPrefix("text/html") == true,
|
||||||
TrekServerStore.url == raw else {
|
TrekServerStore.url == raw else {
|
||||||
@@ -361,6 +477,18 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func openOfflineCopy(_ call: CAPPluginCall) {
|
@objc func openOfflineCopy(_ call: CAPPluginCall) {
|
||||||
|
// The server an update asked to check again, out of reach: back to it on
|
||||||
|
// its copy. The new bridge loads the server, fails, and this screen comes
|
||||||
|
// back with the server set, which then opens the copy below.
|
||||||
|
if TrekServerStore.url == nil {
|
||||||
|
if TrekServerStore.restoreForOffline() {
|
||||||
|
call.resolve(["opened": true])
|
||||||
|
restartBridge()
|
||||||
|
} else {
|
||||||
|
call.resolve(["opened": false])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
// With the trailing slash, like the bridge's serverURL: Capacitor only
|
// With the trailing slash, like the bridge's serverURL: Capacitor only
|
||||||
// keeps a navigation in the app when it starts with that exact string,
|
// keeps a navigation in the app when it starts with that exact string,
|
||||||
// and hands anything else to Safari.
|
// and hands anything else to Safari.
|
||||||
@@ -381,8 +509,123 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Client certificates (mutual TLS)
|
||||||
|
|
||||||
|
extension TrekShellPlugin {
|
||||||
|
/// The address screen's check of a server, made natively so it notices
|
||||||
|
/// whether the server asks for a client certificate and can show the stored
|
||||||
|
/// one. A failed connection resolves with status 0 instead of rejecting.
|
||||||
|
@objc func requestServer(_ call: CAPPluginCall) {
|
||||||
|
guard let raw = call.getString("url"), let url = URL(string: raw),
|
||||||
|
["https", "http"].contains(url.scheme?.lowercased() ?? ""), url.host != nil else {
|
||||||
|
call.reject("A http(s) URL is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let timeout = min(max(Double(call.getInt("timeoutMs") ?? 10000), 1000), 30000) / 1000
|
||||||
|
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: timeout)
|
||||||
|
request.setValue("application/json, text/html;q=0.9, */*;q=0.8", forHTTPHeaderField: "Accept")
|
||||||
|
let delegate = TrekClientCertSessionDelegate.shared
|
||||||
|
var task: URLSessionDataTask?
|
||||||
|
task = TrekClientCertSessionDelegate.session.dataTask(with: request) { data, response, error in
|
||||||
|
let asked = task.flatMap { delegate.ask(for: $0) }
|
||||||
|
var result: [String: Any] = [
|
||||||
|
"certRequested": asked != nil,
|
||||||
|
"certSent": asked == true,
|
||||||
|
"url": response?.url?.absoluteString ?? raw,
|
||||||
|
]
|
||||||
|
if asked != nil, let host = url.host?.lowercased() { result["certHost"] = "\(host):\(url.port ?? 443)" }
|
||||||
|
if let http = response as? HTTPURLResponse {
|
||||||
|
result["status"] = http.statusCode
|
||||||
|
let body = (data ?? Data()).prefix(512 * 1024)
|
||||||
|
result["data"] = String(data: body, encoding: .utf8) ?? ""
|
||||||
|
var headers: [String: String] = [:]
|
||||||
|
for (name, value) in http.allHeaderFields {
|
||||||
|
if let name = name as? String, let value = value as? String { headers[name] = value }
|
||||||
|
}
|
||||||
|
result["headers"] = headers
|
||||||
|
} else {
|
||||||
|
result["status"] = 0
|
||||||
|
result["data"] = ""
|
||||||
|
if let error { result["error"] = (error as NSError).domain + ":" + String((error as NSError).code) }
|
||||||
|
}
|
||||||
|
call.resolve(result)
|
||||||
|
}
|
||||||
|
task?.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The stored client certificate's details, and the last server that asked for one.
|
||||||
|
@objc func clientCertificate(_ call: CAPPluginCall) {
|
||||||
|
var result: [String: Any] = [:]
|
||||||
|
if let info = TrekClientIdentity.info() { result["certificate"] = info } else { result["certificate"] = NSNull() }
|
||||||
|
if let asked = TrekClientIdentity.lastRequest {
|
||||||
|
result["request"] = ["host": asked.host, "port": asked.port, "served": asked.served]
|
||||||
|
}
|
||||||
|
call.resolve(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func removeClientCertificate(_ call: CAPPluginCall) {
|
||||||
|
TrekClientIdentity.remove()
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Picks a .p12/.pfx file, asks for its password until it opens or the user
|
||||||
|
/// gives up, and keeps it for the server at host and port.
|
||||||
|
@objc func importClientCertificate(_ call: CAPPluginCall) {
|
||||||
|
guard let host = call.getString("host"), host.range(of: "^[A-Za-z0-9.-]+$", options: .regularExpression) != nil else {
|
||||||
|
call.reject("A host is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let port = call.getInt("port") ?? 443
|
||||||
|
let labels = (call.getObject("labels") ?? [:]).compactMapValues { $0 as? String }
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
guard let presenter = self?.bridge?.viewController else {
|
||||||
|
call.resolve(["result": "failed", "failure": TrekClientIdentity.Failure.store.rawValue])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
TrekClientCertImporter(presenter: presenter, labels: labels, host: host, port: port) { result in
|
||||||
|
call.resolve(result)
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Positions and errors for the UI, shaped like the Geolocation API's, with the
|
/// Positions and errors for the UI, shaped like the Geolocation API's, with the
|
||||||
/// When-In-Use permission asked the first time.
|
/// When-In-Use permission asked the first time.
|
||||||
|
// MARK: - Quick Look
|
||||||
|
|
||||||
|
extension TrekShellPlugin {
|
||||||
|
/// Kept while Quick Look shows a file: the controller holds its data source weakly.
|
||||||
|
/// One preview at a time, so a static: an extension cannot store per instance.
|
||||||
|
private static var previewSource: TrekFilePreviewSource?
|
||||||
|
|
||||||
|
/// Shows a file the UI wrote to the cache in Quick Look: a PDF to page through,
|
||||||
|
/// an image, a document, with the system's own share button. "unsupported" for
|
||||||
|
/// a file Quick Look cannot show, which the UI then hands to the share sheet.
|
||||||
|
@objc func previewFile(_ call: CAPPluginCall) {
|
||||||
|
guard let path = call.getString("path"), let url = URL(string: path), url.isFileURL,
|
||||||
|
FileManager.default.fileExists(atPath: url.path) else {
|
||||||
|
call.reject("a file in the app's cache is required", "INVALID")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
guard let self, let presenter = self.bridge?.viewController else {
|
||||||
|
call.reject("nothing to show the preview from", "UNAVAILABLE")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard QLPreviewController.canPreview(url as QLPreviewItem) else {
|
||||||
|
call.resolve(["result": "unsupported"])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let source = TrekFilePreviewSource(url: url, title: call.getString("title"))
|
||||||
|
TrekShellPlugin.previewSource = source
|
||||||
|
let preview = QLPreviewController()
|
||||||
|
preview.dataSource = source
|
||||||
|
presenter.present(preview, animated: true)
|
||||||
|
call.resolve(["result": "shown"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Apple Wallet
|
// MARK: - Apple Wallet
|
||||||
|
|
||||||
extension TrekShellPlugin {
|
extension TrekShellPlugin {
|
||||||
@@ -443,9 +686,8 @@ extension TrekShellPlugin {
|
|||||||
/// know are left out, so the shell offers only what can really be bought.
|
/// know are left out, so the shell offers only what can really be bought.
|
||||||
@objc func storeProducts(_ call: CAPPluginCall) {
|
@objc func storeProducts(_ call: CAPPluginCall) {
|
||||||
let ids = call.getArray("ids", String.self) ?? []
|
let ids = call.getArray("ids", String.self) ?? []
|
||||||
// TestFlight, App Review and Xcode builds buy in the sandbox; their receipt says so.
|
|
||||||
let sandbox = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
|
|
||||||
Task {
|
Task {
|
||||||
|
let sandbox = await Self.buysInSandbox()
|
||||||
guard AppStore.canMakePayments, let products = try? await Product.products(for: ids) else {
|
guard AppStore.canMakePayments, let products = try? await Product.products(for: ids) else {
|
||||||
call.resolve(["products": [], "sandbox": sandbox])
|
call.resolve(["products": [], "sandbox": sandbox])
|
||||||
return
|
return
|
||||||
@@ -454,6 +696,26 @@ extension TrekShellPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether this build buys in the App Store sandbox: TestFlight, App Review and
|
||||||
|
/// Xcode builds do, and while TREK Cloud's orders are closed only they may buy.
|
||||||
|
/// The signed app transaction names its environment; the receipt's file name,
|
||||||
|
/// which App Review builds do not always carry, is only the fallback where the
|
||||||
|
/// app transaction is missing (iOS 15) or cannot be read.
|
||||||
|
static func buysInSandbox() async -> Bool {
|
||||||
|
let receiptSaysSandbox = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
|
||||||
|
guard #available(iOS 16.0, *), let result = try? await AppTransaction.shared else {
|
||||||
|
return receiptSaysSandbox
|
||||||
|
}
|
||||||
|
// An unverified transaction still names the environment it was signed in;
|
||||||
|
// it only decides whether the button shows, the cloud checks every purchase itself.
|
||||||
|
let transaction: AppTransaction
|
||||||
|
switch result {
|
||||||
|
case .verified(let signed), .unverified(let signed, _):
|
||||||
|
transaction = signed
|
||||||
|
}
|
||||||
|
return transaction.environment != .production || receiptSaysSandbox
|
||||||
|
}
|
||||||
|
|
||||||
/// Feature storeKit: runs the App Store purchase sheet. Resolves with `kind`
|
/// Feature storeKit: runs the App Store purchase sheet. Resolves with `kind`
|
||||||
/// bought (with the signed transaction the control plane verifies), cancelled,
|
/// bought (with the signed transaction the control plane verifies), cancelled,
|
||||||
/// pending (Ask to Buy, a payment the bank still has to approve) or failed.
|
/// pending (Ask to Buy, a payment the bank still has to approve) or failed.
|
||||||
@@ -465,6 +727,17 @@ extension TrekShellPlugin {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
Task {
|
Task {
|
||||||
|
// One subscription per Apple ID: another plan would change it, not add one.
|
||||||
|
// A held one that was delivered stops the purchase here. One that was paid
|
||||||
|
// but never set up is handed back as bought, so its instance is set up now.
|
||||||
|
if let held = await TrekStore.currentEntitlement(prefix: "cloud.") {
|
||||||
|
if await TrekStore.awaitingSetup(held) {
|
||||||
|
call.resolve(["kind": "bought", "jws": held.jws, "transactionId": String(held.id), "productId": held.productId])
|
||||||
|
} else {
|
||||||
|
call.resolve(["kind": "subscribed"])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
guard let product = try await Product.products(for: [id]).first else {
|
guard let product = try await Product.products(for: [id]).first else {
|
||||||
call.resolve(["kind": "failed"])
|
call.resolve(["kind": "failed"])
|
||||||
@@ -521,6 +794,21 @@ extension TrekShellPlugin {
|
|||||||
call.resolve(["jws": found.jws, "transactionId": String(found.id)])
|
call.resolve(["jws": found.jws, "transactionId": String(found.id)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Feature storeKit: whether this Apple ID holds a delivered subscription under
|
||||||
|
/// `prefix`. Read from the entitlements on the device, so no password is asked;
|
||||||
|
/// while one runs, the shell offers no purchase.
|
||||||
|
@objc func storeHeld(_ call: CAPPluginCall) {
|
||||||
|
let prefix = call.getString("prefix") ?? "cloud."
|
||||||
|
Task {
|
||||||
|
guard let held = await TrekStore.currentEntitlement(prefix: prefix) else {
|
||||||
|
call.resolve(["held": false])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let awaiting = await TrekStore.awaitingSetup(held)
|
||||||
|
call.resolve(["held": !awaiting])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TrekStore {
|
enum TrekStore {
|
||||||
@@ -551,17 +839,62 @@ enum TrekStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func currentEntitlement(prefix: String) async -> (jws: String, id: UInt64)? {
|
typealias Held = (jws: String, id: UInt64, productId: String, firstPurchase: Bool)
|
||||||
var newest: (date: Date, jws: String, id: UInt64)?
|
|
||||||
|
/// The subscription this Apple ID holds under `prefix`, newest first. The
|
||||||
|
/// entitlements on the device come first; on a fresh install they can still
|
||||||
|
/// be empty while the subscription runs, so the status of the subscription
|
||||||
|
/// group, which StoreKit asks the App Store for, decides then.
|
||||||
|
static func currentEntitlement(prefix: String) async -> Held? {
|
||||||
|
var newest: (date: Date, held: Held)?
|
||||||
for await result in Transaction.currentEntitlements {
|
for await result in Transaction.currentEntitlements {
|
||||||
guard case .verified(let transaction) = result,
|
guard case .verified(let transaction) = result,
|
||||||
transaction.productID.hasPrefix(prefix),
|
transaction.productID.hasPrefix(prefix),
|
||||||
transaction.revocationDate == nil else { continue }
|
transaction.revocationDate == nil else { continue }
|
||||||
if newest == nil || transaction.purchaseDate > newest!.date {
|
if newest == nil || transaction.purchaseDate > newest!.date {
|
||||||
newest = (transaction.purchaseDate, result.jwsRepresentation, transaction.id)
|
newest = (transaction.purchaseDate, held(result.jwsRepresentation, transaction))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newest.map { ($0.jws, $0.id) }
|
if let newest { return newest.held }
|
||||||
|
return await subscriptionGroupHeld(prefix: prefix)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The plans the control plane sells (`cloud.<plan>.<monthly|yearly>`, as
|
||||||
|
/// productIdFor in iap.ts); one of them is enough to find their group.
|
||||||
|
private static let plans = ["start", "basis", "plus", "pro"]
|
||||||
|
|
||||||
|
private static func subscriptionGroupHeld(prefix: String) async -> Held? {
|
||||||
|
let ids = plans.flatMap { ["\(prefix)\($0).monthly", "\(prefix)\($0).yearly"] }
|
||||||
|
guard let products = try? await Product.products(for: ids),
|
||||||
|
let group = products.compactMap({ $0.subscription?.subscriptionGroupID }).first,
|
||||||
|
let statuses = try? await Product.SubscriptionInfo.status(for: group) else { return nil }
|
||||||
|
let running: [Product.SubscriptionInfo.RenewalState] = [.subscribed, .inGracePeriod, .inBillingRetryPeriod]
|
||||||
|
for status in statuses where running.contains(status.state) {
|
||||||
|
if case .verified(let transaction) = status.transaction, transaction.revocationDate == nil {
|
||||||
|
return held(status.transaction.jwsRepresentation, transaction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func held(_ jws: String, _ transaction: Transaction) -> Held {
|
||||||
|
(jws: jws, id: transaction.id, productId: transaction.productID, firstPurchase: transaction.originalID == transaction.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A first purchase that was paid but whose instance was never set up: handed
|
||||||
|
/// back as bought so it is set up now. A renewal the device has not finished
|
||||||
|
/// yet is no such purchase; its subscription is running and counts as held.
|
||||||
|
static func awaitingSetup(_ held: Held) async -> Bool {
|
||||||
|
guard held.firstPurchase else { return false }
|
||||||
|
return await isUnfinished(held.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Paid but not delivered yet: the shell finishes a transaction once its instance exists.
|
||||||
|
static func isUnfinished(_ id: UInt64) async -> Bool {
|
||||||
|
for await result in Transaction.unfinished {
|
||||||
|
if case .verified(let transaction) = result, transaction.id == id { return true }
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,3 +1118,26 @@ enum TrekSharedKeychain {
|
|||||||
return SecItemAdd(q as CFDictionary, nil) == errSecSuccess
|
return SecItemAdd(q as CFDictionary, nil) == errSecSuccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The one file Quick Look shows, under the name the user knows it by.
|
||||||
|
final class TrekFilePreviewSource: NSObject, QLPreviewControllerDataSource {
|
||||||
|
private let item: Item
|
||||||
|
|
||||||
|
init(url: URL, title: String?) {
|
||||||
|
item = Item(url: url, title: title)
|
||||||
|
}
|
||||||
|
|
||||||
|
func numberOfPreviewItems(in controller: QLPreviewController) -> Int { 1 }
|
||||||
|
|
||||||
|
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { item }
|
||||||
|
|
||||||
|
final class Item: NSObject, QLPreviewItem {
|
||||||
|
let previewItemURL: URL?
|
||||||
|
let previewItemTitle: String?
|
||||||
|
|
||||||
|
init(url: URL, title: String?) {
|
||||||
|
previewItemURL = url
|
||||||
|
previewItemTitle = title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,399 @@
|
|||||||
|
import CryptoKit
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
import WatchConnectivity
|
||||||
|
import WebKit
|
||||||
|
|
||||||
|
/// The phone's end of WatchConnectivity (feature "watch"). The UI hands over the
|
||||||
|
/// watch's snapshot (client/src/native/watch.ts through TrekShell.setWatchSnapshot);
|
||||||
|
/// this keeps the latest one, sends it as the application context, and as
|
||||||
|
/// complication user info while the day's budget for those lasts and something
|
||||||
|
/// a complication shows has changed. Ticks from the watch arrive as user info,
|
||||||
|
/// are queued here until the UI takes them (TrekShell.takeWatchActions) and
|
||||||
|
/// writes them through its offline-first path, and announced to it at once.
|
||||||
|
final class TrekWatchLink: NSObject, WCSessionDelegate {
|
||||||
|
static let shared = TrekWatchLink()
|
||||||
|
|
||||||
|
/// Told when a tick arrived, on the main queue.
|
||||||
|
var onAction: (() -> Void)?
|
||||||
|
|
||||||
|
private let queue = DispatchQueue(label: "com.liketrek.trek.watch")
|
||||||
|
private let snapshotKey = "trek.watch.snapshot"
|
||||||
|
private let complicationKey = "trek.watch.complicationDigest"
|
||||||
|
private let actionsKey = "trek.watch.actions"
|
||||||
|
/// The most WatchConnectivity carries in one application context, with room to spare.
|
||||||
|
private let maxBytes = 60_000
|
||||||
|
|
||||||
|
/// False on an iPad (and anything else without a paired watch): then this is
|
||||||
|
/// a no-op throughout, and the UI is not offered the feature at all.
|
||||||
|
static var isAvailable: Bool { WCSession.isSupported() }
|
||||||
|
|
||||||
|
func activate() {
|
||||||
|
guard Self.isAvailable else { return }
|
||||||
|
WCSession.default.delegate = self
|
||||||
|
WCSession.default.activate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Snapshots to the watch
|
||||||
|
|
||||||
|
func publish(_ json: Data) {
|
||||||
|
guard Self.isAvailable else { return }
|
||||||
|
let data = withSmallCover(json)
|
||||||
|
queue.async {
|
||||||
|
UserDefaults.standard.set(data, forKey: self.snapshotKey)
|
||||||
|
self.send(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func send(_ data: Data) {
|
||||||
|
guard Self.isAvailable else { return }
|
||||||
|
let session = WCSession.default
|
||||||
|
guard session.activationState == .activated, session.isPaired, session.isWatchAppInstalled else { return }
|
||||||
|
try? session.updateApplicationContext(["snapshot": data])
|
||||||
|
let digest = complicationDigest(data)
|
||||||
|
if session.isComplicationEnabled, session.remainingComplicationUserInfoTransfers > 0,
|
||||||
|
digest != UserDefaults.standard.string(forKey: complicationKey) {
|
||||||
|
session.transferCurrentComplicationUserInfo(["snapshot": data])
|
||||||
|
UserDefaults.standard.set(digest, forKey: complicationKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the complications show of a snapshot: everything but when it was built and the applied ticks.
|
||||||
|
private func complicationDigest(_ data: Data) -> String {
|
||||||
|
guard var object = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any] else { return "" }
|
||||||
|
object.removeValue(forKey: "generatedAt")
|
||||||
|
object.removeValue(forKey: "applied")
|
||||||
|
object.removeValue(forKey: "packing")
|
||||||
|
object.removeValue(forKey: "todos")
|
||||||
|
let canonical = (try? JSONSerialization.data(withJSONObject: object, options: [.sortedKeys])) ?? Data()
|
||||||
|
return SHA256.hash(data: canonical).map { String(format: "%02x", $0) }.joined()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The trip's cover scaled down to a thumbnail the watch can draw, or dropped when it would not fit.
|
||||||
|
private func withSmallCover(_ json: Data) -> Data {
|
||||||
|
guard var object = (try? JSONSerialization.jsonObject(with: json)) as? [String: Any],
|
||||||
|
var trip = object["trip"] as? [String: Any], let cover = trip["cover"] as? String else { return json }
|
||||||
|
trip.removeValue(forKey: "cover")
|
||||||
|
if let data = Data(base64Encoded: cover), let image = UIImage(data: data) {
|
||||||
|
let width: CGFloat = 220
|
||||||
|
let size = CGSize(width: width, height: (width * image.size.height / max(image.size.width, 1)).rounded())
|
||||||
|
let format = UIGraphicsImageRendererFormat()
|
||||||
|
format.scale = 1
|
||||||
|
let small = UIGraphicsImageRenderer(size: size, format: format).image { _ in image.draw(in: CGRect(origin: .zero, size: size)) }
|
||||||
|
if let jpeg = small.jpegData(compressionQuality: 0.6), jpeg.count < 24_000 {
|
||||||
|
trip["cover"] = jpeg.base64EncodedString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
object["trip"] = trip
|
||||||
|
guard let result = try? JSONSerialization.data(withJSONObject: object) else { return json }
|
||||||
|
if result.count > maxBytes, trip["cover"] != nil {
|
||||||
|
trip.removeValue(forKey: "cover")
|
||||||
|
object["trip"] = trip
|
||||||
|
return (try? JSONSerialization.data(withJSONObject: object)) ?? json
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The snapshot the watch has now, as last published.
|
||||||
|
func storedSnapshot() -> Data? {
|
||||||
|
queue.sync { UserDefaults.standard.data(forKey: snapshotKey) }
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Ticks from the watch
|
||||||
|
|
||||||
|
/// The ticks queued so far, oldest first, and the queue emptied.
|
||||||
|
func takeActions() -> [[String: Any]] {
|
||||||
|
queue.sync {
|
||||||
|
let actions = storedActions()
|
||||||
|
UserDefaults.standard.removeObject(forKey: actionsKey)
|
||||||
|
return actions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func storedActions() -> [[String: Any]] {
|
||||||
|
guard let data = UserDefaults.standard.data(forKey: actionsKey),
|
||||||
|
let list = (try? JSONSerialization.jsonObject(with: data)) as? [[String: Any]] else { return [] }
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
/// While the app is in front, its UI writes the tick, through its offline queue
|
||||||
|
/// as a tap would. In the background the WebView is asleep, so the tick is
|
||||||
|
/// written to the server from here at once (TrekWatchWriter), and the trip's
|
||||||
|
/// other devices hear of it over their WebSocket; only a write that fails is
|
||||||
|
/// queued for the UI, which then tries again once it runs.
|
||||||
|
private func receive(_ action: [String: Any], then done: @escaping () -> Void) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
guard UIApplication.shared.applicationState != .active else {
|
||||||
|
self.enqueue(action)
|
||||||
|
done()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
TrekWatchWriter.write(action) { written in
|
||||||
|
if !written { self.enqueue(action) }
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func enqueue(_ action: [String: Any]) {
|
||||||
|
queue.async {
|
||||||
|
// A tick sent twice (the watch resends after a restart) replaces the earlier copy.
|
||||||
|
var actions = self.storedActions().filter { ($0["id"] as? String) != (action["id"] as? String) }
|
||||||
|
actions.append(action)
|
||||||
|
if let data = try? JSONSerialization.data(withJSONObject: Array(actions.suffix(200))) {
|
||||||
|
UserDefaults.standard.set(data, forKey: self.actionsKey)
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async { self.onAction?() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: WCSessionDelegate
|
||||||
|
|
||||||
|
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
|
||||||
|
guard activationState == .activated else { return }
|
||||||
|
queue.async {
|
||||||
|
if let data = UserDefaults.standard.data(forKey: self.snapshotKey) { self.send(data) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sessionDidBecomeInactive(_ session: WCSession) {}
|
||||||
|
|
||||||
|
/// After switching watches the session has to be activated again for the new one.
|
||||||
|
func sessionDidDeactivate(_ session: WCSession) {
|
||||||
|
WCSession.default.activate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func sessionWatchStateDidChange(_ session: WCSession) {
|
||||||
|
queue.async {
|
||||||
|
if let data = UserDefaults.standard.data(forKey: self.snapshotKey) { self.send(data) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) {
|
||||||
|
if let action = userInfo["action"] as? [String: Any] { receive(action) {} }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The watch asks for the latest snapshot when it opens while the phone is in
|
||||||
|
/// reach, and sends its ticks this way while it is (WatchLink.send).
|
||||||
|
func session(_ session: WCSession, didReceiveMessage message: [String: Any], replyHandler: @escaping ([String: Any]) -> Void) {
|
||||||
|
if let action = message["action"] as? [String: Any] {
|
||||||
|
receive(action) { replyHandler(["queued": true]) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
queue.async {
|
||||||
|
if message["request"] as? String == "snapshot", let data = UserDefaults.standard.data(forKey: self.snapshotKey) {
|
||||||
|
replyHandler(["snapshot": data])
|
||||||
|
} else {
|
||||||
|
replyHandler([:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes a tick from the watch straight to the TREK server, for when the app is
|
||||||
|
/// in the background and its UI cannot. The same request the UI makes for a tap
|
||||||
|
/// (PUT /api/trips/:trip/packing|todo/:item with the box's new state), with the
|
||||||
|
/// session the WebView holds (its cookies) and the tick's id as the idempotency
|
||||||
|
/// key, so a tick that also reaches the server another way is taken once.
|
||||||
|
enum TrekWatchWriter {
|
||||||
|
private final class BackgroundTask {
|
||||||
|
var id = UIBackgroundTaskIdentifier.invalid
|
||||||
|
|
||||||
|
func end() {
|
||||||
|
guard id != .invalid else { return }
|
||||||
|
UIApplication.shared.endBackgroundTask(id)
|
||||||
|
id = .invalid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called on the main queue, as is `completion`.
|
||||||
|
static func write(_ action: [String: Any], completion: @escaping (Bool) -> Void) {
|
||||||
|
guard let request = Self.request(for: action) else {
|
||||||
|
completion(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let task = BackgroundTask()
|
||||||
|
task.id = UIApplication.shared.beginBackgroundTask(withName: "trek.watch.tick") { task.end() }
|
||||||
|
let finish: (Bool) -> Void = { written in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
completion(written)
|
||||||
|
task.end()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
perform(request) { _, ok in finish(ok) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sends a request with the WebView's session (its cookies for the server).
|
||||||
|
/// Called on the main queue; `completion` runs on a background queue.
|
||||||
|
static func perform(_ request: URLRequest, completion: @escaping (Data?, Bool) -> Void) {
|
||||||
|
WKWebsiteDataStore.default().httpCookieStore.getAllCookies { cookies in
|
||||||
|
guard let host = request.url?.host else { return completion(nil, false) }
|
||||||
|
let session = cookies.filter { cookie in
|
||||||
|
let domain = cookie.domain.hasPrefix(".") ? String(cookie.domain.dropFirst()) : cookie.domain
|
||||||
|
return host == domain || host.hasSuffix("." + domain)
|
||||||
|
}
|
||||||
|
guard !session.isEmpty else { return completion(nil, false) }
|
||||||
|
var signed = request
|
||||||
|
for (field, value) in HTTPCookie.requestHeaderFields(with: session) {
|
||||||
|
signed.setValue(value, forHTTPHeaderField: field)
|
||||||
|
}
|
||||||
|
TrekClientCertSessionDelegate.session.dataTask(with: signed) { data, response, error in
|
||||||
|
let status = (response as? HTTPURLResponse)?.statusCode ?? 0
|
||||||
|
completion(data, error == nil && (200..<300).contains(status))
|
||||||
|
}.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The server's address for an API path, or nil without a server.
|
||||||
|
static func url(_ path: [String]) -> URL? {
|
||||||
|
guard let server = TrekServerStore.url, let base = URL(string: server),
|
||||||
|
base.scheme == "https" || base.scheme == "http" else { return nil }
|
||||||
|
return path.reduce(base.appendingPathComponent("api")) { $0.appendingPathComponent($1) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The write for a tick as the watch sends it, or nil for anything else.
|
||||||
|
static func request(for action: [String: Any]) -> URLRequest? {
|
||||||
|
guard let server = TrekServerStore.url, let base = URL(string: server),
|
||||||
|
base.scheme == "https" || base.scheme == "http",
|
||||||
|
let id = action["id"] as? String, !id.isEmpty, id.count <= 64,
|
||||||
|
let tripId = action["tripId"] as? Int, let itemId = action["itemId"] as? Int,
|
||||||
|
let list = action["list"] as? String, list == "packing" || list == "todo",
|
||||||
|
let done = action["done"] as? Bool,
|
||||||
|
let body = try? JSONSerialization.data(withJSONObject: ["checked": done]) else { return nil }
|
||||||
|
let url = base.appendingPathComponent("api").appendingPathComponent("trips")
|
||||||
|
.appendingPathComponent(String(tripId)).appendingPathComponent(list).appendingPathComponent(String(itemId))
|
||||||
|
var request = URLRequest(url: url, timeoutInterval: 10)
|
||||||
|
request.httpMethod = "PUT"
|
||||||
|
request.httpShouldHandleCookies = false
|
||||||
|
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||||
|
request.setValue("watch-\(id)", forHTTPHeaderField: "X-Idempotency-Key")
|
||||||
|
request.httpBody = body
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Brings the watch's packing list and to-dos up to date while the app is in the
|
||||||
|
/// background, woken by the server's silent push (WatchSyncPushService in TREK):
|
||||||
|
/// reads both lists of the trip the watch shows from the server and puts them
|
||||||
|
/// into the snapshot the watch has, built the way the UI builds them
|
||||||
|
/// (watchPacking and watchTodos in client/src/native/watch.ts). Everything else
|
||||||
|
/// in the snapshot stays as the UI last made it. In front, the UI does this
|
||||||
|
/// itself as soon as the lists change, so nothing is done here then.
|
||||||
|
enum TrekWatchRefresher {
|
||||||
|
private static let maxName = 80
|
||||||
|
private static let maxGroup = 40
|
||||||
|
/// Below what WatchConnectivity carries in one application context.
|
||||||
|
private static let maxBytes = 55_000
|
||||||
|
|
||||||
|
static func refresh(completion: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||||
|
guard TrekWatchLink.isAvailable, UIApplication.shared.applicationState != .active,
|
||||||
|
let stored = TrekWatchLink.shared.storedSnapshot(),
|
||||||
|
var snapshot = (try? JSONSerialization.jsonObject(with: stored)) as? [String: Any],
|
||||||
|
let trip = snapshot["trip"] as? [String: Any], let tripId = trip["id"] as? Int,
|
||||||
|
let packingURL = TrekWatchWriter.url(["trips", String(tripId), "packing"]),
|
||||||
|
let todoURL = TrekWatchWriter.url(["trips", String(tripId), "todo"]) else {
|
||||||
|
return completion(.noData)
|
||||||
|
}
|
||||||
|
let group = DispatchGroup()
|
||||||
|
var packing: [[String: Any]]?
|
||||||
|
var todos: [[String: Any]]?
|
||||||
|
group.enter()
|
||||||
|
items(at: packingURL) { list in
|
||||||
|
packing = list
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
group.enter()
|
||||||
|
items(at: todoURL) { list in
|
||||||
|
todos = list
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
group.notify(queue: .main) {
|
||||||
|
guard let packing, let todos else { return completion(.failed) }
|
||||||
|
snapshot["packing"] = packingList(packing)
|
||||||
|
snapshot["todos"] = todoList(todos)
|
||||||
|
snapshot["generatedAt"] = ISO8601DateFormatter().string(from: Date())
|
||||||
|
guard let data = fitted(snapshot) else { return completion(.failed) }
|
||||||
|
TrekWatchLink.shared.publish(data)
|
||||||
|
completion(.newData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `items` of a list endpoint, on the main queue; nil when it could not be read.
|
||||||
|
private static func items(at url: URL, then completion: @escaping ([[String: Any]]?) -> Void) {
|
||||||
|
var request = URLRequest(url: url, timeoutInterval: 10)
|
||||||
|
request.httpShouldHandleCookies = false
|
||||||
|
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
||||||
|
TrekWatchWriter.perform(request) { data, ok in
|
||||||
|
var list: [[String: Any]]?
|
||||||
|
if ok, let data, let body = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any] {
|
||||||
|
list = body["items"] as? [[String: Any]]
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async { completion(list) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func done(_ item: [String: Any]) -> Bool {
|
||||||
|
(item["checked"] as? Bool) ?? ((item["checked"] as? Int).map { $0 != 0 } ?? false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func trimmed(_ value: Any?, _ max: Int) -> String? {
|
||||||
|
guard let text = (value as? String)?.trimmingCharacters(in: .whitespacesAndNewlines), !text.isEmpty else { return nil }
|
||||||
|
return String(text.prefix(max))
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func entry(_ item: [String: Any]) -> [String: Any]? {
|
||||||
|
guard let id = item["id"] as? Int, let name = item["name"] as? String else { return nil }
|
||||||
|
var out: [String: Any] = ["id": id, "name": String(name.prefix(maxName)), "done": done(item)]
|
||||||
|
if let group = trimmed(item["category"], maxGroup) { out["group"] = group }
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Unpacked first, then packed, each in the list's own order.
|
||||||
|
static func packingList(_ items: [[String: Any]]) -> Any {
|
||||||
|
guard !items.isEmpty else { return NSNull() }
|
||||||
|
let sorted = items.sorted {
|
||||||
|
let (a, b) = (done($0) ? 1 : 0, done($1) ? 1 : 0)
|
||||||
|
return a != b ? a < b : (($0["sort_order"] as? Int) ?? 0) < (($1["sort_order"] as? Int) ?? 0)
|
||||||
|
}
|
||||||
|
let packed = items.filter { done($0) }.count
|
||||||
|
return ["items": sorted.compactMap(entry), "packed": packed, "total": items.count]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Open ones first by due date (undated last) and priority, then the done ones.
|
||||||
|
static func todoList(_ items: [[String: Any]]) -> Any {
|
||||||
|
guard !items.isEmpty else { return NSNull() }
|
||||||
|
let due = { (item: [String: Any]) -> String? in trimmed(item["due_date"], 10) }
|
||||||
|
let sorted = items.sorted { a, b in
|
||||||
|
if done(a) != done(b) { return !done(a) }
|
||||||
|
if (due(a) == nil) != (due(b) == nil) { return due(a) != nil }
|
||||||
|
if let da = due(a), let db = due(b), da != db { return da < db }
|
||||||
|
let (pa, pb) = ((a["priority"] as? Int) ?? 0, (b["priority"] as? Int) ?? 0)
|
||||||
|
if pa != pb { return pa > pb }
|
||||||
|
return ((a["sort_order"] as? Int) ?? 0) < ((b["sort_order"] as? Int) ?? 0)
|
||||||
|
}
|
||||||
|
let rows = sorted.compactMap { item -> [String: Any]? in
|
||||||
|
guard var row = entry(item) else { return nil }
|
||||||
|
if let date = due(item) { row["due"] = date }
|
||||||
|
if let priority = item["priority"] as? Int, priority > 0 { row["priority"] = min(3, priority) }
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
return ["items": rows, "open": items.filter { !done($0) }.count, "total": items.count]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The snapshot as JSON within the size the watch takes: done items go first, as on the UI's side.
|
||||||
|
private static func fitted(_ snapshot: [String: Any]) -> Data? {
|
||||||
|
var object = snapshot
|
||||||
|
// A list that is now empty leaves the snapshot, as the UI leaves it out.
|
||||||
|
for key in ["packing", "todos"] where object[key] is NSNull { object.removeValue(forKey: key) }
|
||||||
|
guard var data = try? JSONSerialization.data(withJSONObject: object) else { return nil }
|
||||||
|
if data.count > maxBytes {
|
||||||
|
for key in ["packing", "todos"] {
|
||||||
|
guard var list = object[key] as? [String: Any], let items = list["items"] as? [[String: Any]] else { continue }
|
||||||
|
list["items"] = items.filter { ($0["done"] as? Bool) != true }
|
||||||
|
object[key] = list
|
||||||
|
}
|
||||||
|
data = (try? JSONSerialization.data(withJSONObject: object)) ?? data
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,9 @@ let package = Package(
|
|||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.5.2"),
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.5.2"),
|
||||||
|
.package(name: "CapacitorActionSheet", path: "../../../../node_modules/@capacitor/action-sheet"),
|
||||||
.package(name: "CapacitorApp", path: "../../../../node_modules/@capacitor/app"),
|
.package(name: "CapacitorApp", path: "../../../../node_modules/@capacitor/app"),
|
||||||
|
.package(name: "CapacitorDialog", path: "../../../../node_modules/@capacitor/dialog"),
|
||||||
.package(name: "CapacitorFilesystem", path: "../../../../node_modules/@capacitor/filesystem"),
|
.package(name: "CapacitorFilesystem", path: "../../../../node_modules/@capacitor/filesystem"),
|
||||||
.package(name: "CapacitorHaptics", path: "../../../../node_modules/@capacitor/haptics"),
|
.package(name: "CapacitorHaptics", path: "../../../../node_modules/@capacitor/haptics"),
|
||||||
.package(name: "CapacitorKeyboard", path: "../../../../node_modules/@capacitor/keyboard"),
|
.package(name: "CapacitorKeyboard", path: "../../../../node_modules/@capacitor/keyboard"),
|
||||||
@@ -26,7 +28,9 @@ let package = Package(
|
|||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
||||||
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
||||||
|
.product(name: "CapacitorActionSheet", package: "CapacitorActionSheet"),
|
||||||
.product(name: "CapacitorApp", package: "CapacitorApp"),
|
.product(name: "CapacitorApp", package: "CapacitorApp"),
|
||||||
|
.product(name: "CapacitorDialog", package: "CapacitorDialog"),
|
||||||
.product(name: "CapacitorFilesystem", package: "CapacitorFilesystem"),
|
.product(name: "CapacitorFilesystem", package: "CapacitorFilesystem"),
|
||||||
.product(name: "CapacitorHaptics", package: "CapacitorHaptics"),
|
.product(name: "CapacitorHaptics", package: "CapacitorHaptics"),
|
||||||
.product(name: "CapacitorKeyboard", package: "CapacitorKeyboard"),
|
.product(name: "CapacitorKeyboard", package: "CapacitorKeyboard"),
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ enum ShareHandoff {
|
|||||||
static func store(_ item: ShareItem, tripId: Int?) -> Bool {
|
static func store(_ item: ShareItem, tripId: Int?) -> Bool {
|
||||||
var meta: [String: Any] = ["name": item.name, "mimeType": item.mimeType]
|
var meta: [String: Any] = ["name": item.name, "mimeType": item.mimeType]
|
||||||
if let tripId { meta["tripId"] = tripId }
|
if let tripId { meta["tripId"] = tripId }
|
||||||
|
if let url = item.url {
|
||||||
|
meta["url"] = url
|
||||||
|
meta["title"] = item.title
|
||||||
|
}
|
||||||
guard let metaData = try? JSONSerialization.data(withJSONObject: meta) else { return false }
|
guard let metaData = try? JSONSerialization.data(withJSONObject: meta) else { return false }
|
||||||
return write(dataAccount, item.data) && write(metaAccount, metaData)
|
return write(dataAccount, item.data) && write(metaAccount, metaData)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ struct ShareItem {
|
|||||||
var title: String
|
var title: String
|
||||||
/// A host, for a page.
|
/// A host, for a page.
|
||||||
var source: String?
|
var source: String?
|
||||||
|
/// The web address it came from, when it is a page or a link: the app offers to
|
||||||
|
/// keep it among the trip's links as well as to read a booking out of it.
|
||||||
|
var url: String? = nil
|
||||||
|
|
||||||
var sizeLabel: String {
|
var sizeLabel: String {
|
||||||
ByteCountFormatter.string(fromByteCount: Int64(data.count), countStyle: .file)
|
ByteCountFormatter.string(fromByteCount: Int64(data.count), countStyle: .file)
|
||||||
@@ -88,6 +91,10 @@ enum ShareLoader {
|
|||||||
let text = (item as? String) ?? (item as? Data).flatMap { String(data: $0, encoding: .utf8) } ?? ""
|
let text = (item as? String) ?? (item as? Data).flatMap { String(data: $0, encoding: .utf8) } ?? ""
|
||||||
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
guard !trimmed.isEmpty else { throw ShareLoadError.unsupported }
|
guard !trimmed.isEmpty else { throw ShareLoadError.unsupported }
|
||||||
|
// A text that is just a link (what many apps share) is that link.
|
||||||
|
if !trimmed.contains(where: \.isWhitespace), let url = URL(string: trimmed), webAddress(url) != nil {
|
||||||
|
return try await page(at: url)
|
||||||
|
}
|
||||||
let firstLine = trimmed.split(whereSeparator: \.isNewline).first.map(String.init) ?? trimmed
|
let firstLine = trimmed.split(whereSeparator: \.isNewline).first.map(String.init) ?? trimmed
|
||||||
return try checked(ShareItem(kind: .text, name: "shared-text.txt", mimeType: "text/plain",
|
return try checked(ShareItem(kind: .text, name: "shared-text.txt", mimeType: "text/plain",
|
||||||
data: Data(trimmed.utf8), title: String(firstLine.prefix(80)), source: nil))
|
data: Data(trimmed.utf8), title: String(firstLine.prefix(80)), source: nil))
|
||||||
@@ -133,21 +140,39 @@ enum ShareLoader {
|
|||||||
let url = (results["url"] as? String).flatMap(URL.init(string:))
|
let url = (results["url"] as? String).flatMap(URL.init(string:))
|
||||||
let title = (results["title"] as? String).flatMap { $0.isEmpty ? nil : $0 } ?? url?.host ?? "Page"
|
let title = (results["title"] as? String).flatMap { $0.isEmpty ? nil : $0 } ?? url?.host ?? "Page"
|
||||||
return try checked(ShareItem(kind: .page, name: "\(slug(title)).html", mimeType: "text/html",
|
return try checked(ShareItem(kind: .page, name: "\(slug(title)).html", mimeType: "text/html",
|
||||||
data: Data(html.utf8), title: title, source: url?.host))
|
data: Data(html.utf8), title: title, source: url?.host,
|
||||||
|
url: url.flatMap(webAddress)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A link shared from an app other than Safari: the page as the server sends it.
|
/// A link shared from an app other than Safari: the page as the server sends it,
|
||||||
|
/// or the bare link when the page cannot be read (a sign-in wall, an app-only
|
||||||
|
/// page, no network), which the app can still keep among the trip's links.
|
||||||
private static func page(at url: URL) async throws -> ShareItem {
|
private static func page(at url: URL) async throws -> ShareItem {
|
||||||
guard url.scheme == "https" || url.scheme == "http" else { throw ShareLoadError.unsupported }
|
guard let address = webAddress(url) else { throw ShareLoadError.unsupported }
|
||||||
var request = URLRequest(url: url, timeoutInterval: 10)
|
var request = URLRequest(url: url, timeoutInterval: 10)
|
||||||
request.setValue("text/html", forHTTPHeaderField: "Accept")
|
request.setValue("text/html", forHTTPHeaderField: "Accept")
|
||||||
let (data, response) = try await URLSession.shared.data(for: request)
|
if let fetched = try? await URLSession.shared.data(for: request),
|
||||||
guard let http = response as? HTTPURLResponse, (200..<300).contains(http.statusCode),
|
let http = fetched.1 as? HTTPURLResponse, (200..<300).contains(http.statusCode),
|
||||||
(http.mimeType ?? "").contains("html") else { throw ShareLoadError.unsupported }
|
(http.mimeType ?? "").contains("html"), !fetched.0.isEmpty, fetched.0.count <= maxBytes {
|
||||||
let html = String(decoding: data, as: UTF8.self)
|
let data = fetched.0
|
||||||
let title = pageTitle(html) ?? url.host ?? "Page"
|
let html = String(decoding: data, as: UTF8.self)
|
||||||
return try checked(ShareItem(kind: .page, name: "\(slug(title)).html", mimeType: "text/html",
|
let title = pageTitle(html) ?? url.host ?? "Page"
|
||||||
data: data, title: title, source: url.host))
|
return ShareItem(kind: .page, name: "\(slug(title)).html", mimeType: "text/html",
|
||||||
|
data: data, title: title, source: url.host, url: address)
|
||||||
|
}
|
||||||
|
return link(url, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The link alone, as a text/uri-list the app recognises as nothing to read a booking from.
|
||||||
|
private static func link(_ url: URL, _ address: String) -> ShareItem {
|
||||||
|
ShareItem(kind: .page, name: "link.url", mimeType: "text/uri-list", data: Data(address.utf8),
|
||||||
|
title: url.host ?? address, source: url.host, url: address)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An http(s) address, the only kind a trip's links take.
|
||||||
|
private static func webAddress(_ url: URL) -> String? {
|
||||||
|
guard url.scheme == "https" || url.scheme == "http", url.host != nil else { return nil }
|
||||||
|
return url.absoluteString
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func fromFile(_ url: URL) throws -> ShareItem {
|
private static func fromFile(_ url: URL) throws -> ShareItem {
|
||||||
|
|||||||
@@ -6,16 +6,24 @@ import SwiftUI
|
|||||||
struct ShareView: View {
|
struct ShareView: View {
|
||||||
@ObservedObject var model: ShareModel
|
@ObservedObject var model: ShareModel
|
||||||
@Environment(\.colorScheme) private var scheme
|
@Environment(\.colorScheme) private var scheme
|
||||||
|
@Environment(\.horizontalSizeClass) private var widthClass
|
||||||
@State private var shown = false
|
@State private var shown = false
|
||||||
|
|
||||||
|
/// An iPad window of regular width: the card stands centred over the dimmed
|
||||||
|
/// app, as a form does there, instead of rising from the bottom edge. A
|
||||||
|
/// narrow Split View or Slide Over window keeps the iPhone's bottom card.
|
||||||
|
private var centred: Bool { widthClass == .regular }
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack(alignment: .bottom) {
|
ZStack(alignment: centred ? .center : .bottom) {
|
||||||
Color.black.opacity(shown ? 0.28 : 0)
|
Color.black.opacity(shown ? (centred ? 0.36 : 0.28) : 0)
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
.onTapGesture { dismiss() }
|
.onTapGesture { dismiss() }
|
||||||
|
|
||||||
card
|
card
|
||||||
.offset(y: shown ? 0 : 520)
|
.offset(y: shown ? 0 : (centred ? 40 : 520))
|
||||||
|
.opacity(centred && !shown ? 0 : 1)
|
||||||
|
.padding(.vertical, centred ? 24 : 0)
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
withAnimation(.spring(response: 0.5, dampingFraction: 0.86)) { shown = true }
|
withAnimation(.spring(response: 0.5, dampingFraction: 0.86)) { shown = true }
|
||||||
@@ -31,14 +39,17 @@ struct ShareView: View {
|
|||||||
|
|
||||||
private var card: some View {
|
private var card: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
Capsule()
|
// The grabber belongs to a card that rises from the bottom edge.
|
||||||
.fill(ShareStyle.faint(scheme).opacity(0.5))
|
if !centred {
|
||||||
.frame(width: 38, height: 5)
|
Capsule()
|
||||||
.padding(.top, 8)
|
.fill(ShareStyle.faint(scheme).opacity(0.5))
|
||||||
|
.frame(width: 38, height: 5)
|
||||||
|
.padding(.top, 8)
|
||||||
|
}
|
||||||
|
|
||||||
header
|
header
|
||||||
.padding(.horizontal, 20)
|
.padding(.horizontal, 20)
|
||||||
.padding(.top, 14)
|
.padding(.top, centred ? 22 : 14)
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
switch model.phase {
|
switch model.phase {
|
||||||
@@ -50,7 +61,7 @@ struct ShareView: View {
|
|||||||
}
|
}
|
||||||
.padding(.top, 16)
|
.padding(.top, 16)
|
||||||
}
|
}
|
||||||
.padding(.bottom, 12)
|
.padding(.bottom, centred ? 20 : 12)
|
||||||
.frame(maxWidth: 560)
|
.frame(maxWidth: 560)
|
||||||
.background(
|
.background(
|
||||||
RoundedRectangle(cornerRadius: 32, style: .continuous)
|
RoundedRectangle(cornerRadius: 32, style: .continuous)
|
||||||
@@ -60,9 +71,9 @@ struct ShareView: View {
|
|||||||
.strokeBorder(ShareStyle.edge(scheme), lineWidth: 1)
|
.strokeBorder(ShareStyle.edge(scheme), lineWidth: 1)
|
||||||
)
|
)
|
||||||
.shadow(color: .black.opacity(0.25), radius: 30, y: 10)
|
.shadow(color: .black.opacity(0.25), radius: 30, y: 10)
|
||||||
.ignoresSafeArea(edges: .bottom)
|
.ignoresSafeArea(edges: centred ? [] : .bottom)
|
||||||
)
|
)
|
||||||
.padding(.horizontal, 6)
|
.padding(.horizontal, centred ? 24 : 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var header: some View {
|
private var header: some View {
|
||||||
|
|||||||
@@ -9,6 +9,24 @@ import UIKit
|
|||||||
final class ShareViewController: UIViewController {
|
final class ShareViewController: UIViewController {
|
||||||
private let model = ShareModel()
|
private let model = ShareModel()
|
||||||
|
|
||||||
|
// On an iPad the system would put the extension in a form sheet, a box in the
|
||||||
|
// middle of the screen with this sheet's own dimming and card inside it. Over
|
||||||
|
// the full screen instead, the card stands centred over the app that shared,
|
||||||
|
// the way an iPad presents a small form.
|
||||||
|
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||||
|
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||||
|
presentOverFullScreenOnPad()
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
super.init(coder: coder)
|
||||||
|
presentOverFullScreenOnPad()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func presentOverFullScreenOnPad() {
|
||||||
|
if UIDevice.current.userInterfaceIdiom == .pad { modalPresentationStyle = .overFullScreen }
|
||||||
|
}
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
view.backgroundColor = .clear
|
view.backgroundColor = .clear
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"colors": [
|
||||||
|
{
|
||||||
|
"color": {
|
||||||
|
"color-space": "srgb",
|
||||||
|
"components": { "alpha": "1.000", "blue": "1.000", "green": "1.000", "red": "1.000" }
|
||||||
|
},
|
||||||
|
"idiom": "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info": {
|
||||||
|
"author": "xcode",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user