Compare commits
766 Commits
create-pul
...
create-pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f974bf8b74 | ||
|
|
f3e5c74154 | ||
|
|
05a06eea27 | ||
|
|
663d7f3354 | ||
|
|
dbe5b88b52 | ||
|
|
c839fffadb | ||
|
|
8edfe53b45 | ||
|
|
0153fc54f1 | ||
|
|
f6b0af153f | ||
|
|
cfefce1baf | ||
|
|
ff1683d5b4 | ||
|
|
e181a866f7 | ||
|
|
1571d5766c | ||
|
|
1a4582adae | ||
|
|
88335b970f | ||
|
|
cac2dffb6c | ||
|
|
8a868e17bc | ||
|
|
1d05e96690 | ||
|
|
1d315d530f | ||
|
|
597fefa9c9 | ||
|
|
764834bbae | ||
|
|
582cfb4cf0 | ||
|
|
998fb16a03 | ||
|
|
40dd95f9c2 | ||
|
|
a27a6733e8 | ||
|
|
c76de152fc | ||
|
|
d0d75a4f50 | ||
|
|
df42111f83 | ||
|
|
da52a3685f | ||
|
|
bd85711e7f | ||
|
|
a02bf3e05c | ||
|
|
a397199834 | ||
|
|
27c16c2faf | ||
|
|
131004494b | ||
|
|
777bde7b5e | ||
|
|
3ba8f36108 | ||
|
|
773a0fa6d4 | ||
|
|
e88a537aec | ||
|
|
6ac60f9546 | ||
|
|
6fd6379ef3 | ||
|
|
2a4949a505 | ||
|
|
386a24305d | ||
|
|
45c4b89a4d | ||
|
|
73ea525d8b | ||
|
|
2ab267f601 | ||
|
|
ae54e91382 | ||
|
|
45c082fba9 | ||
|
|
aeedd9c3ac | ||
|
|
e76e4f42f2 | ||
|
|
f68a1f1c86 | ||
|
|
45a07d361c | ||
|
|
b786fd60b4 | ||
|
|
66646758a8 | ||
|
|
ece309fbde | ||
|
|
99c472330f | ||
|
|
246d5b5e4c | ||
|
|
8a8b243012 | ||
|
|
4612473e62 | ||
|
|
ab94e05e91 | ||
|
|
d2ecad5c3f | ||
|
|
a4c9d5a345 | ||
|
|
5b30a11da3 | ||
|
|
bda159a343 | ||
|
|
f473d31f13 | ||
|
|
1afe181085 | ||
|
|
647b7185df | ||
|
|
f301726a02 | ||
|
|
819be647b5 | ||
|
|
6215972732 | ||
|
|
90e406c30e | ||
|
|
d7a5a47393 | ||
|
|
8bacd4d1f5 | ||
|
|
a4d9ef0cb1 | ||
|
|
8bed9c753b | ||
|
|
47e598ede1 | ||
|
|
7edd41b08f | ||
|
|
a00dd69005 | ||
|
|
201c2b5964 | ||
|
|
5329a69e4d | ||
|
|
7ab0ffa0a3 | ||
|
|
33471e91be | ||
|
|
129bffe4b7 | ||
|
|
3f3a9ac807 | ||
|
|
c702efbd1e | ||
|
|
088098edad | ||
|
|
1e3e3c0e2e | ||
|
|
d9781e207c | ||
|
|
4a83c21d0d | ||
|
|
5d592e253b | ||
|
|
820091b8fa | ||
|
|
40c5eab3c5 | ||
|
|
c133fcf08a | ||
|
|
8094b7cc47 | ||
|
|
abd8716b56 | ||
|
|
cecad8351e | ||
|
|
4d1af69ed8 | ||
|
|
f468c06801 | ||
|
|
a0ef9b8d1b | ||
|
|
27f1f6f179 | ||
|
|
6ea1120517 | ||
|
|
2f7c44cbbe | ||
|
|
dd866a0f2b | ||
|
|
889d1beab4 | ||
|
|
357052ee42 | ||
|
|
19eda065ba | ||
|
|
5279c5c3b2 | ||
|
|
17be4e739f | ||
|
|
f2dd2e4d7e | ||
|
|
7c6ce077c1 | ||
|
|
45bf552eff | ||
|
|
633d412b52 | ||
|
|
54b8fb2d78 | ||
|
|
443e9f110b | ||
|
|
ac80bed084 | ||
|
|
802717c7a4 | ||
|
|
68b931f3b5 | ||
|
|
d4a4067754 | ||
|
|
ca18cfd6d1 | ||
|
|
18d80d2a4a | ||
|
|
ba4b9e4234 | ||
|
|
b87d531069 | ||
|
|
5cbb2505e3 | ||
|
|
e500a13c7e | ||
|
|
a4e9333c6e | ||
|
|
9dbe39e1a4 | ||
|
|
13c78eaee5 | ||
|
|
ef0e36b8be | ||
|
|
a1351563c1 | ||
|
|
303b40e572 | ||
|
|
622ea37554 | ||
|
|
8a80d16f11 | ||
|
|
4ea515c342 | ||
|
|
ce3dbaf902 | ||
|
|
a429b858e2 | ||
|
|
d8d228aa67 | ||
|
|
b31785a705 | ||
|
|
48b5e9f775 | ||
|
|
150ef5982a | ||
|
|
f91b94d100 | ||
|
|
6f25cc416f | ||
|
|
8358e982f9 | ||
|
|
637fdeebe6 | ||
|
|
96cf5274b1 | ||
|
|
1df5772857 | ||
|
|
44690dae55 | ||
|
|
ff46db7ac2 | ||
|
|
8f03595683 | ||
|
|
ac7494d08d | ||
|
|
e6ae0dab30 | ||
|
|
bc7da41da4 | ||
|
|
2fc5216cf1 | ||
|
|
8a792481b6 | ||
|
|
53e4e6b675 | ||
|
|
f06d338c5a | ||
|
|
fef65bd5d2 | ||
|
|
b830040639 | ||
|
|
2662178bef | ||
|
|
2a15ba9fe4 | ||
|
|
f777491dcd | ||
|
|
81445a21ff | ||
|
|
ff410542fb | ||
|
|
343e10f433 | ||
|
|
8023372a03 | ||
|
|
cd999f2346 | ||
|
|
4272d48fbf | ||
|
|
ae40737b75 | ||
|
|
4fe55be866 | ||
|
|
c5c4cf615f | ||
|
|
44e542ed5a | ||
|
|
bc2be8d33c | ||
|
|
73ed0edab7 | ||
|
|
a34a091cdb | ||
|
|
4f3d162d7a | ||
|
|
99605d7d18 | ||
|
|
fa152510a6 | ||
|
|
ddc868894e | ||
|
|
0a65fb607a | ||
|
|
921c76459c | ||
|
|
abf1ad61d6 | ||
|
|
fbcc2ef4fe | ||
|
|
699e7ce489 | ||
|
|
a45588abee | ||
|
|
44d5095101 | ||
|
|
b0b6de9a7d | ||
|
|
6b13e83146 | ||
|
|
cbac67728e | ||
|
|
400f4d20c1 | ||
|
|
3288b4602a | ||
|
|
74dec728ad | ||
|
|
aa72663440 | ||
|
|
f2fa6ed96d | ||
|
|
9b8e78a264 | ||
|
|
0e442beed5 | ||
|
|
ff1d38d159 | ||
|
|
5f8c8048e6 | ||
|
|
dc6d951241 | ||
|
|
9037ae0d53 | ||
|
|
83e7aa61fa | ||
|
|
11030b1e6a | ||
|
|
2f37e2a9c7 | ||
|
|
fcf891647c | ||
|
|
8465131d41 | ||
|
|
a33656d43b | ||
|
|
52397ab340 | ||
|
|
930a730252 | ||
|
|
37a707ba1d | ||
|
|
d9e4f58687 | ||
|
|
98bbca85b2 | ||
|
|
0f9aac76e2 | ||
|
|
7c933f888c | ||
|
|
9ae02ddb15 | ||
|
|
8333dd0d0c | ||
|
|
c21159c571 | ||
|
|
81db39d4e1 | ||
|
|
3e77ab6845 | ||
|
|
562ae9cd56 | ||
|
|
cb321ffdb8 | ||
|
|
a8d654b8d5 | ||
|
|
b2806cd000 | ||
|
|
d4166f681d | ||
|
|
19829be16a | ||
|
|
666ee288c3 | ||
|
|
2a8b5f983f | ||
|
|
adf8ae9878 | ||
|
|
7a6bee4a13 | ||
|
|
4a05031e42 | ||
|
|
8c86cc3c1a | ||
|
|
5205011610 | ||
|
|
f689cb6a8e | ||
|
|
412215603e | ||
|
|
97c34f8ae6 | ||
|
|
6563bc1b70 | ||
|
|
205bda34ae | ||
|
|
663f68fff9 | ||
|
|
dc9f4fafde | ||
|
|
6651aff962 | ||
|
|
55a6dfafed | ||
|
|
a6bf282db5 | ||
|
|
63bd0edb10 | ||
|
|
9f2adf4691 | ||
|
|
d36b95d275 | ||
|
|
c7fdd63d7d | ||
|
|
412077e2ab | ||
|
|
0f1005c193 | ||
|
|
7353414ae6 | ||
|
|
894a3dd44f | ||
|
|
4b86f3e822 | ||
|
|
b6077e1dd6 | ||
|
|
267efb8905 | ||
|
|
9412a70517 | ||
|
|
de754acf92 | ||
|
|
fce7bf9cd0 | ||
|
|
6f335d44a0 | ||
|
|
2fa6af7de9 | ||
|
|
4b9dfc9e0c | ||
|
|
3ead1ab079 | ||
|
|
ff5ffed8aa | ||
|
|
d047c38bc2 | ||
|
|
52b62b1075 | ||
|
|
ad384af7e4 | ||
|
|
06b3ec09be | ||
|
|
c803c5be8b | ||
|
|
f120a00a75 | ||
|
|
99a244ae2e | ||
|
|
713af1aeaa | ||
|
|
1cc7ac3f4d | ||
|
|
dfee86186a | ||
|
|
d82574136a | ||
|
|
766f953e65 | ||
|
|
593a4098a5 | ||
|
|
ecfc29feb9 | ||
|
|
84ce92cebc | ||
|
|
489a2eb037 | ||
|
|
e48e0233bb | ||
|
|
b67471df92 | ||
|
|
be727462ee | ||
|
|
ed72b41527 | ||
|
|
309980836a | ||
|
|
fb3ab11700 | ||
|
|
ccbcc8b736 | ||
|
|
7fcfcf7bdb | ||
|
|
f7231a3ac5 | ||
|
|
c4ae77123d | ||
|
|
81c6874aff | ||
|
|
de05560297 | ||
|
|
816a3b2f2c | ||
|
|
c8af3fe35e | ||
|
|
f3448d06c1 | ||
|
|
3442cf3a35 | ||
|
|
03115c0de1 | ||
|
|
9f5f7f0dd8 | ||
|
|
4901a6b183 | ||
|
|
f2372c40aa | ||
|
|
3f1c0695b8 | ||
|
|
fd9991ceb1 | ||
|
|
2628a9856b | ||
|
|
c1f3fae50b | ||
|
|
2d5cd25696 | ||
|
|
dc8b7d6ae4 | ||
|
|
a2211947cd | ||
|
|
db2617e2d4 | ||
|
|
412f48d801 | ||
|
|
bd7bf7ddbe | ||
|
|
e7a99ad7b6 | ||
|
|
8fce04cf45 | ||
|
|
62f2545f9e | ||
|
|
d22e0bd5e5 | ||
|
|
61d206f318 | ||
|
|
7bfef398c3 | ||
|
|
2311acc15e | ||
|
|
14787cc520 | ||
|
|
7b57b603aa | ||
|
|
185f6d1a5f | ||
|
|
791cf7224e | ||
|
|
8cab9a4204 | ||
|
|
42a8efd5e5 | ||
|
|
85e171ae4a | ||
|
|
18d5438c38 | ||
|
|
0f311d1901 | ||
|
|
5f33679ddd | ||
|
|
ce0fab5b38 | ||
|
|
d6ba49add5 | ||
|
|
2dcb561882 | ||
|
|
25153d98e7 | ||
|
|
ee90044a59 | ||
|
|
4a0a23a8f7 | ||
|
|
09d5b68baf | ||
|
|
402a5ef044 | ||
|
|
31fd642295 | ||
|
|
68dc947c4c | ||
|
|
4daa00111b | ||
|
|
b6e00fa096 | ||
|
|
3cf5910e62 | ||
|
|
681d0744d4 | ||
|
|
c19d6dd2f2 | ||
|
|
35b81437f8 | ||
|
|
f1403e6fce | ||
|
|
7f12530b8e | ||
|
|
850209c00b | ||
|
|
72e7b8127a | ||
|
|
db2808fa94 | ||
|
|
d9c3509bbc | ||
|
|
231b17d955 | ||
|
|
310a1266a5 | ||
|
|
407e7293af | ||
|
|
577ab84020 | ||
|
|
650cf559ba | ||
|
|
b3b53cd25a | ||
|
|
160456d21c | ||
|
|
37b5ed2c24 | ||
|
|
5c410d4817 | ||
|
|
940ba85e3d | ||
|
|
92508bdd2b | ||
|
|
235cbce123 | ||
|
|
060cfa75bf | ||
|
|
329770576e | ||
|
|
4881212adb | ||
|
|
5b7ed3f4e5 | ||
|
|
bdd6bc3923 | ||
|
|
1d5d5419dc | ||
|
|
196051dc82 | ||
|
|
4962701224 | ||
|
|
a74c801977 | ||
|
|
409f35719d | ||
|
|
f761ae6c3e | ||
|
|
d56f1eb2a3 | ||
|
|
23907a558d | ||
|
|
6b77aff18f | ||
|
|
b66383e9ab | ||
|
|
863316d7b4 | ||
|
|
33d5632b6d | ||
|
|
67d8ae2d90 | ||
|
|
c933b76a8c | ||
|
|
9d12123f71 | ||
|
|
beff5e0aa4 | ||
|
|
d61da3e499 | ||
|
|
8419122193 | ||
|
|
20559d1506 | ||
|
|
5e3de19e7b | ||
|
|
2463599ba2 | ||
|
|
ea90d26a0a | ||
|
|
8339de2596 | ||
|
|
e283d3abd8 | ||
|
|
b8980e3708 | ||
|
|
2d306a2046 | ||
|
|
fe79e03fb3 | ||
|
|
e938c29601 | ||
|
|
45d76468dc | ||
|
|
d8aab4f956 | ||
|
|
7084420781 | ||
|
|
b4b90cdf48 | ||
|
|
e899d902f7 | ||
|
|
e04fead496 | ||
|
|
4d5c4bfc6e | ||
|
|
6779693213 | ||
|
|
f2db558eaf | ||
|
|
cecf0bf1bc | ||
|
|
9110d3cc17 | ||
|
|
032380e872 | ||
|
|
53ea1741c0 | ||
|
|
51e75f61ec | ||
|
|
a590e6dca1 | ||
|
|
e25128947c | ||
|
|
da6c81595c | ||
|
|
1fc5a1e04a | ||
|
|
faa5946c15 | ||
|
|
d35911724c | ||
|
|
2acd9d87f4 | ||
|
|
43c2e3e78a | ||
|
|
1ea3dc77f0 | ||
|
|
eeb27dc169 | ||
|
|
7cc09e4a0d | ||
|
|
8ca0bcd97c | ||
|
|
8bfdef6f9c | ||
|
|
e7155a55bd | ||
|
|
0405a96710 | ||
|
|
a4a988393c | ||
|
|
155d732ec7 | ||
|
|
c07eefd48f | ||
|
|
edf4a67590 | ||
|
|
442072641a | ||
|
|
7719ece810 | ||
|
|
6de0473582 | ||
|
|
4da1d3d1c3 | ||
|
|
4a70c1f6c9 | ||
|
|
873d7e3cd1 | ||
|
|
fce8f6cdb9 | ||
|
|
207781fa58 | ||
|
|
3aae958a1b | ||
|
|
65b699564e | ||
|
|
acf7314f6c | ||
|
|
8b394cc644 | ||
|
|
a1385be797 | ||
|
|
cf9249b97e | ||
|
|
91f953915d | ||
|
|
f6263e6cf5 | ||
|
|
e48ff4d6a3 | ||
|
|
a93ee35c9b | ||
|
|
6b561d00f3 | ||
|
|
ffd9b9c097 | ||
|
|
4b4d7f537d | ||
|
|
58bad96b2e | ||
|
|
67701840bb | ||
|
|
d936209b0e | ||
|
|
14f7116aad | ||
|
|
132844f6ce | ||
|
|
a50789a7e9 | ||
|
|
513e3d97f6 | ||
|
|
58f1944268 | ||
|
|
aa75c22328 | ||
|
|
3b72ada8d0 | ||
|
|
a65131bdf6 | ||
|
|
b9622d3da9 | ||
|
|
234bb86d7e | ||
|
|
b6243a1f2f | ||
|
|
5f01eef75a | ||
|
|
9c43752134 | ||
|
|
e7d965576f | ||
|
|
2111357c7d | ||
|
|
37c7f88f82 | ||
|
|
15b466c9a6 | ||
|
|
42a0e5abd8 | ||
|
|
feb217f1ba | ||
|
|
c5e56ca27d | ||
|
|
6ccfdaef83 | ||
|
|
081c0b8507 | ||
|
|
351ee7caed | ||
|
|
7fb3c73877 | ||
|
|
b1102fbcc0 | ||
|
|
b9a5032b15 | ||
|
|
d6e52e17ee | ||
|
|
fc25082a9a | ||
|
|
7625d783f3 | ||
|
|
f61c9adf61 | ||
|
|
cba8d637f5 | ||
|
|
79853e597b | ||
|
|
dd69182347 | ||
|
|
e5fb836131 | ||
|
|
2026c4e171 | ||
|
|
ac8e89d65f | ||
|
|
2f97628c52 | ||
|
|
59d373aa74 | ||
|
|
742e8799f1 | ||
|
|
bbbda9bd1d | ||
|
|
8ad1f044fd | ||
|
|
59d6c047ed | ||
|
|
bccba88ad0 | ||
|
|
c6486e4f25 | ||
|
|
047f9df218 | ||
|
|
e8ab75ec77 | ||
|
|
a1bd671ed4 | ||
|
|
a458065e4f | ||
|
|
1e48191431 | ||
|
|
b05432446f | ||
|
|
9449639014 | ||
|
|
fe1d53b2ee | ||
|
|
62f6d17e43 | ||
|
|
a3d96a6dcf | ||
|
|
c5df55d5ae | ||
|
|
447433f865 | ||
|
|
bb1f5c979e | ||
|
|
d258c9bd47 | ||
|
|
156ad3d60d | ||
|
|
2a632f47f8 | ||
|
|
c660267aed | ||
|
|
22fede920f | ||
|
|
89f730b23a | ||
|
|
c67b1b9fe4 | ||
|
|
2b931f68fe | ||
|
|
884b84effc | ||
|
|
54d41285fd | ||
|
|
12f8f258b6 | ||
|
|
1deb094ca8 | ||
|
|
b6910dc03a | ||
|
|
b50b367058 | ||
|
|
983026d313 | ||
|
|
a471fa36c8 | ||
|
|
e0eebb665b | ||
|
|
a8ab204036 | ||
|
|
11e821a074 | ||
|
|
19aaa80b7f | ||
|
|
241591db0f | ||
|
|
058b822a52 | ||
|
|
d21a53dbf0 | ||
|
|
511f9e25b8 | ||
|
|
bed1b11384 | ||
|
|
d16350351f | ||
|
|
a7d47477d1 | ||
|
|
8cd33189fa | ||
|
|
0af7ced380 | ||
|
|
a514f285f7 | ||
|
|
5634df1f5a | ||
|
|
f2b46310de | ||
|
|
a646717277 | ||
|
|
63e992be5c | ||
|
|
98a574f223 | ||
|
|
6dfbcc3577 | ||
|
|
4c00c8b94d | ||
|
|
cde3dd8ecf | ||
|
|
e22ad2c4a8 | ||
|
|
62aeadae71 | ||
|
|
7e89db428b | ||
|
|
50e13c22c6 | ||
|
|
7e323dc342 | ||
|
|
c0cd051831 | ||
|
|
b1b97c8972 | ||
|
|
256687ecdb | ||
|
|
9829cc3100 | ||
|
|
2aa8be2642 | ||
|
|
75a6482c0e | ||
|
|
14e953db4c | ||
|
|
60e3c864c8 | ||
|
|
87ca4a5dd3 | ||
|
|
a70671cf0b | ||
|
|
67d7ea4ca2 | ||
|
|
53f58940dd | ||
|
|
f2639612f0 | ||
|
|
d29344af73 | ||
|
|
32635bdc9a | ||
|
|
8457cc06d2 | ||
|
|
a8316769a1 | ||
|
|
2f6bae7333 | ||
|
|
e951402049 | ||
|
|
4d5e3043ff | ||
|
|
d57f528165 | ||
|
|
14e84e5e0f | ||
|
|
fe79d3e866 | ||
|
|
88369ea070 | ||
|
|
944e83e480 | ||
|
|
8bb15bcb57 | ||
|
|
cb6358892b | ||
|
|
9956f6de34 | ||
|
|
893bd551e0 | ||
|
|
5c67459330 | ||
|
|
e2988ec29a | ||
|
|
2c96b11725 | ||
|
|
0d52a49e8b | ||
|
|
504ab7f148 | ||
|
|
d75f228632 | ||
|
|
410f0f2a6f | ||
|
|
c4672d282c | ||
|
|
9297fee839 | ||
|
|
acc72c0937 | ||
|
|
54c27f7038 | ||
|
|
7277ff26fc | ||
|
|
9a0149def8 | ||
|
|
e217e99864 | ||
|
|
9674af3bae | ||
|
|
a2b85dd37a | ||
|
|
220fe96268 | ||
|
|
917b6cfb7d | ||
|
|
0b687e1788 | ||
|
|
b35fa810ef | ||
|
|
0d1e10d064 | ||
|
|
96359e5942 | ||
|
|
bf63390f65 | ||
|
|
6f54981333 | ||
|
|
aed145239b | ||
|
|
99a8c917b9 | ||
|
|
ef39f30fd7 | ||
|
|
24e996e1a9 | ||
|
|
4178dce4e2 | ||
|
|
514eaae616 | ||
|
|
5692251668 | ||
|
|
6208dd3fd9 | ||
|
|
85288a3658 | ||
|
|
bae7e676b4 | ||
|
|
6ae7491a18 | ||
|
|
e5de694711 | ||
|
|
996cd2cd2c | ||
|
|
8f6bd8c266 | ||
|
|
599d58e3c7 | ||
|
|
1dd58bf2d0 | ||
|
|
90cf3adc25 | ||
|
|
26797addb8 | ||
|
|
b320e6f253 | ||
|
|
48d9ac4eed | ||
|
|
388eb273e4 | ||
|
|
0eee713712 | ||
|
|
3ff1262149 | ||
|
|
f4a420b699 | ||
|
|
b35b0cf1f9 | ||
|
|
2f4ee75c85 | ||
|
|
b3356b6575 | ||
|
|
359a37c8a6 | ||
|
|
a5a57fe8c8 | ||
|
|
c1f088c191 | ||
|
|
fec8d05927 | ||
|
|
466f068e36 | ||
|
|
b5880223a5 | ||
|
|
0a8a621fad | ||
|
|
5267607b79 | ||
|
|
5474a516f4 | ||
|
|
221b8cd7d1 | ||
|
|
2b544a74bd | ||
|
|
bcb7df24ec | ||
|
|
59fb95a4a7 | ||
|
|
157617fe4a | ||
|
|
ecdfeee3e6 | ||
|
|
3cd3a53268 | ||
|
|
9edf3c3028 | ||
|
|
82d8addafa | ||
|
|
3b446145b8 | ||
|
|
92fec8558e | ||
|
|
df858a7d65 | ||
|
|
a4c0c51a45 | ||
|
|
33d4b3ab7c | ||
|
|
06dc720108 | ||
|
|
a24805232c | ||
|
|
5ec1bcb721 | ||
|
|
cddc273333 | ||
|
|
0bd46b96cb | ||
|
|
2b6926c800 | ||
|
|
ceb6bb8328 | ||
|
|
8fd88e29ec | ||
|
|
d97b1cc1d0 | ||
|
|
baf2848ce0 | ||
|
|
b16ea272ae | ||
|
|
59fa7d143d | ||
|
|
658cfd2d4a | ||
|
|
a428db36c4 | ||
|
|
469eaefcb6 | ||
|
|
e991c9fdc1 | ||
|
|
43c9e7f7ac | ||
|
|
b410f100e8 | ||
|
|
e2413f8538 | ||
|
|
745f1ba8cc | ||
|
|
482b16e772 | ||
|
|
f284c4807f | ||
|
|
9927d6a544 | ||
|
|
0b4c474ece | ||
|
|
344e853839 | ||
|
|
865f5f67d7 | ||
|
|
5f8e7ab702 | ||
|
|
6ac864e3aa | ||
|
|
e0a012f3a4 | ||
|
|
5f1ae9db8e | ||
|
|
dcb5cd882e | ||
|
|
9d27df7e10 | ||
|
|
a11682181c | ||
|
|
a9b7f47053 | ||
|
|
809a91b16a | ||
|
|
2c6e56342c | ||
|
|
df2b7ffc1b | ||
|
|
3c5f28b496 | ||
|
|
7942bfc3f7 | ||
|
|
9e8e7fd8c2 | ||
|
|
e8c5caa2f3 | ||
|
|
b697aa389a | ||
|
|
a19f5b91a8 | ||
|
|
e1ebeec623 | ||
|
|
7734727e16 | ||
|
|
d4d1e9e649 | ||
|
|
b3b45fcc50 | ||
|
|
3bf63b855f | ||
|
|
c24ac94307 | ||
|
|
94c8f1f82d | ||
|
|
5d455a31b3 | ||
|
|
b43fe087d6 | ||
|
|
c7c414c218 | ||
|
|
775b55fd23 | ||
|
|
4cb601e0ce | ||
|
|
c42533aba5 | ||
|
|
df919417cb | ||
|
|
90afc5594f | ||
|
|
7b62e1871d | ||
|
|
fc483b449b | ||
|
|
62dbc9c97f | ||
|
|
ed9beb0752 | ||
|
|
6b750ff84b | ||
|
|
17be2599f0 | ||
|
|
20820c27f8 | ||
|
|
b83f629c09 | ||
|
|
bfc79f6d97 | ||
|
|
e297620ea2 | ||
|
|
83e5240871 | ||
|
|
2e68290d0c | ||
|
|
690d405f87 | ||
|
|
4c711a991a | ||
|
|
79795ff328 | ||
|
|
c178fb230e | ||
|
|
0acaf0598a | ||
|
|
7b99bf86fa | ||
|
|
6cf68abfc7 | ||
|
|
0e95dadb6c | ||
|
|
77b525809d | ||
|
|
d624316207 | ||
|
|
353c8090a9 | ||
|
|
7928cf8332 | ||
|
|
75bcade01c | ||
|
|
2d33774b56 | ||
|
|
26e5a1fbab | ||
|
|
b516736b6c | ||
|
|
881b3fefef | ||
|
|
a4c14e3c88 | ||
|
|
2943b64634 | ||
|
|
0af74ef8de | ||
|
|
8556507c6a | ||
|
|
ff8c662423 | ||
|
|
9314637094 | ||
|
|
8def5cbe5b | ||
|
|
6c7f21d6fd | ||
|
|
edc3c38d14 | ||
|
|
4045566514 | ||
|
|
9b5af3b221 | ||
|
|
b5fc0af979 | ||
|
|
4c643b3c61 | ||
|
|
01e198c94b | ||
|
|
6b09656164 | ||
|
|
21b051c422 | ||
|
|
9a8fa4ad1a | ||
|
|
2ac2f07c80 | ||
|
|
e893923164 | ||
|
|
ebacb6fe4c | ||
|
|
fb329f410a | ||
|
|
f95d7d62dd | ||
|
|
482303b775 | ||
|
|
d02a359cc3 | ||
|
|
9b24158acc | ||
|
|
cf65476f16 | ||
|
|
02d04614e0 | ||
|
|
a543d4d4bf | ||
|
|
f4de708e42 | ||
|
|
f1079f4e5d | ||
|
|
4d09077b2f | ||
|
|
f62fc879c5 |
4
.design/README.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
VectorDrawable does not support all SVG features, such as shadows and masks.
|
||||
Therefore the ic_launcher files are slightly different from the master files: no shadows, minor color tweaks, path optimisation.
|
||||
Use ic_launcher_*.svg files to generate assets for the app icon
|
||||
Use master_*.svg files to generate other assets (e.g. feature graphic, playstore icon) or to rework the icon design
|
||||
3
.design/ic_launcher_background.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="108" height="108" viewBox="0 0 108 108" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="108" height="108" fill="#1F4262"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 155 B |
18
.design/ic_launcher_foreground.svg
Normal file
@@ -0,0 +1,18 @@
|
||||
<svg width="108" height="108" viewBox="0 0 108 108" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M45.5 30.5768L68.0526 22.3683C70.1285 21.6127 72.4239 22.6831 73.1795 24.759L75.9156 32.2765L49.6042 41.8531L45.5 30.5768Z" fill="#F5A3A3"/>
|
||||
<path d="M70.3604 25.785C70.1715 25.2661 69.5977 24.9985 69.0787 25.1874L49.3451 32.3698L51.3973 38.008L72.0705 30.4835L70.3604 25.785ZM75.9156 32.2765L49.6042 41.8531L45.5 30.5768L68.0526 22.3683C70.1285 21.6127 72.4239 22.6831 73.1795 24.759L75.9156 32.2765Z" fill="#CF1717"/>
|
||||
<path d="M58.4155 30.5767L35.8629 22.3682C33.787 21.6126 31.4916 22.683 30.7361 24.7589L27.9999 32.2764L54.3113 41.853L58.4155 30.5767Z" fill="#F5A3A3"/>
|
||||
<path d="M33.5551 25.7849C33.744 25.2659 34.3179 24.9984 34.8368 25.1873L54.5704 32.3697L52.5183 38.0078L31.845 30.4834L33.5551 25.7849ZM27.9999 32.2764L54.3113 41.853L58.4155 30.5767L35.8629 22.3682C33.787 21.6126 31.4916 22.683 30.7361 24.7589L27.9999 32.2764Z" fill="#DD1818"/>
|
||||
<path d="M28.6958 37.5992C29.0794 35.4236 31.1543 33.9709 33.3298 34.3545L80.6006 42.6897C82.7761 43.0734 84.2288 45.148 83.8452 47.3235L81.8157 58.8328C82.2998 59.0988 84.6663 60.1572 87.416 57.2288V57.229C87.9156 56.6942 88.4507 56.2283 89.0068 55.8575C91.764 54.0193 93.9993 55.2156 93.9993 58.5293C93.9992 61.343 92.3876 64.7782 90.2134 66.8763C86.626 70.5423 80.6933 70.5552 79.7524 70.5332L77.5938 82.7766C77.2101 84.9522 75.1355 86.4049 72.96 86.0213L25.6892 77.6861C25.6723 77.6831 25.6555 77.6797 25.6387 77.6765C23.4483 77.3198 22.0001 76.7026 22 76.0003C22 75.7175 22.2348 75.4485 22.6582 75.2046C22.3986 74.5429 22.3121 73.8036 22.4446 73.0523L28.6958 37.5992Z" fill="#B81414"/>
|
||||
<path d="M90.6707 60.748C90.6707 61.8526 89.9257 63.2447 89.0066 63.8574C88.0876 64.4701 87.3425 64.0714 87.3425 62.9668C87.3425 61.8622 88.0876 60.4701 89.0066 59.8574C89.9257 59.2447 90.6707 59.6434 90.6707 60.748Z" fill="#E82E2E"/>
|
||||
<path d="M78 30C80.2091 30 82 31.7909 82 34V70C82 72.2091 80.2091 74 78 74H30C25.5817 74 22 74.8954 22 76V32C22 30.8954 25.5817 30 30 30H78Z" fill="#E82E2E"/>
|
||||
<path d="M51.2008 54.25C51.615 53.5325 52.5324 53.2867 53.2498 53.7009C53.9449 54.1022 54.1973 54.9757 53.8358 55.6822L53.762 55.8178C53.4005 56.5242 53.6529 57.3977 54.3479 57.799C55.043 58.2003 55.9256 57.9821 56.3567 57.3158L56.4372 57.1841C56.8683 56.5178 57.751 56.2997 58.446 56.7009C59.1634 57.1151 59.4092 58.0325 58.995 58.75C57.7524 60.9023 55.0002 61.6397 52.8479 60.3971C50.6956 59.1544 49.9582 56.4023 51.2008 54.25Z" fill="#8A0F0F"/>
|
||||
<path d="M52.795 54.25C52.3808 53.5325 51.4634 53.2867 50.746 53.7009C50.051 54.1022 49.7986 54.9757 50.1601 55.6822L50.2339 55.8178C50.5954 56.5242 50.343 57.3977 49.6479 57.799C48.9529 58.2003 48.0702 57.9821 47.6392 57.3158L47.5586 57.1841C47.1276 56.5178 46.2449 56.2997 45.5499 56.7009C44.8324 57.1151 44.5866 58.0325 45.0008 58.75C46.2435 60.9023 48.9956 61.6397 51.1479 60.3971C53.3002 59.1544 54.0377 56.4023 52.795 54.25Z" fill="#8A0F0F"/>
|
||||
<path d="M53.2989 56.75C52.7216 57.75 51.2782 57.75 50.7009 56.75L48.1028 52.25C47.5254 51.25 48.2471 50 49.4018 50L54.598 50C55.7527 50 56.4744 51.25 55.897 52.25L53.2989 56.75Z" fill="#8A0F0F"/>
|
||||
<path d="M40.4999 40.5C43.7321 40.5 46.4561 42.6167 47.4233 45.5269C47.6845 46.313 47.2592 47.162 46.4731 47.4233C45.687 47.6846 44.8379 47.2592 44.5766 46.4731C43.9982 44.7328 42.3813 43.5 40.4999 43.5C38.6186 43.5 37.0016 44.7328 36.4233 46.4731C36.162 47.2592 35.3129 47.6846 34.5268 47.4233C33.7407 47.162 33.3153 46.313 33.5766 45.5269C34.5438 42.6167 37.2678 40.5 40.4999 40.5Z" fill="#8A0F0F"/>
|
||||
<path d="M63.4999 40.5C66.7321 40.5 69.4561 42.6167 70.4233 45.5269C70.6845 46.313 70.2592 47.162 69.4731 47.4233C68.687 47.6846 67.8379 47.2592 67.5766 46.4731C66.9982 44.7328 65.3813 43.5 63.4999 43.5C61.6186 43.5 60.0016 44.7328 59.4233 46.4731C59.162 47.2592 58.3129 47.6846 57.5268 47.4233C56.7407 47.162 56.3153 46.313 56.5766 45.5269C57.5438 42.6167 60.2678 40.5 63.4999 40.5Z" fill="#8A0F0F"/>
|
||||
<path d="M26 55C25.4477 55 25 54.5523 25 54C25 53.4477 25.4477 53 26 53H42C42.5523 53 43 53.4477 43 54C43 54.5523 42.5523 55 42 55H26Z" fill="#8A0F0F"/>
|
||||
<path d="M26.3511 60.9363C25.834 61.1302 25.2576 60.8682 25.0637 60.3511C24.8698 59.834 25.1318 59.2575 25.6489 59.0636L41.6488 53.0637C42.1659 52.8698 42.7423 53.1318 42.9362 53.6489C43.1302 54.166 42.8681 54.7424 42.351 54.9363L26.3511 60.9363Z" fill="#8A0F0F"/>
|
||||
<path d="M61.649 54.9364C61.1319 54.7425 60.8699 54.1661 61.0638 53.6489C61.2577 53.1318 61.8341 52.8698 62.3512 53.0637L78.3511 59.0637C78.8682 59.2576 79.1302 59.834 78.9363 60.3511C78.7424 60.8683 78.166 61.1303 77.6489 60.9364L61.649 54.9364Z" fill="#8A0F0F"/>
|
||||
<path d="M78 55C78.5523 55 79 54.5523 79 54C79 53.4477 78.5523 53 78 53H62C61.4477 53 61 53.4477 61 54C61 54.5523 61.4477 55 62 55H78Z" fill="#8A0F0F"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
10
.design/ic_launcher_monochrome.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="108" height="108" viewBox="0 0 108 108" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M75 31.0001C78.3137 31.0001 81 33.6864 81 37.0001V44.4339C81.8278 45.6739 82.1977 47.2224 81.9185 48.8065L81 54.0147V55.8692C81.2385 55.7207 81.5023 55.5135 81.7856 55.2232L81.864 55.1412C82.3815 54.5878 82.9573 54.0824 83.5825 53.6656L83.7239 53.5736C85.1958 52.6378 87.0298 52.1726 88.6753 53.0533C90.3738 53.9624 90.9907 55.8341 90.9907 57.6305L90.9895 57.7735C90.9384 60.7815 89.2885 64.1632 87.1213 66.2555L87.1211 66.2552C85.2162 68.1795 82.7376 69.0841 80.7588 69.5221C80.6417 69.548 80.5255 69.572 80.4106 69.5951C79.8487 70.7645 78.9192 71.7235 77.7715 72.3223L76.709 78.3509C76.1335 81.6141 73.0215 83.7931 69.7583 83.2179L30.3657 76.2718C30.328 76.2652 30.292 76.2576 30.2576 76.2508C29.124 76.0893 28.0601 75.8434 27.2224 75.4942C26.8046 75.32 26.3313 75.075 25.9299 74.7176C25.538 74.3686 25.0098 73.7183 25.0005 72.7752C25.0005 72.7766 25.0007 72.778 25.0007 72.7794C25.0006 72.7696 25 72.7599 25 72.7501V34.5001C25 33.8368 25.3232 33.2494 25.8203 32.8856C26.2266 32.4885 26.6978 32.2406 27.0352 32.0872C27.6048 31.8283 28.2727 31.6301 28.9683 31.4781C29.7466 31.308 30.6353 31.1794 31.5925 31.0987C31.5854 31.0993 31.5784 31.0998 31.5713 31.1004L32.6726 28.0748L32.7275 27.93C33.9136 24.9114 37.2979 23.3732 40.363 24.4888L52.8337 29.0277L65.3047 24.4888C68.4185 23.3555 71.8617 24.9609 72.9951 28.0748L74.0598 31.0001H75ZM34.8474 73.0001L70.4529 79.2784C71.5406 79.4701 72.5777 78.7437 72.7695 77.6561L73.5906 73.0001H34.8474ZM34 35.0001C32.3461 35.0001 30.8829 35.1543 29.8225 35.3861C29.4849 35.4599 29.2118 35.5362 29 35.6082V69.4718C30.4021 69.1686 32.1493 69.0001 34 69.0001H75L75.103 68.9974C76.1256 68.9455 76.9454 68.1256 76.9973 67.1031L77 67.0001V37.0001C77 35.8955 76.1046 35.0001 75 35.0001H34ZM86.782 56.5904C86.6812 56.5851 86.3996 56.6115 85.8818 56.9412L85.8013 56.9937C85.4702 57.2144 85.1253 57.5101 84.7834 57.8761C84.7824 57.8772 84.7811 57.8783 84.78 57.8795L84.6406 58.025C83.4435 59.2483 82.1848 59.8799 81 60.1214V65.3201C82.1999 64.9382 83.3456 64.358 84.219 63.5015L84.343 63.3775C85.8843 61.8895 86.9907 59.4316 86.9907 57.6305L86.9897 57.5343C86.9769 56.9198 86.8422 56.671 86.782 56.5904ZM46.5574 31.0001L38.9949 28.2476C37.9893 27.8817 36.8807 28.3724 36.469 29.347L36.4314 29.4429L35.8645 31.0001H46.5574ZM69.803 31.0001L69.2363 29.4429C68.8586 28.4051 67.7109 27.8698 66.6729 28.2476L59.1104 31.0001H69.803Z" fill="black"/>
|
||||
<path d="M55.165 51C56.3197 51.0001 57.0412 52.25 56.4639 53.25L54.6943 56.3145C54.5983 56.7617 54.7947 57.2387 55.2122 57.4797C55.7303 57.7788 56.3927 57.6015 56.6919 57.0835C57.1061 56.3661 58.0235 56.1202 58.741 56.5344C59.4584 56.9487 59.7042 57.8661 59.29 58.5835C58.1625 60.5364 55.6651 61.2054 53.7122 60.0779C53.4495 59.9262 53.2103 59.7495 52.9954 59.553C52.7804 59.7495 52.5414 59.9263 52.2788 60.0779C50.3258 61.2055 47.8283 60.5365 46.7007 58.5835C46.2865 57.8661 46.5324 56.9487 47.2498 56.5344C47.9672 56.1202 48.8846 56.3661 49.2988 57.0835C49.598 57.6016 50.2607 57.7789 50.7788 57.4797C51.2042 57.2341 51.3997 56.7436 51.2905 56.2891L49.5359 53.25C48.9586 52.25 49.6801 51.0001 50.8347 51H55.165Z" fill="black"/>
|
||||
<path d="M43.2499 42.5C46.0011 42.5 48.4844 44.0694 49.4008 46.4639C49.6968 47.2376 49.3097 48.1048 48.536 48.4009C47.7623 48.697 46.8951 48.3098 46.599 47.5361C46.1806 46.4427 44.9148 45.5 43.2499 45.5C41.5849 45.5 40.3192 46.4427 39.9008 47.5361C39.6047 48.3098 38.7374 48.697 37.9637 48.4009C37.1901 48.1048 36.8029 47.2376 37.099 46.4639C38.0153 44.0694 40.4987 42.5 43.2499 42.5Z" fill="black"/>
|
||||
<path d="M62.7499 42.5C65.5011 42.5 67.9844 44.0694 68.9008 46.4639C69.1968 47.2376 68.8097 48.1048 68.036 48.4009C67.2623 48.697 66.3951 48.3098 66.099 47.5361C65.6806 46.4427 64.4148 45.5 62.7499 45.5C61.0849 45.5 59.8192 46.4427 59.4008 47.5361C59.1047 48.3098 58.2374 48.697 57.4637 48.4009C56.6901 48.1048 56.3029 47.2376 56.599 46.4639C57.5153 44.0694 59.9987 42.5 62.7499 42.5Z" fill="black"/>
|
||||
<path d="M33 55C32.1716 55 31.5 54.3284 31.5 53.5C31.5 52.6716 32.1716 52 33 52H44.25C45.0784 52 45.75 52.6716 45.75 53.5C45.75 54.3284 45.0784 55 44.25 55H33Z" fill="black"/>
|
||||
<path d="M33.6106 59.8701C32.8538 60.2073 31.9671 59.8671 31.6299 59.1104C31.2928 58.3537 31.6329 57.467 32.3896 57.1298L43.6118 52.1298C44.3685 51.7926 45.2553 52.1328 45.5924 52.8895C45.9296 53.6462 45.5894 54.533 44.8327 54.8701L33.6106 59.8701Z" fill="black"/>
|
||||
<path d="M60.8488 54.8768C60.0885 54.5478 59.7389 53.6647 60.0678 52.9044C60.3968 52.1441 61.2798 51.7945 62.0401 52.1234L73.5957 57.1233C74.356 57.4523 74.7056 58.3353 74.3767 59.0956C74.0477 59.8559 73.1647 60.2056 72.4043 59.8766L60.8488 54.8768Z" fill="black"/>
|
||||
<path d="M73 52C73.8284 52 74.5 52.6716 74.5 53.5C74.5 54.3284 73.8284 55 73 55H61.5C60.6716 55 60 54.3284 60 53.5C60 52.6716 60.6716 52 61.5 52H73Z" fill="black"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
69
.design/master_color.svg
Normal file
@@ -0,0 +1,69 @@
|
||||
<svg width="432" height="432" viewBox="0 0 432 432" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="432" height="432" fill="#1F4262"/>
|
||||
<g filter="url(#filter0_d_39_7)">
|
||||
<path d="M182 122.308L272.21 89.4737C280.514 86.4514 289.696 90.7328 292.718 99.0364L303.663 129.107L198.417 167.413L182 122.308Z" fill="#F5A3A3"/>
|
||||
<path d="M274.263 95.1118C279.452 93.2229 285.191 95.8988 287.08 101.089L295.972 125.521L202.003 159.723L189.69 125.894L274.263 95.1118Z" stroke="#E82E2E" stroke-width="12"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_d_39_7)">
|
||||
<path d="M233.662 122.307L143.452 89.4727C135.148 86.4504 125.966 90.7318 122.944 99.0355L112 129.106L217.245 167.412L233.662 122.307Z" fill="#F5A3A3"/>
|
||||
<path d="M141.399 95.1109C136.21 93.2219 130.471 95.8978 128.582 101.088L119.69 125.52L213.659 159.722L225.972 125.893L141.399 95.1109Z" stroke="#E82E2E" stroke-width="12"/>
|
||||
</g>
|
||||
<g filter="url(#filter2_d_39_7)">
|
||||
<path d="M114.783 150.397C116.318 141.695 124.617 135.884 133.319 137.419L322.402 170.759C331.104 172.293 336.915 180.592 335.381 189.294L327.263 235.331C329.199 236.395 338.665 240.629 349.664 228.915V228.916C351.663 226.777 353.803 224.913 356.027 223.43C367.056 216.077 375.997 220.862 375.997 234.117C375.997 245.372 369.551 259.113 360.854 267.505C346.504 282.169 322.773 282.222 319.01 282.134L310.375 331.106C308.841 339.809 300.542 345.619 291.84 344.085L102.757 310.745C102.684 310.732 102.611 310.717 102.538 310.703C93.7855 309.276 88 306.809 88 304.001C88 302.87 88.9396 301.794 90.6338 300.818C89.5953 298.172 89.2485 295.215 89.7783 292.21L114.783 150.397Z" fill="#B81414"/>
|
||||
</g>
|
||||
<circle cx="8" cy="8" r="8" transform="matrix(0.83205 -0.5547 0 1 349.37 243.867)" fill="#E82E2E"/>
|
||||
<g filter="url(#filter3_d_39_7)">
|
||||
<path d="M312 120C320.837 120 328 127.163 328 136V280C328 288.837 320.837 296 312 296H120C102.327 296 88 299.582 88 304V128C88 123.582 102.327 120 120 120H312Z" fill="#E82E2E"/>
|
||||
</g>
|
||||
<path d="M230.785 232C227.471 237.74 220.132 239.706 214.392 236.392C208.653 233.079 206.686 225.74 210 220" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M185.2 232C188.513 237.74 195.853 239.706 201.592 236.392C207.332 233.079 209.298 225.74 205.984 220" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M213.196 227C210.887 231 205.113 231 202.804 227L192.412 209C190.102 205 192.989 200 197.608 200L218.392 200C223.011 200 225.898 205 223.588 209L213.196 227Z" fill="#8A0F0F"/>
|
||||
<path d="M184 184C180.909 174.699 172.227 168 162 168C151.773 168 143.091 174.699 140 184" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M276 184C272.909 174.699 264.227 168 254 168C243.773 168 235.091 174.699 232 184" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M168 216H104" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M168 216L104 240" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M312 240L248 216" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M248 216H312" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<defs>
|
||||
<filter id="filter0_d_39_7" x="166" y="72.5049" width="153.663" height="110.908" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_39_7"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_39_7" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter1_d_39_7" x="95.9995" y="72.5039" width="153.663" height="110.908" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_39_7"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_39_7" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter2_d_39_7" x="72" y="121.173" width="319.997" height="239.158" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_39_7"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_39_7" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter3_d_39_7" x="72" y="104" width="272" height="216" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_39_7"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_39_7" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.7 KiB |
18
.design/master_monochrome.svg
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
14
.github/workflows/android.yml
vendored
@@ -24,7 +24,7 @@ permissions:
|
||||
security-events: none
|
||||
statuses: none
|
||||
env:
|
||||
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
|
||||
JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -32,14 +32,14 @@ jobs:
|
||||
matrix:
|
||||
flavor: [Foss, Gplay]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/checkout@v5
|
||||
- name: Fail on bad translations
|
||||
run: if grep -ri "<xliff" app/src/main/res/values*/strings.xml; then echo "Invalidly escaped translations found"; exit 1; fi
|
||||
- uses: gradle/actions/wrapper-validation@v4
|
||||
- name: set up OpenJDK 17
|
||||
- uses: gradle/actions/wrapper-validation@v5
|
||||
- name: set up OpenJDK 21
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y openjdk-17-jdk-headless
|
||||
sudo apt-get install -y openjdk-21-jdk-headless
|
||||
sudo update-alternatives --auto java
|
||||
- name: Build
|
||||
run: ./gradlew assemble${{ matrix.flavor }}Release
|
||||
@@ -64,11 +64,9 @@ jobs:
|
||||
api-level: 35
|
||||
arch: x86_64
|
||||
script: ./gradlew connected${{ matrix.flavor }}DebugAndroidTest
|
||||
- name: SpotBugs
|
||||
run: ./gradlew spotbugs${{ matrix.flavor }}Release
|
||||
- name: Archive test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@v5.0.0
|
||||
with:
|
||||
name: test-results-flavor${{ matrix.flavor }}
|
||||
path: app/build/reports
|
||||
|
||||
18
.github/workflows/changelog-to-fastlane.yml
vendored
@@ -1,4 +1,5 @@
|
||||
name: Convert CHANGELOG to Fastlane
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
@@ -6,20 +7,11 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- 'CHANGELOG.md'
|
||||
|
||||
permissions:
|
||||
actions: none
|
||||
checks: none
|
||||
contents: write
|
||||
deployments: none
|
||||
discussions: none
|
||||
id-token: none
|
||||
issues: none
|
||||
packages: none
|
||||
pages: none
|
||||
pull-requests: write
|
||||
repository-projects: none
|
||||
security-events: none
|
||||
statuses: none
|
||||
|
||||
jobs:
|
||||
convert_changelog_to_fastlane:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -27,9 +19,9 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
id: checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5.6.0
|
||||
uses: actions/setup-python@v6.0.0
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Run converter script
|
||||
|
||||
16
.github/workflows/contributors-to-file.yml
vendored
@@ -1,22 +1,14 @@
|
||||
name: Write contributors to file
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '3 4 * * 0'
|
||||
|
||||
permissions:
|
||||
actions: none
|
||||
checks: none
|
||||
contents: write
|
||||
deployments: none
|
||||
discussions: none
|
||||
id-token: none
|
||||
issues: none
|
||||
packages: none
|
||||
pages: none
|
||||
pull-requests: write
|
||||
repository-projects: none
|
||||
security-events: none
|
||||
statuses: none
|
||||
|
||||
jobs:
|
||||
contributors_to_file:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -25,7 +17,7 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
id: checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
uses: actions/checkout@v5
|
||||
- name: Update contributors
|
||||
id: update_contributors
|
||||
uses: TheLastProject/contributors-to-file-action@v3.2.0
|
||||
|
||||
16
.github/workflows/generate-feature-graphic.yml
vendored
@@ -1,4 +1,5 @@
|
||||
name: Generate feature graphic
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
@@ -7,25 +8,16 @@ on:
|
||||
paths:
|
||||
- 'fastlane/**/title.txt'
|
||||
- '.scripts/generate_feature_graphic/**'
|
||||
|
||||
permissions:
|
||||
actions: none
|
||||
checks: none
|
||||
contents: write
|
||||
deployments: none
|
||||
discussions: none
|
||||
id-token: none
|
||||
issues: none
|
||||
packages: none
|
||||
pages: none
|
||||
pull-requests: write
|
||||
repository-projects: none
|
||||
security-events: none
|
||||
statuses: none
|
||||
|
||||
jobs:
|
||||
generate-feature-graphic:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/checkout@v5
|
||||
- name: Install requirements
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
||||
33
.github/workflows/gradle-update.yml
vendored
@@ -1,33 +0,0 @@
|
||||
name: Gradle update
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '3 6 * * *'
|
||||
permissions:
|
||||
actions: none
|
||||
checks: none
|
||||
contents: write
|
||||
deployments: none
|
||||
discussions: none
|
||||
id-token: none
|
||||
issues: none
|
||||
packages: none
|
||||
pages: none
|
||||
pull-requests: write
|
||||
repository-projects: none
|
||||
security-events: none
|
||||
statuses: none
|
||||
jobs:
|
||||
gradle-update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: obfusk/gradle-update-action@v3.0.0
|
||||
id: gradle-update
|
||||
- uses: gradle/actions/wrapper-validation@v4
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v7.0.8
|
||||
with:
|
||||
title: "Update Gradle to ${{ steps.gradle-update.outputs.version }}"
|
||||
commit-message: "Update Gradle to ${{ steps.gradle-update.outputs.version }}"
|
||||
branch-suffix: timestamp
|
||||
19
.github/workflows/update-gradle-wrapper.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Update Gradle Wrapper
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update-gradle-wrapper:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Update Gradle Wrapper
|
||||
uses: gradle-update/update-gradle-wrapper-action@v2
|
||||
16
.github/workflows/update-locales.yml
vendored
@@ -1,4 +1,5 @@
|
||||
name: Update locales
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
@@ -7,25 +8,16 @@ on:
|
||||
paths:
|
||||
- app/src/main/res/values-*/strings.xml
|
||||
- app/src/main/res/values/settings.xml
|
||||
|
||||
permissions:
|
||||
actions: none
|
||||
checks: none
|
||||
contents: write
|
||||
deployments: none
|
||||
discussions: none
|
||||
id-token: none
|
||||
issues: none
|
||||
packages: none
|
||||
pages: none
|
||||
pull-requests: write
|
||||
repository-projects: none
|
||||
security-events: none
|
||||
statuses: none
|
||||
|
||||
jobs:
|
||||
update-locales:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/checkout@v5
|
||||
- name: Add new locales
|
||||
run: .scripts/new-locales.py
|
||||
- name: Update locales
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import csv
|
||||
import json
|
||||
import msgpack
|
||||
|
||||
MSGPACK = "bootstrapdata.msgpack"
|
||||
OUTFILE = "stocard_stores.csv"
|
||||
|
||||
|
||||
def load(fh):
|
||||
data = []
|
||||
for r in msgpack.Unpacker(fh, raw=False):
|
||||
if r["collection"] == "/loyalty-card-providers/":
|
||||
d = json.loads(r["data"])
|
||||
data.append([r["resource_id"], d["name"], d["default_barcode_format"]])
|
||||
return data
|
||||
|
||||
|
||||
def save(data, output_file=OUTFILE):
|
||||
with open(output_file, "w") as fh:
|
||||
writer = csv.writer(fh, lineterminator="\n")
|
||||
writer.writerow(["_id", "name", "barcodeFormat"])
|
||||
for row in data:
|
||||
writer.writerow(row)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(
|
||||
epilog=f"INPUT_FILE must be a .msgpack or .apk and defaults to {MSGPACK}; "
|
||||
f"OUTPUT_FILE defaults to {OUTFILE}")
|
||||
parser.add_argument("input_file", metavar="INPUT_FILE", nargs="?", default=MSGPACK)
|
||||
parser.add_argument("output_file", metavar="OUTPUT_FILE", nargs="?", default=OUTFILE)
|
||||
args = parser.parse_args()
|
||||
if args.input_file.lower().endswith(".apk"):
|
||||
import zipfile
|
||||
with zipfile.ZipFile(args.input_file) as zf:
|
||||
with zf.open(f"assets/{MSGPACK}") as fh:
|
||||
data = load(fh)
|
||||
else:
|
||||
with open(args.input_file, "rb") as fh:
|
||||
data = load(fh)
|
||||
save(data, args.output_file)
|
||||
@@ -1,15 +1,76 @@
|
||||
<svg width="1024" height="500" viewBox="0 0 1024 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="1024" height="500" fill="#223355"/>
|
||||
<text direction="ltr" fill="white" xml:space="preserve" style="" font-family="Yesteryear" font-size="150" letter-spacing="0em"><tspan x="470.082" y="285.511">Catima
|
||||
</tspan></text>
|
||||
<path d="M381.046 147.001L236.3 211.446L276.524 301.79L421.27 237.345L381.046 147.001Z" fill="#F0F0F0" stroke="#C80000" stroke-width="2"/>
|
||||
<path d="M402.077 219.13L240.07 147L191.984 255.004L353.99 327.135L402.077 219.13Z" fill="#F0F0F0" stroke="#C80000" stroke-width="2"/>
|
||||
<path d="M437.17 236.241L251.831 183.096L220.071 293.855L405.41 347L437.17 236.241Z" fill="#C80000" stroke="#C80000" stroke-width="6" stroke-linejoin="round"/>
|
||||
<path d="M412.879 178.633H220.071V293.855H412.879V178.633Z" fill="#FF0000" stroke="#FF0000" stroke-width="6" stroke-linejoin="round"/>
|
||||
<path d="M221.482 296.217C238.316 296.217 251.963 269.366 251.963 236.244C251.963 203.121 238.316 176.27 221.482 176.27C204.647 176.27 191 203.121 191 236.244C191 269.366 204.647 296.217 221.482 296.217Z" fill="#FF0000" stroke="#FF0000" stroke-width="3.44232" stroke-linejoin="round"/>
|
||||
<path d="M307.256 250.444C307.256 253.187 306.289 255.842 304.526 257.944C302.763 260.045 300.316 261.458 297.614 261.934C294.913 262.41 292.13 261.92 289.755 260.548C287.379 259.177 285.563 257.012 284.625 254.435" stroke="#F0F0F0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M330.301 254.298C329.363 256.875 327.547 259.04 325.171 260.411C322.796 261.783 320.013 262.273 317.312 261.797C314.61 261.321 312.163 259.908 310.4 257.807C308.637 255.706 307.671 253.05 307.671 250.307" stroke="#F0F0F0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M248.345 225.937L266.818 207.465L285.29 225.937" stroke="#F0F0F0" stroke-width="2"/>
|
||||
<path d="M329.625 225.937L348.098 207.465L366.571 225.937" stroke="#F0F0F0" stroke-width="2"/>
|
||||
<text direction="ltr" fill="white" xml:space="preserve" style="" font-family="Lexend Deca" font-size="35" font-weight="200" letter-spacing="0em"><tspan x="466" y="340">Loyalty Card Wallet</tspan></text>
|
||||
<g clip-path="url(#clip0_78_203)">
|
||||
<path d="M1024 0H0V500H1024V0Z" fill="#1F4262"/>
|
||||
<text fill="white" xml:space="preserve" style="white-space: pre" font-family="Lexend" font-size="35" letter-spacing="0em"><tspan x="481" y="325">Loyalty Card Wallet</tspan></text>
|
||||
<text fill="white" xml:space="preserve" style="white-space: pre" font-family="Lobster" font-size="150" letter-spacing="0em"><tspan x="469" y="270">Catima</tspan></text>
|
||||
<g filter="url(#filter0_d_78_203)">
|
||||
<path d="M218 156.307L308.21 123.473C316.514 120.45 325.696 124.732 328.718 133.035L339.663 163.106L234.417 201.412L218 156.307Z" fill="#F5A3A3"/>
|
||||
<path d="M310.263 129.111C315.452 127.222 321.191 129.898 323.08 135.088L331.972 159.52L238.003 193.722L225.69 159.893L310.263 129.111Z" stroke="#E82E2E" stroke-width="12"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_d_78_203)">
|
||||
<path d="M269.662 156.307L179.452 123.473C171.148 120.45 161.966 124.732 158.944 133.035L148 163.106L253.245 201.412L269.662 156.307Z" fill="#F5A3A3"/>
|
||||
<path d="M177.399 129.111C172.21 127.222 166.471 129.898 164.582 135.088L155.69 159.52L249.659 193.722L261.972 159.893L177.399 129.111Z" stroke="#E82E2E" stroke-width="12"/>
|
||||
</g>
|
||||
<g filter="url(#filter2_d_78_203)">
|
||||
<path d="M150.783 184.396C152.318 175.694 160.617 169.884 169.319 171.418L358.402 204.759C367.104 206.293 372.915 214.592 371.381 223.294L363.263 269.331C365.199 270.395 374.665 274.629 385.664 262.915V262.916C387.662 260.777 389.802 258.913 392.027 257.43C403.056 250.077 411.997 254.862 411.997 268.117C411.997 279.372 405.55 293.113 396.853 301.505C382.504 316.169 358.773 316.221 355.01 316.133L346.375 365.106C344.84 373.809 336.542 379.619 327.84 378.085L138.757 344.744C138.689 344.732 138.622 344.719 138.555 344.706C129.793 343.279 124 340.81 124 338.001C124 336.87 124.939 335.794 126.633 334.818C125.594 332.171 125.248 329.214 125.778 326.209L150.783 184.396Z" fill="#B81414"/>
|
||||
</g>
|
||||
<circle cx="8" cy="8" r="8" transform="matrix(0.83205 -0.5547 0 1 385.37 277.867)" fill="#E82E2E"/>
|
||||
<g filter="url(#filter3_d_78_203)">
|
||||
<path d="M348 154C356.837 154 364 161.163 364 170V314C364 322.837 356.837 330 348 330H156C138.327 330 124 333.582 124 338V162C124 157.582 138.327 154 156 154H348Z" fill="#E82E2E"/>
|
||||
</g>
|
||||
<path d="M266.784 266C263.471 271.74 256.132 273.706 250.392 270.392C244.653 267.079 242.686 259.74 246 254" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M221.2 266C224.514 271.74 231.853 273.706 237.592 270.392C243.332 267.079 245.298 259.74 241.984 254" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M249.196 261C246.887 265 241.113 265 238.804 261L228.412 243C226.102 239 228.989 234 233.608 234L254.392 234C259.011 234 261.898 239 259.588 243L249.196 261Z" fill="#8A0F0F"/>
|
||||
<path d="M220 218C216.909 208.699 208.227 202 198 202C187.773 202 179.091 208.699 176 218" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M312 218C308.909 208.699 300.227 202 290 202C279.773 202 271.091 208.699 268 218" stroke="#8A0F0F" stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="M204 250H140" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M204 250L140 274" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M348 274L284 250" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M284 250H348" stroke="#8A0F0F" stroke-width="8" stroke-linecap="round"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_78_203" x="202" y="106.504" width="153.663" height="110.908" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_78_203"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_78_203" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter1_d_78_203" x="132" y="106.504" width="153.663" height="110.908" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_78_203"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_78_203" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter2_d_78_203" x="108" y="155.172" width="319.997" height="239.159" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_78_203"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_78_203" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter3_d_78_203" x="108" y="138" width="272" height="216" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="8"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_78_203"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_78_203" result="shape"/>
|
||||
</filter>
|
||||
<clipPath id="clip0_78_203">
|
||||
<rect width="1024" height="500" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 6.2 KiB |
@@ -2,7 +2,7 @@ Copyright 2018 The Lexend Project Authors (https://github.com/googlefonts/lexend
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
@@ -1,9 +1,8 @@
|
||||
Copyright (c) 2011 by Brian J. Bonislawsky DBA Astigmatic (AOETI)
|
||||
(astigma@astigmatic.com), with Reserved Font Names "Yesteryear"
|
||||
Copyright 2010 The Lobster Project Authors (https://github.com/impallari/The-Lobster-Font), with Reserved Font Name "Lobster".
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
@@ -33,20 +33,22 @@ for lang in "$script_location/../../fastlane/metadata/android/"*; do
|
||||
perl -pi -e 's/Catima/$ENV{appname}/' featureGraphic.svg
|
||||
perl -pi -e 's/Loyalty Card Wallet/$ENV{subtext}/' featureGraphic.svg
|
||||
# Set correct font or font size for language if needed
|
||||
# (Lexend Deca has limited support and some characters are big)
|
||||
# We specifically need the Serif version because of the 200 weight
|
||||
# (Lobster and Lexend have limited language support)
|
||||
case "$(basename "$lang")" in
|
||||
bg|el-GR|ru-RU|uk) sed -i "s/Lexend Deca/Noto Serif/" featureGraphic.svg ;;
|
||||
fa-IR) sed -i -e 's/svg direction="ltr"/svg direction="rtl"/' -e "s/Yesteryear/Noto Sans Arabic/" -e "s/Lexend Deca/Noto Sans Arabic/" featureGraphic.svg ;;
|
||||
hi-IN) sed -i -e "s/Yesteryear/Noto Sans Devanagari/" -e "s/Lexend Deca/Noto Serif Devanagari/" featureGraphic.svg ;;
|
||||
ja-JP) sed -i "s/Lexend Deca/Noto Serif CJK JP/" featureGraphic.svg ;;
|
||||
kn-IN) sed -i -e 's/font-size="150"/font-size="100"/' -e "s/Yesteryear/Noto Serif Kannada/" featureGraphic.svg ;;
|
||||
ko) sed -i "s/Lexend Deca/Noto Serif CJK KR/" featureGraphic.svg ;;
|
||||
zh-CN) sed -i "s/Lexend Deca/Noto Serif CJK SC/" featureGraphic.svg ;;
|
||||
zh-TW) sed -i -e "s/Yesteryear/Noto Sans CJK TC/" -e "s/Lexend Deca/Noto Serif CJK TC/" featureGraphic.svg ;;
|
||||
bg|el-GR|ru-RU|uk) sed -i "s/Lexend/Noto Sans/" featureGraphic.svg ;;
|
||||
ar|fa-IR) sed -i -e 's/svg direction="ltr"/svg direction="rtl"/' -e "s/Lobster/Noto Sans Arabic/" -e "s/Lexend/Noto Sans Arabic/" featureGraphic.svg ;;
|
||||
he-IL) sed -i -e "s/Lobster/Noto Sans Hebrew/" -e "s/Lexend/Noto Sans Hebrew/" featureGraphic.svg ;;
|
||||
hi-IN) sed -i -e "s/Lobster/Noto Sans Devanagari/" -e "s/Lexend/Noto Sans Devanagari/" featureGraphic.svg ;;
|
||||
ja-JP) sed -i "s/Lexend/Noto Sans CJK JP/" featureGraphic.svg ;;
|
||||
kn-IN) sed -i -e 's/font-size="150"/font-size="125"/' -e 's/\(<tspan x="469" \)y="270"/\1y="240"/' -e "s/Lobster/Noto Sans Kannada/" -e "s/Lexend/Noto Sans Kannada/" featureGraphic.svg ;;
|
||||
ko) sed -i "s/Lexend/Noto Sans CJK KR/" featureGraphic.svg ;;
|
||||
ta-IN) sed -i -e 's/font-size="150"/font-size="110"/' featureGraphic.svg ;;
|
||||
zh-CN) sed -i "s/Lexend/Noto Sans CJK SC/" featureGraphic.svg ;;
|
||||
zh-TW) sed -i -e "s/Lobster/Noto Sans CJK TC/" -e "s/Lexend/Noto Sans CJK TC/" featureGraphic.svg ;;
|
||||
*) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Ensure images directory exists
|
||||
mkdir -p images
|
||||
# Generate .png (we use Inkscape because ImageMagick ignores RTL)
|
||||
|
||||
@@ -11,6 +11,7 @@ MIN_PERCENT = 90
|
||||
NOT_LANGS = ("night", "w600dp")
|
||||
REPLACE_CODES = {
|
||||
"el": "el-rGR",
|
||||
"he": "iw",
|
||||
"id": "in-rID",
|
||||
"ro": "ro-rRO",
|
||||
"zh_Hans": "zh-rCN",
|
||||
|
||||
33
CHANGELOG.md
@@ -1,6 +1,37 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased - 148
|
||||
## v2.39.1 - 154 (2025-10-01)
|
||||
|
||||
- Fix possible crash that could occur for cards missing colour information in the database
|
||||
|
||||
## v2.39.0 - 153 (2025-09-30)
|
||||
|
||||
- Target Android 16
|
||||
- Fix possible crash after removing image from card
|
||||
- Remove "Screen orientation" feature (Google removed the ability for apps to control screen rotation when targeting Android 16)
|
||||
- Add crash reporter to FOSS build (not used in Google Play version, only in other app stores)
|
||||
|
||||
## v2.38.0 - 152 (2025-09-12)
|
||||
|
||||
- Add support for .pkpasses files
|
||||
- Remove Stocard importer (Stocard no longer exists)
|
||||
- Temporarily disable widget images below Android 12L (workaround for a crash issue)
|
||||
|
||||
## v2.37.0 - 151 (2025-08-22)
|
||||
|
||||
- New redesign of the Catima logo
|
||||
- Translation updates
|
||||
|
||||
## v2.36.0 - 150 (2025-08-05)
|
||||
|
||||
- Add a widget showing all non-archived cards
|
||||
- Prevent the keyboard from overlapping the save button in edit and group screens
|
||||
|
||||
## v2.35.1 - 149 (2025-06-17)
|
||||
|
||||
- Dependency and translation updates
|
||||
|
||||
## v2.35.0 - 148 (2025-05-17)
|
||||
|
||||
- Add ability to choose barcode width in fullscreen view
|
||||
- Remove confusing import from app function
|
||||
|
||||
@@ -23,6 +23,30 @@ for good reason.
|
||||
|
||||
## Code Changes
|
||||
|
||||
Note: submitting LLM ("AI") generated code is strongly discouraged, as such
|
||||
code is often (subtly) incorrect or overcomplicated (for example: unnecessarily
|
||||
pulling in extra libraries for functionality already covered by existing
|
||||
libraries). It also often makes unrelated changes that increase the risk of
|
||||
introducing new issues and complicates reviewing. Even when it doesn't do any
|
||||
of the before mentioned things, it will often not fit the coding style and flow
|
||||
of existing code, requiring excessive refactoring.
|
||||
|
||||
While we cannot ever control or be sure if LLMs were used to generate the
|
||||
submitted code, it is your responsibility to ensure that whatever code you
|
||||
submit is correct and fits within the design of existing code. It is never
|
||||
acceptable to defend a change by stating a LLM suggested it.
|
||||
|
||||
This is a personal plea more than anything: please understand that writing code
|
||||
is the easy part. The hard part is making sure the code fits the design of the
|
||||
rest of the application and is maintainable. Reviewing is a very time-consuming
|
||||
task for this reason. Please do not use LLMs to quickly generate a "fix" and
|
||||
moving the cost of labor to me as a reviewer. If you do use LLMs to generate
|
||||
part of your code, please be open about this, explain what was generated how
|
||||
and how you confirmed and refactored the code to fit the project and minimized
|
||||
risk.
|
||||
|
||||
Please never submit LLM-generated code as-is.
|
||||
|
||||
### Test Your Code
|
||||
|
||||
There are four possible tests you can run to verify your code. The first
|
||||
@@ -36,10 +60,6 @@ These are the Android lint checker, run using:
|
||||
|
||||
# ./gradlew lintRelease
|
||||
|
||||
and SpotBugs, run using:
|
||||
|
||||
# ./gradlew spotbugsRelease
|
||||
|
||||
The final check is by testing the application on a live device and verifying
|
||||
the basic functionality works as expected.
|
||||
|
||||
|
||||
5
Gemfile
@@ -1,3 +1,8 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "fastlane"
|
||||
|
||||
# https://github.com/fastlane/fastlane/issues/29183
|
||||
gem "abbrev"
|
||||
gem "mutex_m"
|
||||
gem "ostruct"
|
||||
|
||||
45
Gemfile.lock
@@ -5,29 +5,31 @@ GEM
|
||||
base64
|
||||
nkf
|
||||
rexml
|
||||
abbrev (0.1.2)
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.3.2)
|
||||
aws-partitions (1.1072.0)
|
||||
aws-sdk-core (3.220.2)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1117.0)
|
||||
aws-sdk-core (3.226.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
aws-sdk-kms (1.99.0)
|
||||
aws-sdk-core (~> 3, >= 3.216.0)
|
||||
logger
|
||||
aws-sdk-kms (1.105.0)
|
||||
aws-sdk-core (~> 3, >= 3.225.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.182.0)
|
||||
aws-sdk-core (~> 3, >= 3.216.0)
|
||||
aws-sdk-s3 (1.189.1)
|
||||
aws-sdk-core (~> 3, >= 3.225.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.11.0)
|
||||
aws-sigv4 (1.12.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.2.0)
|
||||
base64 (0.3.0)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
@@ -56,10 +58,10 @@ GEM
|
||||
faraday (>= 0.8.0)
|
||||
http-cookie (~> 1.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-em_synchrony (1.0.1)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.1.0)
|
||||
faraday-multipart (1.1.1)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
@@ -69,7 +71,7 @@ GEM
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.0)
|
||||
fastlane (2.227.0)
|
||||
fastlane (2.228.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
@@ -109,7 +111,7 @@ GEM
|
||||
tty-spinner (>= 0.8.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.4.0)
|
||||
xcpretty (~> 0.4.1)
|
||||
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
|
||||
fastlane-sirp (1.0.0)
|
||||
sysrandom (~> 1.0)
|
||||
@@ -156,22 +158,24 @@ GEM
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.10.2)
|
||||
json (2.12.2)
|
||||
jwt (2.10.1)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.2.1)
|
||||
naturally (2.3.0)
|
||||
nkf (0.2.0)
|
||||
optparse (0.6.0)
|
||||
os (1.1.4)
|
||||
ostruct (0.6.1)
|
||||
plist (3.7.2)
|
||||
public_suffix (6.0.1)
|
||||
rake (13.2.1)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.3.0)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
@@ -182,7 +186,7 @@ GEM
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
signet (0.19.0)
|
||||
signet (0.20.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
@@ -209,7 +213,7 @@ GEM
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.4.0)
|
||||
rexml (>= 3.3.6, < 4.0)
|
||||
xcpretty (0.4.0)
|
||||
xcpretty (0.4.1)
|
||||
rouge (~> 3.28.0)
|
||||
xcpretty-travis-formatter (1.0.1)
|
||||
xcpretty (~> 0.2, >= 0.0.7)
|
||||
@@ -218,7 +222,10 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
abbrev
|
||||
fastlane
|
||||
mutex_m
|
||||
ostruct
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.22
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
**Last updated**
|
||||
August 30 2023
|
||||
September 30 2025
|
||||
|
||||
# Privacy Policy
|
||||
Catima does not collect or transmit any personal information.
|
||||
@@ -11,6 +11,12 @@ To ensure correct app functionality, we require access to the following:
|
||||
|
||||
Catima offers a feature to share cards with other users. All the relevant data is in the generated shareable URLs and never transmitted to our servers. When viewed through catima.app, the data in the URL is rendered using client-side Javascript to further ensure no data is ever transmitted to us.
|
||||
|
||||
## Crash reporting privacy
|
||||
|
||||
In the FOSS version of Catima (the version used on IzzyOnDroid, F-Droid and GitHub), the open source crash reporter ACRA is used for crash reporting. When a crash is detected, Catima will ask the user if they are willing to report the crash. If they choose to do so, the user's mail client is opened so they can review the data that would be sent. Crash reporting data is only sent when the user explicitly chooses to do so, it is **never** sent automatically. Crash reporting data is only used to solve crashes and no (potentially) sensitive information is ever shared. Users who do not want to be asked to report crashes can disable the "Ask to send crash reports" setting in Catima settings.
|
||||
|
||||
For the Google Play version of Catima, crash reporting is [managed by Google](https://support.google.com/googleplay/android-developer/answer/9859174?hl=en). Users can opt in or out of crash reporting through the Google app under the "Usage and diagnostics" setting.
|
||||
|
||||
# Changes
|
||||
This Privacy Policy may be updated from time to time for any reason. We will notify you of any changes to our Privacy Policy by posting the new Privacy Policy to https://catima.app/privacy-policy/. A snapshot of the Privacy Policy is available within the Catima app, though it may be outdated. When the Privacy Policy on the website and in the app differ, the website should be considered leading. You are advised to consult the Privacy Policy regularly for any changes, as continued use is deemed approval of all changes.
|
||||
|
||||
|
||||
@@ -1,39 +1,35 @@
|
||||
import com.android.build.gradle.internal.tasks.factory.dependsOn
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("com.github.spotbugs")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
alias(libs.plugins.com.android.application)
|
||||
alias(libs.plugins.org.jetbrains.kotlin.android)
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures.set(false)
|
||||
setEffort("max")
|
||||
excludeFilter.set(file("./config/spotbugs/exclude.xml"))
|
||||
reportsDir.set(layout.buildDirectory.file("reports/spotbugs/").get().asFile)
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "protect.card_locker"
|
||||
compileSdk = 35
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "me.hackerchick.catima"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
versionCode = 147
|
||||
versionName = "2.34.5"
|
||||
targetSdk = 36
|
||||
versionCode = 154
|
||||
versionName = "2.39.1"
|
||||
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
multiDexEnabled = true
|
||||
|
||||
resourceConfigurations += listOf("ar", "be", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "et", "fi", "fr", "gl", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "pt-rBR", "pt-rPT", "ro-rRO", "ru", "sk", "sl", "sr", "sv", "ta", "tr", "uk", "vi", "zh-rCN", "zh-rTW")
|
||||
resourceConfigurations += listOf("ar", "be", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "et", "fa", "fi", "fr", "gl", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "pt-rBR", "pt-rPT", "ro-rRO", "ru", "sk", "sl", "sr", "sv", "ta", "tr", "uk", "vi", "zh-rCN", "zh-rTW")
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
buildConfigField("boolean", "showDonate", "true")
|
||||
buildConfigField("boolean", "showRateOnGooglePlay", "false")
|
||||
buildConfigField("boolean", "useAcraCrashReporter", "true")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -66,6 +62,9 @@ android {
|
||||
// Google doesn't allow donation links
|
||||
buildConfigField("boolean", "showDonate", "false")
|
||||
buildConfigField("boolean", "showRateOnGooglePlay", "true")
|
||||
|
||||
// Google Play already sends crashes to the Google Play Console
|
||||
buildConfigField("boolean", "useAcraCrashReporter", "false")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,58 +103,48 @@ android {
|
||||
lintConfig = file("lint.xml")
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
jvmTarget = "21"
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// AndroidX
|
||||
implementation("androidx.appcompat:appcompat:1.7.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
|
||||
implementation("androidx.core:core-ktx:1.16.0")
|
||||
implementation("androidx.core:core-splashscreen:1.0.1")
|
||||
implementation("androidx.exifinterface:exifinterface:1.4.1")
|
||||
implementation("androidx.palette:palette:1.0.0")
|
||||
implementation("androidx.preference:preference:1.2.1")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
|
||||
implementation(libs.androidx.appcompat.appcompat)
|
||||
implementation(libs.androidx.constraintlayout.constraintlayout)
|
||||
implementation(libs.androidx.core.core.ktx)
|
||||
implementation(libs.androidx.core.core.remoteviews)
|
||||
implementation(libs.androidx.core.core.splashscreen)
|
||||
implementation(libs.androidx.exifinterface.exifinterface)
|
||||
implementation(libs.androidx.palette.palette)
|
||||
implementation(libs.androidx.preference.preference)
|
||||
implementation(libs.com.google.android.material.material)
|
||||
coreLibraryDesugaring(libs.com.android.tools.desugar.jdk.libs)
|
||||
|
||||
// Third-party
|
||||
implementation("com.journeyapps:zxing-android-embedded:4.3.0@aar")
|
||||
implementation("com.github.yalantis:ucrop:2.2.10")
|
||||
implementation("com.google.zxing:core:3.5.3")
|
||||
implementation("org.apache.commons:commons-csv:1.9.0")
|
||||
implementation("com.jaredrummler:colorpicker:1.1.0")
|
||||
implementation("net.lingala.zip4j:zip4j:2.11.5")
|
||||
implementation(libs.com.journeyapps.zxing.android.embedded)
|
||||
implementation(libs.com.github.yalantis.ucrop)
|
||||
implementation(libs.com.google.zxing.core)
|
||||
implementation(libs.org.apache.commons.commons.csv)
|
||||
implementation(libs.com.jaredrummler.colorpicker)
|
||||
implementation(libs.net.lingala.zip4j.zip4j)
|
||||
|
||||
// SpotBugs
|
||||
implementation("io.wcm.tooling.spotbugs:io.wcm.tooling.spotbugs.annotations:1.0.0")
|
||||
// Crash reporting
|
||||
implementation(libs.bundles.acra)
|
||||
|
||||
// Testing
|
||||
val androidXTestVersion = "1.6.1"
|
||||
val junitVersion = "4.13.2"
|
||||
testImplementation("androidx.test:core:$androidXTestVersion")
|
||||
testImplementation("junit:junit:$junitVersion")
|
||||
testImplementation("org.robolectric:robolectric:4.14.1")
|
||||
testImplementation(libs.androidx.test.core)
|
||||
testImplementation(libs.junit.junit)
|
||||
testImplementation(libs.org.robolectric.robolectric)
|
||||
|
||||
androidTestImplementation("androidx.test:core:$androidXTestVersion")
|
||||
androidTestImplementation("junit:junit:$junitVersion")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.2.1")
|
||||
androidTestImplementation("androidx.test:runner:$androidXTestVersion")
|
||||
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
||||
}
|
||||
|
||||
tasks.withType<SpotBugsTask>().configureEach {
|
||||
description = "Run spotbugs"
|
||||
group = "verification"
|
||||
|
||||
//classes = fileTree("build/intermediates/javac/debug/compileDebugJavaWithJavac/classes")
|
||||
//source = fileTree("src/main/java")
|
||||
//classpath = files()
|
||||
|
||||
reports.maybeCreate("xml").required.set(false)
|
||||
reports.maybeCreate("html").required.set(true)
|
||||
androidTestImplementation(libs.bundles.androidx.test)
|
||||
androidTestImplementation(libs.junit.junit)
|
||||
androidTestImplementation(libs.androidx.test.ext.junit)
|
||||
androidTestImplementation(libs.androidx.test.uiautomator.uiautomator)
|
||||
androidTestImplementation(libs.androidx.test.espresso.espresso.core)
|
||||
}
|
||||
|
||||
tasks.register("copyRawResFiles", Copy::class) {
|
||||
|
||||
17
app/proguard-rules.pro
vendored
@@ -21,4 +21,19 @@
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# This keep the class and method names the same, for debugging stack traces
|
||||
-dontobfuscate
|
||||
-dontobfuscate
|
||||
|
||||
# Required for uCrop 2.2.11
|
||||
# This is generated automatically by the Android Gradle plugin.
|
||||
-dontwarn javax.annotation.processing.AbstractProcessor
|
||||
-dontwarn javax.annotation.processing.SupportedOptions
|
||||
-dontwarn okhttp3.Call
|
||||
-dontwarn okhttp3.Dispatcher
|
||||
-dontwarn okhttp3.OkHttpClient
|
||||
-dontwarn okhttp3.Request$Builder
|
||||
-dontwarn okhttp3.Request
|
||||
-dontwarn okhttp3.Response
|
||||
-dontwarn okhttp3.ResponseBody
|
||||
-dontwarn okio.BufferedSource
|
||||
-dontwarn okio.Okio
|
||||
-dontwarn okio.Sink
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
||||
<resources>
|
||||
<string name="app_name">קטימה ניפוי באגים</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
||||
<resources>
|
||||
<string name="app_name">கேட்டிமா Debug</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Catima 除錯版</string>
|
||||
</resources>
|
||||
<string name="app_name">卡提碼除錯版</string>
|
||||
</resources>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<permission
|
||||
android:description="@string/permissionReadCardsDescription"
|
||||
android:icon="@drawable/ic_launcher_foreground"
|
||||
android:icon="@drawable/ic_launcher_monochrome"
|
||||
android:label="@string/permissionReadCardsLabel"
|
||||
android:name="${applicationId}.READ_CARDS"
|
||||
android:protectionLevel="dangerous" />
|
||||
@@ -30,6 +30,20 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:localeConfig="@xml/locales_config">
|
||||
|
||||
<receiver
|
||||
android:name=".ListWidget"
|
||||
android:label="@string/card_list_widget_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/list_widget_info" />
|
||||
</receiver>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
@@ -51,6 +65,7 @@
|
||||
<data android:mimeType="application/vnd.apple.pkpass" />
|
||||
<data android:mimeType="application/vnd-com.apple.pkpass" />
|
||||
<data android:mimeType="application/vnd.espass-espass" />
|
||||
<data android:mimeType="application/vnd.apple.pkpasses" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
@@ -62,6 +77,7 @@
|
||||
<data android:mimeType="application/vnd.apple.pkpass" />
|
||||
<data android:mimeType="application/vnd-com.apple.pkpass" />
|
||||
<data android:mimeType="application/vnd.espass-espass" />
|
||||
<data android:mimeType="application/vnd.apple.pkpasses" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
@@ -75,7 +91,8 @@
|
||||
<activity
|
||||
android:name=".ManageGroupActivity"
|
||||
android:label="@string/group_edit"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustResize"/>
|
||||
<activity
|
||||
android:name=".LoyaltyCardViewActivity"
|
||||
android:exported="true"
|
||||
@@ -127,12 +144,11 @@
|
||||
android:name=".preferences.SettingsActivity"
|
||||
android:label="@string/settings"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<!-- FIXME: locked screenOrientation is a workaround for https://github.com/CatimaLoyalty/Android/issues/1715, remove when https://github.com/CatimaLoyalty/Android/issues/513 is fixed -->
|
||||
<!-- FIXME: ImportExportActivity cancels import on rotation -->
|
||||
<activity
|
||||
android:name=".ImportExportActivity"
|
||||
android:label="@string/importExport"
|
||||
android:exported="true"
|
||||
android:screenOrientation="locked"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
<!-- ZIP Intent Filter -->
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 20 KiB |
@@ -99,9 +99,9 @@ public class AboutContent {
|
||||
|
||||
public String getThirdPartyLibraries() {
|
||||
final List<ThirdPartyInfo> usedLibraries = new ArrayList<>();
|
||||
usedLibraries.add(new ThirdPartyInfo("ACRA", "https://github.com/ACRA/acra", "Apache 2.0"));
|
||||
usedLibraries.add(new ThirdPartyInfo("Color Picker", "https://github.com/jaredrummler/ColorPicker", "Apache 2.0"));
|
||||
usedLibraries.add(new ThirdPartyInfo("Commons CSV", "https://commons.apache.org/proper/commons-csv/", "Apache 2.0"));
|
||||
usedLibraries.add(new ThirdPartyInfo("NumberPickerPreference", "https://github.com/invissvenska/NumberPickerPreference", "GNU LGPL 3.0"));
|
||||
usedLibraries.add(new ThirdPartyInfo("uCrop", "https://github.com/Yalantis/uCrop", "Apache 2.0"));
|
||||
usedLibraries.add(new ThirdPartyInfo("Zip4j", "https://github.com/srikanth-lingala/zip4j", "Apache 2.0"));
|
||||
usedLibraries.add(new ThirdPartyInfo("ZXing", "https://github.com/zxing/zxing", "Apache 2.0"));
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
public interface BarcodeImageWriterResultCallback {
|
||||
void onBarcodeImageWriterResult(boolean success);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package protect.card_locker
|
||||
|
||||
interface BarcodeImageWriterResultCallback {
|
||||
fun onBarcodeImageWriterResult(success: Boolean)
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import protect.card_locker.databinding.BarcodeSelectorActivityBinding;
|
||||
|
||||
/**
|
||||
* This activity is callable and will allow a user to enter
|
||||
* barcode data and generate all barcodes possible for
|
||||
* the data. The user may then select any barcode, where its
|
||||
* data and type will be returned to the caller.
|
||||
*/
|
||||
public class BarcodeSelectorActivity extends CatimaAppCompatActivity implements BarcodeSelectorAdapter.BarcodeSelectorListener {
|
||||
private BarcodeSelectorActivityBinding binding;
|
||||
private static final String TAG = "Catima";
|
||||
|
||||
// Result this activity will return
|
||||
public static final String BARCODE_CONTENTS = "contents";
|
||||
public static final String BARCODE_FORMAT = "format";
|
||||
|
||||
private final Handler typingDelayHandler = new Handler(Looper.getMainLooper());
|
||||
public static final Integer INPUT_DELAY = 250;
|
||||
|
||||
private BarcodeSelectorAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = BarcodeSelectorActivityBinding.inflate(getLayoutInflater());
|
||||
setTitle(R.string.selectBarcodeTitle);
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
enableToolbarBackButton();
|
||||
|
||||
EditText cardId = binding.cardId;
|
||||
ListView mBarcodeList = binding.barcodes;
|
||||
mAdapter = new BarcodeSelectorAdapter(this, new ArrayList<>(), this);
|
||||
mBarcodeList.setAdapter(mAdapter);
|
||||
|
||||
cardId.addTextChangedListener(new SimpleTextWatcher() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Delay the input processing so we avoid overload
|
||||
typingDelayHandler.removeCallbacksAndMessages(null);
|
||||
|
||||
typingDelayHandler.postDelayed(() -> {
|
||||
Log.d(TAG, "Entered text: " + s);
|
||||
|
||||
runOnUiThread(() -> {
|
||||
generateBarcodes(s.toString());
|
||||
});
|
||||
}, INPUT_DELAY);
|
||||
}
|
||||
});
|
||||
|
||||
final Bundle b = getIntent().getExtras();
|
||||
final String initialCardId = b != null ? b.getString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID) : null;
|
||||
|
||||
if (initialCardId != null) {
|
||||
cardId.setText(initialCardId);
|
||||
} else {
|
||||
generateBarcodes("");
|
||||
}
|
||||
}
|
||||
|
||||
private void generateBarcodes(String value) {
|
||||
// Update barcodes
|
||||
ArrayList<CatimaBarcodeWithValue> barcodes = new ArrayList<>();
|
||||
for (BarcodeFormat barcodeFormat : CatimaBarcode.barcodeFormats) {
|
||||
CatimaBarcode catimaBarcode = CatimaBarcode.fromBarcode(barcodeFormat);
|
||||
barcodes.add(new CatimaBarcodeWithValue(catimaBarcode, value));
|
||||
}
|
||||
mAdapter.setBarcodes(barcodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
setResult(Activity.RESULT_CANCELED);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowClicked(int inputPosition, View view) {
|
||||
CatimaBarcodeWithValue barcodeWithValue = mAdapter.getItem(inputPosition);
|
||||
CatimaBarcode catimaBarcode = barcodeWithValue.catimaBarcode();
|
||||
|
||||
if (!mAdapter.isValid(view)) {
|
||||
Toast.makeText(this, getString(R.string.wrongValueForBarcodeType), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String barcodeFormat = catimaBarcode.format().name();
|
||||
String value = barcodeWithValue.value();
|
||||
|
||||
Log.d(TAG, "Selected barcode type " + barcodeFormat);
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra(BARCODE_FORMAT, barcodeFormat);
|
||||
result.putExtra(BARCODE_CONTENTS, value);
|
||||
BarcodeSelectorActivity.this.setResult(RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
118
app/src/main/java/protect/card_locker/BarcodeSelectorActivity.kt
Normal file
@@ -0,0 +1,118 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import protect.card_locker.BarcodeSelectorAdapter.BarcodeSelectorListener
|
||||
import protect.card_locker.databinding.BarcodeSelectorActivityBinding
|
||||
|
||||
/**
|
||||
* This activity is callable and will allow a user to enter
|
||||
* barcode data and generate all barcodes possible for
|
||||
* the data. The user may then select any barcode, where its
|
||||
* data and type will be returned to the caller.
|
||||
*/
|
||||
class BarcodeSelectorActivity : CatimaAppCompatActivity(), BarcodeSelectorListener, MenuProvider {
|
||||
|
||||
private lateinit var binding: BarcodeSelectorActivityBinding
|
||||
private lateinit var mAdapter: BarcodeSelectorAdapter
|
||||
|
||||
companion object {
|
||||
private const val TAG = "Catima"
|
||||
|
||||
// Result this activity will return
|
||||
const val BARCODE_CONTENTS = "contents"
|
||||
const val BARCODE_FORMAT = "format"
|
||||
|
||||
const val INPUT_DELAY = 250L
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
addMenuProvider(this)
|
||||
binding = BarcodeSelectorActivityBinding.inflate(layoutInflater)
|
||||
setTitle(R.string.selectBarcodeTitle)
|
||||
setContentView(binding.getRoot())
|
||||
Utils.applyWindowInsets(binding.getRoot())
|
||||
setSupportActionBar(binding.toolbar)
|
||||
enableToolbarBackButton()
|
||||
|
||||
var typingDelayJob: Job? = null
|
||||
val cardId = binding.cardId
|
||||
val mBarcodeList = binding.barcodes
|
||||
mAdapter = BarcodeSelectorAdapter(this, ArrayList<CatimaBarcodeWithValue?>(), this)
|
||||
mBarcodeList.adapter = mAdapter
|
||||
|
||||
cardId.doOnTextChanged { s, _, _, _ ->
|
||||
typingDelayJob?.cancel()
|
||||
typingDelayJob =
|
||||
lifecycleScope.launch {
|
||||
delay(INPUT_DELAY) // Delay the input processing so we avoid overload
|
||||
Log.d(TAG, "Entered text: $s")
|
||||
generateBarcodes(s.toString())
|
||||
}
|
||||
}
|
||||
|
||||
val initialCardId = intent.extras?.getString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID)
|
||||
|
||||
initialCardId?.let {
|
||||
cardId.setText(initialCardId)
|
||||
} ?: generateBarcodes("")
|
||||
|
||||
}
|
||||
|
||||
private fun generateBarcodes(value: String?) {
|
||||
// Update barcodes
|
||||
val barcodes = ArrayList<CatimaBarcodeWithValue?>()
|
||||
CatimaBarcode.barcodeFormats.forEach {
|
||||
val catimaBarcode = CatimaBarcode.fromBarcode(it)
|
||||
barcodes.add(CatimaBarcodeWithValue(catimaBarcode, value))
|
||||
}
|
||||
mAdapter.setBarcodes(barcodes)
|
||||
}
|
||||
|
||||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {}
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
if (menuItem.itemId == android.R.id.home) {
|
||||
setResult(RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onRowClicked(inputPosition: Int, view: View) {
|
||||
val barcodeWithValue = mAdapter.getItem(inputPosition)
|
||||
val catimaBarcode = barcodeWithValue!!.catimaBarcode()
|
||||
|
||||
if (!mAdapter.isValid(view)) {
|
||||
Toast.makeText(this, getString(R.string.wrongValueForBarcodeType), Toast.LENGTH_LONG).show()
|
||||
return
|
||||
}
|
||||
|
||||
val barcodeFormat = catimaBarcode.format().name
|
||||
val value = barcodeWithValue.value()
|
||||
|
||||
Log.d(TAG, "Selected barcode type $barcodeFormat")
|
||||
|
||||
Intent().apply {
|
||||
putExtra(BARCODE_FORMAT, barcodeFormat)
|
||||
putExtra(BARCODE_CONTENTS, value)
|
||||
setResult(RESULT_OK, this)
|
||||
}
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.pm.ShortcutInfoCompat;
|
||||
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import protect.card_locker.databinding.CardShortcutConfigureActivityBinding;
|
||||
import protect.card_locker.preferences.Settings;
|
||||
|
||||
/**
|
||||
* The configuration screen for creating a shortcut.
|
||||
*/
|
||||
public class CardShortcutConfigure extends CatimaAppCompatActivity implements LoyaltyCardCursorAdapter.CardAdapterListener {
|
||||
private CardShortcutConfigureActivityBinding binding;
|
||||
static final String TAG = "Catima";
|
||||
private SQLiteDatabase mDatabase;
|
||||
private LoyaltyCardCursorAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
binding = CardShortcutConfigureActivityBinding.inflate(getLayoutInflater());
|
||||
mDatabase = new DBHelper(this).getReadableDatabase();
|
||||
|
||||
// Set the result to CANCELED. This will cause nothing to happen if the
|
||||
// aback button is pressed.
|
||||
setResult(RESULT_CANCELED);
|
||||
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
toolbar.setTitle(R.string.shortcutSelectCard);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// If there are no cards, bail
|
||||
int cardCount = DBHelper.getLoyaltyCardCount(mDatabase);
|
||||
if (cardCount == 0) {
|
||||
Toast.makeText(this, R.string.noCardsMessage, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
Cursor cardCursor = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.All);
|
||||
mAdapter = new LoyaltyCardCursorAdapter(this, cardCursor, this, null);
|
||||
binding.list.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
var layoutManager = (GridLayoutManager) binding.list.getLayoutManager();
|
||||
if (layoutManager != null) {
|
||||
var settings = new Settings(this);
|
||||
layoutManager.setSpanCount(settings.getPreferredColumnCount());
|
||||
}
|
||||
}
|
||||
|
||||
private void onClickAction(int position) {
|
||||
Cursor selected = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.All);
|
||||
selected.moveToPosition(position);
|
||||
LoyaltyCard loyaltyCard = LoyaltyCard.fromCursor(CardShortcutConfigure.this, selected);
|
||||
|
||||
Log.d(TAG, "Creating shortcut for card " + loyaltyCard.store + "," + loyaltyCard.id);
|
||||
|
||||
ShortcutInfoCompat shortcut = ShortcutHelper.createShortcutBuilder(CardShortcutConfigure.this, loyaltyCard).build();
|
||||
|
||||
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(CardShortcutConfigure.this, shortcut));
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu inputMenu) {
|
||||
getMenuInflater().inflate(R.menu.card_details_menu, inputMenu);
|
||||
|
||||
return super.onCreateOptionsMenu(inputMenu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem inputItem) {
|
||||
int id = inputItem.getItemId();
|
||||
|
||||
if (id == R.id.action_display_options) {
|
||||
mAdapter.showDisplayOptionsDialog();
|
||||
invalidateOptionsMenu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(inputItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowClicked(int inputPosition) {
|
||||
onClickAction(inputPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowLongClicked(int inputPosition) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import protect.card_locker.LoyaltyCardCursorAdapter.CardAdapterListener
|
||||
import protect.card_locker.databinding.CardShortcutConfigureActivityBinding
|
||||
import protect.card_locker.preferences.Settings
|
||||
|
||||
class CardShortcutConfigure : CatimaAppCompatActivity(), CardAdapterListener, MenuProvider {
|
||||
|
||||
private lateinit var binding: CardShortcutConfigureActivityBinding
|
||||
private lateinit var mDatabase: SQLiteDatabase
|
||||
private lateinit var mAdapter: LoyaltyCardCursorAdapter
|
||||
|
||||
private companion object {
|
||||
private const val TAG: String = "Catima"
|
||||
}
|
||||
|
||||
public override fun onCreate(savedInstanceBundle: Bundle?) {
|
||||
super.onCreate(savedInstanceBundle)
|
||||
addMenuProvider(this)
|
||||
binding = CardShortcutConfigureActivityBinding.inflate(layoutInflater)
|
||||
mDatabase = DBHelper(this).readableDatabase
|
||||
|
||||
// Set the result to CANCELED.
|
||||
// This will cause nothing to happen if the back button is pressed.
|
||||
setResult(RESULT_CANCELED)
|
||||
|
||||
setContentView(binding.getRoot())
|
||||
Utils.applyWindowInsets(binding.getRoot())
|
||||
|
||||
binding.toolbar.apply {
|
||||
setTitle(R.string.shortcutSelectCard)
|
||||
setSupportActionBar(this)
|
||||
}
|
||||
|
||||
// If there are no cards, bail
|
||||
if (DBHelper.getLoyaltyCardCount(mDatabase) == 0) {
|
||||
Toast.makeText(this, R.string.noCardsMessage, Toast.LENGTH_LONG).show()
|
||||
finish()
|
||||
}
|
||||
|
||||
val cardCursor = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.All)
|
||||
mAdapter = LoyaltyCardCursorAdapter(this, cardCursor, this, null)
|
||||
binding.list.setAdapter(mAdapter)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
val layoutManager = binding.list.layoutManager as GridLayoutManager?
|
||||
layoutManager?.setSpanCount(Settings(this).getPreferredColumnCount())
|
||||
}
|
||||
|
||||
private fun onClickAction(position: Int) {
|
||||
val selected = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.All)
|
||||
selected.moveToPosition(position)
|
||||
val loyaltyCard = LoyaltyCard.fromCursor(this, selected)
|
||||
|
||||
Log.d(TAG, "Creating shortcut for card ${loyaltyCard.store}, ${loyaltyCard.id}")
|
||||
|
||||
val shortcut = ShortcutHelper.createShortcutBuilder(this, loyaltyCard).build()
|
||||
|
||||
setResult(RESULT_OK,
|
||||
ShortcutManagerCompat.createShortcutResultIntent(this, shortcut))
|
||||
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onCreateMenu(inputMenu: Menu, menuInflater: MenuInflater) {
|
||||
menuInflater.inflate(R.menu.card_details_menu, inputMenu)
|
||||
}
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
if (menuItem.itemId == R.id.action_display_options) {
|
||||
mAdapter.showDisplayOptionsDialog()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onRowClicked(inputPosition: Int) {
|
||||
onClickAction(inputPosition)
|
||||
}
|
||||
|
||||
override fun onRowLongClicked(inputPosition: Int) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import protect.card_locker.async.TaskHandler;
|
||||
import protect.card_locker.databinding.ImportExportActivityBinding;
|
||||
import protect.card_locker.importexport.DataFormat;
|
||||
import protect.card_locker.importexport.ImportExportResult;
|
||||
import protect.card_locker.importexport.ImportExportResultType;
|
||||
|
||||
public class ImportExportActivity extends CatimaAppCompatActivity {
|
||||
private ImportExportActivityBinding binding;
|
||||
private static final String TAG = "Catima";
|
||||
|
||||
private ImportExportTask importExporter;
|
||||
|
||||
private String importAlertTitle;
|
||||
private String importAlertMessage;
|
||||
private DataFormat importDataFormat;
|
||||
private String exportPassword;
|
||||
|
||||
private ActivityResultLauncher<Intent> fileCreateLauncher;
|
||||
private ActivityResultLauncher<String> fileOpenLauncher;
|
||||
|
||||
final private TaskHandler mTasks = new TaskHandler();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ImportExportActivityBinding.inflate(getLayoutInflater());
|
||||
setTitle(R.string.importExport);
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
enableToolbarBackButton();
|
||||
|
||||
Intent fileIntent = getIntent();
|
||||
if (fileIntent != null && fileIntent.getType() != null) {
|
||||
chooseImportType(fileIntent.getData());
|
||||
}
|
||||
|
||||
// would use ActivityResultContracts.CreateDocument() but mime type cannot be set
|
||||
fileCreateLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
Intent intent = result.getData();
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "Activity returned NULL data");
|
||||
return;
|
||||
}
|
||||
Uri uri = intent.getData();
|
||||
if (uri == null) {
|
||||
Log.e(TAG, "Activity returned NULL uri");
|
||||
return;
|
||||
}
|
||||
// Running this in a thread prevents Android from throwing a NetworkOnMainThreadException for large files
|
||||
// FIXME: This is still suboptimal, because showing that the export started is delayed until the network request finishes
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
OutputStream writer = getContentResolver().openOutputStream(uri);
|
||||
Log.d(TAG, "Starting file export with: " + result);
|
||||
startExport(writer, uri, exportPassword.toCharArray(), true);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to export file: " + result, e);
|
||||
onExportComplete(new ImportExportResult(ImportExportResultType.GenericFailure, result.toString()), uri);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
});
|
||||
fileOpenLauncher = registerForActivityResult(new ActivityResultContracts.GetContent(), result -> {
|
||||
if (result == null) {
|
||||
Log.e(TAG, "Activity returned NULL data");
|
||||
return;
|
||||
}
|
||||
openFileForImport(result, null);
|
||||
});
|
||||
|
||||
// Check that there is a file manager available
|
||||
final Intent intentCreateDocumentAction = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
intentCreateDocumentAction.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intentCreateDocumentAction.setType("application/zip");
|
||||
intentCreateDocumentAction.putExtra(Intent.EXTRA_TITLE, "catima.zip");
|
||||
|
||||
Button exportButton = binding.exportButton;
|
||||
exportButton.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(ImportExportActivity.this);
|
||||
builder.setTitle(R.string.exportPassword);
|
||||
|
||||
FrameLayout container = new FrameLayout(ImportExportActivity.this);
|
||||
|
||||
final TextInputLayout textInputLayout = new TextInputLayout(ImportExportActivity.this);
|
||||
textInputLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(50, 10, 50, 0);
|
||||
textInputLayout.setLayoutParams(params);
|
||||
|
||||
final EditText input = new EditText(ImportExportActivity.this);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
input.setHint(R.string.exportPasswordHint);
|
||||
|
||||
textInputLayout.addView(input);
|
||||
container.addView(textInputLayout);
|
||||
builder.setView(container);
|
||||
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> {
|
||||
exportPassword = input.getText().toString();
|
||||
try {
|
||||
fileCreateLauncher.launch(intentCreateDocumentAction);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getApplicationContext(), R.string.failedOpeningFileManager, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, "No activity found to handle intent", e);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.cancel());
|
||||
builder.show();
|
||||
});
|
||||
|
||||
// Check that there is a file manager available
|
||||
Button importFilesystem = binding.importOptionFilesystemButton;
|
||||
importFilesystem.setOnClickListener(v -> chooseImportType(null));
|
||||
|
||||
// FIXME: The importer/exporter is currently quite broken
|
||||
// To prevent the screen from turning off during import/export and some devices killing Catima as it's no longer foregrounded, force the screen to stay on here
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
private void openFileForImport(Uri uri, char[] password) {
|
||||
// Running this in a thread prevents Android from throwing a NetworkOnMainThreadException for large files
|
||||
// FIXME: This is still suboptimal, because showing that the import started is delayed until the network request finishes
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
InputStream reader = getContentResolver().openInputStream(uri);
|
||||
Log.d(TAG, "Starting file import with: " + uri);
|
||||
startImport(reader, uri, importDataFormat, password, true);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to import file: " + uri, e);
|
||||
onImportComplete(new ImportExportResult(ImportExportResultType.GenericFailure, e.toString()), uri, importDataFormat);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private void chooseImportType(@Nullable Uri fileData) {
|
||||
|
||||
List<CharSequence> betaImportOptions = new ArrayList<>();
|
||||
betaImportOptions.add("Fidme");
|
||||
betaImportOptions.add("Stocard");
|
||||
List<CharSequence> importOptions = new ArrayList<>();
|
||||
|
||||
for (String importOption : getResources().getStringArray(R.array.import_types_array)) {
|
||||
if (betaImportOptions.contains(importOption)) {
|
||||
importOption = importOption + " (BETA)";
|
||||
}
|
||||
|
||||
importOptions.add(importOption);
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
builder.setTitle(R.string.chooseImportType)
|
||||
.setItems(importOptions.toArray(new CharSequence[importOptions.size()]), (dialog, which) -> {
|
||||
switch (which) {
|
||||
// Catima
|
||||
case 0:
|
||||
importAlertTitle = getString(R.string.importCatima);
|
||||
importAlertMessage = getString(R.string.importCatimaMessage);
|
||||
importDataFormat = DataFormat.Catima;
|
||||
break;
|
||||
// Fidme
|
||||
case 1:
|
||||
importAlertTitle = getString(R.string.importFidme);
|
||||
importAlertMessage = getString(R.string.importFidmeMessage);
|
||||
importDataFormat = DataFormat.Fidme;
|
||||
break;
|
||||
// Loyalty Card Keychain
|
||||
case 2:
|
||||
importAlertTitle = getString(R.string.importLoyaltyCardKeychain);
|
||||
importAlertMessage = getString(R.string.importLoyaltyCardKeychainMessage);
|
||||
importDataFormat = DataFormat.Catima;
|
||||
break;
|
||||
// Stocard
|
||||
case 3:
|
||||
importAlertTitle = getString(R.string.importStocard);
|
||||
importAlertMessage = getString(R.string.importStocardMessage);
|
||||
importDataFormat = DataFormat.Stocard;
|
||||
break;
|
||||
// Voucher Vault
|
||||
case 4:
|
||||
importAlertTitle = getString(R.string.importVoucherVault);
|
||||
importAlertMessage = getString(R.string.importVoucherVaultMessage);
|
||||
importDataFormat = DataFormat.VoucherVault;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown DataFormat");
|
||||
}
|
||||
|
||||
if (fileData != null) {
|
||||
openFileForImport(fileData, null);
|
||||
return;
|
||||
}
|
||||
|
||||
new MaterialAlertDialogBuilder(this)
|
||||
.setTitle(importAlertTitle)
|
||||
.setMessage(importAlertMessage)
|
||||
.setPositiveButton(R.string.ok, (dialog1, which1) -> {
|
||||
try {
|
||||
fileOpenLauncher.launch("*/*");
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getApplicationContext(), R.string.failedOpeningFileManager, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, "No activity found to handle intent", e);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void startImport(final InputStream target, final Uri targetUri, final DataFormat dataFormat, final char[] password, final boolean closeWhenDone) {
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.IMPORT, true, false, false);
|
||||
ImportExportTask.TaskCompleteListener listener = new ImportExportTask.TaskCompleteListener() {
|
||||
@Override
|
||||
public void onTaskComplete(ImportExportResult result, DataFormat dataFormat) {
|
||||
onImportComplete(result, targetUri, dataFormat);
|
||||
if (closeWhenDone) {
|
||||
try {
|
||||
target.close();
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
importExporter = new ImportExportTask(ImportExportActivity.this,
|
||||
dataFormat, target, password, listener);
|
||||
mTasks.executeTask(TaskHandler.TYPE.IMPORT, importExporter);
|
||||
}
|
||||
|
||||
private void startExport(final OutputStream target, final Uri targetUri, char[] password, final boolean closeWhenDone) {
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.EXPORT, true, false, false);
|
||||
ImportExportTask.TaskCompleteListener listener = new ImportExportTask.TaskCompleteListener() {
|
||||
@Override
|
||||
public void onTaskComplete(ImportExportResult result, DataFormat dataFormat) {
|
||||
onExportComplete(result, targetUri);
|
||||
if (closeWhenDone) {
|
||||
try {
|
||||
target.close();
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
importExporter = new ImportExportTask(ImportExportActivity.this,
|
||||
DataFormat.Catima, target, password, listener);
|
||||
mTasks.executeTask(TaskHandler.TYPE.EXPORT, importExporter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.IMPORT, true, false, false);
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.EXPORT, true, false, false);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void retryWithPassword(DataFormat dataFormat, Uri uri) {
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
builder.setTitle(R.string.passwordRequired);
|
||||
|
||||
FrameLayout container = new FrameLayout(ImportExportActivity.this);
|
||||
|
||||
final TextInputLayout textInputLayout = new TextInputLayout(ImportExportActivity.this);
|
||||
textInputLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(50, 10, 50, 0);
|
||||
textInputLayout.setLayoutParams(params);
|
||||
|
||||
final EditText input = new EditText(ImportExportActivity.this);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
input.setHint(R.string.exportPasswordHint);
|
||||
|
||||
textInputLayout.addView(input);
|
||||
container.addView(textInputLayout);
|
||||
builder.setView(container);
|
||||
|
||||
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> {
|
||||
openFileForImport(uri, input.getText().toString().toCharArray());
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.cancel());
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private String buildResultDialogMessage(ImportExportResult result, boolean isImport) {
|
||||
int messageId;
|
||||
|
||||
if (result.resultType() == ImportExportResultType.Success) {
|
||||
messageId = isImport ? R.string.importSuccessful : R.string.exportSuccessful;
|
||||
} else {
|
||||
messageId = isImport ? R.string.importFailed : R.string.exportFailed;
|
||||
}
|
||||
|
||||
StringBuilder messageBuilder = new StringBuilder(getResources().getString(messageId));
|
||||
if (result.developerDetails() != null) {
|
||||
messageBuilder.append("\n\n");
|
||||
messageBuilder.append(getResources().getString(R.string.include_if_asking_support));
|
||||
messageBuilder.append("\n\n");
|
||||
messageBuilder.append(result.developerDetails());
|
||||
}
|
||||
|
||||
return messageBuilder.toString();
|
||||
}
|
||||
|
||||
private void onImportComplete(ImportExportResult result, Uri path, DataFormat dataFormat) {
|
||||
ImportExportResultType resultType = result.resultType();
|
||||
|
||||
if (resultType == ImportExportResultType.BadPassword) {
|
||||
retryWithPassword(dataFormat, path);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
builder.setTitle(resultType == ImportExportResultType.Success ? R.string.importSuccessfulTitle : R.string.importFailedTitle);
|
||||
builder.setMessage(buildResultDialogMessage(result, true));
|
||||
builder.setNeutralButton(R.string.ok, (dialog, which) -> dialog.dismiss());
|
||||
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void onExportComplete(ImportExportResult result, final Uri path) {
|
||||
ImportExportResultType resultType = result.resultType();
|
||||
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
builder.setTitle(resultType == ImportExportResultType.Success ? R.string.exportSuccessfulTitle : R.string.exportFailedTitle);
|
||||
builder.setMessage(buildResultDialogMessage(result, false));
|
||||
builder.setNeutralButton(R.string.ok, (dialog, which) -> dialog.dismiss());
|
||||
|
||||
if (resultType == ImportExportResultType.Success) {
|
||||
final CharSequence sendLabel = ImportExportActivity.this.getResources().getText(R.string.sendLabel);
|
||||
|
||||
builder.setPositiveButton(sendLabel, (dialog, which) -> {
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, path);
|
||||
sendIntent.setType("text/csv");
|
||||
|
||||
// set flag to give temporary permission to external app to use the FileProvider
|
||||
sendIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
ImportExportActivity.this.startActivity(Intent.createChooser(sendIntent,
|
||||
sendLabel));
|
||||
|
||||
dialog.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
||||
416
app/src/main/java/protect/card_locker/ImportExportActivity.kt
Normal file
@@ -0,0 +1,416 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import protect.card_locker.async.TaskHandler
|
||||
import protect.card_locker.databinding.ImportExportActivityBinding
|
||||
import protect.card_locker.importexport.DataFormat
|
||||
import protect.card_locker.importexport.ImportExportResult
|
||||
import protect.card_locker.importexport.ImportExportResultType
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
class ImportExportActivity : CatimaAppCompatActivity() {
|
||||
private lateinit var binding: ImportExportActivityBinding
|
||||
|
||||
private var importExporter: ImportExportTask? = null
|
||||
|
||||
private var importAlertTitle: String? = null
|
||||
private var importAlertMessage: String? = null
|
||||
private var importDataFormat: DataFormat? = null
|
||||
private var exportPassword: String? = null
|
||||
|
||||
private lateinit var fileCreateLauncher: ActivityResultLauncher<Intent>
|
||||
private lateinit var fileOpenLauncher: ActivityResultLauncher<String>
|
||||
|
||||
private val mTasks = TaskHandler()
|
||||
|
||||
companion object {
|
||||
private const val TAG = "Catima"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ImportExportActivityBinding.inflate(layoutInflater)
|
||||
setTitle(R.string.importExport)
|
||||
setContentView(binding.root)
|
||||
Utils.applyWindowInsets(binding.root)
|
||||
val toolbar: Toolbar = binding.toolbar
|
||||
setSupportActionBar(toolbar)
|
||||
enableToolbarBackButton()
|
||||
|
||||
val fileIntent = intent
|
||||
if (fileIntent?.type != null) {
|
||||
chooseImportType(fileIntent.data)
|
||||
}
|
||||
|
||||
// would use ActivityResultContracts.CreateDocument() but mime type cannot be set
|
||||
fileCreateLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
val intent = result.data
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "Activity returned NULL data")
|
||||
return@registerForActivityResult
|
||||
}
|
||||
val uri = intent.data
|
||||
if (uri == null) {
|
||||
Log.e(TAG, "Activity returned NULL uri")
|
||||
return@registerForActivityResult
|
||||
}
|
||||
// Running this in a thread prevents Android from throwing a NetworkOnMainThreadException for large files
|
||||
// FIXME: This is still suboptimal, because showing that the export started is delayed until the network request finishes
|
||||
Thread {
|
||||
try {
|
||||
val writer = contentResolver.openOutputStream(uri)
|
||||
Log.d(TAG, "Starting file export with: $result")
|
||||
startExport(writer, uri, exportPassword?.toCharArray(), true)
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "Failed to export file: $result", e)
|
||||
onExportComplete(
|
||||
ImportExportResult(
|
||||
ImportExportResultType.GenericFailure,
|
||||
result.toString()
|
||||
), uri
|
||||
)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
fileOpenLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.GetContent()) { result ->
|
||||
if (result == null) {
|
||||
Log.e(TAG, "Activity returned NULL data")
|
||||
return@registerForActivityResult
|
||||
}
|
||||
openFileForImport(result, null)
|
||||
}
|
||||
|
||||
// Check that there is a file manager available
|
||||
val intentCreateDocumentAction = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
type = "application/zip"
|
||||
putExtra(Intent.EXTRA_TITLE, "catima.zip")
|
||||
}
|
||||
|
||||
val exportButton: Button = binding.exportButton
|
||||
exportButton.setOnClickListener {
|
||||
val builder = MaterialAlertDialogBuilder(this@ImportExportActivity)
|
||||
builder.setTitle(R.string.exportPassword)
|
||||
|
||||
val container = FrameLayout(this@ImportExportActivity)
|
||||
|
||||
val textInputLayout = TextInputLayout(this@ImportExportActivity).apply {
|
||||
endIconMode = TextInputLayout.END_ICON_PASSWORD_TOGGLE
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
setMargins(50, 10, 50, 0)
|
||||
}
|
||||
}
|
||||
|
||||
val input = EditText(this@ImportExportActivity).apply {
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||
setHint(R.string.exportPasswordHint)
|
||||
}
|
||||
|
||||
textInputLayout.addView(input)
|
||||
container.addView(textInputLayout)
|
||||
builder.setView(container)
|
||||
builder.setPositiveButton(R.string.ok) { _, _ ->
|
||||
exportPassword = input.text.toString()
|
||||
try {
|
||||
fileCreateLauncher.launch(intentCreateDocumentAction)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
R.string.failedOpeningFileManager,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
Log.e(TAG, "No activity found to handle intent", e)
|
||||
}
|
||||
}
|
||||
builder.setNegativeButton(R.string.cancel) { dialogInterface, _ -> dialogInterface.cancel() }
|
||||
builder.show()
|
||||
}
|
||||
|
||||
// Check that there is a file manager available
|
||||
val importFilesystem: Button = binding.importOptionFilesystemButton
|
||||
importFilesystem.setOnClickListener { chooseImportType(null) }
|
||||
|
||||
// FIXME: The importer/exporter is currently quite broken
|
||||
// To prevent the screen from turning off during import/export and some devices killing Catima as it's no longer foregrounded, force the screen to stay on here
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
private fun openFileForImport(uri: Uri, password: CharArray?) {
|
||||
// Running this in a thread prevents Android from throwing a NetworkOnMainThreadException for large files
|
||||
// FIXME: This is still suboptimal, because showing that the import started is delayed until the network request finishes
|
||||
Thread {
|
||||
try {
|
||||
val reader = contentResolver.openInputStream(uri)
|
||||
Log.d(TAG, "Starting file import with: $uri")
|
||||
startImport(reader, uri, importDataFormat, password, true)
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "Failed to import file: $uri", e)
|
||||
onImportComplete(
|
||||
ImportExportResult(
|
||||
ImportExportResultType.GenericFailure,
|
||||
e.toString()
|
||||
), uri, importDataFormat
|
||||
)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun chooseImportType(fileData: Uri?) {
|
||||
val betaImportOptions = mutableListOf<CharSequence>()
|
||||
betaImportOptions.add("Fidme")
|
||||
val importOptions = mutableListOf<CharSequence>()
|
||||
|
||||
for (importOption in resources.getStringArray(R.array.import_types_array)) {
|
||||
var option = importOption
|
||||
if (betaImportOptions.contains(importOption)) {
|
||||
option = "$importOption (BETA)"
|
||||
}
|
||||
importOptions.add(option)
|
||||
}
|
||||
|
||||
val builder = MaterialAlertDialogBuilder(this)
|
||||
builder.setTitle(R.string.chooseImportType)
|
||||
.setItems(importOptions.toTypedArray()) { _, which ->
|
||||
when (which) {
|
||||
// Catima
|
||||
0 -> {
|
||||
importAlertTitle = getString(R.string.importCatima)
|
||||
importAlertMessage = getString(R.string.importCatimaMessage)
|
||||
importDataFormat = DataFormat.Catima
|
||||
}
|
||||
// Fidme
|
||||
1 -> {
|
||||
importAlertTitle = getString(R.string.importFidme)
|
||||
importAlertMessage = getString(R.string.importFidmeMessage)
|
||||
importDataFormat = DataFormat.Fidme
|
||||
}
|
||||
// Loyalty Card Keychain
|
||||
2 -> {
|
||||
importAlertTitle = getString(R.string.importLoyaltyCardKeychain)
|
||||
importAlertMessage = getString(R.string.importLoyaltyCardKeychainMessage)
|
||||
importDataFormat = DataFormat.Catima
|
||||
}
|
||||
// Voucher Vault
|
||||
3 -> {
|
||||
importAlertTitle = getString(R.string.importVoucherVault)
|
||||
importAlertMessage = getString(R.string.importVoucherVaultMessage)
|
||||
importDataFormat = DataFormat.VoucherVault
|
||||
}
|
||||
|
||||
else -> throw IllegalArgumentException("Unknown DataFormat")
|
||||
}
|
||||
|
||||
if (fileData != null) {
|
||||
openFileForImport(fileData, null)
|
||||
return@setItems
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(importAlertTitle)
|
||||
.setMessage(importAlertMessage)
|
||||
.setPositiveButton(R.string.ok) { _, _ ->
|
||||
try {
|
||||
fileOpenLauncher.launch("*/*")
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
R.string.failedOpeningFileManager,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
Log.e(TAG, "No activity found to handle intent", e)
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
builder.show()
|
||||
}
|
||||
|
||||
private fun startImport(
|
||||
target: InputStream?,
|
||||
targetUri: Uri,
|
||||
dataFormat: DataFormat?,
|
||||
password: CharArray?,
|
||||
closeWhenDone: Boolean
|
||||
) {
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.IMPORT, true, false, false)
|
||||
val listener = ImportExportTask.TaskCompleteListener { result, dataFormat ->
|
||||
onImportComplete(result, targetUri, dataFormat)
|
||||
if (closeWhenDone) {
|
||||
try {
|
||||
target?.close()
|
||||
} catch (ioException: IOException) {
|
||||
ioException.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
importExporter = ImportExportTask(
|
||||
this@ImportExportActivity,
|
||||
dataFormat, target, password, listener
|
||||
)
|
||||
mTasks.executeTask(TaskHandler.TYPE.IMPORT, importExporter)
|
||||
}
|
||||
|
||||
private fun startExport(
|
||||
target: OutputStream?,
|
||||
targetUri: Uri,
|
||||
password: CharArray?,
|
||||
closeWhenDone: Boolean
|
||||
) {
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.EXPORT, true, false, false)
|
||||
val listener = ImportExportTask.TaskCompleteListener { result, dataFormat ->
|
||||
onExportComplete(result, targetUri)
|
||||
if (closeWhenDone) {
|
||||
try {
|
||||
target?.close()
|
||||
} catch (ioException: IOException) {
|
||||
ioException.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
importExporter = ImportExportTask(
|
||||
this@ImportExportActivity,
|
||||
DataFormat.Catima, target, password, listener
|
||||
)
|
||||
mTasks.executeTask(TaskHandler.TYPE.EXPORT, importExporter)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.IMPORT, true, false, false)
|
||||
mTasks.flushTaskList(TaskHandler.TYPE.EXPORT, true, false, false)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val id = item.itemId
|
||||
|
||||
if (id == android.R.id.home) {
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun retryWithPassword(dataFormat: DataFormat, uri: Uri) {
|
||||
val builder = MaterialAlertDialogBuilder(this)
|
||||
builder.setTitle(R.string.passwordRequired)
|
||||
|
||||
val container = FrameLayout(this@ImportExportActivity)
|
||||
|
||||
val textInputLayout = TextInputLayout(this@ImportExportActivity).apply {
|
||||
endIconMode = TextInputLayout.END_ICON_PASSWORD_TOGGLE
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
setMargins(50, 10, 50, 0)
|
||||
}
|
||||
}
|
||||
|
||||
val input = EditText(this@ImportExportActivity).apply {
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||
setHint(R.string.exportPasswordHint)
|
||||
}
|
||||
|
||||
textInputLayout.addView(input)
|
||||
container.addView(textInputLayout)
|
||||
builder.setView(container)
|
||||
|
||||
builder.setPositiveButton(R.string.ok) { _, _ ->
|
||||
openFileForImport(uri, input.text.toString().toCharArray())
|
||||
}
|
||||
builder.setNegativeButton(R.string.cancel) { dialogInterface, _ -> dialogInterface.cancel() }
|
||||
|
||||
builder.show()
|
||||
}
|
||||
|
||||
private fun buildResultDialogMessage(result: ImportExportResult, isImport: Boolean): String {
|
||||
val messageId = if (result.resultType() == ImportExportResultType.Success) {
|
||||
if (isImport) R.string.importSuccessful else R.string.exportSuccessful
|
||||
} else {
|
||||
if (isImport) R.string.importFailed else R.string.exportFailed
|
||||
}
|
||||
|
||||
val messageBuilder = StringBuilder(resources.getString(messageId))
|
||||
if (result.developerDetails() != null) {
|
||||
messageBuilder.append("\n\n")
|
||||
messageBuilder.append(resources.getString(R.string.include_if_asking_support))
|
||||
messageBuilder.append("\n\n")
|
||||
messageBuilder.append(result.developerDetails())
|
||||
}
|
||||
|
||||
return messageBuilder.toString()
|
||||
}
|
||||
|
||||
private fun onImportComplete(result: ImportExportResult, path: Uri, dataFormat: DataFormat?) {
|
||||
val resultType = result.resultType()
|
||||
|
||||
if (resultType == ImportExportResultType.BadPassword) {
|
||||
retryWithPassword(dataFormat!!, path)
|
||||
return
|
||||
}
|
||||
|
||||
val builder = MaterialAlertDialogBuilder(this)
|
||||
builder.setTitle(if (resultType == ImportExportResultType.Success) R.string.importSuccessfulTitle else R.string.importFailedTitle)
|
||||
builder.setMessage(buildResultDialogMessage(result, true))
|
||||
builder.setNeutralButton(R.string.ok) { dialog, _ -> dialog.dismiss() }
|
||||
|
||||
builder.create().show()
|
||||
}
|
||||
|
||||
private fun onExportComplete(result: ImportExportResult, path: Uri) {
|
||||
val resultType = result.resultType()
|
||||
|
||||
val builder = MaterialAlertDialogBuilder(this)
|
||||
builder.setTitle(if (resultType == ImportExportResultType.Success) R.string.exportSuccessfulTitle else R.string.exportFailedTitle)
|
||||
builder.setMessage(buildResultDialogMessage(result, false))
|
||||
builder.setNeutralButton(R.string.ok) { dialog, _ -> dialog.dismiss() }
|
||||
|
||||
if (resultType == ImportExportResultType.Success) {
|
||||
val sendLabel = this@ImportExportActivity.resources.getText(R.string.sendLabel)
|
||||
|
||||
builder.setPositiveButton(sendLabel) { dialog, _ ->
|
||||
val sendIntent = Intent(Intent.ACTION_SEND).apply {
|
||||
putExtra(Intent.EXTRA_STREAM, path)
|
||||
type = "text/csv"
|
||||
// set flag to give temporary permission to external app to use the FileProvider
|
||||
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
}
|
||||
|
||||
this@ImportExportActivity.startActivity(Intent.createChooser(sendIntent, sendLabel))
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
builder.create().show()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -32,7 +37,7 @@ public class ImportExportTask implements CompatCallable<ImportExportResult> {
|
||||
private char[] password;
|
||||
private TaskCompleteListener listener;
|
||||
|
||||
private ProgressDialog progress;
|
||||
private AlertDialog progress;
|
||||
|
||||
/**
|
||||
* Constructor which will setup a task for exporting to the given file
|
||||
@@ -88,12 +93,36 @@ public class ImportExportTask implements CompatCallable<ImportExportResult> {
|
||||
}
|
||||
|
||||
public void onPreExecute() {
|
||||
progress = new ProgressDialog(activity);
|
||||
progress.setTitle(doImport ? R.string.importing : R.string.exporting);
|
||||
MaterialAlertDialogBuilder progressDialogBuilder = new MaterialAlertDialogBuilder(activity);
|
||||
progressDialogBuilder.setCancelable(false); // Don't cancel if user taps next to dialog
|
||||
progressDialogBuilder.setTitle(doImport ? R.string.importing : R.string.exporting);
|
||||
|
||||
progress.setOnCancelListener(dialog -> cancel());
|
||||
progress.setOnDismissListener(dialog -> cancel());
|
||||
// Create components
|
||||
TextView progressDialogTextView = new TextView(activity);
|
||||
progressDialogTextView.setText(R.string.pleaseDoNotRotateTheDevice); // FIXME: Instead of telling the user to not rotate, rotation should not cancel the import
|
||||
ProgressBar progressDialogProgressBar = new ProgressBar(activity);
|
||||
progressDialogProgressBar.setIndeterminate(true);
|
||||
|
||||
// Create LinearLayout (to put the components below each other)
|
||||
LinearLayout progressDialogLayout = new LinearLayout(activity);
|
||||
progressDialogLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout.LayoutParams progressDialogLayoutParams = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
);
|
||||
int contentPadding = activity.getResources().getDimensionPixelSize(R.dimen.alert_dialog_content_padding);
|
||||
progressDialogLayoutParams.setMargins(contentPadding, contentPadding / 2, contentPadding, 0);
|
||||
|
||||
// Put components in layout
|
||||
progressDialogLayout.addView(progressDialogTextView, progressDialogLayoutParams);
|
||||
progressDialogLayout.addView(progressDialogProgressBar, progressDialogLayoutParams);
|
||||
|
||||
// Create and show dialog
|
||||
progressDialogBuilder.setView(progressDialogLayout);
|
||||
progressDialogBuilder.setNeutralButton(R.string.cancel, (dialogInterface, i) -> cancel());
|
||||
progressDialogBuilder.setOnCancelListener(dialogInterface -> cancel());
|
||||
progressDialogBuilder.setOnDismissListener(dialogInterface -> cancel());
|
||||
progress = progressDialogBuilder.create();
|
||||
progress.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ import androidx.core.graphics.PaintCompat;
|
||||
* is shown instead.
|
||||
*/
|
||||
class LetterBitmap {
|
||||
|
||||
/**
|
||||
* The number of available tile colors
|
||||
*/
|
||||
private static final int NUM_OF_TILE_COLORS = 8;
|
||||
/**
|
||||
* The letter bitmap
|
||||
*/
|
||||
@@ -121,7 +116,7 @@ class LetterBitmap {
|
||||
private static int pickColor(String key, TypedArray colors) {
|
||||
// String.hashCode() is not supposed to change across java versions, so
|
||||
// this should guarantee the same key always maps to the same color
|
||||
final int color = Math.abs(key.hashCode()) % NUM_OF_TILE_COLORS;
|
||||
final int color = Math.abs(key.hashCode()) % colors.length();
|
||||
return colors.getColor(color, Color.BLACK);
|
||||
}
|
||||
|
||||
|
||||
131
app/src/main/java/protect/card_locker/ListWidget.kt
Normal file
@@ -0,0 +1,131 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import androidx.core.widget.RemoteViewsCompat
|
||||
import protect.card_locker.DBHelper.LoyaltyCardArchiveFilter
|
||||
|
||||
class ListWidget : AppWidgetProvider() {
|
||||
fun updateAll(context: Context) {
|
||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||
val componentName = ComponentName(context, ListWidget::class.java)
|
||||
onUpdate(
|
||||
context,
|
||||
appWidgetManager,
|
||||
appWidgetManager.getAppWidgetIds(componentName)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onUpdate(
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetIds: IntArray
|
||||
) {
|
||||
for (appWidgetId in appWidgetIds) {
|
||||
val database = DBHelper(context).readableDatabase
|
||||
|
||||
// Get cards
|
||||
val order = Utils.getLoyaltyCardOrder(context);
|
||||
val orderDirection = Utils.getLoyaltyCardOrderDirection(context);
|
||||
|
||||
val loyaltyCardCursor = DBHelper.getLoyaltyCardCursor(
|
||||
database,
|
||||
"",
|
||||
null,
|
||||
order,
|
||||
orderDirection,
|
||||
LoyaltyCardArchiveFilter.Unarchived
|
||||
)
|
||||
|
||||
// Bind every card to cell in the grid
|
||||
var hasCards = false
|
||||
val remoteCollectionItemsBuilder = RemoteViewsCompat.RemoteCollectionItems.Builder()
|
||||
if (loyaltyCardCursor.moveToFirst()) {
|
||||
do {
|
||||
val loyaltyCard = LoyaltyCard.fromCursor(context, loyaltyCardCursor)
|
||||
remoteCollectionItemsBuilder.addItem(
|
||||
loyaltyCard.id.toLong(),
|
||||
createRemoteViews(
|
||||
context, loyaltyCard
|
||||
)
|
||||
)
|
||||
hasCards = true
|
||||
} while (loyaltyCardCursor.moveToNext())
|
||||
}
|
||||
loyaltyCardCursor.close()
|
||||
|
||||
// Create the base empty view
|
||||
var views = RemoteViews(context.packageName, R.layout.list_widget_empty)
|
||||
|
||||
if (hasCards) {
|
||||
// If we have cards, create the list
|
||||
views = RemoteViews(context.packageName, R.layout.list_widget)
|
||||
val templateIntent = Intent(context, LoyaltyCardViewActivity::class.java)
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
templateIntent,
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
views.setPendingIntentTemplate(R.id.grid_view, pendingIntent)
|
||||
|
||||
RemoteViewsCompat.setRemoteAdapter(
|
||||
context,
|
||||
views,
|
||||
appWidgetId,
|
||||
R.id.grid_view,
|
||||
remoteCollectionItemsBuilder.build()
|
||||
)
|
||||
}
|
||||
|
||||
// Let Android know the widget is ready for display
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createRemoteViews(context: Context, loyaltyCard: LoyaltyCard): RemoteViews {
|
||||
// Create a single cell for the grid view, bind it to open in the LoyaltyCardViewActivity
|
||||
// Note: Android 5 will not use bitmaps
|
||||
val remoteViews = RemoteViews(context.packageName, R.layout.list_widget_item).apply {
|
||||
val headerColor = Utils.getHeaderColor(context, loyaltyCard)
|
||||
val foreground = if (Utils.needsDarkForeground(headerColor)) Color.BLACK else Color.WHITE
|
||||
setInt(R.id.item_container_foreground, "setBackgroundColor", headerColor)
|
||||
val icon = loyaltyCard.getImageThumbnail(context)
|
||||
// setImageViewIcon is not supported on Android 5, so force Android 5 down the text path
|
||||
// FIXME: The icon flow causes a crash up to Android 12L, so SDK_INT is forced up from 23 to 33
|
||||
if (icon != null && Build.VERSION.SDK_INT >= 32) {
|
||||
setInt(R.id.item_container_foreground, "setBackgroundColor", foreground)
|
||||
setImageViewIcon(R.id.item_image, Icon.createWithBitmap(icon))
|
||||
setViewVisibility(R.id.item_text, View.INVISIBLE)
|
||||
setViewVisibility(R.id.item_image, View.VISIBLE)
|
||||
} else {
|
||||
setImageViewBitmap(R.id.item_image, null)
|
||||
setTextViewText(R.id.item_text, loyaltyCard.store)
|
||||
setViewVisibility(R.id.item_text, View.VISIBLE)
|
||||
setViewVisibility(R.id.item_image, View.INVISIBLE)
|
||||
setTextColor(
|
||||
R.id.item_text,
|
||||
foreground
|
||||
)
|
||||
}
|
||||
|
||||
// Add the card ID to the intent template
|
||||
val fillInIntent = Intent().apply {
|
||||
putExtra(LoyaltyCardViewActivity.BUNDLE_ID, loyaltyCard.id)
|
||||
}
|
||||
|
||||
setOnClickFillInIntent(R.id.item_container, fillInIntent)
|
||||
}
|
||||
|
||||
return remoteViews
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,9 @@ import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
@@ -297,7 +300,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = LoyaltyCardEditActivityBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Utils.applyWindowInsetsAndFabOffset(binding.getRoot(), binding.fabSave);
|
||||
|
||||
viewModel = new ViewModelProvider(this).get(LoyaltyCardEditActivityViewModel.class);
|
||||
|
||||
@@ -576,7 +579,6 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
|
||||
|
||||
binding.tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
viewModel.setTabIndex(tab.getPosition());
|
||||
showPart(tab.getText().toString());
|
||||
@@ -588,7 +590,6 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
viewModel.setTabIndex(tab.getPosition());
|
||||
showPart(tab.getText().toString());
|
||||
@@ -718,7 +719,6 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
|
||||
int colorOnSurface = MaterialColors.getColor(this, com.google.android.material.R.attr.colorOnSurface, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
|
||||
int colorBackground = MaterialColors.getColor(this, android.R.attr.colorBackground, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
|
||||
mCropperOptions.setToolbarColor(colorSurface);
|
||||
mCropperOptions.setStatusBarColor(colorSurface);
|
||||
mCropperOptions.setToolbarWidgetColor(colorOnSurface);
|
||||
mCropperOptions.setRootViewBackgroundColor(colorBackground);
|
||||
// set tool tip to be the darker of primary color
|
||||
|
||||
@@ -4,6 +4,12 @@ import android.app.Application;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.acra.config.CoreConfigurationBuilder;
|
||||
import org.acra.config.DialogConfigurationBuilder;
|
||||
import org.acra.config.MailSenderConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
|
||||
import protect.card_locker.preferences.Settings;
|
||||
|
||||
public class LoyaltyCardLockerApplication extends Application {
|
||||
@@ -12,6 +18,27 @@ public class LoyaltyCardLockerApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// Initialize crash reporter (if enabled)
|
||||
if (BuildConfig.useAcraCrashReporter) {
|
||||
ACRA.init(this, new CoreConfigurationBuilder()
|
||||
//core configuration:
|
||||
.withBuildConfigClass(BuildConfig.class)
|
||||
.withReportFormat(StringFormat.KEY_VALUE_LIST)
|
||||
.withPluginConfigurations(
|
||||
new DialogConfigurationBuilder()
|
||||
.withText(String.format(getString(R.string.acra_catima_has_crashed), getString(R.string.app_name)))
|
||||
.withCommentPrompt(getString(R.string.acra_explain_crash))
|
||||
.withResTheme(R.style.AppTheme)
|
||||
.build(),
|
||||
new MailSenderConfigurationBuilder()
|
||||
.withMailTo("acra-crash@catima.app")
|
||||
.withSubject(String.format(getString(R.string.acra_crash_email_subject), getString(R.string.app_name)))
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set theme
|
||||
Settings settings = new Settings(this);
|
||||
AppCompatDelegate.setDefaultNightMode(settings.getTheme());
|
||||
}
|
||||
|
||||
@@ -262,19 +262,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
|
||||
settings = new Settings(this);
|
||||
|
||||
String cardOrientation = settings.getCardViewOrientation();
|
||||
if (cardOrientation.equals(getString(R.string.settings_key_follow_sensor_orientation))) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||
} else if (cardOrientation.equals(getString(R.string.settings_key_lock_on_opening_orientation))) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
} else if (cardOrientation.equals(getString(R.string.settings_key_portrait_orientation))) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else if (cardOrientation.equals(getString(R.string.settings_key_landscape_orientation))) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mainImageIndex = savedInstanceState.getInt(STATE_IMAGEINDEX);
|
||||
isFullscreen = savedInstanceState.getBoolean(STATE_FULLSCREEN);
|
||||
@@ -880,6 +867,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
} else if (id == R.id.action_star_unstar) {
|
||||
DBHelper.updateLoyaltyCardStarStatus(database, loyaltyCardId, loyaltyCard.starStatus == 0 ? 1 : 0);
|
||||
|
||||
new ListWidget().updateAll(LoyaltyCardViewActivity.this);
|
||||
|
||||
// Re-init loyaltyCard with new data from DB
|
||||
onResume();
|
||||
invalidateOptionsMenu();
|
||||
@@ -890,6 +879,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
Toast.makeText(LoyaltyCardViewActivity.this, R.string.archived, Toast.LENGTH_LONG).show();
|
||||
|
||||
ShortcutHelper.removeShortcut(LoyaltyCardViewActivity.this, loyaltyCardId);
|
||||
new ListWidget().updateAll(LoyaltyCardViewActivity.this);
|
||||
|
||||
// Re-init loyaltyCard with new data from DB
|
||||
onResume();
|
||||
@@ -915,6 +905,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
DBHelper.deleteLoyaltyCard(database, LoyaltyCardViewActivity.this, loyaltyCardId);
|
||||
|
||||
ShortcutHelper.removeShortcut(LoyaltyCardViewActivity.this, loyaltyCardId);
|
||||
new ListWidget().updateAll(LoyaltyCardViewActivity.this);
|
||||
|
||||
finish();
|
||||
dialog.dismiss();
|
||||
@@ -1094,6 +1085,12 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
}
|
||||
|
||||
private void setMainImagePreviousNextButtons() {
|
||||
// Ensure the main image index is valid. After a card update, some images (front/back/barcode)
|
||||
// may have been removed, so the index should not exceed the number of available images.
|
||||
if(mainImageIndex > imageTypes.size() - 1){
|
||||
mainImageIndex = 0;
|
||||
}
|
||||
|
||||
if (imageTypes.size() < 2) {
|
||||
binding.mainLeftButton.setVisibility(View.INVISIBLE);
|
||||
binding.mainRightButton.setVisibility(View.INVISIBLE);
|
||||
|
||||
@@ -2,6 +2,8 @@ package protect.card_locker;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.SearchManager;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -330,22 +332,8 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard
|
||||
selectedTab = activeTabPref.getInt(getString(R.string.sharedpreference_active_tab), 0);
|
||||
|
||||
// Restore sort preferences from Shared Preferences
|
||||
// If one of the sorting prefererences has never been set or is set to an invalid value,
|
||||
// stick to the defaults.
|
||||
SharedPreferences sortPref = getApplicationContext().getSharedPreferences(
|
||||
getString(R.string.sharedpreference_sort),
|
||||
Context.MODE_PRIVATE);
|
||||
|
||||
String orderString = sortPref.getString(getString(R.string.sharedpreference_sort_order), null);
|
||||
String orderDirectionString = sortPref.getString(getString(R.string.sharedpreference_sort_direction), null);
|
||||
|
||||
if (orderString != null && orderDirectionString != null) {
|
||||
try {
|
||||
mOrder = DBHelper.LoyaltyCardOrder.valueOf(orderString);
|
||||
mOrderDirection = DBHelper.LoyaltyCardOrderDirection.valueOf(orderDirectionString);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
mOrder = Utils.getLoyaltyCardOrder(this);
|
||||
mOrderDirection = Utils.getLoyaltyCardOrderDirection(this);
|
||||
|
||||
mGroup = null;
|
||||
|
||||
@@ -442,6 +430,8 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard
|
||||
if (mCurrentActionMode != null) {
|
||||
mCurrentActionMode.finish();
|
||||
}
|
||||
|
||||
new ListWidget().updateAll(mAdapter.mContext);
|
||||
}
|
||||
|
||||
private void processParseResultList(List<ParseResult> parseResultList, String group, boolean closeAppOnNoBarcode) {
|
||||
@@ -508,6 +498,8 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard
|
||||
// However, several users stated in https://github.com/CatimaLoyalty/Android/issues/2197 that the formats are extremely similar to the point they could rename an .espass file to .pkpass and have it imported
|
||||
// So it makes sense to "unofficially" treat it as a PKPASS for now, even though not completely correct
|
||||
parseResultList = Utils.retrieveBarcodesFromPkPass(this, data);
|
||||
} else if (receivedType.equals("application/vnd.apple.pkpasses")) {
|
||||
parseResultList = Utils.retrieveBarcodesFromPkPasses(this, data);
|
||||
} else {
|
||||
Log.e(TAG, "Wrong mime-type");
|
||||
return;
|
||||
@@ -709,6 +701,8 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard
|
||||
showReversed.isChecked() ? DBHelper.LoyaltyCardOrderDirection.Descending : DBHelper.LoyaltyCardOrderDirection.Ascending
|
||||
);
|
||||
|
||||
new ListWidget().updateAll(this);
|
||||
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,242 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import protect.card_locker.databinding.ActivityManageGroupBinding;
|
||||
|
||||
public class ManageGroupActivity extends CatimaAppCompatActivity implements ManageGroupCursorAdapter.CardAdapterListener {
|
||||
private ActivityManageGroupBinding binding;
|
||||
private SQLiteDatabase mDatabase;
|
||||
private ManageGroupCursorAdapter mAdapter;
|
||||
|
||||
private final String SAVE_INSTANCE_ADAPTER_STATE = "adapterState";
|
||||
private final String SAVE_INSTANCE_CURRENT_GROUP_NAME = "currentGroupName";
|
||||
|
||||
protected Group mGroup = null;
|
||||
private RecyclerView mCardList;
|
||||
private TextView noGroupCardsText;
|
||||
private EditText mGroupNameText;
|
||||
|
||||
private boolean mGroupNameNotInUse;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle inputSavedInstanceState) {
|
||||
super.onCreate(inputSavedInstanceState);
|
||||
binding = ActivityManageGroupBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mDatabase = new DBHelper(this).getWritableDatabase();
|
||||
|
||||
noGroupCardsText = binding.include.noGroupCardsText;
|
||||
mCardList = binding.include.list;
|
||||
FloatingActionButton saveButton = binding.fabSave;
|
||||
|
||||
mGroupNameText = binding.editTextGroupName;
|
||||
|
||||
mGroupNameText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
mGroupNameNotInUse = true;
|
||||
mGroupNameText.setError(null);
|
||||
String currentGroupName = mGroupNameText.getText().toString().trim();
|
||||
if (currentGroupName.length() == 0) {
|
||||
mGroupNameText.setError(getResources().getText(R.string.group_name_is_empty));
|
||||
return;
|
||||
}
|
||||
if (!mGroup._id.equals(currentGroupName)) {
|
||||
if (DBHelper.getGroup(mDatabase, currentGroupName) != null) {
|
||||
mGroupNameNotInUse = false;
|
||||
mGroupNameText.setError(getResources().getText(R.string.group_name_already_in_use));
|
||||
} else {
|
||||
mGroupNameNotInUse = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Intent intent = getIntent();
|
||||
String groupId = intent.getStringExtra("group");
|
||||
if (groupId == null) {
|
||||
throw (new IllegalArgumentException("this activity expects a group loaded into it's intent"));
|
||||
}
|
||||
Log.d("groupId", "groupId: " + groupId);
|
||||
mGroup = DBHelper.getGroup(mDatabase, groupId);
|
||||
if (mGroup == null) {
|
||||
throw (new IllegalArgumentException("cannot load group " + groupId + " from database"));
|
||||
}
|
||||
mGroupNameText.setText(mGroup._id);
|
||||
setTitle(getString(R.string.editGroup, mGroup._id));
|
||||
mAdapter = new ManageGroupCursorAdapter(this, null, this, mGroup, null);
|
||||
mCardList.setAdapter(mAdapter);
|
||||
registerForContextMenu(mCardList);
|
||||
|
||||
if (inputSavedInstanceState != null) {
|
||||
mAdapter.importInGroupState(integerArrayToAdapterState(inputSavedInstanceState.getIntegerArrayList(SAVE_INSTANCE_ADAPTER_STATE)));
|
||||
mGroupNameText.setText(inputSavedInstanceState.getString(SAVE_INSTANCE_CURRENT_GROUP_NAME));
|
||||
}
|
||||
|
||||
enableToolbarBackButton();
|
||||
|
||||
saveButton.setOnClickListener(v -> {
|
||||
String currentGroupName = mGroupNameText.getText().toString().trim();
|
||||
if (!currentGroupName.equals(mGroup._id)) {
|
||||
if (currentGroupName.length() == 0) {
|
||||
Toast.makeText(getApplicationContext(), R.string.group_name_is_empty, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (!mGroupNameNotInUse) {
|
||||
Toast.makeText(getApplicationContext(), R.string.group_name_already_in_use, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.commitToDatabase();
|
||||
if (!currentGroupName.equals(mGroup._id)) {
|
||||
DBHelper.updateGroup(mDatabase, mGroup._id, currentGroupName);
|
||||
}
|
||||
Toast.makeText(getApplicationContext(), R.string.group_updated, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
});
|
||||
// this setText is here because content_main.xml is reused from main activity
|
||||
noGroupCardsText.setText(getResources().getText(R.string.noGiftCardsGroup));
|
||||
updateLoyaltyCardList();
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
leaveWithoutSaving();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ArrayList<Integer> adapterStateToIntegerArray(HashMap<Integer, Boolean> adapterState) {
|
||||
ArrayList<Integer> ret = new ArrayList<>(adapterState.size() * 2);
|
||||
for (Map.Entry<Integer, Boolean> entry : adapterState.entrySet()) {
|
||||
ret.add(entry.getKey());
|
||||
ret.add(entry.getValue() ? 1 : 0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private HashMap<Integer, Boolean> integerArrayToAdapterState(ArrayList<Integer> in) {
|
||||
HashMap<Integer, Boolean> ret = new HashMap<>();
|
||||
if (in.size() % 2 != 0) {
|
||||
throw (new RuntimeException("failed restoring adapterState from integer array list"));
|
||||
}
|
||||
for (int i = 0; i < in.size(); i += 2) {
|
||||
ret.put(in.get(i), in.get(i + 1) == 1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu inputMenu) {
|
||||
getMenuInflater().inflate(R.menu.card_details_menu, inputMenu);
|
||||
|
||||
return super.onCreateOptionsMenu(inputMenu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem inputItem) {
|
||||
int id = inputItem.getItemId();
|
||||
|
||||
if (id == R.id.action_display_options) {
|
||||
mAdapter.showDisplayOptionsDialog();
|
||||
invalidateOptionsMenu();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(inputItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putIntegerArrayList(SAVE_INSTANCE_ADAPTER_STATE, adapterStateToIntegerArray(mAdapter.exportInGroupState()));
|
||||
outState.putString(SAVE_INSTANCE_CURRENT_GROUP_NAME, mGroupNameText.getText().toString());
|
||||
}
|
||||
|
||||
private void updateLoyaltyCardList() {
|
||||
mAdapter.swapCursor(DBHelper.getLoyaltyCardCursor(mDatabase));
|
||||
|
||||
if (mAdapter.getItemCount() == 0) {
|
||||
mCardList.setVisibility(View.GONE);
|
||||
noGroupCardsText.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mCardList.setVisibility(View.VISIBLE);
|
||||
noGroupCardsText.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void leaveWithoutSaving() {
|
||||
if (hasChanged()) {
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(ManageGroupActivity.this);
|
||||
builder.setTitle(R.string.leaveWithoutSaveTitle);
|
||||
builder.setMessage(R.string.leaveWithoutSaveConfirmation);
|
||||
builder.setPositiveButton(R.string.confirm, (dialog, which) -> finish());
|
||||
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasChanged() {
|
||||
return mAdapter.hasChanged() || !mGroup._id.equals(mGroupNameText.getText().toString().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowLongClicked(int inputPosition) {
|
||||
mAdapter.toggleSelection(inputPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowClicked(int inputPosition) {
|
||||
mAdapter.toggleSelection(inputPosition);
|
||||
|
||||
}
|
||||
}
|
||||
236
app/src/main/java/protect/card_locker/ManageGroupActivity.kt
Normal file
@@ -0,0 +1,236 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import protect.card_locker.LoyaltyCardCursorAdapter.CardAdapterListener
|
||||
import protect.card_locker.databinding.ActivityManageGroupBinding
|
||||
|
||||
class ManageGroupActivity : CatimaAppCompatActivity(), CardAdapterListener {
|
||||
private lateinit var binding: ActivityManageGroupBinding
|
||||
private lateinit var mDatabase: SQLiteDatabase
|
||||
private lateinit var mAdapter: ManageGroupCursorAdapter
|
||||
|
||||
private lateinit var mGroup: Group
|
||||
private lateinit var mCardList: RecyclerView
|
||||
private lateinit var noGroupCardsText: TextView
|
||||
private lateinit var mGroupNameText: EditText
|
||||
|
||||
private var mGroupNameNotInUse = false
|
||||
|
||||
override fun onCreate(inputSavedInstanceState: Bundle?) {
|
||||
super.onCreate(inputSavedInstanceState)
|
||||
binding = ActivityManageGroupBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
Utils.applyWindowInsetsAndFabOffset(binding.root, binding.fabSave)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
mDatabase = DBHelper(this).writableDatabase
|
||||
noGroupCardsText = binding.include.noGroupCardsText
|
||||
mCardList = binding.include.list
|
||||
|
||||
mGroupNameText = binding.editTextGroupName
|
||||
mGroupNameText.doAfterTextChanged {
|
||||
mGroupNameNotInUse = true
|
||||
mGroupNameText.error = null
|
||||
val currentGroupName = mGroupNameText.text.trim().toString()
|
||||
if (currentGroupName.isEmpty()) {
|
||||
mGroupNameText.error = getText(R.string.group_name_is_empty)
|
||||
return@doAfterTextChanged
|
||||
}
|
||||
if (mGroup._id != currentGroupName) {
|
||||
if (DBHelper.getGroup(mDatabase, currentGroupName) != null) {
|
||||
mGroupNameNotInUse = false
|
||||
mGroupNameText.error = getText(R.string.group_name_already_in_use)
|
||||
} else {
|
||||
mGroupNameNotInUse = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val groupId = intent.getStringExtra("group")
|
||||
?: throw (IllegalArgumentException("this activity expects a group loaded into it's intent"))
|
||||
Log.d("groupId", "groupId: $groupId")
|
||||
mGroup = DBHelper.getGroup(mDatabase, groupId)
|
||||
?: throw IllegalArgumentException("Cannot load group $groupId from database")
|
||||
mGroupNameText.setText(mGroup._id)
|
||||
setTitle(getString(R.string.editGroup, mGroup._id))
|
||||
mAdapter = ManageGroupCursorAdapter(this, null, this, mGroup, null)
|
||||
mCardList.adapter = mAdapter
|
||||
registerForContextMenu(mCardList)
|
||||
|
||||
if (inputSavedInstanceState != null) {
|
||||
mAdapter.importInGroupState(
|
||||
bundleToAdapterState(
|
||||
adapterStateBundle = inputSavedInstanceState.getBundle(
|
||||
SAVE_INSTANCE_ADAPTER_STATE
|
||||
)
|
||||
)
|
||||
)
|
||||
mGroupNameText.setText(
|
||||
inputSavedInstanceState.getString(
|
||||
SAVE_INSTANCE_CURRENT_GROUP_NAME
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
enableToolbarBackButton()
|
||||
|
||||
binding.fabSave.setOnClickListener { v: View ->
|
||||
val currentGroupName = mGroupNameText.text.trim().toString()
|
||||
if (currentGroupName != mGroup._id) {
|
||||
when {
|
||||
currentGroupName.isEmpty() -> {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
R.string.group_name_is_empty,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
!mGroupNameNotInUse -> {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
R.string.group_name_already_in_use,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.commitToDatabase()
|
||||
if (currentGroupName != mGroup._id) {
|
||||
DBHelper.updateGroup(mDatabase, mGroup._id, currentGroupName)
|
||||
}
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
R.string.group_updated,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
finish()
|
||||
}
|
||||
// this setText is here because content_main.xml is reused from main activity
|
||||
noGroupCardsText.text = getText(R.string.noGiftCardsGroup)
|
||||
updateLoyaltyCardList()
|
||||
|
||||
onBackPressedDispatcher.addCallback(
|
||||
owner = this,
|
||||
onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
leaveWithoutSaving()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun adapterStateToBundle(adapterState: HashMap<Int, Boolean>): Bundle {
|
||||
val adapterStateBundle = Bundle().apply {
|
||||
for (entry in adapterState.entries) {
|
||||
putBoolean(entry.key.toString(), entry.value)
|
||||
}
|
||||
}
|
||||
return adapterStateBundle
|
||||
}
|
||||
|
||||
private fun bundleToAdapterState(adapterStateBundle: Bundle?): Map<Int, Boolean> {
|
||||
adapterStateBundle ?: return emptyMap()
|
||||
val adapterStateMap = buildMap {
|
||||
for (key in adapterStateBundle.keySet()) {
|
||||
put(key.toInt(), adapterStateBundle.getBoolean(key))
|
||||
}
|
||||
}
|
||||
return adapterStateMap
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(inputMenu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.card_details_menu, inputMenu)
|
||||
|
||||
return super.onCreateOptionsMenu(inputMenu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(inputItem: MenuItem): Boolean {
|
||||
val id = inputItem.itemId
|
||||
|
||||
if (id == R.id.action_display_options) {
|
||||
mAdapter.showDisplayOptionsDialog()
|
||||
invalidateOptionsMenu()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(inputItem)
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
|
||||
outState.putBundle(
|
||||
SAVE_INSTANCE_ADAPTER_STATE,
|
||||
adapterStateToBundle(mAdapter.exportInGroupState())
|
||||
)
|
||||
outState.putString(SAVE_INSTANCE_CURRENT_GROUP_NAME, mGroupNameText.text.toString())
|
||||
}
|
||||
|
||||
private fun updateLoyaltyCardList() {
|
||||
mAdapter.swapCursor(DBHelper.getLoyaltyCardCursor(mDatabase))
|
||||
|
||||
if (mAdapter.itemCount == 0) {
|
||||
mCardList.visibility = View.GONE
|
||||
noGroupCardsText.visibility = View.VISIBLE
|
||||
} else {
|
||||
mCardList.visibility = View.VISIBLE
|
||||
noGroupCardsText.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun leaveWithoutSaving() {
|
||||
if (hasChanged()) {
|
||||
MaterialAlertDialogBuilder(this@ManageGroupActivity).apply {
|
||||
setTitle(R.string.leaveWithoutSaveTitle)
|
||||
setMessage(R.string.leaveWithoutSaveConfirmation)
|
||||
setPositiveButton(R.string.confirm) { dialog: DialogInterface, _ ->
|
||||
finish()
|
||||
}
|
||||
setNegativeButton(R.string.cancel) { dialog: DialogInterface, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}.create().show()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
return true
|
||||
}
|
||||
|
||||
private fun hasChanged(): Boolean {
|
||||
return mAdapter.hasChanged() || mGroup._id != mGroupNameText.text.trim().toString()
|
||||
}
|
||||
|
||||
override fun onRowLongClicked(inputPosition: Int) {
|
||||
mAdapter.toggleSelection(inputPosition)
|
||||
}
|
||||
|
||||
override fun onRowClicked(inputPosition: Int) {
|
||||
mAdapter.toggleSelection(inputPosition)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val SAVE_INSTANCE_ADAPTER_STATE = "adapterState"
|
||||
const val SAVE_INSTANCE_CURRENT_GROUP_NAME = "currentGroupName"
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class ManageGroupCursorAdapter extends LoyaltyCardCursorAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void importInGroupState(HashMap<Integer, Boolean> cardIdInGroupMap) {
|
||||
public void importInGroupState(Map<Integer, Boolean> cardIdInGroupMap) {
|
||||
mInGroupOverlay = new HashMap<>(cardIdInGroupMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import protect.card_locker.databinding.ManageGroupsActivityBinding;
|
||||
|
||||
public class ManageGroupsActivity extends CatimaAppCompatActivity implements GroupCursorAdapter.GroupAdapterListener {
|
||||
private ManageGroupsActivityBinding binding;
|
||||
private static final String TAG = "Catima";
|
||||
|
||||
private SQLiteDatabase mDatabase;
|
||||
private TextView mHelpText;
|
||||
private RecyclerView mGroupList;
|
||||
GroupCursorAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ManageGroupsActivityBinding.inflate(getLayoutInflater());
|
||||
setTitle(R.string.groups);
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
enableToolbarBackButton();
|
||||
|
||||
mDatabase = new DBHelper(this).getWritableDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
FloatingActionButton addButton = binding.fabAdd;
|
||||
addButton.setOnClickListener(v -> createGroup());
|
||||
addButton.bringToFront();
|
||||
|
||||
mGroupList = binding.include.list;
|
||||
mHelpText = binding.include.helpText;
|
||||
|
||||
// Init group list
|
||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
mGroupList.setLayoutManager(mLayoutManager);
|
||||
mGroupList.setItemAnimator(new DefaultItemAnimator());
|
||||
|
||||
mAdapter = new GroupCursorAdapter(this, null, this);
|
||||
mGroupList.setAdapter(mAdapter);
|
||||
|
||||
updateGroupList();
|
||||
}
|
||||
|
||||
private void updateGroupList() {
|
||||
mAdapter.swapCursor(DBHelper.getGroupCursor(mDatabase));
|
||||
|
||||
if (DBHelper.getGroupCount(mDatabase) == 0) {
|
||||
mGroupList.setVisibility(View.GONE);
|
||||
mHelpText.setVisibility(View.VISIBLE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mGroupList.setVisibility(View.VISIBLE);
|
||||
mHelpText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void invalidateHomescreenActiveTab() {
|
||||
SharedPreferences activeTabPref = getApplicationContext().getSharedPreferences(
|
||||
getString(R.string.sharedpreference_active_tab),
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor activeTabPrefEditor = activeTabPref.edit();
|
||||
activeTabPrefEditor.putInt(getString(R.string.sharedpreference_active_tab), 0);
|
||||
activeTabPrefEditor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void createGroup() {
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
|
||||
// Header
|
||||
builder.setTitle(R.string.enter_group_name);
|
||||
|
||||
// Layout
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
int contentPadding = getResources().getDimensionPixelSize(R.dimen.alert_dialog_content_padding);
|
||||
params.leftMargin = contentPadding;
|
||||
params.topMargin = contentPadding / 2;
|
||||
params.rightMargin = contentPadding;
|
||||
|
||||
// EditText with spacing
|
||||
final EditText input = new EditText(this);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
input.setLayoutParams(params);
|
||||
layout.addView(input);
|
||||
|
||||
// Set layout
|
||||
builder.setView(layout);
|
||||
|
||||
// Buttons
|
||||
builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
|
||||
DBHelper.insertGroup(mDatabase, input.getText().toString().trim());
|
||||
updateGroupList();
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||
AlertDialog dialog = builder.create();
|
||||
|
||||
// Now that the dialog exists, we can bind something that affects the OK button
|
||||
input.addTextChangedListener(new SimpleTextWatcher() {
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String groupName = s.toString().trim();
|
||||
|
||||
if (groupName.length() == 0) {
|
||||
input.setError(getString(R.string.group_name_is_empty));
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DBHelper.getGroup(mDatabase, groupName) != null) {
|
||||
input.setError(getString(R.string.group_name_already_in_use));
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
input.setError(null);
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
|
||||
// Disable button (must be done **after** dialog is shown to prevent crash
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
// Set focus on input field
|
||||
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
input.requestFocus();
|
||||
}
|
||||
|
||||
private String getGroupName(View view) {
|
||||
TextView groupNameTextView = view.findViewById(R.id.name);
|
||||
return (String) groupNameTextView.getText();
|
||||
}
|
||||
|
||||
private void moveGroup(View view, boolean up) {
|
||||
List<Group> groups = DBHelper.getGroups(mDatabase);
|
||||
final String groupName = getGroupName(view);
|
||||
|
||||
int currentIndex = DBHelper.getGroup(mDatabase, groupName).order;
|
||||
int newIndex;
|
||||
|
||||
// Reinsert group in correct position
|
||||
if (up) {
|
||||
newIndex = currentIndex - 1;
|
||||
} else {
|
||||
newIndex = currentIndex + 1;
|
||||
}
|
||||
|
||||
// Don't try to move out of bounds
|
||||
if (newIndex < 0 || newIndex >= groups.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Group group = groups.remove(currentIndex);
|
||||
groups.add(newIndex, group);
|
||||
|
||||
// Update database
|
||||
DBHelper.reorderGroups(mDatabase, groups);
|
||||
|
||||
// Update UI
|
||||
updateGroupList();
|
||||
|
||||
// Ordering may have changed, so invalidate
|
||||
invalidateHomescreenActiveTab();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveDownButtonClicked(View view) {
|
||||
moveGroup(view, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveUpButtonClicked(View view) {
|
||||
moveGroup(view, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEditButtonClicked(View view) {
|
||||
Intent intent = new Intent(this, ManageGroupActivity.class);
|
||||
intent.putExtra("group", getGroupName(view));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteButtonClicked(View view) {
|
||||
final String groupName = getGroupName(view);
|
||||
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
builder.setTitle(R.string.deleteConfirmationGroup);
|
||||
builder.setMessage(groupName);
|
||||
|
||||
builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
|
||||
DBHelper.deleteGroup(mDatabase, groupName);
|
||||
updateGroupList();
|
||||
// Delete may change ordering, so invalidate
|
||||
invalidateHomescreenActiveTab();
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
240
app/src/main/java/protect/card_locker/ManageGroupsActivity.kt
Normal file
@@ -0,0 +1,240 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import protect.card_locker.GroupCursorAdapter.GroupAdapterListener
|
||||
import protect.card_locker.databinding.ManageGroupsActivityBinding
|
||||
|
||||
class ManageGroupsActivity : CatimaAppCompatActivity(), GroupAdapterListener {
|
||||
private lateinit var binding: ManageGroupsActivityBinding
|
||||
private lateinit var mDatabase: SQLiteDatabase
|
||||
private lateinit var mHelpText: TextView
|
||||
private lateinit var mGroupList: RecyclerView
|
||||
private lateinit var mAdapter: GroupCursorAdapter
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ManageGroupsActivityBinding.inflate(layoutInflater)
|
||||
setTitle(R.string.groups)
|
||||
setContentView(binding.root)
|
||||
Utils.applyWindowInsets(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
enableToolbarBackButton()
|
||||
|
||||
mDatabase = DBHelper(this).writableDatabase
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
with(binding.fabAdd) {
|
||||
setOnClickListener { v: View ->
|
||||
createGroup()
|
||||
}
|
||||
bringToFront()
|
||||
}
|
||||
|
||||
mGroupList = binding.include.list
|
||||
mHelpText = binding.include.helpText
|
||||
|
||||
// Init group list
|
||||
LinearLayoutManager(applicationContext).apply {
|
||||
mGroupList.layoutManager = this
|
||||
}
|
||||
mGroupList.setItemAnimator(DefaultItemAnimator())
|
||||
mAdapter = GroupCursorAdapter(this, null, this)
|
||||
mGroupList.setAdapter(mAdapter)
|
||||
|
||||
updateGroupList()
|
||||
}
|
||||
|
||||
private fun updateGroupList() {
|
||||
mAdapter.swapCursor(DBHelper.getGroupCursor(mDatabase))
|
||||
|
||||
if (DBHelper.getGroupCount(mDatabase) == 0) {
|
||||
mGroupList.visibility = View.GONE
|
||||
mHelpText.visibility = View.VISIBLE
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
mGroupList.visibility = View.VISIBLE
|
||||
mHelpText.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun invalidateHomescreenActiveTab() {
|
||||
val activeTabPref = getSharedPreferences(
|
||||
getString(R.string.sharedpreference_active_tab),
|
||||
MODE_PRIVATE
|
||||
)
|
||||
activeTabPref.edit {
|
||||
putInt(getString(R.string.sharedpreference_active_tab), 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
finish()
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun createGroup() {
|
||||
val builder: AlertDialog.Builder = MaterialAlertDialogBuilder(this)
|
||||
|
||||
// Header
|
||||
builder.setTitle(R.string.enter_group_name)
|
||||
|
||||
// Layout
|
||||
val layout = LinearLayout(this)
|
||||
layout.orientation = LinearLayout.VERTICAL
|
||||
val params = LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
val contentPadding =
|
||||
resources.getDimensionPixelSize(R.dimen.alert_dialog_content_padding)
|
||||
leftMargin = contentPadding
|
||||
topMargin = contentPadding / 2
|
||||
rightMargin = contentPadding
|
||||
}
|
||||
|
||||
// EditText with spacing
|
||||
val input = EditText(this)
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT)
|
||||
input.setLayoutParams(params)
|
||||
layout.addView(input)
|
||||
|
||||
// Set layout
|
||||
builder.setView(layout)
|
||||
|
||||
// Buttons
|
||||
builder.setPositiveButton(getString(R.string.ok)) { dialog: DialogInterface, which: Int ->
|
||||
DBHelper.insertGroup(mDatabase, input.text.trim().toString())
|
||||
updateGroupList()
|
||||
}
|
||||
builder.setNegativeButton(getString(R.string.cancel)) { dialog: DialogInterface, which: Int ->
|
||||
dialog.cancel()
|
||||
}
|
||||
val dialog = builder.create()
|
||||
|
||||
// Now that the dialog exists, we can bind something that affects the OK button
|
||||
input.doOnTextChanged { s: CharSequence?, start: Int, before: Int, count: Int ->
|
||||
val groupName = s?.trim().toString()
|
||||
|
||||
if (groupName.isEmpty()) {
|
||||
input.error = getString(R.string.group_name_is_empty)
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false)
|
||||
return@doOnTextChanged
|
||||
}
|
||||
|
||||
if (DBHelper.getGroup(mDatabase, groupName) != null) {
|
||||
input.error = getString(R.string.group_name_already_in_use)
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false)
|
||||
return@doOnTextChanged
|
||||
}
|
||||
|
||||
input.error = null
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true)
|
||||
}
|
||||
|
||||
dialog.apply {
|
||||
show()
|
||||
// Disable button (must be done **after** dialog is shown to prevent crash
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false)
|
||||
// Set focus on input field
|
||||
window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
}
|
||||
|
||||
input.requestFocus()
|
||||
}
|
||||
|
||||
private fun getGroupName(view: View): String {
|
||||
val groupNameTextView = view.findViewById<TextView>(R.id.name)
|
||||
return groupNameTextView.text.toString()
|
||||
}
|
||||
|
||||
private fun moveGroup(view: View, up: Boolean) {
|
||||
val groups = DBHelper.getGroups(mDatabase)
|
||||
val groupName = getGroupName(view)
|
||||
|
||||
val currentIndex = DBHelper.getGroup(mDatabase, groupName).order
|
||||
|
||||
// Reinsert group in correct position
|
||||
val newIndex: Int = if (up) {
|
||||
currentIndex - 1
|
||||
} else {
|
||||
currentIndex + 1
|
||||
}
|
||||
|
||||
// Don't try to move out of bounds
|
||||
if (newIndex < 0 || newIndex >= groups.size) {
|
||||
return
|
||||
}
|
||||
|
||||
val group = groups.removeAt(currentIndex)
|
||||
groups.add(newIndex, group)
|
||||
|
||||
// Update database
|
||||
DBHelper.reorderGroups(mDatabase, groups)
|
||||
|
||||
// Update UI
|
||||
updateGroupList()
|
||||
|
||||
// Ordering may have changed, so invalidate
|
||||
invalidateHomescreenActiveTab()
|
||||
}
|
||||
|
||||
override fun onMoveDownButtonClicked(view: View) {
|
||||
moveGroup(view, false)
|
||||
}
|
||||
|
||||
override fun onMoveUpButtonClicked(view: View) {
|
||||
moveGroup(view, true)
|
||||
}
|
||||
|
||||
override fun onEditButtonClicked(view: View) {
|
||||
Intent(this, ManageGroupActivity::class.java).apply {
|
||||
putExtra("group", getGroupName(view))
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDeleteButtonClicked(view: View) {
|
||||
val groupName = getGroupName(view)
|
||||
|
||||
MaterialAlertDialogBuilder(this).apply {
|
||||
setTitle(R.string.deleteConfirmationGroup)
|
||||
setMessage(groupName)
|
||||
|
||||
setPositiveButton(getString(R.string.ok)) { dialog: DialogInterface, which: Int ->
|
||||
DBHelper.deleteGroup(mDatabase, groupName)
|
||||
updateGroupList()
|
||||
// Delete may change ordering, so invalidate
|
||||
invalidateHomescreenActiveTab()
|
||||
}
|
||||
setNegativeButton(getString(R.string.cancel)) { dialog: DialogInterface, which: Int ->
|
||||
dialog.cancel()
|
||||
}
|
||||
}.create().show()
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,17 @@ class PkpassParser(context: Context, uri: Uri?) {
|
||||
try {
|
||||
mContext.contentResolver.openInputStream(uri).use { inputStream ->
|
||||
ZipInputStream(inputStream).use { zipInputStream ->
|
||||
var localFileHeader: LocalFileHeader
|
||||
while ((zipInputStream.nextEntry.also { localFileHeader = it }) != null) {
|
||||
var localFileHeader: LocalFileHeader?
|
||||
|
||||
while (true) {
|
||||
// Retrieve the next file
|
||||
localFileHeader = zipInputStream.nextEntry
|
||||
|
||||
// If no next file, exit loop
|
||||
if (localFileHeader == null) {
|
||||
break
|
||||
}
|
||||
|
||||
// Ignore directories
|
||||
if (localFileHeader.isDirectory) continue
|
||||
|
||||
|
||||
73
app/src/main/java/protect/card_locker/PkpassesParser.kt
Normal file
@@ -0,0 +1,73 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.core.net.toUri
|
||||
import net.lingala.zip4j.io.inputstream.ZipInputStream
|
||||
import net.lingala.zip4j.model.LocalFileHeader
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
|
||||
class PkpassesParser(context: Context, uri: Uri?) {
|
||||
private var mContext = context
|
||||
private val pkPassParsers: ArrayList<PkpassParser> = ArrayList()
|
||||
|
||||
init {
|
||||
mContext = context
|
||||
|
||||
Log.i(TAG, "Received Pkpasses file")
|
||||
if (uri == null) {
|
||||
Log.e(TAG, "Uri did not contain any data")
|
||||
throw IOException(context.getString(R.string.errorReadingFile))
|
||||
}
|
||||
|
||||
try {
|
||||
mContext.contentResolver.openInputStream(uri).use { inputStream ->
|
||||
ZipInputStream(inputStream).use { zipInputStream ->
|
||||
var localFileHeader: LocalFileHeader?
|
||||
|
||||
while (true) {
|
||||
// Retrieve the next file
|
||||
localFileHeader = zipInputStream.nextEntry
|
||||
|
||||
// If no next file, exit loop
|
||||
if (localFileHeader == null) {
|
||||
break
|
||||
}
|
||||
|
||||
// Ignore directories
|
||||
if (localFileHeader.isDirectory) continue
|
||||
|
||||
// Ignore non-pkpass files
|
||||
if (!localFileHeader.fileName.endsWith(".pkpass")) continue
|
||||
|
||||
// Extract .pkpass (.zip) inside .pkpasses to cache directory
|
||||
val tempFileName = "pkpassparser_" + System.currentTimeMillis() + "_" + localFileHeader.fileName
|
||||
val tempFile = Utils.copyToTempFile(mContext, zipInputStream, tempFileName)
|
||||
|
||||
// Parse temporary file
|
||||
pkPassParsers.add(
|
||||
PkpassParser(mContext, tempFile.toUri())
|
||||
)
|
||||
|
||||
// Delete temporary file
|
||||
tempFile.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: FileNotFoundException) {
|
||||
throw IOException(mContext.getString(R.string.errorReadingFile))
|
||||
} catch (e: Exception) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
fun getPkpassParsers(): ArrayList<PkpassParser> {
|
||||
return pkPassParsers
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "Catima"
|
||||
}
|
||||
}
|
||||
@@ -1,542 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import static protect.card_locker.BarcodeSelectorActivity.BARCODE_CONTENTS;
|
||||
import static protect.card_locker.BarcodeSelectorActivity.BARCODE_FORMAT;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.InputType;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.client.android.Intents;
|
||||
import com.journeyapps.barcodescanner.BarcodeCallback;
|
||||
import com.journeyapps.barcodescanner.BarcodeResult;
|
||||
import com.journeyapps.barcodescanner.CaptureManager;
|
||||
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import protect.card_locker.databinding.CustomBarcodeScannerBinding;
|
||||
import protect.card_locker.databinding.ScanActivityBinding;
|
||||
|
||||
/**
|
||||
* Custom Scannner Activity extending from Activity to display a custom layout form scanner view.
|
||||
* <p>
|
||||
* Based on https://github.com/journeyapps/zxing-android-embedded/blob/0fdfbce9fb3285e985bad9971c5f7c0a7a334e7b/sample/src/main/java/example/zxing/CustomScannerActivity.java
|
||||
* originally licensed under Apache 2.0
|
||||
*/
|
||||
public class ScanActivity extends CatimaAppCompatActivity {
|
||||
private ScanActivityBinding binding;
|
||||
private CustomBarcodeScannerBinding customBarcodeScannerBinding;
|
||||
private static final String TAG = "Catima";
|
||||
|
||||
private static final int MEDIUM_SCALE_FACTOR_DIP = 460;
|
||||
private static final int COMPAT_SCALE_FACTOR_DIP = 320;
|
||||
|
||||
private static final int PERMISSION_SCAN_ADD_FROM_IMAGE = 100;
|
||||
private static final int PERMISSION_SCAN_ADD_FROM_PDF = 101;
|
||||
private static final int PERMISSION_SCAN_ADD_FROM_PKPASS = 102;
|
||||
|
||||
private CaptureManager capture;
|
||||
private DecoratedBarcodeView barcodeScannerView;
|
||||
|
||||
private String cardId;
|
||||
private String addGroup;
|
||||
private boolean torch = false;
|
||||
|
||||
private ActivityResultLauncher<Intent> manualAddLauncher;
|
||||
// can't use the pre-made contract because that launches the file manager for image type instead of gallery
|
||||
private ActivityResultLauncher<Intent> photoPickerLauncher;
|
||||
private ActivityResultLauncher<Intent> pdfPickerLauncher;
|
||||
private ActivityResultLauncher<Intent> pkpassPickerLauncher;
|
||||
|
||||
static final String STATE_SCANNER_ACTIVE = "scannerActive";
|
||||
private boolean mScannerActive = true;
|
||||
private boolean mHasError = false;
|
||||
|
||||
private void extractIntentFields(Intent intent) {
|
||||
final Bundle b = intent.getExtras();
|
||||
cardId = b != null ? b.getString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID) : null;
|
||||
addGroup = b != null ? b.getString(LoyaltyCardEditActivity.BUNDLE_ADDGROUP) : null;
|
||||
Log.d(TAG, "Scan activity: id=" + cardId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ScanActivityBinding.inflate(getLayoutInflater());
|
||||
customBarcodeScannerBinding = CustomBarcodeScannerBinding.bind(binding.zxingBarcodeScanner);
|
||||
setTitle(R.string.scanCardBarcode);
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
enableToolbarBackButton();
|
||||
|
||||
extractIntentFields(getIntent());
|
||||
|
||||
manualAddLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> handleActivityResult(Utils.SELECT_BARCODE_REQUEST, result.getResultCode(), result.getData()));
|
||||
photoPickerLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> handleActivityResult(Utils.BARCODE_IMPORT_FROM_IMAGE_FILE, result.getResultCode(), result.getData()));
|
||||
pdfPickerLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> handleActivityResult(Utils.BARCODE_IMPORT_FROM_PDF_FILE, result.getResultCode(), result.getData()));
|
||||
pkpassPickerLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> handleActivityResult(Utils.BARCODE_IMPORT_FROM_PKPASS_FILE, result.getResultCode(), result.getData()));
|
||||
customBarcodeScannerBinding.fabOtherOptions.setOnClickListener(view -> {
|
||||
setScannerActive(false);
|
||||
|
||||
ArrayList<HashMap<String, Object>> list = new ArrayList<>();
|
||||
String[] texts = new String[]{
|
||||
getString(R.string.addWithoutBarcode),
|
||||
getString(R.string.addManually),
|
||||
getString(R.string.addFromImage),
|
||||
getString(R.string.addFromPdfFile),
|
||||
getString(R.string.addFromPkpass)
|
||||
};
|
||||
Object[] icons = new Object[]{
|
||||
R.drawable.baseline_block_24,
|
||||
R.drawable.ic_edit,
|
||||
R.drawable.baseline_image_24,
|
||||
R.drawable.baseline_picture_as_pdf_24,
|
||||
R.drawable.local_activity_24px
|
||||
};
|
||||
String[] columns = new String[]{"text", "icon"};
|
||||
|
||||
for (int i = 0; i < texts.length; i++) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put(columns[0], texts[i]);
|
||||
map.put(columns[1], icons[i]);
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
ListAdapter adapter = new SimpleAdapter(
|
||||
ScanActivity.this,
|
||||
list,
|
||||
R.layout.alertdialog_row_with_icon,
|
||||
columns,
|
||||
new int[]{R.id.textView, R.id.imageView}
|
||||
);
|
||||
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ScanActivity.this);
|
||||
builder.setTitle(getString(R.string.add_a_card_in_a_different_way));
|
||||
builder.setAdapter(
|
||||
adapter,
|
||||
(dialogInterface, i) -> {
|
||||
switch (i) {
|
||||
case 0:
|
||||
addWithoutBarcode();
|
||||
break;
|
||||
case 1:
|
||||
addManually();
|
||||
break;
|
||||
case 2:
|
||||
addFromImage();
|
||||
break;
|
||||
case 3:
|
||||
addFromPdf();
|
||||
break;
|
||||
case 4:
|
||||
addFromPkPass();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown 'Add a card in a different way' dialog option");
|
||||
}
|
||||
}
|
||||
);
|
||||
builder.setOnCancelListener(dialogInterface -> setScannerActive(true));
|
||||
builder.show();
|
||||
});
|
||||
|
||||
// Configure barcodeScanner
|
||||
barcodeScannerView = binding.zxingBarcodeScanner;
|
||||
Intent barcodeScannerIntent = new Intent();
|
||||
Bundle barcodeScannerIntentBundle = new Bundle();
|
||||
barcodeScannerIntentBundle.putBoolean(DecodeHintType.ALSO_INVERTED.name(), Boolean.TRUE);
|
||||
barcodeScannerIntent.putExtras(barcodeScannerIntentBundle);
|
||||
barcodeScannerView.initializeFromIntent(barcodeScannerIntent);
|
||||
|
||||
// Even though we do the actual decoding with the barcodeScannerView
|
||||
// CaptureManager needs to be running to show the camera and scanning bar
|
||||
capture = new CatimaCaptureManager(this, barcodeScannerView, this::onCaptureManagerError);
|
||||
Intent captureIntent = new Intent();
|
||||
Bundle captureIntentBundle = new Bundle();
|
||||
captureIntentBundle.putBoolean(Intents.Scan.BEEP_ENABLED, false);
|
||||
captureIntent.putExtras(captureIntentBundle);
|
||||
capture.initializeFromIntent(captureIntent, savedInstanceState);
|
||||
|
||||
barcodeScannerView.decodeSingle(new BarcodeCallback() {
|
||||
@Override
|
||||
public void barcodeResult(BarcodeResult result) {
|
||||
LoyaltyCard loyaltyCard = new LoyaltyCard();
|
||||
loyaltyCard.setCardId(result.getText());
|
||||
loyaltyCard.setBarcodeType(CatimaBarcode.fromBarcode(result.getBarcodeFormat()));
|
||||
|
||||
returnResult(new ParseResult(ParseResultType.BARCODE_ONLY, loyaltyCard));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void possibleResultPoints(List<ResultPoint> resultPoints) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (mScannerActive) {
|
||||
capture.onResume();
|
||||
}
|
||||
|
||||
if (!Utils.deviceHasCamera(this)) {
|
||||
showCameraError(getString(R.string.noCameraFoundGuideText), false);
|
||||
} else if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||
showCameraPermissionMissingText();
|
||||
} else {
|
||||
hideCameraError();
|
||||
}
|
||||
|
||||
scaleScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
capture.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
capture.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
capture.onSaveInstanceState(savedInstanceState);
|
||||
|
||||
savedInstanceState.putBoolean(STATE_SCANNER_ACTIVE, mScannerActive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
|
||||
mScannerActive = savedInstanceState.getBoolean(STATE_SCANNER_ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return barcodeScannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
|
||||
getMenuInflater().inflate(R.menu.scan_menu, menu);
|
||||
}
|
||||
|
||||
barcodeScannerView.setTorchOff();
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
setResult(Activity.RESULT_CANCELED);
|
||||
finish();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_toggle_flashlight) {
|
||||
if (torch) {
|
||||
torch = false;
|
||||
barcodeScannerView.setTorchOff();
|
||||
item.setTitle(R.string.turn_flashlight_on);
|
||||
item.setIcon(R.drawable.ic_flashlight_off_white_24dp);
|
||||
} else {
|
||||
torch = true;
|
||||
barcodeScannerView.setTorchOn();
|
||||
item.setTitle(R.string.turn_flashlight_off);
|
||||
item.setIcon(R.drawable.ic_flashlight_on_white_24dp);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void setScannerActive(boolean isActive) {
|
||||
if (isActive) {
|
||||
barcodeScannerView.resume();
|
||||
} else {
|
||||
barcodeScannerView.pause();
|
||||
}
|
||||
mScannerActive = isActive;
|
||||
}
|
||||
|
||||
private void returnResult(ParseResult parseResult) {
|
||||
Intent result = new Intent();
|
||||
Bundle bundle = parseResult.toLoyaltyCardBundle(ScanActivity.this);
|
||||
if (addGroup != null) {
|
||||
bundle.putString(LoyaltyCardEditActivity.BUNDLE_ADDGROUP, addGroup);
|
||||
}
|
||||
result.putExtras(bundle);
|
||||
ScanActivity.this.setResult(RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void handleActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
|
||||
List<ParseResult> parseResultList = Utils.parseSetBarcodeActivityResult(requestCode, resultCode, intent, this);
|
||||
|
||||
if (parseResultList.isEmpty()) {
|
||||
setScannerActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.makeUserChooseParseResultFromList(this, parseResultList, new ParseResultListDisambiguatorCallback() {
|
||||
@Override
|
||||
public void onUserChoseParseResult(ParseResult parseResult) {
|
||||
returnResult(parseResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserDismissedSelector() {
|
||||
setScannerActive(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addWithoutBarcode() {
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
|
||||
builder.setOnCancelListener(dialogInterface -> setScannerActive(true));
|
||||
|
||||
// Header
|
||||
builder.setTitle(R.string.addWithoutBarcode);
|
||||
|
||||
// Layout
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
int contentPadding = getResources().getDimensionPixelSize(R.dimen.alert_dialog_content_padding);
|
||||
params.leftMargin = contentPadding;
|
||||
params.topMargin = contentPadding / 2;
|
||||
params.rightMargin = contentPadding;
|
||||
|
||||
// Description
|
||||
TextView currentTextview = new TextView(this);
|
||||
currentTextview.setText(getString(R.string.enter_card_id));
|
||||
currentTextview.setLayoutParams(params);
|
||||
layout.addView(currentTextview);
|
||||
|
||||
// EditText with spacing
|
||||
final EditText input = new EditText(this);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
input.setLayoutParams(params);
|
||||
layout.addView(input);
|
||||
|
||||
// Set layout
|
||||
builder.setView(layout);
|
||||
|
||||
// Buttons
|
||||
builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
|
||||
LoyaltyCard loyaltyCard = new LoyaltyCard();
|
||||
loyaltyCard.setCardId(input.getText().toString());
|
||||
returnResult(new ParseResult(ParseResultType.BARCODE_ONLY, loyaltyCard));
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||
AlertDialog dialog = builder.create();
|
||||
|
||||
// Now that the dialog exists, we can bind something that affects the OK button
|
||||
input.addTextChangedListener(new SimpleTextWatcher() {
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (s.length() == 0) {
|
||||
input.setError(getString(R.string.card_id_must_not_be_empty));
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
} else {
|
||||
input.setError(null);
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
|
||||
// Disable button (must be done **after** dialog is shown to prevent crash
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
// Set focus on input field
|
||||
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
input.requestFocus();
|
||||
}
|
||||
|
||||
public void addManually() {
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ScanActivity.this);
|
||||
builder.setTitle(R.string.add_manually_warning_title);
|
||||
builder.setMessage(R.string.add_manually_warning_message);
|
||||
builder.setPositiveButton(R.string.continue_, (dialog, which) -> {
|
||||
Intent i = new Intent(getApplicationContext(), BarcodeSelectorActivity.class);
|
||||
if (cardId != null) {
|
||||
final Bundle b = new Bundle();
|
||||
b.putString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID, cardId);
|
||||
i.putExtras(b);
|
||||
}
|
||||
manualAddLauncher.launch(i);
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, (dialog, which) -> setScannerActive(true));
|
||||
builder.setOnCancelListener(dialog -> setScannerActive(true));
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public void addFromImage() {
|
||||
PermissionUtils.requestStorageReadPermission(this, PERMISSION_SCAN_ADD_FROM_IMAGE);
|
||||
}
|
||||
|
||||
public void addFromPdf() {
|
||||
PermissionUtils.requestStorageReadPermission(this, PERMISSION_SCAN_ADD_FROM_PDF);
|
||||
}
|
||||
|
||||
public void addFromPkPass() {
|
||||
PermissionUtils.requestStorageReadPermission(this, PERMISSION_SCAN_ADD_FROM_PKPASS);
|
||||
}
|
||||
|
||||
private void addFromImageOrFileAfterPermission(String mimeType, ActivityResultLauncher<Intent> launcher, int chooserText, int errorMessage) {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||
photoPickerIntent.setType(mimeType);
|
||||
Intent contentIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
contentIntent.setType(mimeType);
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(photoPickerIntent, getString(chooserText));
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { contentIntent });
|
||||
try {
|
||||
launcher.launch(chooserIntent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
setScannerActive(true);
|
||||
Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, "No activity found to handle intent", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCaptureManagerError(String errorMessage) {
|
||||
if (mHasError) {
|
||||
// We're already showing an error, ignore this new error
|
||||
return;
|
||||
}
|
||||
|
||||
showCameraError(errorMessage, false);
|
||||
}
|
||||
|
||||
private void showCameraPermissionMissingText() {
|
||||
showCameraError(getString(R.string.noCameraPermissionDirectToSystemSetting), true);
|
||||
}
|
||||
|
||||
private void showCameraError(String message, boolean setOnClick) {
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorMessage.setText(message);
|
||||
|
||||
setCameraErrorState(true, setOnClick);
|
||||
}
|
||||
|
||||
private void hideCameraError() {
|
||||
setCameraErrorState(false, false);
|
||||
}
|
||||
|
||||
private void setCameraErrorState(boolean visible, boolean setOnClick) {
|
||||
mHasError = visible;
|
||||
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorClickableArea.setOnClickListener(visible && setOnClick ? v -> {
|
||||
navigateToSystemPermissionSetting();
|
||||
} : null);
|
||||
customBarcodeScannerBinding.cardInputContainer.setBackgroundColor(visible ? obtainThemeAttribute(com.google.android.material.R.attr.colorSurface) : Color.TRANSPARENT);
|
||||
customBarcodeScannerBinding.cameraErrorLayout.getRoot().setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void scaleScreen() {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
float mediumSizePx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,MEDIUM_SCALE_FACTOR_DIP,getResources().getDisplayMetrics());
|
||||
boolean shouldScaleSmaller = screenHeight < mediumSizePx;
|
||||
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorIcon.setVisibility(shouldScaleSmaller ? View.GONE : View.VISIBLE);
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorTitle.setVisibility(shouldScaleSmaller ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private int obtainThemeAttribute(int attribute) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
getTheme().resolveAttribute(attribute, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
private void navigateToSystemPermissionSetting() {
|
||||
Intent permissionIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null));
|
||||
permissionIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(permissionIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
onMockedRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
public void onMockedRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
if (requestCode == CaptureManager.getCameraPermissionReqCode()) {
|
||||
if (granted) {
|
||||
hideCameraError();
|
||||
} else {
|
||||
showCameraPermissionMissingText();
|
||||
}
|
||||
} else if (requestCode == PERMISSION_SCAN_ADD_FROM_IMAGE || requestCode == PERMISSION_SCAN_ADD_FROM_PDF || requestCode == PERMISSION_SCAN_ADD_FROM_PKPASS) {
|
||||
if (granted) {
|
||||
if (requestCode == PERMISSION_SCAN_ADD_FROM_IMAGE) {
|
||||
addFromImageOrFileAfterPermission("image/*", photoPickerLauncher, R.string.addFromImage, R.string.failedLaunchingPhotoPicker);
|
||||
} else if (requestCode == PERMISSION_SCAN_ADD_FROM_PDF) {
|
||||
addFromImageOrFileAfterPermission("application/pdf", pdfPickerLauncher, R.string.addFromPdfFile, R.string.failedLaunchingFileManager);
|
||||
} else {
|
||||
addFromImageOrFileAfterPermission("application/*", pkpassPickerLauncher, R.string.addFromPkpass, R.string.failedLaunchingFileManager);
|
||||
}
|
||||
} else {
|
||||
setScannerActive(true);
|
||||
Toast.makeText(this, R.string.storageReadPermissionRequired, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
599
app/src/main/java/protect/card_locker/ScanActivity.kt
Normal file
@@ -0,0 +1,599 @@
|
||||
package protect.card_locker
|
||||
|
||||
|
||||
import android.Manifest
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.text.InputType
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ListAdapter
|
||||
import android.widget.SimpleAdapter
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.zxing.DecodeHintType
|
||||
import com.google.zxing.ResultPoint
|
||||
import com.journeyapps.barcodescanner.BarcodeCallback
|
||||
import com.journeyapps.barcodescanner.BarcodeResult
|
||||
import com.journeyapps.barcodescanner.CaptureManager
|
||||
import com.journeyapps.barcodescanner.DecoratedBarcodeView
|
||||
import protect.card_locker.databinding.CustomBarcodeScannerBinding
|
||||
import protect.card_locker.databinding.ScanActivityBinding
|
||||
|
||||
/**
|
||||
* Custom Scannner Activity extending from Activity to display a custom layout form scanner view.
|
||||
* <p>
|
||||
* Based on https://github.com/journeyapps/zxing-android-embedded/blob/0fdfbce9fb3285e985bad9971c5f7c0a7a334e7b/sample/src/main/java/example/zxing/CustomScannerActivity.java
|
||||
* originally licensed under Apache 2.0
|
||||
*/
|
||||
class ScanActivity : CatimaAppCompatActivity() {
|
||||
private lateinit var binding: ScanActivityBinding
|
||||
private lateinit var customBarcodeScannerBinding: CustomBarcodeScannerBinding
|
||||
|
||||
companion object {
|
||||
private const val TAG = "Catima"
|
||||
|
||||
private const val MEDIUM_SCALE_FACTOR_DIP = 460
|
||||
private const val COMPAT_SCALE_FACTOR_DIP = 320
|
||||
|
||||
private const val PERMISSION_SCAN_ADD_FROM_IMAGE = 100
|
||||
private const val PERMISSION_SCAN_ADD_FROM_PDF = 101
|
||||
private const val PERMISSION_SCAN_ADD_FROM_PKPASS = 102
|
||||
|
||||
private const val STATE_SCANNER_ACTIVE = "scannerActive"
|
||||
}
|
||||
|
||||
private lateinit var capture: CaptureManager
|
||||
private lateinit var barcodeScannerView: DecoratedBarcodeView
|
||||
private var cardId: String? = null
|
||||
private var addGroup: String? = null
|
||||
private var torch = false
|
||||
|
||||
private lateinit var manualAddLauncher: ActivityResultLauncher<Intent>
|
||||
// can't use the pre-made contract because that launches the file manager for image type instead of gallery
|
||||
private lateinit var photoPickerLauncher: ActivityResultLauncher<Intent>
|
||||
private lateinit var pdfPickerLauncher: ActivityResultLauncher<Intent>
|
||||
private lateinit var pkpassPickerLauncher: ActivityResultLauncher<Intent>
|
||||
|
||||
private var mScannerActive = true
|
||||
private var mHasError = false
|
||||
|
||||
private fun extractIntentFields(intent: Intent) {
|
||||
val b = intent.extras
|
||||
cardId = b?.getString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID)
|
||||
addGroup = b?.getString(LoyaltyCardEditActivity.BUNDLE_ADDGROUP)
|
||||
Log.d(TAG, "Scan activity: id=$cardId")
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ScanActivityBinding.inflate(layoutInflater)
|
||||
customBarcodeScannerBinding = CustomBarcodeScannerBinding.bind(binding.zxingBarcodeScanner)
|
||||
setTitle(R.string.scanCardBarcode)
|
||||
setContentView(binding.root)
|
||||
Utils.applyWindowInsets(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
enableToolbarBackButton()
|
||||
|
||||
extractIntentFields(intent)
|
||||
|
||||
manualAddLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
handleActivityResult(
|
||||
Utils.SELECT_BARCODE_REQUEST,
|
||||
result.resultCode,
|
||||
result.data
|
||||
)
|
||||
}
|
||||
photoPickerLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
handleActivityResult(
|
||||
Utils.BARCODE_IMPORT_FROM_IMAGE_FILE,
|
||||
result.resultCode,
|
||||
result.data
|
||||
)
|
||||
}
|
||||
pdfPickerLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
handleActivityResult(
|
||||
Utils.BARCODE_IMPORT_FROM_PDF_FILE,
|
||||
result.resultCode,
|
||||
result.data
|
||||
)
|
||||
}
|
||||
pkpassPickerLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
handleActivityResult(
|
||||
Utils.BARCODE_IMPORT_FROM_PKPASS_FILE,
|
||||
result.resultCode,
|
||||
result.data
|
||||
)
|
||||
}
|
||||
|
||||
customBarcodeScannerBinding.fabOtherOptions.setOnClickListener {
|
||||
setScannerActive(false)
|
||||
|
||||
val list: ArrayList<HashMap<String, Any>> = arrayListOf()
|
||||
val texts = arrayOf(
|
||||
getString(R.string.addWithoutBarcode),
|
||||
getString(R.string.addManually),
|
||||
getString(R.string.addFromImage),
|
||||
getString(R.string.addFromPdfFile),
|
||||
getString(R.string.addFromPkpass)
|
||||
)
|
||||
val icons = arrayOf(
|
||||
R.drawable.baseline_block_24,
|
||||
R.drawable.ic_edit,
|
||||
R.drawable.baseline_image_24,
|
||||
R.drawable.baseline_picture_as_pdf_24,
|
||||
R.drawable.local_activity_24px
|
||||
)
|
||||
val columns = arrayOf("text", "icon")
|
||||
|
||||
for (i in 0 until texts.size) {
|
||||
val map: HashMap<String, Any> = hashMapOf()
|
||||
map.put(columns[0], texts[i])
|
||||
map.put(columns[1], icons[i])
|
||||
list.add(map)
|
||||
}
|
||||
|
||||
val adapter: ListAdapter = SimpleAdapter(
|
||||
this,
|
||||
list,
|
||||
R.layout.alertdialog_row_with_icon,
|
||||
columns,
|
||||
intArrayOf(R.id.textView, R.id.imageView)
|
||||
)
|
||||
|
||||
val builder = MaterialAlertDialogBuilder(this).apply {
|
||||
setTitle(getString(R.string.add_a_card_in_a_different_way))
|
||||
setAdapter(adapter) { _, i ->
|
||||
when (i) {
|
||||
0 -> addWithoutBarcode()
|
||||
1 -> addManually()
|
||||
2 -> addFromImage()
|
||||
3 -> addFromPdf()
|
||||
4 -> addFromPkPass()
|
||||
else -> throw IllegalArgumentException(
|
||||
"Unknown 'Add a card in a different way' dialog option: $i"
|
||||
)
|
||||
}
|
||||
}
|
||||
setOnCancelListener { _ -> setScannerActive(true) }
|
||||
}
|
||||
builder.show()
|
||||
}
|
||||
|
||||
// Configure barcodeScanner
|
||||
barcodeScannerView = binding.zxingBarcodeScanner
|
||||
|
||||
val barcodeScannerIntent = Intent().apply {
|
||||
val barcodeScannerIntentBundle = Bundle().apply {
|
||||
putBoolean(DecodeHintType.ALSO_INVERTED.name, true)
|
||||
}
|
||||
putExtras(barcodeScannerIntentBundle)
|
||||
}
|
||||
barcodeScannerView.initializeFromIntent(barcodeScannerIntent)
|
||||
|
||||
// Even though we do the actual decoding with the barcodeScannerView
|
||||
// CaptureManager needs to be running to show the camera and scanning bar
|
||||
capture = CatimaCaptureManager(this, barcodeScannerView, this::onCaptureManagerError)
|
||||
val captureIntent = Intent().apply {
|
||||
val captureIntentBundle = Bundle().apply {
|
||||
putBoolean(DecodeHintType.ALSO_INVERTED.name, false)
|
||||
}
|
||||
putExtras(captureIntentBundle)
|
||||
}
|
||||
capture.initializeFromIntent(captureIntent, savedInstanceState)
|
||||
|
||||
barcodeScannerView.decodeSingle(object : BarcodeCallback {
|
||||
override fun barcodeResult(result: BarcodeResult) {
|
||||
val loyaltyCard = LoyaltyCard().apply {
|
||||
setCardId(result.text)
|
||||
setBarcodeType(CatimaBarcode.fromBarcode(result.barcodeFormat))
|
||||
}
|
||||
|
||||
returnResult(ParseResult(ParseResultType.BARCODE_ONLY, loyaltyCard))
|
||||
}
|
||||
|
||||
override fun possibleResultPoints(resultPoints: List<ResultPoint?>?) {}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
if (mScannerActive) {
|
||||
capture.onResume()
|
||||
}
|
||||
|
||||
if (!Utils.deviceHasCamera(this)) {
|
||||
showCameraError(getString(R.string.noCameraFoundGuideText), false)
|
||||
} else if (ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.CAMERA
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
showCameraPermissionMissingText()
|
||||
} else {
|
||||
hideCameraError()
|
||||
}
|
||||
|
||||
scaleScreen()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
capture.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
capture.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||
super.onSaveInstanceState(savedInstanceState)
|
||||
capture.onSaveInstanceState(savedInstanceState)
|
||||
|
||||
savedInstanceState.putBoolean(STATE_SCANNER_ACTIVE, mScannerActive)
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
|
||||
mScannerActive = savedInstanceState.getBoolean(STATE_SCANNER_ACTIVE)
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
return barcodeScannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
|
||||
menuInflater.inflate(R.menu.scan_menu, menu)
|
||||
}
|
||||
|
||||
barcodeScannerView.setTorchOff()
|
||||
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
setResult(RESULT_CANCELED)
|
||||
finish()
|
||||
return true
|
||||
} else if (item.itemId == R.id.action_toggle_flashlight) {
|
||||
if (torch) {
|
||||
torch = false
|
||||
barcodeScannerView.setTorchOff()
|
||||
item.setTitle(R.string.turn_flashlight_on)
|
||||
item.setIcon(R.drawable.ic_flashlight_off_white_24dp)
|
||||
} else {
|
||||
torch = true
|
||||
barcodeScannerView.setTorchOn()
|
||||
item.setTitle(R.string.turn_flashlight_off)
|
||||
item.setIcon(R.drawable.ic_flashlight_on_white_24dp)
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun setScannerActive(isActive: Boolean) {
|
||||
if (isActive) {
|
||||
barcodeScannerView.resume()
|
||||
} else {
|
||||
barcodeScannerView.pause()
|
||||
}
|
||||
mScannerActive = isActive
|
||||
}
|
||||
|
||||
private fun returnResult(parseResult: ParseResult) {
|
||||
val bundle = parseResult.toLoyaltyCardBundle(this).apply {
|
||||
addGroup?.let { putString(LoyaltyCardEditActivity.BUNDLE_ADDGROUP, it) }
|
||||
}
|
||||
val result = Intent().apply { putExtras(bundle) }
|
||||
this.setResult(RESULT_OK, result)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun handleActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
||||
super.onActivityResult(resultCode, resultCode, intent)
|
||||
|
||||
val parseResultList: List<ParseResult> =
|
||||
Utils.parseSetBarcodeActivityResult(requestCode, resultCode, intent, this)
|
||||
|
||||
if (parseResultList.isEmpty()) {
|
||||
setScannerActive(true)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Utils.makeUserChooseParseResultFromList(
|
||||
this,
|
||||
parseResultList,
|
||||
object : ParseResultListDisambiguatorCallback {
|
||||
override fun onUserChoseParseResult(parseResult: ParseResult) {
|
||||
returnResult(parseResult)
|
||||
}
|
||||
|
||||
override fun onUserDismissedSelector() {
|
||||
setScannerActive(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun addWithoutBarcode() {
|
||||
val builder: AlertDialog.Builder = MaterialAlertDialogBuilder(this).apply {
|
||||
setOnCancelListener { dialogInterface -> setScannerActive(true) }
|
||||
// Header
|
||||
setTitle(R.string.addWithoutBarcode)
|
||||
}
|
||||
|
||||
// Layout
|
||||
val layout = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
}
|
||||
val contentPadding = resources.getDimensionPixelSize(R.dimen.alert_dialog_content_padding)
|
||||
val params = LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
leftMargin = contentPadding
|
||||
topMargin = contentPadding / 2
|
||||
rightMargin = contentPadding
|
||||
}
|
||||
|
||||
// Description
|
||||
val currentTextview = TextView(this).apply {
|
||||
text = getString(R.string.enter_card_id)
|
||||
layoutParams = params
|
||||
}
|
||||
layout.addView(currentTextview)
|
||||
|
||||
//EditText with spacing
|
||||
val input = EditText(this).apply {
|
||||
inputType = InputType.TYPE_CLASS_TEXT
|
||||
layoutParams = params
|
||||
}
|
||||
layout.addView(input)
|
||||
|
||||
// Set layout
|
||||
builder.setView(layout).apply {
|
||||
|
||||
setPositiveButton(getString(R.string.ok)) { _, _ ->
|
||||
val loyaltyCard = LoyaltyCard()
|
||||
loyaltyCard.cardId = input.text.toString()
|
||||
returnResult(ParseResult(ParseResultType.BARCODE_ONLY, loyaltyCard))
|
||||
}
|
||||
setNegativeButton(getString(R.string.cancel)) { dialog, _ ->
|
||||
dialog.cancel()
|
||||
}
|
||||
}
|
||||
val dialog: AlertDialog = builder.create()
|
||||
|
||||
// Now that the dialog exists, we can bind something that affects the OK button
|
||||
input.doOnTextChanged { text, _, _, _ ->
|
||||
if (text.isNullOrEmpty()) {
|
||||
input.error = getString(R.string.card_id_must_not_be_empty)
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
} else {
|
||||
input.error = null
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
|
||||
// Disable button (must be done **after** dialog is shown to prevent crash
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
// Set focus on input field
|
||||
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
input.requestFocus()
|
||||
}
|
||||
|
||||
fun addManually() {
|
||||
val builder = MaterialAlertDialogBuilder(this).apply {
|
||||
setTitle(R.string.add_manually_warning_title)
|
||||
setMessage(R.string.add_manually_warning_message)
|
||||
setPositiveButton(R.string.continue_) { _, _ ->
|
||||
val i = Intent(applicationContext, BarcodeSelectorActivity::class.java)
|
||||
if (cardId != null) {
|
||||
val b = Bundle()
|
||||
b.putString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID, cardId)
|
||||
i.putExtras(b)
|
||||
}
|
||||
manualAddLauncher.launch(i)
|
||||
}
|
||||
setNegativeButton(R.string.cancel) { _, _ -> setScannerActive(true) }
|
||||
setOnCancelListener { _ -> setScannerActive(true) }
|
||||
}
|
||||
builder.show()
|
||||
}
|
||||
|
||||
fun addFromImage() {
|
||||
PermissionUtils.requestStorageReadPermission(this, PERMISSION_SCAN_ADD_FROM_IMAGE)
|
||||
}
|
||||
|
||||
fun addFromPdf() {
|
||||
PermissionUtils.requestStorageReadPermission(this, PERMISSION_SCAN_ADD_FROM_PDF)
|
||||
}
|
||||
|
||||
fun addFromPkPass() {
|
||||
PermissionUtils.requestStorageReadPermission(this, PERMISSION_SCAN_ADD_FROM_PKPASS)
|
||||
}
|
||||
|
||||
private fun addFromImageOrFileAfterPermission(
|
||||
mimeType: String,
|
||||
launcher: ActivityResultLauncher<Intent>,
|
||||
chooserText: Int,
|
||||
errorMessage: Int
|
||||
) {
|
||||
val photoPickerIntent = Intent(Intent.ACTION_PICK)
|
||||
photoPickerIntent.type = mimeType
|
||||
val contentIntent = Intent(Intent.ACTION_GET_CONTENT)
|
||||
contentIntent.type = mimeType
|
||||
|
||||
val chooserIntent = Intent.createChooser(photoPickerIntent, getString(chooserText))
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arrayOf(contentIntent))
|
||||
try {
|
||||
launcher.launch(chooserIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
setScannerActive(true)
|
||||
Toast.makeText(applicationContext, errorMessage, Toast.LENGTH_LONG).show()
|
||||
Log.e(TAG, "No activity found to handle intent", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun onCaptureManagerError(errorMessage: String) {
|
||||
if (mHasError) {
|
||||
// We're already showing an error, ignore this new error
|
||||
return
|
||||
}
|
||||
|
||||
showCameraError(errorMessage, false)
|
||||
}
|
||||
|
||||
private fun showCameraPermissionMissingText() {
|
||||
showCameraError(getString(R.string.noCameraPermissionDirectToSystemSetting), true)
|
||||
}
|
||||
|
||||
private fun showCameraError(message: String, setOnClick: Boolean) {
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorMessage.text = message
|
||||
|
||||
setCameraErrorState(true, setOnClick)
|
||||
}
|
||||
|
||||
private fun hideCameraError() {
|
||||
setCameraErrorState(false, false)
|
||||
}
|
||||
|
||||
private fun setCameraErrorState(visible: Boolean, setOnClick: Boolean) {
|
||||
mHasError = visible
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorClickableArea.setOnClickListener(
|
||||
if (visible && setOnClick) { _ -> navigateToSystemPermissionSetting() }
|
||||
else null
|
||||
)
|
||||
customBarcodeScannerBinding.cardInputContainer.setBackgroundColor(
|
||||
if (visible) obtainThemeAttribute(com.google.android.material.R.attr.colorSurface)
|
||||
else Color.TRANSPARENT
|
||||
)
|
||||
customBarcodeScannerBinding.cameraErrorLayout.root.visibility =
|
||||
if (visible) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
private fun scaleScreen() {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||
val screenHeight: Int = displayMetrics.heightPixels
|
||||
val mediumSizePx: Float = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
MEDIUM_SCALE_FACTOR_DIP.toFloat(),
|
||||
resources.displayMetrics
|
||||
)
|
||||
val shouldScaleSmaller = screenHeight < mediumSizePx
|
||||
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorIcon.visibility =
|
||||
if (shouldScaleSmaller) View.GONE else View.VISIBLE
|
||||
customBarcodeScannerBinding.cameraErrorLayout.cameraErrorTitle.visibility =
|
||||
if (shouldScaleSmaller) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
private fun obtainThemeAttribute(attribute: Int): Int {
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(attribute, typedValue, true)
|
||||
return typedValue.data
|
||||
}
|
||||
|
||||
private fun navigateToSystemPermissionSetting() {
|
||||
val permissionIntent = Intent(
|
||||
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", getPackageName(), null)
|
||||
)
|
||||
permissionIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(permissionIntent)
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String?>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
|
||||
onMockedRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
}
|
||||
|
||||
override fun onMockedRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String?>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
val granted =
|
||||
grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
if (requestCode == CaptureManager.getCameraPermissionReqCode()) {
|
||||
if (granted) {
|
||||
hideCameraError()
|
||||
} else {
|
||||
showCameraPermissionMissingText()
|
||||
}
|
||||
} else if (requestCode in listOf(
|
||||
PERMISSION_SCAN_ADD_FROM_IMAGE,
|
||||
PERMISSION_SCAN_ADD_FROM_PDF,
|
||||
PERMISSION_SCAN_ADD_FROM_PKPASS
|
||||
)
|
||||
) {
|
||||
if (granted) {
|
||||
if (requestCode == PERMISSION_SCAN_ADD_FROM_IMAGE) {
|
||||
addFromImageOrFileAfterPermission(
|
||||
"image/*",
|
||||
photoPickerLauncher,
|
||||
R.string.addFromImage,
|
||||
R.string.failedLaunchingPhotoPicker
|
||||
)
|
||||
} else if (requestCode == PERMISSION_SCAN_ADD_FROM_PDF) {
|
||||
addFromImageOrFileAfterPermission(
|
||||
"application/pdf",
|
||||
pdfPickerLauncher,
|
||||
R.string.addFromPdfFile,
|
||||
R.string.failedLaunchingFileManager
|
||||
)
|
||||
} else {
|
||||
addFromImageOrFileAfterPermission(
|
||||
"application/*",
|
||||
pkpassPickerLauncher,
|
||||
R.string.addFromPkpass,
|
||||
R.string.failedLaunchingFileManager
|
||||
)
|
||||
}
|
||||
} else {
|
||||
setScannerActive(true)
|
||||
Toast.makeText(this, R.string.storageReadPermissionRequired, Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
public class ThirdPartyInfo {
|
||||
private final String mName;
|
||||
private final String mUrl;
|
||||
private final String mLicense;
|
||||
|
||||
public ThirdPartyInfo(String name, String url, String license) {
|
||||
mName = name;
|
||||
mUrl = url;
|
||||
mLicense = license;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public String url() {
|
||||
return mUrl;
|
||||
}
|
||||
|
||||
public String license() {
|
||||
return mLicense;
|
||||
}
|
||||
|
||||
public String toHtml() {
|
||||
return String.format("<a href=\"%s\">%s</a> (%s)", url(), name(), license());
|
||||
}
|
||||
}
|
||||
23
app/src/main/java/protect/card_locker/ThirdPartyInfo.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package protect.card_locker
|
||||
|
||||
class ThirdPartyInfo(
|
||||
private val mName: String,
|
||||
private val mUrl: String,
|
||||
private val mLicense: String
|
||||
) {
|
||||
fun name(): String {
|
||||
return mName
|
||||
}
|
||||
|
||||
fun url(): String {
|
||||
return mUrl
|
||||
}
|
||||
|
||||
fun license(): String {
|
||||
return mLicense
|
||||
}
|
||||
|
||||
fun toHtml(): String {
|
||||
return String.format("<a href=\"%s\">%s</a> (%s)", url(), name(), license())
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.textview.MaterialTextView;
|
||||
import com.yalantis.ucrop.UCropActivity;
|
||||
|
||||
public class UCropWrapper extends UCropActivity {
|
||||
public static final String UCROP_TOOLBAR_TYPEFACE_STYLE = "ucop_toolbar_typeface_style";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Utils.applyWindowInsets(findViewById(android.R.id.content));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
boolean darkMode = Utils.isDarkModeEnabled(this);
|
||||
Window window = getWindow();
|
||||
// setup status bar to look like the rest of the app
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (window != null) {
|
||||
View decorView = window.getDecorView();
|
||||
WindowInsetsControllerCompat wic = new WindowInsetsControllerCompat(window, decorView);
|
||||
wic.setAppearanceLightStatusBars(!darkMode);
|
||||
}
|
||||
} else {
|
||||
// icons are always white back then
|
||||
if (window != null && !darkMode) {
|
||||
window.setStatusBarColor(ColorUtils.compositeColors(Color.argb(127, 0, 0, 0), window.getStatusBarColor()));
|
||||
}
|
||||
}
|
||||
|
||||
// find and check views that we wish to color modify
|
||||
// for when we update ucrop or switch to another cropper
|
||||
View check = findViewById(com.yalantis.ucrop.R.id.wrapper_controls);
|
||||
if (check instanceof FrameLayout) {
|
||||
FrameLayout controls = (FrameLayout) check;
|
||||
check = findViewById(com.yalantis.ucrop.R.id.wrapper_states);
|
||||
if (check instanceof LinearLayout) {
|
||||
LinearLayout states = (LinearLayout) check;
|
||||
for (int i = 0; i < controls.getChildCount(); i++) {
|
||||
check = controls.getChildAt(i);
|
||||
if (check instanceof AppCompatImageView) {
|
||||
AppCompatImageView controlsBackgroundImage = (AppCompatImageView) check;
|
||||
// everything gathered and are as expected, now perform color patching
|
||||
Utils.patchColors(this);
|
||||
int colorSurface = MaterialColors.getColor(this, com.google.android.material.R.attr.colorSurface, ContextCompat.getColor(this, R.color.md_theme_light_surface));
|
||||
int colorOnSurface = MaterialColors.getColor(this, com.google.android.material.R.attr.colorOnSurface, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
|
||||
|
||||
Drawable controlsBackgroundImageDrawable = controlsBackgroundImage.getBackground();
|
||||
controlsBackgroundImageDrawable.mutate();
|
||||
controlsBackgroundImageDrawable.setTint(darkMode ? colorOnSurface : colorSurface);
|
||||
controlsBackgroundImage.setBackgroundDrawable(controlsBackgroundImageDrawable);
|
||||
|
||||
states.setBackgroundColor(darkMode ? colorSurface : colorOnSurface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// change toolbar font
|
||||
check = findViewById(com.yalantis.ucrop.R.id.toolbar_title);
|
||||
if (check instanceof MaterialTextView) {
|
||||
MaterialTextView toolbarTextview = (MaterialTextView) check;
|
||||
Intent intent = getIntent();
|
||||
int style = intent.getIntExtra(UCROP_TOOLBAR_TYPEFACE_STYLE, -1);
|
||||
if (style != -1) {
|
||||
toolbarTextview.setTypeface(Typeface.defaultFromStyle(style));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
122
app/src/main/java/protect/card_locker/UCropWrapper.kt
Normal file
@@ -0,0 +1,122 @@
|
||||
package protect.card_locker
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.children
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import com.yalantis.ucrop.UCropActivity
|
||||
|
||||
class UCropWrapper : UCropActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
Utils.applyWindowInsets(findViewById(android.R.id.content))
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
val darkMode = Utils.isDarkModeEnabled(this)
|
||||
// setup status bar to look like the rest of the app
|
||||
setupStatusBar(darkMode)
|
||||
// find and check views that we wish to color modify
|
||||
// for when we update ucrop or switch to another cropper
|
||||
checkViews(darkMode)
|
||||
// change toolbar font
|
||||
changeToolbarFont()
|
||||
}
|
||||
|
||||
private fun setupStatusBar(darkMode: Boolean) {
|
||||
if (window == null) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
val decorView = window.decorView
|
||||
val wic = WindowInsetsControllerCompat(window, decorView)
|
||||
wic.isAppearanceLightStatusBars = !darkMode
|
||||
} else if (!darkMode) {
|
||||
window.statusBarColor = ColorUtils.compositeColors(
|
||||
Color.argb(127, 0, 0, 0),
|
||||
window.statusBarColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkViews(darkMode: Boolean) {
|
||||
var view = findViewById<View?>(com.yalantis.ucrop.R.id.wrapper_controls)
|
||||
if (view !is FrameLayout) {
|
||||
return
|
||||
}
|
||||
|
||||
val controls = view
|
||||
view = findViewById(com.yalantis.ucrop.R.id.wrapper_states)
|
||||
if (view !is LinearLayout) {
|
||||
return
|
||||
}
|
||||
val states = view
|
||||
controls.children.firstOrNull { it is AppCompatImageView }?.let {
|
||||
// everything gathered and are as expected, now perform color patching
|
||||
Utils.patchColors(this)
|
||||
val colorSurface = MaterialColors.getColor(
|
||||
this,
|
||||
com.google.android.material.R.attr.colorSurface,
|
||||
ContextCompat.getColor(
|
||||
this,
|
||||
R.color.md_theme_light_surface
|
||||
)
|
||||
)
|
||||
val colorOnSurface = MaterialColors.getColor(
|
||||
this,
|
||||
com.google.android.material.R.attr.colorOnSurface,
|
||||
ContextCompat.getColor(
|
||||
this,
|
||||
R.color.md_theme_light_onSurface
|
||||
)
|
||||
)
|
||||
|
||||
val controlsBackgroundImageDrawable = it.background
|
||||
controlsBackgroundImageDrawable.mutate()
|
||||
controlsBackgroundImageDrawable.setTint(
|
||||
if (darkMode) {
|
||||
colorOnSurface
|
||||
} else {
|
||||
colorSurface
|
||||
}
|
||||
)
|
||||
it.background = controlsBackgroundImageDrawable
|
||||
states.setBackgroundColor(
|
||||
if (darkMode) {
|
||||
colorSurface
|
||||
} else {
|
||||
colorOnSurface
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeToolbarFont() {
|
||||
val toolbar = findViewById<View?>(com.yalantis.ucrop.R.id.toolbar_title)
|
||||
if (toolbar !is MaterialTextView) {
|
||||
return
|
||||
}
|
||||
|
||||
val style = intent.getIntExtra(UCROP_TOOLBAR_TYPEFACE_STYLE, -1)
|
||||
if (style != -1) {
|
||||
toolbar.setTypeface(Typeface.defaultFromStyle(style))
|
||||
}
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
const val UCROP_TOOLBAR_TYPEFACE_STYLE: String = "ucop_toolbar_typeface_style"
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -50,6 +51,7 @@ import androidx.palette.graphics.Palette;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.LuminanceSource;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
@@ -85,10 +87,10 @@ import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.EnumMap;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -226,6 +228,58 @@ public class Utils {
|
||||
return parseResultList;
|
||||
}
|
||||
|
||||
static public List<ParseResult> retrieveBarcodesFromPkPasses(Context context, Uri uri) {
|
||||
Log.i(TAG, "Received Pkpasses file with possible barcode");
|
||||
if (uri == null) {
|
||||
Log.e(TAG, "Pkpasses did not contain any data");
|
||||
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
PkpassesParser pkpassesParser;
|
||||
try {
|
||||
pkpassesParser = new PkpassesParser(context, uri);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error reading pkpasses file", e);
|
||||
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<ParseResult> parseResultList = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (PkpassParser pkpassParser : pkpassesParser.getPkpassParsers()) {
|
||||
ParseResult parseResult;
|
||||
List<String> locales = pkpassParser.listLocales();
|
||||
if (locales.isEmpty()) {
|
||||
try {
|
||||
parseResult = new ParseResult(ParseResultType.FULL, pkpassParser.toLoyaltyCard(null));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error calling toLoyaltyCard on pkpass file", e);
|
||||
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
parseResult.setNote(String.format(context.getString(R.string.cardWithNumber), i+1));
|
||||
parseResultList.add(parseResult);
|
||||
} else {
|
||||
for (String locale : locales) {
|
||||
try {
|
||||
parseResult = new ParseResult(ParseResultType.FULL, pkpassParser.toLoyaltyCard(locale));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error calling toLoyaltyCard on pkpass file", e);
|
||||
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
parseResult.setNote(String.format(context.getString(R.string.cardWithNumberAndLocale), i+1, locale));
|
||||
parseResultList.add(parseResult);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return parseResultList;
|
||||
}
|
||||
|
||||
static public List<ParseResult> retrieveBarcodesFromPdf(Context context, Uri uri) {
|
||||
Log.i(TAG, "Received PDF file with possible barcode");
|
||||
if (uri == null) {
|
||||
@@ -317,7 +371,19 @@ public class Utils {
|
||||
}
|
||||
|
||||
if (requestCode == Utils.BARCODE_IMPORT_FROM_PKPASS_FILE) {
|
||||
return retrieveBarcodesFromPkPass(context, intent.getData());
|
||||
Uri intentData = intent.getData();
|
||||
|
||||
if (intentData == null) {
|
||||
Log.e(TAG, "Uri did not contain any data");
|
||||
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (Objects.equals(context.getContentResolver().getType(intentData), "application/vnd.apple.pkpasses")) {
|
||||
return retrieveBarcodesFromPkPasses(context, intentData);
|
||||
}
|
||||
|
||||
return retrieveBarcodesFromPkPass(context, intentData);
|
||||
}
|
||||
|
||||
if (requestCode == Utils.BARCODE_SCAN || requestCode == Utils.SELECT_BARCODE_REQUEST) {
|
||||
@@ -594,6 +660,11 @@ public class Utils {
|
||||
double width = bitmap.getWidth();
|
||||
double height = bitmap.getHeight();
|
||||
|
||||
// Early exit
|
||||
if (Math.max(width, height) <= maxSize) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
if (height > width) {
|
||||
double scale = height / maxSize;
|
||||
height = maxSize;
|
||||
@@ -843,7 +914,7 @@ public class Utils {
|
||||
|
||||
public static File copyToTempFile(Context context, InputStream input, String name) throws IOException {
|
||||
File file = createTempFile(context, name);
|
||||
try (input; FileOutputStream out = new FileOutputStream(file)) {
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
byte[] buf = new byte[4096];
|
||||
int len;
|
||||
while ((len = input.read(buf)) != -1) {
|
||||
@@ -1134,6 +1205,27 @@ public class Utils {
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
});
|
||||
}
|
||||
|
||||
public static void applyWindowInsetsAndFabOffset(View root, FloatingActionButton fab) {
|
||||
/* This function is a copy of applyWindowInsets, with the added behaviour that it ensures the FAB will be displayed vertically above the keyboard at all times */
|
||||
ViewCompat.setOnApplyWindowInsetsListener(root, (view, windowInsets) -> {
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
||||
layoutParams.leftMargin = insets.left;
|
||||
layoutParams.bottomMargin = insets.bottom;
|
||||
layoutParams.rightMargin = insets.right;
|
||||
layoutParams.topMargin = insets.top;
|
||||
view.setLayoutParams(layoutParams);
|
||||
|
||||
// This is required to move the FAB above the keyboard when keyboard is open
|
||||
Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
|
||||
boolean isKeyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());
|
||||
fab.setTranslationY(isKeyboardVisible ? (- imeInsets.bottom) : 0);
|
||||
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
});
|
||||
}
|
||||
|
||||
public static ImageView.ScaleType getRecommendedScaleTypeForThumbnailImage(@Nullable Bitmap image) {
|
||||
// Return something sensible if no image
|
||||
@@ -1149,4 +1241,40 @@ public class Utils {
|
||||
|
||||
return ImageView.ScaleType.FIT_CENTER;
|
||||
}
|
||||
|
||||
public static DBHelper.LoyaltyCardOrder getLoyaltyCardOrder(Context context) {
|
||||
SharedPreferences sortPref = context.getSharedPreferences(
|
||||
"sharedpreference_sort",
|
||||
Context.MODE_PRIVATE
|
||||
);
|
||||
|
||||
String orderString = sortPref.getString("sharedpreference_sort_order", null);
|
||||
|
||||
if (orderString != null) {
|
||||
try {
|
||||
return DBHelper.LoyaltyCardOrder.valueOf(orderString);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return DBHelper.LoyaltyCardOrder.Alpha;
|
||||
}
|
||||
|
||||
public static DBHelper.LoyaltyCardOrderDirection getLoyaltyCardOrderDirection(Context context) {
|
||||
SharedPreferences sortPref = context.getSharedPreferences(
|
||||
"sharedpreference_sort",
|
||||
Context.MODE_PRIVATE
|
||||
);
|
||||
|
||||
String orderDirectionString = sortPref.getString("sharedpreference_sort_direction", null);
|
||||
|
||||
if (orderDirectionString != null) {
|
||||
try {
|
||||
return DBHelper.LoyaltyCardOrderDirection.valueOf(orderDirectionString);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return DBHelper.LoyaltyCardOrderDirection.Ascending;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package protect.card_locker.async;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public interface CompatCallable<T> extends Callable<T> {
|
||||
void onPostExecute(Object result);
|
||||
|
||||
void onPreExecute();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package protect.card_locker.async
|
||||
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
interface CompatCallable<T> : Callable<T?> {
|
||||
fun onPostExecute(result: Any?)
|
||||
|
||||
fun onPreExecute()
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package protect.card_locker.importexport;
|
||||
|
||||
public enum DataFormat {
|
||||
Catima,
|
||||
Fidme,
|
||||
Stocard,
|
||||
VoucherVault;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package protect.card_locker.importexport
|
||||
|
||||
enum class DataFormat {
|
||||
Catima,
|
||||
Fidme,
|
||||
VoucherVault
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package protect.card_locker.importexport;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Interface for a class which can export the contents of the database
|
||||
* in a given format.
|
||||
*/
|
||||
public interface Exporter {
|
||||
/**
|
||||
* Export the database to the output stream in a given format.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
void exportData(Context context, SQLiteDatabase database, OutputStream output, char[] password) throws IOException, InterruptedException;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package protect.card_locker.importexport
|
||||
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
|
||||
/**
|
||||
* Interface for a class which can export the contents of the database
|
||||
* in a given format.
|
||||
*/
|
||||
interface Exporter {
|
||||
/**
|
||||
* Export the database to the output stream in a given format.
|
||||
*
|
||||
* @throws IOException, InterruptedException
|
||||
*/
|
||||
@Throws(IOException::class, InterruptedException::class)
|
||||
fun exportData(
|
||||
context: Context,
|
||||
database: SQLiteDatabase,
|
||||
output: OutputStream,
|
||||
password: CharArray
|
||||
)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package protect.card_locker.importexport;
|
||||
|
||||
public enum ImportExportResultType {
|
||||
Success,
|
||||
GenericFailure,
|
||||
BadPassword;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package protect.card_locker.importexport
|
||||
|
||||
enum class ImportExportResultType {
|
||||
Success,
|
||||
GenericFailure,
|
||||
BadPassword
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package protect.card_locker.importexport;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import protect.card_locker.FormatException;
|
||||
|
||||
/**
|
||||
* Interface for a class which can import the contents of a stream
|
||||
* into the database.
|
||||
*/
|
||||
public interface Importer {
|
||||
/**
|
||||
* Import data from the input stream in a given format into
|
||||
* the database.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws FormatException
|
||||
*/
|
||||
void importData(Context context, SQLiteDatabase database, File inputFile, char[] password) throws IOException, FormatException, InterruptedException, JSONException, ParseException;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package protect.card_locker.importexport
|
||||
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import org.json.JSONException
|
||||
import protect.card_locker.FormatException
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.text.ParseException
|
||||
|
||||
/**
|
||||
* Interface for a class which can import the contents of a stream
|
||||
* into the database.
|
||||
*/
|
||||
interface Importer {
|
||||
/**
|
||||
* Import data from the input stream in a given format into
|
||||
* the database.
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws FormatException
|
||||
* @throws InterruptedException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
*/
|
||||
@Throws(
|
||||
IOException::class,
|
||||
FormatException::class,
|
||||
InterruptedException::class,
|
||||
JSONException::class,
|
||||
ParseException::class
|
||||
)
|
||||
fun importData(
|
||||
context: Context,
|
||||
database: SQLiteDatabase,
|
||||
inputFile: File,
|
||||
password: CharArray
|
||||
)
|
||||
}
|
||||
@@ -37,9 +37,6 @@ public class MultiFormatImporter {
|
||||
case Fidme:
|
||||
importer = new FidmeImporter();
|
||||
break;
|
||||
case Stocard:
|
||||
importer = new StocardImporter();
|
||||
break;
|
||||
case VoucherVault:
|
||||
importer = new VoucherVaultImporter();
|
||||
break;
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
package protect.card_locker.importexport;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.io.inputstream.ZipInputStream;
|
||||
import net.lingala.zip4j.model.FileHeader;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVParser;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import protect.card_locker.CatimaBarcode;
|
||||
import protect.card_locker.DBHelper;
|
||||
import protect.card_locker.FormatException;
|
||||
import protect.card_locker.ImageLocationType;
|
||||
import protect.card_locker.LoyaltyCard;
|
||||
import protect.card_locker.R;
|
||||
import protect.card_locker.Utils;
|
||||
import protect.card_locker.ZipUtils;
|
||||
|
||||
/**
|
||||
* Class for importing a database from CSV (Comma Separate Values)
|
||||
* formatted data.
|
||||
* <p>
|
||||
* The database's loyalty cards are expected to appear in the CSV data.
|
||||
* A header is expected for the each table showing the names of the columns.
|
||||
*/
|
||||
public class StocardImporter implements Importer {
|
||||
public static class StocardProvider {
|
||||
public String name = null;
|
||||
public String barcodeFormat = null;
|
||||
public Bitmap logo = null;
|
||||
}
|
||||
|
||||
public static class StocardRecord {
|
||||
public String providerId = null;
|
||||
public String store = null;
|
||||
public String label = null;
|
||||
public String note = null;
|
||||
public String cardId = null;
|
||||
public String barcodeType = null;
|
||||
public Long lastUsed = null;
|
||||
public Bitmap frontImage = null;
|
||||
public Bitmap backImage = null;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"StocardRecord{%n providerId=%s,%n store=%s,%n label=%s,%n note=%s,%n cardId=%s,%n"
|
||||
+ " barcodeType=%s,%n lastUsed=%s,%n frontImage=%s,%n backImage=%s%n}",
|
||||
this.providerId,
|
||||
this.store,
|
||||
this.label,
|
||||
this.note,
|
||||
this.cardId,
|
||||
this.barcodeType,
|
||||
this.lastUsed,
|
||||
this.frontImage,
|
||||
this.backImage
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ZIPData {
|
||||
public final Map<String, StocardRecord> cards;
|
||||
public final Map<String, StocardProvider> providers;
|
||||
|
||||
ZIPData(final Map<String, StocardRecord> cards, final Map<String, StocardProvider> providers) {
|
||||
this.cards = cards;
|
||||
this.providers = providers;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ImportedData {
|
||||
public final List<LoyaltyCard> cards;
|
||||
public final Map<Integer, Map<ImageLocationType, Bitmap>> images;
|
||||
|
||||
ImportedData(final List<LoyaltyCard> cards, final Map<Integer, Map<ImageLocationType, Bitmap>> images) {
|
||||
this.cards = cards;
|
||||
this.images = images;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String PROVIDER_PREFIX = "/loyalty-card-providers/";
|
||||
|
||||
private static final String TAG = "Catima";
|
||||
|
||||
public void importData(Context context, SQLiteDatabase database, File inputFile, char[] password) throws IOException, FormatException, JSONException, ParseException {
|
||||
ZIPData zipData = new ZIPData(new HashMap<>(), new HashMap<>());
|
||||
|
||||
final CSVParser parser = new CSVParser(new InputStreamReader(context.getResources().openRawResource(R.raw.stocard_stores), StandardCharsets.UTF_8), CSVFormat.RFC4180.builder().setHeader().build());
|
||||
|
||||
try {
|
||||
for (CSVRecord record : parser) {
|
||||
StocardProvider provider = new StocardProvider();
|
||||
provider.name = record.get("name").trim();
|
||||
provider.barcodeFormat = record.get("barcodeFormat").trim();
|
||||
|
||||
zipData.providers.put(record.get("_id").trim(), provider);
|
||||
}
|
||||
|
||||
parser.close();
|
||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||
throw new FormatException("Issue parsing CSV data", e);
|
||||
}
|
||||
|
||||
ZipFile zipFile = new ZipFile(inputFile, password);
|
||||
zipData = importZIP(zipFile, zipData);
|
||||
zipFile.close();
|
||||
|
||||
if (zipData.cards.keySet().size() == 0) {
|
||||
throw new FormatException("Couldn't find any loyalty cards in this Stocard export.");
|
||||
}
|
||||
|
||||
ImportedData importedData = importLoyaltyCardHashMap(context, zipData);
|
||||
saveAndDeduplicate(context, database, importedData);
|
||||
}
|
||||
|
||||
public ZIPData importZIP(ZipFile zipFile, final ZIPData zipData) throws IOException, FormatException, JSONException {
|
||||
Map<String, StocardRecord> cards = zipData.cards;
|
||||
Map<String, StocardProvider> providers = zipData.providers;
|
||||
|
||||
String[] customProvidersBaseName = null;
|
||||
String[] cardBaseName = null;
|
||||
String customProviderId = "";
|
||||
String cardName = "";
|
||||
for (FileHeader fileHeader : zipFile.getFileHeaders()) {
|
||||
String fileName = fileHeader.getFileName();
|
||||
String[] nameParts = fileName.split("/");
|
||||
|
||||
if (nameParts.length < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String userId = nameParts[1];
|
||||
ZipInputStream zipInputStream = zipFile.getInputStream(fileHeader);
|
||||
|
||||
if (customProvidersBaseName == null) {
|
||||
// FIXME: can we use the points-account/statement/content.json balance info somehow?
|
||||
/*
|
||||
Known files:
|
||||
extracts/<user-UUID>/users/<user-UUID>/
|
||||
analytics-properties/content.json
|
||||
devices/<device-UUID>/
|
||||
analytics-properties/content.json
|
||||
content.json
|
||||
ip-location-wifi/content.json
|
||||
enabled-regions/<UUID>/content.json
|
||||
loyalty-card-custom-providers/<provider-UUID>/content.json - custom providers
|
||||
loyalty-cards/<card-UUID>/
|
||||
card-linked-coupons/accounts/default/
|
||||
content.json
|
||||
user-coupons/<UUID>/content.json
|
||||
content.json - card itself
|
||||
images/back.png - back image (legacy)
|
||||
images/back/back.jpg - back image
|
||||
images/back/content.json
|
||||
images/front.png - front image (legacy)
|
||||
images/front/content.json
|
||||
images/front/front.jpg - front image
|
||||
notes/default/content.json - note
|
||||
points-account/
|
||||
content.json
|
||||
statement/content.json
|
||||
usages/<UUID>/content.json - timestamps
|
||||
usage-statistics/content.json - timestamps
|
||||
reward-program-balances/<UUID>/content.json
|
||||
*/
|
||||
customProvidersBaseName = new String[]{
|
||||
"extracts",
|
||||
userId,
|
||||
"users",
|
||||
userId,
|
||||
"loyalty-card-custom-providers"
|
||||
};
|
||||
cardBaseName = new String[]{
|
||||
"extracts",
|
||||
userId,
|
||||
"users",
|
||||
userId,
|
||||
"loyalty-cards"
|
||||
};
|
||||
}
|
||||
|
||||
if (startsWith(nameParts, customProvidersBaseName, 1)) {
|
||||
// Extract providerId
|
||||
customProviderId = nameParts[customProvidersBaseName.length];
|
||||
|
||||
StocardProvider provider = providers.get(customProviderId);
|
||||
if (provider == null) {
|
||||
provider = new StocardProvider();
|
||||
providers.put(customProviderId, provider);
|
||||
}
|
||||
|
||||
// Name file
|
||||
if (fileName.endsWith(customProviderId + "/content.json")) {
|
||||
JSONObject jsonObject = ZipUtils.readJSON(zipInputStream);
|
||||
provider.name = jsonObject.getString("name");
|
||||
} else if (fileName.endsWith("logo.png")) {
|
||||
provider.logo = ZipUtils.readImage(zipInputStream);
|
||||
} else if (!fileName.endsWith("/")) {
|
||||
Log.d(TAG, "Unknown or unused loyalty-card-custom-providers file " + fileName + ", skipping...");
|
||||
}
|
||||
} else if (startsWith(nameParts, cardBaseName, 1)) {
|
||||
// Extract cardName
|
||||
cardName = nameParts[cardBaseName.length];
|
||||
|
||||
StocardRecord record = cards.get(cardName);
|
||||
if (record == null) {
|
||||
record = new StocardRecord();
|
||||
cards.put(cardName, record);
|
||||
}
|
||||
|
||||
// This is the card itself
|
||||
if (fileName.endsWith(cardName + "/content.json")) {
|
||||
JSONObject jsonObject = ZipUtils.readJSON(zipInputStream);
|
||||
record.cardId = jsonObject.getString("input_id");
|
||||
|
||||
if (jsonObject.has("input_provider_name")) {
|
||||
record.store = jsonObject.getString("input_provider_name");
|
||||
}
|
||||
|
||||
if (jsonObject.has("label")) {
|
||||
String label = jsonObject.getString("label");
|
||||
if (!label.isBlank()) {
|
||||
record.label = label;
|
||||
}
|
||||
}
|
||||
|
||||
// Provider ID can be either custom or not, extract whatever version is relevant
|
||||
String customProviderPrefix = "/users/" + userId + "/loyalty-card-custom-providers/";
|
||||
String providerId = jsonObject
|
||||
.getJSONObject("input_provider_reference")
|
||||
.getString("identifier");
|
||||
if (providerId.startsWith(customProviderPrefix)) {
|
||||
providerId = providerId.substring(customProviderPrefix.length());
|
||||
} else if (providerId.startsWith(PROVIDER_PREFIX)) {
|
||||
providerId = providerId.substring(PROVIDER_PREFIX.length());
|
||||
} else {
|
||||
throw new FormatException("Unsupported provider ID format: " + providerId);
|
||||
}
|
||||
|
||||
record.providerId = providerId;
|
||||
|
||||
if (jsonObject.has("input_barcode_format")) {
|
||||
record.barcodeType = jsonObject.getString("input_barcode_format");
|
||||
}
|
||||
} else if (fileName.endsWith("notes/default/content.json")) {
|
||||
record.note = ZipUtils.readJSON(zipInputStream).getString("content");
|
||||
} else if (fileName.endsWith("usage-statistics/content.json")) {
|
||||
JSONArray usages = ZipUtils.readJSON(zipInputStream).getJSONArray("usages");
|
||||
for (int i = 0; i < usages.length(); i++) {
|
||||
JSONObject lastUsedObject = usages.getJSONObject(i);
|
||||
String lastUsedString = lastUsedObject.getJSONObject("time").getString("value");
|
||||
long timeStamp = Instant.parse(lastUsedString).getEpochSecond();
|
||||
if (record.lastUsed == null || timeStamp > record.lastUsed) {
|
||||
record.lastUsed = timeStamp;
|
||||
}
|
||||
}
|
||||
} else if (fileName.matches(".*/usages/[^/]+/content.json")) {
|
||||
JSONObject lastUsedObject = ZipUtils.readJSON(zipInputStream);
|
||||
String lastUsedString = lastUsedObject.getJSONObject("time").getString("value");
|
||||
long timeStamp = Instant.parse(lastUsedString).getEpochSecond();
|
||||
if (record.lastUsed == null || timeStamp > record.lastUsed) {
|
||||
record.lastUsed = timeStamp;
|
||||
}
|
||||
} else if (fileName.endsWith("/images/front.png") || fileName.endsWith("/images/front/front.jpg")) {
|
||||
record.frontImage = ZipUtils.readImage(zipInputStream);
|
||||
} else if (fileName.endsWith("/images/back.png") || fileName.endsWith("/images/back/back.jpg")) {
|
||||
record.backImage = ZipUtils.readImage(zipInputStream);
|
||||
} else if (!fileName.endsWith("/")) {
|
||||
Log.d(TAG, "Unknown or unused loyalty-cards file " + fileName + ", skipping...");
|
||||
}
|
||||
} else if (!fileName.endsWith("/")) {
|
||||
Log.d(TAG, "Unknown or unused file " + fileName + ", skipping...");
|
||||
}
|
||||
|
||||
zipInputStream.close();
|
||||
}
|
||||
|
||||
return new ZIPData(cards, providers);
|
||||
}
|
||||
|
||||
public ImportedData importLoyaltyCardHashMap(Context context, final ZIPData zipData) throws FormatException {
|
||||
ImportedData importedData = new ImportedData(new ArrayList<>(), new HashMap<>());
|
||||
int tempID = 0;
|
||||
|
||||
List<String> cardKeys = new ArrayList<>(zipData.cards.keySet());
|
||||
Collections.sort(cardKeys);
|
||||
|
||||
for (String key : cardKeys) {
|
||||
StocardRecord record = zipData.cards.get(key);
|
||||
|
||||
if (record.providerId == null) {
|
||||
Log.d(TAG, "Missing providerId for card " + record + ", ignoring...");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (record.cardId == null) {
|
||||
throw new FormatException("No card ID listed, but is required");
|
||||
}
|
||||
|
||||
StocardProvider provider = zipData.providers.get(record.providerId);
|
||||
|
||||
// Read store from card, if not available (old export), fall back to providerData
|
||||
String store = record.store != null ? record.store : provider != null ? provider.name : record.providerId;
|
||||
String note = record.note != null ? record.note : "";
|
||||
String barcodeTypeString = record.barcodeType != null ? record.barcodeType : provider != null ? provider.barcodeFormat : null;
|
||||
|
||||
if (record.label != null && !record.label.equals(store) && !record.label.equals(note)) {
|
||||
note = note.isEmpty() ? record.label : note + "\n" + record.label;
|
||||
}
|
||||
|
||||
CatimaBarcode barcodeType = null;
|
||||
if (barcodeTypeString != null && !barcodeTypeString.isEmpty()) {
|
||||
if (barcodeTypeString.equals("RSS_DATABAR_EXPANDED")) {
|
||||
barcodeType = CatimaBarcode.fromBarcode(BarcodeFormat.RSS_EXPANDED);
|
||||
} else if (barcodeTypeString.equals("GS1_128")) {
|
||||
barcodeType = CatimaBarcode.fromBarcode(BarcodeFormat.CODE_128);
|
||||
} else {
|
||||
barcodeType = CatimaBarcode.fromName(barcodeTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
int headerColor = Utils.getRandomHeaderColor(context);
|
||||
if (provider != null && provider.logo != null) {
|
||||
headerColor = Utils.getHeaderColorFromImage(provider.logo, headerColor);
|
||||
}
|
||||
|
||||
long lastUsed = record.lastUsed != null ? record.lastUsed : Utils.getUnixTime();
|
||||
|
||||
LoyaltyCard card = new LoyaltyCard(
|
||||
tempID,
|
||||
store,
|
||||
note,
|
||||
null,
|
||||
null,
|
||||
BigDecimal.valueOf(0),
|
||||
null,
|
||||
record.cardId,
|
||||
null,
|
||||
barcodeType,
|
||||
headerColor,
|
||||
0,
|
||||
lastUsed,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
importedData.cards.add(card);
|
||||
|
||||
Map<ImageLocationType, Bitmap> images = new HashMap<>();
|
||||
|
||||
if (provider != null && provider.logo != null) {
|
||||
images.put(ImageLocationType.icon, provider.logo);
|
||||
}
|
||||
if (record.frontImage != null) {
|
||||
images.put(ImageLocationType.front, record.frontImage);
|
||||
}
|
||||
if (record.backImage != null) {
|
||||
images.put(ImageLocationType.back, record.backImage);
|
||||
}
|
||||
|
||||
importedData.images.put(tempID, images);
|
||||
tempID++;
|
||||
}
|
||||
|
||||
return importedData;
|
||||
}
|
||||
|
||||
public void saveAndDeduplicate(Context context, SQLiteDatabase database, final ImportedData data) throws IOException {
|
||||
// This format does not have IDs that can cause conflicts
|
||||
// Proper deduplication for all formats will be implemented later
|
||||
for (LoyaltyCard card : data.cards) {
|
||||
// card.id is temporary and only used to index the images Map
|
||||
long id = DBHelper.insertLoyaltyCard(database, card.store, card.note, card.validFrom, card.expiry, card.balance, card.balanceType,
|
||||
card.cardId, card.barcodeId, card.barcodeType, card.headerColor, card.starStatus, card.lastUsed, card.archiveStatus);
|
||||
for (Map.Entry<ImageLocationType, Bitmap> entry : data.images.get(card.id).entrySet()) {
|
||||
Utils.saveCardImage(context, entry.getValue(), (int) id, entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean startsWith(String[] full, String[] start, int minExtraLength) {
|
||||
if (full.length - minExtraLength < start.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < start.length; i++) {
|
||||
if (!start[i].contentEquals(full[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -74,10 +74,6 @@ public class Settings {
|
||||
return getBoolean(R.string.settings_key_display_barcode_max_brightness, true);
|
||||
}
|
||||
|
||||
public String getCardViewOrientation() {
|
||||
return getString(R.string.settings_key_card_orientation, getResString(R.string.settings_key_follow_system_orientation));
|
||||
}
|
||||
|
||||
public boolean getKeepScreenOn() {
|
||||
return getBoolean(R.string.settings_key_keep_screen_on, true);
|
||||
}
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
package protect.card_locker.preferences;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import protect.card_locker.CatimaAppCompatActivity;
|
||||
import protect.card_locker.MainActivity;
|
||||
import protect.card_locker.R;
|
||||
import protect.card_locker.Utils;
|
||||
import protect.card_locker.databinding.SettingsActivityBinding;
|
||||
|
||||
public class SettingsActivity extends CatimaAppCompatActivity {
|
||||
|
||||
private SettingsActivityBinding binding;
|
||||
private final static String RELOAD_MAIN_STATE = "mReloadMain";
|
||||
private SettingsFragment fragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = SettingsActivityBinding.inflate(getLayoutInflater());
|
||||
setTitle(R.string.settings);
|
||||
setContentView(binding.getRoot());
|
||||
Utils.applyWindowInsets(binding.getRoot());
|
||||
Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
enableToolbarBackButton();
|
||||
|
||||
// Display the fragment as the main content.
|
||||
fragment = new SettingsFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.settings_container, fragment)
|
||||
.commit();
|
||||
|
||||
// restore reload main state
|
||||
if (savedInstanceState != null) {
|
||||
fragment.mReloadMain = savedInstanceState.getBoolean(RELOAD_MAIN_STATE);
|
||||
}
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
finishSettingsActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(RELOAD_MAIN_STATE, fragment.mReloadMain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == android.R.id.home) {
|
||||
finishSettingsActivity();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void finishSettingsActivity() {
|
||||
if (fragment.mReloadMain) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(MainActivity.RESTART_ACTIVITY_INTENT, true);
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(Activity.RESULT_OK);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragmentCompat {
|
||||
private static final String DIALOG_FRAGMENT_TAG = "SettingsFragment";
|
||||
|
||||
public boolean mReloadMain;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
// Show pretty names and summaries
|
||||
ListPreference themePreference = findPreference(getResources().getString(R.string.settings_key_theme));
|
||||
assert themePreference != null;
|
||||
themePreference.setOnPreferenceChangeListener((preference, o) -> {
|
||||
if (o.toString().equals(getResources().getString(R.string.settings_key_light_theme))) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
} else if (o.toString().equals(getResources().getString(R.string.settings_key_dark_theme))) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
ListPreference themeColorPreference = findPreference(getResources().getString(R.string.setting_key_theme_color));
|
||||
assert themeColorPreference != null;
|
||||
themeColorPreference.setOnPreferenceChangeListener((preference, o) -> {
|
||||
refreshActivity(true);
|
||||
return true;
|
||||
});
|
||||
if (!DynamicColors.isDynamicColorAvailable()) {
|
||||
themeColorPreference.setEntryValues(R.array.color_values_no_dynamic);
|
||||
themeColorPreference.setEntries(R.array.color_value_strings_no_dynamic);
|
||||
}
|
||||
|
||||
Preference oledDarkPreference = findPreference(getResources().getString(R.string.settings_key_oled_dark));
|
||||
assert oledDarkPreference != null;
|
||||
oledDarkPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
refreshActivity(true);
|
||||
return true;
|
||||
});
|
||||
|
||||
ListPreference localePreference = findPreference(getResources().getString(R.string.settings_key_locale));
|
||||
assert localePreference != null;
|
||||
CharSequence[] entryValues = localePreference.getEntryValues();
|
||||
List<CharSequence> entries = new ArrayList<>();
|
||||
for (CharSequence entry : entryValues) {
|
||||
if (entry.length() == 0) {
|
||||
entries.add(getResources().getString(R.string.settings_system_locale));
|
||||
} else {
|
||||
Locale entryLocale = Utils.stringToLocale(entry.toString());
|
||||
entries.add(entryLocale.getDisplayName(entryLocale));
|
||||
}
|
||||
}
|
||||
localePreference.setEntries(entries.toArray(new CharSequence[entryValues.length]));
|
||||
// Make locale picker preference in sync with system settings
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
Locale sysLocale = AppCompatDelegate.getApplicationLocales().get(0);
|
||||
if (sysLocale == null) {
|
||||
// Corresponds to "System"
|
||||
localePreference.setValue("");
|
||||
} else {
|
||||
// Need to set preference's value to one of localePreference.getEntryValues() to match the locale.
|
||||
// Locale.toLanguageTag() theoretically should be one of the values in localePreference.getEntryValues()...
|
||||
// But it doesn't work for some locales. so trying something more heavyweight.
|
||||
|
||||
// Obtain all locales supported by the app.
|
||||
List<Locale> appLocales = Arrays.stream(localePreference.getEntryValues())
|
||||
.map(Objects::toString)
|
||||
.map(Utils::stringToLocale)
|
||||
.collect(Collectors.toList());
|
||||
// Get the app locale that best matches the system one
|
||||
Locale bestMatchLocale = Utils.getBestMatchLocale(appLocales, sysLocale);
|
||||
// Get its index in supported locales
|
||||
int index = appLocales.indexOf(bestMatchLocale);
|
||||
// Set preference value to entry value at that index
|
||||
localePreference.setValue(localePreference.getEntryValues()[index].toString());
|
||||
}
|
||||
}
|
||||
|
||||
localePreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
// See corresponding comment in Utils.updateBaseContextLocale for Android 6- notes
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
refreshActivity(true);
|
||||
return true;
|
||||
}
|
||||
String newLocale = (String) newValue;
|
||||
// If newLocale is empty, that means "System" was selected
|
||||
AppCompatDelegate.setApplicationLocales(newLocale.isEmpty() ? LocaleListCompat.getEmptyLocaleList() : LocaleListCompat.create(Utils.stringToLocale(newLocale)));
|
||||
return true;
|
||||
});
|
||||
|
||||
// Disable content provider on SDK < 23 since dangerous permissions
|
||||
// are granted at install-time
|
||||
Preference contentProviderReadPreference = findPreference(getResources().getString(R.string.settings_key_allow_content_provider_read));
|
||||
assert contentProviderReadPreference != null;
|
||||
contentProviderReadPreference.setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
|
||||
}
|
||||
|
||||
private void refreshActivity(boolean reloadMain) {
|
||||
mReloadMain = reloadMain || mReloadMain;
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package protect.card_locker.preferences
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import protect.card_locker.BuildConfig
|
||||
import protect.card_locker.CatimaAppCompatActivity
|
||||
import protect.card_locker.MainActivity
|
||||
import protect.card_locker.R
|
||||
import protect.card_locker.Utils
|
||||
import protect.card_locker.databinding.SettingsActivityBinding
|
||||
|
||||
class SettingsActivity : CatimaAppCompatActivity() {
|
||||
|
||||
private lateinit var binding: SettingsActivityBinding
|
||||
private lateinit var fragment: SettingsFragment
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = SettingsActivityBinding.inflate(layoutInflater)
|
||||
setTitle(R.string.settings)
|
||||
setContentView(binding.root)
|
||||
Utils.applyWindowInsets(binding.root)
|
||||
val toolbar = binding.toolbar
|
||||
setSupportActionBar(toolbar)
|
||||
enableToolbarBackButton()
|
||||
|
||||
// Display the fragment as the main content.
|
||||
fragment = SettingsFragment()
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.settings_container, fragment)
|
||||
.commit()
|
||||
|
||||
// restore reload main state
|
||||
if (savedInstanceState != null) {
|
||||
fragment.mReloadMain = savedInstanceState.getBoolean(RELOAD_MAIN_STATE)
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
finishSettingsActivity()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putBoolean(RELOAD_MAIN_STATE, fragment.mReloadMain)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val id = item.itemId
|
||||
|
||||
if (id == android.R.id.home) {
|
||||
finishSettingsActivity()
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun finishSettingsActivity() {
|
||||
if (fragment.mReloadMain) {
|
||||
val intent = Intent()
|
||||
intent.putExtra(MainActivity.RESTART_ACTIVITY_INTENT, true)
|
||||
setResult(RESULT_OK, intent)
|
||||
} else {
|
||||
setResult(RESULT_OK)
|
||||
}
|
||||
finish()
|
||||
}
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
var mReloadMain: Boolean = false
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.preferences)
|
||||
|
||||
// Show pretty names and summaries
|
||||
val themePreference = findPreference<ListPreference>(getString(R.string.settings_key_theme))
|
||||
themePreference!!.setOnPreferenceChangeListener { _, o ->
|
||||
when (o.toString()) {
|
||||
getString(R.string.settings_key_light_theme) -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
}
|
||||
getString(R.string.settings_key_dark_theme) -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
}
|
||||
else -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
val themeColorPreference = findPreference<ListPreference>(getString(R.string.setting_key_theme_color))
|
||||
themeColorPreference!!.setOnPreferenceChangeListener { _, _ ->
|
||||
refreshActivity(true)
|
||||
true
|
||||
}
|
||||
if (!DynamicColors.isDynamicColorAvailable()) {
|
||||
themeColorPreference.setEntryValues(R.array.color_values_no_dynamic)
|
||||
themeColorPreference.setEntries(R.array.color_value_strings_no_dynamic)
|
||||
}
|
||||
|
||||
val oledDarkPreference = findPreference<Preference>(getString(R.string.settings_key_oled_dark))
|
||||
oledDarkPreference!!.setOnPreferenceChangeListener { _, _ ->
|
||||
refreshActivity(true)
|
||||
true
|
||||
}
|
||||
|
||||
val localePreference =
|
||||
findPreference<ListPreference>(getString(R.string.settings_key_locale))!!
|
||||
localePreference.let {
|
||||
val entryValues = it.entryValues
|
||||
val entries = entryValues.map { entry ->
|
||||
if (entry.isEmpty()) {
|
||||
getString(R.string.settings_system_locale)
|
||||
} else {
|
||||
val entryLocale = Utils.stringToLocale(entry.toString())
|
||||
entryLocale.getDisplayName(entryLocale)
|
||||
}
|
||||
}
|
||||
it.entries = entries.toTypedArray()
|
||||
|
||||
// Make locale picker preference in sync with system settings
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
val sysLocale = AppCompatDelegate.getApplicationLocales()[0]
|
||||
if (sysLocale == null) {
|
||||
// Corresponds to "System"
|
||||
it.value = ""
|
||||
} else {
|
||||
// Need to set preference's value to one of localePreference.getEntryValues() to match the locale.
|
||||
// Locale.toLanguageTag() theoretically should be one of the values in localePreference.getEntryValues()...
|
||||
// But it doesn't work for some locales. so trying something more heavyweight.
|
||||
|
||||
// Obtain all locales supported by the app.
|
||||
val appLocales = entryValues.map { entry -> Utils.stringToLocale(entry.toString()) }
|
||||
// Get the app locale that best matches the system one
|
||||
val bestMatchLocale = Utils.getBestMatchLocale(appLocales, sysLocale)
|
||||
// Get its index in supported locales
|
||||
val index = appLocales.indexOf(bestMatchLocale)
|
||||
// Set preference value to entry value at that index
|
||||
it.value = entryValues[index].toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
localePreference.setOnPreferenceChangeListener { _, newValue ->
|
||||
// See corresponding comment in Utils.updateBaseContextLocale for Android 6- notes
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
refreshActivity(true)
|
||||
return@setOnPreferenceChangeListener true
|
||||
}
|
||||
val newLocale = newValue as String
|
||||
// If newLocale is empty, that means "System" was selected
|
||||
AppCompatDelegate.setApplicationLocales(if (newLocale.isEmpty()) LocaleListCompat.getEmptyLocaleList() else LocaleListCompat.create(Utils.stringToLocale(newLocale)))
|
||||
true
|
||||
}
|
||||
|
||||
// Disable content provider on SDK < 23 since dangerous permissions
|
||||
// are granted at install-time
|
||||
val contentProviderReadPreference = findPreference<Preference>(getString(R.string.settings_key_allow_content_provider_read))
|
||||
contentProviderReadPreference!!.isVisible =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
|
||||
// Hide crash reporter settings on builds it's not enabled on
|
||||
val crashReporterPreference = findPreference<Preference>("acra.enable")
|
||||
crashReporterPreference!!.isVisible = BuildConfig.useAcraCrashReporter
|
||||
}
|
||||
|
||||
private fun refreshActivity(reloadMain: Boolean) {
|
||||
mReloadMain = reloadMain || mReloadMain
|
||||
activity?.recreate()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val RELOAD_MAIN_STATE = "mReloadMain"
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-nodpi/widget_preview.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
9
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:pathData="M0,0h108v108h-108z"
|
||||
android:fillColor="#1F4262"/>
|
||||
</vector>
|
||||
@@ -3,69 +3,57 @@
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<group android:scaleX="1.5307087"
|
||||
android:scaleY="1.5307087"
|
||||
android:translateX="15.12"
|
||||
android:translateY="15.12">
|
||||
<group android:scaleX="0.75"
|
||||
android:scaleY="0.75"
|
||||
android:translateX="13.5"
|
||||
android:translateY="13.5">
|
||||
<path
|
||||
android:pathData="M14.3354,20.1954l20.7318,-9.2304l5.7612,12.9398l-20.7318,9.2304z"
|
||||
android:strokeLineJoin="miter"
|
||||
android:strokeWidth="0.529167"
|
||||
android:fillColor="#f0f0f0"
|
||||
android:strokeColor="#c80000"/>
|
||||
android:pathData="M45.5,30.58L68.05,22.37C70.13,21.61 72.42,22.68 73.18,24.76L75.92,32.28L49.6,41.85L45.5,30.58Z"
|
||||
android:fillColor="#F5A3A3"/>
|
||||
<path
|
||||
android:pathData="M14.8755,10.9648l23.2041,10.3311l-6.8874,15.4694l-23.2041,-10.3311z"
|
||||
android:strokeLineJoin="miter"
|
||||
android:strokeWidth="0.529167"
|
||||
android:fillColor="#f0f0f0"
|
||||
android:strokeColor="#c80000"/>
|
||||
android:pathData="M70.36,25.78C70.17,25.27 69.6,25 69.08,25.19L49.35,32.37L51.4,38.01L72.07,30.48L70.36,25.78ZM75.92,32.28L49.6,41.85L45.5,30.58L68.05,22.37C70.13,21.61 72.42,22.68 73.18,24.76L75.92,32.28Z"
|
||||
android:fillColor="#CF1717"/>
|
||||
<path
|
||||
android:pathData="M16.5599,16.1348l26.5459,7.6119l-4.5489,15.8639l-26.5459,-7.6119z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.5875"
|
||||
android:fillColor="#c80000"
|
||||
android:strokeColor="#c80000"
|
||||
android:fillType="evenOdd"/>
|
||||
android:pathData="M58.42,30.58L35.86,22.37C33.79,21.61 31.49,22.68 30.74,24.76L28,32.28L54.31,41.85L58.42,30.58Z"
|
||||
android:fillColor="#F5A3A3"/>
|
||||
<path
|
||||
android:pathData="M12.011,15.4955h27.6157v16.5032h-27.6157z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="1.5875"
|
||||
android:fillColor="#ff0000"
|
||||
android:strokeColor="#ff0000"
|
||||
android:fillType="evenOdd"/>
|
||||
android:pathData="M33.56,25.78C33.74,25.27 34.32,25 34.84,25.19L54.57,32.37L52.52,38.01L31.84,30.48L33.56,25.78ZM28,32.28L54.31,41.85L58.42,30.58L35.86,22.37C33.79,21.61 31.49,22.68 30.74,24.76L28,32.28Z"
|
||||
android:fillColor="#DD1818"/>
|
||||
<path
|
||||
android:pathData="M7.8471,23.7471a4.3659,8.5899 0,1 0,8.7317 0a4.3659,8.5899 0,1 0,-8.7317 0z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="0.91078"
|
||||
android:fillColor="#ff0000"
|
||||
android:strokeColor="#ff0000"/>
|
||||
android:pathData="M28.7,37.6C29.08,35.42 31.15,33.97 33.33,34.35L80.6,42.69C82.78,43.07 84.23,45.15 83.85,47.32L81.82,58.83C82.3,59.1 84.67,60.16 87.42,57.23V57.23C87.92,56.69 88.45,56.23 89.01,55.86C91.76,54.02 94,55.22 94,58.53C94,61.34 92.39,64.78 90.21,66.88C86.63,70.54 80.69,70.56 79.75,70.53L77.59,82.78C77.21,84.95 75.14,86.4 72.96,86.02L25.69,77.69C25.67,77.68 25.66,77.68 25.64,77.68C23.45,77.32 22,76.7 22,76C22,75.72 22.23,75.45 22.66,75.2C22.4,74.54 22.31,73.8 22.44,73.05L28.7,37.6Z"
|
||||
android:fillColor="#B81414"/>
|
||||
<path
|
||||
android:pathData="m24.4983,25.781a1.6711,1.6711 0,0 1,-1.3809 1.6457,1.6711 1.6711,0 0,1 -1.8605,-1.0741"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="0.529167"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#f0f0f0"
|
||||
android:strokeLineCap="round"/>
|
||||
android:pathData="M90.67,60.75C90.67,61.85 89.93,63.24 89.01,63.86C88.09,64.47 87.34,64.07 87.34,62.97C87.34,61.86 88.09,60.47 89.01,59.86C89.93,59.24 90.67,59.64 90.67,60.75Z"
|
||||
android:fillColor="#E82E2E"/>
|
||||
<path
|
||||
android:pathData="m27.7991,26.333a1.6711,1.6711 0,0 1,-1.8605 1.0741,1.6711 1.6711,0 0,1 -1.3809,-1.6457"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="0.529167"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#f0f0f0"
|
||||
android:strokeLineCap="round"/>
|
||||
android:pathData="M78,30C80.21,30 82,31.79 82,34V70C82,72.21 80.21,74 78,74H30C25.58,74 22,74.9 22,76V32C22,30.9 25.58,30 30,30H78Z"
|
||||
android:fillColor="#E82E2E"/>
|
||||
<path
|
||||
android:pathData="m16.0606,22.271 l2.6458,-2.6458 2.6458,2.6458"
|
||||
android:strokeLineJoin="miter"
|
||||
android:strokeWidth="0.529167"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#f0f0f0"
|
||||
android:strokeLineCap="butt"/>
|
||||
android:pathData="M51.2,54.25C51.62,53.53 52.53,53.29 53.25,53.7C53.94,54.1 54.2,54.98 53.84,55.68L53.76,55.82C53.4,56.52 53.65,57.4 54.35,57.8C55.04,58.2 55.93,57.98 56.36,57.32L56.44,57.18C56.87,56.52 57.75,56.3 58.45,56.7C59.16,57.12 59.41,58.03 58.99,58.75C57.75,60.9 55,61.64 52.85,60.4C50.7,59.15 49.96,56.4 51.2,54.25Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="m27.7023,22.271 l2.6458,-2.6458 2.6458,2.6458"
|
||||
android:strokeLineJoin="miter"
|
||||
android:strokeWidth="0.529167"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#f0f0f0"
|
||||
android:strokeLineCap="butt"/>
|
||||
android:pathData="M52.79,54.25C52.38,53.53 51.46,53.29 50.75,53.7C50.05,54.1 49.8,54.98 50.16,55.68L50.23,55.82C50.6,56.52 50.34,57.4 49.65,57.8C48.95,58.2 48.07,57.98 47.64,57.32L47.56,57.18C47.13,56.52 46.24,56.3 45.55,56.7C44.83,57.12 44.59,58.03 45,58.75C46.24,60.9 49,61.64 51.15,60.4C53.3,59.15 54.04,56.4 52.79,54.25Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M53.3,56.75C52.72,57.75 51.28,57.75 50.7,56.75L48.1,52.25C47.53,51.25 48.25,50 49.4,50L54.6,50C55.75,50 56.47,51.25 55.9,52.25L53.3,56.75Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M40.5,40.5C43.73,40.5 46.46,42.62 47.42,45.53C47.68,46.31 47.26,47.16 46.47,47.42C45.69,47.68 44.84,47.26 44.58,46.47C44,44.73 42.38,43.5 40.5,43.5C38.62,43.5 37,44.73 36.42,46.47C36.16,47.26 35.31,47.68 34.53,47.42C33.74,47.16 33.32,46.31 33.58,45.53C34.54,42.62 37.27,40.5 40.5,40.5Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M63.5,40.5C66.73,40.5 69.46,42.62 70.42,45.53C70.68,46.31 70.26,47.16 69.47,47.42C68.69,47.68 67.84,47.26 67.58,46.47C67,44.73 65.38,43.5 63.5,43.5C61.62,43.5 60,44.73 59.42,46.47C59.16,47.26 58.31,47.68 57.53,47.42C56.74,47.16 56.32,46.31 56.58,45.53C57.54,42.62 60.27,40.5 63.5,40.5Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M26,55C25.45,55 25,54.55 25,54C25,53.45 25.45,53 26,53H42C42.55,53 43,53.45 43,54C43,54.55 42.55,55 42,55H26Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M26.35,60.94C25.83,61.13 25.26,60.87 25.06,60.35C24.87,59.83 25.13,59.26 25.65,59.06L41.65,53.06C42.17,52.87 42.74,53.13 42.94,53.65C43.13,54.17 42.87,54.74 42.35,54.94L26.35,60.94Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M61.65,54.94C61.13,54.74 60.87,54.17 61.06,53.65C61.26,53.13 61.83,52.87 62.35,53.06L78.35,59.06C78.87,59.26 79.13,59.83 78.94,60.35C78.74,60.87 78.17,61.13 77.65,60.94L61.65,54.94Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
<path
|
||||
android:pathData="M78,55C78.55,55 79,54.55 79,54C79,53.45 78.55,53 78,53H62C61.45,53 61,53.45 61,54C61,54.55 61.45,55 62,55H78Z"
|
||||
android:fillColor="#8A0F0F"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
||||
@@ -3,25 +3,34 @@
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M53.26,40.92l14.35,-6.39l2.86,6.42"
|
||||
android:strokeAlpha="0.4"
|
||||
android:fillAlpha="0.4"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M36.14,40.95l2.86,-6.42l14.24,6.34"
|
||||
android:strokeAlpha="0.4"
|
||||
android:fillAlpha="0.4"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M40.01,37.17l7.73,3.44H38.48l1.53,-3.44m26.58,0 l1.53,3.44H58.86l7.73,-3.44M39,34.53l-2.86,6.42v1.66H70.47V40.95L67.61,34.53 53.27,40.92l-0.02,-0.05L39,34.53Z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M74.07,51.23l4.93,1.41l-6.44,22.48l-37.61,-10.79l39.13,0l0,-13.11z"
|
||||
android:strokeAlpha="0.7"
|
||||
android:fillAlpha="0.7"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M34.94,40.95C31.66,40.95 29,46.19 29,52.64s2.66,11.69 5.94,11.69L74.07,64.34L74.07,40.95ZM41.21,51.08 L40.15,50.02 44.43,45.74 48.71,50.02 47.65,51.08 44.43,47.86ZM58.02,56.56a3.11,3.11 0,0 1,-2.93 2.05,3.15 3.15,0 0,1 -0.55,-0.05 3.11,3.11 0,0 1,-1.83 -1.04,3.12 3.12,0 0,1 -5.3,-0.96 0.75,0.75 0,0 1,1.41 -0.51,1.62 1.62,0 0,0 3.14,-0.55 0.75,0.75 0,0 1,1.5 0,1.62 1.62,0 0,0 3.14,0.55 0.75,0.75 0,0 1,1.41 0.51ZM64.14,51.08 L60.92,47.86L57.71,51.08l-1.06,-1.06 4.28,-4.28 4.28,4.28Z"/>
|
||||
<group android:scaleX="0.75"
|
||||
android:scaleY="0.75"
|
||||
android:translateX="13.5"
|
||||
android:translateY="13.5">
|
||||
<path
|
||||
android:pathData="M75,31C78.31,31 81,33.69 81,37V44.43C81.83,45.67 82.2,47.22 81.92,48.81L81,54.01V55.87C81.24,55.72 81.5,55.51 81.79,55.22L81.86,55.14C82.38,54.59 82.96,54.08 83.58,53.67L83.72,53.57C85.2,52.64 87.03,52.17 88.68,53.05C90.37,53.96 90.99,55.83 90.99,57.63L90.99,57.77C90.94,60.78 89.29,64.16 87.12,66.26L87.12,66.26C85.22,68.18 82.74,69.08 80.76,69.52C80.64,69.55 80.53,69.57 80.41,69.6C79.85,70.76 78.92,71.72 77.77,72.32L76.71,78.35C76.13,81.61 73.02,83.79 69.76,83.22L30.37,76.27C30.33,76.27 30.29,76.26 30.26,76.25C29.12,76.09 28.06,75.84 27.22,75.49C26.8,75.32 26.33,75.07 25.93,74.72C25.54,74.37 25.01,73.72 25,72.78C25,72.78 25,72.78 25,72.78C25,72.77 25,72.76 25,72.75V34.5C25,33.84 25.32,33.25 25.82,32.89C26.23,32.49 26.7,32.24 27.04,32.09C27.6,31.83 28.27,31.63 28.97,31.48C29.75,31.31 30.64,31.18 31.59,31.1C31.59,31.1 31.58,31.1 31.57,31.1L32.67,28.07L32.73,27.93C33.91,24.91 37.3,23.37 40.36,24.49L52.83,29.03L65.3,24.49C68.42,23.36 71.86,24.96 73,28.07L74.06,31H75ZM34.85,73L70.45,79.28C71.54,79.47 72.58,78.74 72.77,77.66L73.59,73H34.85ZM34,35C32.35,35 30.88,35.15 29.82,35.39C29.48,35.46 29.21,35.54 29,35.61V69.47C30.4,69.17 32.15,69 34,69H75L75.1,69C76.13,68.95 76.95,68.13 77,67.1L77,67V37C77,35.9 76.1,35 75,35H34ZM86.78,56.59C86.68,56.59 86.4,56.61 85.88,56.94L85.8,56.99C85.47,57.21 85.13,57.51 84.78,57.88C84.78,57.88 84.78,57.88 84.78,57.88L84.64,58.03C83.44,59.25 82.18,59.88 81,60.12V65.32C82.2,64.94 83.35,64.36 84.22,63.5L84.34,63.38C85.88,61.89 86.99,59.43 86.99,57.63L86.99,57.53C86.98,56.92 86.84,56.67 86.78,56.59ZM46.56,31L38.99,28.25C37.99,27.88 36.88,28.37 36.47,29.35L36.43,29.44L35.86,31H46.56ZM69.8,31L69.24,29.44C68.86,28.41 67.71,27.87 66.67,28.25L59.11,31H69.8Z"
|
||||
android:fillColor="#000000"
|
||||
android:fillType="evenOdd"/>
|
||||
<path
|
||||
android:pathData="M55.17,51C56.32,51 57.04,52.25 56.46,53.25L54.69,56.31C54.6,56.76 54.79,57.24 55.21,57.48C55.73,57.78 56.39,57.6 56.69,57.08C57.11,56.37 58.02,56.12 58.74,56.53C59.46,56.95 59.7,57.87 59.29,58.58C58.16,60.54 55.67,61.21 53.71,60.08C53.45,59.93 53.21,59.75 53,59.55C52.78,59.75 52.54,59.93 52.28,60.08C50.33,61.21 47.83,60.54 46.7,58.58C46.29,57.87 46.53,56.95 47.25,56.53C47.97,56.12 48.88,56.37 49.3,57.08C49.6,57.6 50.26,57.78 50.78,57.48C51.2,57.23 51.4,56.74 51.29,56.29L49.54,53.25C48.96,52.25 49.68,51 50.83,51H55.17Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path
|
||||
android:pathData="M43.25,42.5C46,42.5 48.48,44.07 49.4,46.46C49.7,47.24 49.31,48.1 48.54,48.4C47.76,48.7 46.9,48.31 46.6,47.54C46.18,46.44 44.91,45.5 43.25,45.5C41.58,45.5 40.32,46.44 39.9,47.54C39.6,48.31 38.74,48.7 37.96,48.4C37.19,48.1 36.8,47.24 37.1,46.46C38.02,44.07 40.5,42.5 43.25,42.5Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path
|
||||
android:pathData="M62.75,42.5C65.5,42.5 67.98,44.07 68.9,46.46C69.2,47.24 68.81,48.1 68.04,48.4C67.26,48.7 66.4,48.31 66.1,47.54C65.68,46.44 64.41,45.5 62.75,45.5C61.08,45.5 59.82,46.44 59.4,47.54C59.1,48.31 58.24,48.7 57.46,48.4C56.69,48.1 56.3,47.24 56.6,46.46C57.52,44.07 60,42.5 62.75,42.5Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path
|
||||
android:pathData="M33,55C32.17,55 31.5,54.33 31.5,53.5C31.5,52.67 32.17,52 33,52H44.25C45.08,52 45.75,52.67 45.75,53.5C45.75,54.33 45.08,55 44.25,55H33Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path
|
||||
android:pathData="M33.61,59.87C32.85,60.21 31.97,59.87 31.63,59.11C31.29,58.35 31.63,57.47 32.39,57.13L43.61,52.13C44.37,51.79 45.26,52.13 45.59,52.89C45.93,53.65 45.59,54.53 44.83,54.87L33.61,59.87Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path
|
||||
android:pathData="M60.85,54.88C60.09,54.55 59.74,53.66 60.07,52.9C60.4,52.14 61.28,51.79 62.04,52.12L73.6,57.12C74.36,57.45 74.71,58.34 74.38,59.1C74.05,59.86 73.16,60.21 72.4,59.88L60.85,54.88Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path
|
||||
android:pathData="M73,52C73.83,52 74.5,52.67 74.5,53.5C74.5,54.33 73.83,55 73,55H61.5C60.67,55 60,54.33 60,53.5C60,52.67 60.67,52 61.5,52H73Z"
|
||||
android:fillColor="#000000"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
||||
18
app/src/main/res/layout/list_widget.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- android:columnWidth must be kept in sync with list_widget_item.xml -->
|
||||
<GridView
|
||||
android:id="@+id/grid_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:numColumns="auto_fit"
|
||||
android:columnWidth="107dp"
|
||||
android:verticalSpacing="4dp"
|
||||
android:horizontalSpacing="4dp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
17
app/src/main/res/layout/list_widget_empty.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/widget_layout"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/no_cards_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/card_list_widget_empty"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:autoSizeMinTextSize="12sp"
|
||||
app:autoSizeMaxTextSize="100sp"
|
||||
app:autoSizeStepGranularity="2sp" />
|
||||
</LinearLayout>
|
||||
36
app/src/main/res/layout/list_widget_item.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
85.6dp : 53.98dp
|
||||
Both multiplied by 1.25 to fit better
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="107dp"
|
||||
android:layout_height="67.475dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:id="@+id/item_container"
|
||||
android:background="@drawable/round_outline"
|
||||
android:clipToOutline="true">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/item_container_foreground">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center|center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:autoSizeMinTextSize="6sp"
|
||||
app:autoSizeTextType="uniform"
|
||||
android:layout_gravity="center|center"
|
||||
android:gravity="center" />
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@drawable/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
||||
</adaptive-icon>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@drawable/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
||||
</adaptive-icon>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |